我正在使用条带支付集成,并希望动态验证所有测试卡号。 这是我验证只有一个数字的代码。
if ($expe[0] === 4242424242424242 )
{
}
else
{
return back()->withErrors('Add a valid card no ');
}
答案 0 :(得分:0)
我使用abstract class和一堆条纹信用卡。然后我在我的测试类中使用const
创建所需的数组。
<?php namespace App;
abstract class StripeToken
{
const BYPASS_PENDING_TOKEN = 'tok_bypassPending';
const BYPASS_PENDING_CC = '4000000000000077';
const BYPASS_PENDING_LAST4 = '0077';
const BYPASS_PENDING_DESC = 'Charge succeeds and funds will be added directly to your available balance (bypassing your pending balance).';
const DOMESTIC_PRICING_TOKEN = 'tok_domesticPricing';
const DOMESTIC_PRICING_CC = '4000000000000093';
const DOMESTIC_PRICING_LAST4 = '0093';
const DOMESTIC_PRICING_DESC = 'Charge succeeds and domestic pricing is used (other test cards use international pricing). This card is only significant in countries with split pricing.';
const AVS_FAIL_TOKEN = 'tok_avsFail';
const AVS_FAIL_CC = '4000000000000010';
const AVS_FAIL_LAST4 = '0010';
const AVS_FAIL_DESC = 'The address_line1_check and address_zip_check verifications fail. If your account is blocking payments that fail ZIP code validation, the charge is declined.';
const AVS_LINE1_FAIL_TOKEN = 'tok_avsLine1Fail';
const AVS_LINE1_FAIL_CC = '4000000000000028';
const AVS_LINE1_FAIL_LAST4 = '0028';
const AVS_LINE1_FAIL_DESC = 'Charge succeeds but the address_line1_check verification fails.';
const AVS_ZIP_FAIL_TOKEN = 'tok_avsZipFail';
const AVS_ZIP_FAIL_CC = '4000000000000036';
const AVS_ZIP_FAIL_LAST4 = '0036';
const AVS_ZIP_FAIL_DESC = 'The address_zip_check verification fails. If your account is blocking payments that fail ZIP code validation, the charge is declined.';
const AVS_UNCHECKED_TOKEN = 'tok_avsUnchecked';
const AVS_UNCHECKED_CC = '4000000000000044';
const AVS_UNCHECKED_LAST4 = '0044';
const AVS_UNCHECKED_DESC = 'Charge succeeds but the address_zip_check and address_line1_check verifications are both unavailable.';
const CVC_CHECK_FAIL_TOKEN = 'tok_cvcCheckFail';
const CVC_CHECK_FAIL_CC = '4000000000000101';
const CVC_CHECK_FAIL_LAST4 = '0101';
const CVC_CHECK_FAIL_DESC = 'If a CVC number is provided, the cvc_check fails. If your account is blocking payments that fail CVC code validation, the charge is declined.';
const CHARGE_CUSTOMER_FAIL_TOKEN = 'tok_chargeCustomerFail';
const CHARGE_CUSTOMER_FAIL_CC = '4000000000000341';
const CHARGE_CUSTOMER_FAIL_LAST4 = '0341';
const CHARGE_CUSTOMER_FAIL_DESC = 'Attaching this card to a Customer object succeeds, but attempts to charge the customer fail.';
const CHARGE_CUSTOMER_FAIL_MESSAGE = 'Your card was declined.';
const RISK_LEVEL_ELEVATED_TOKEN = 'tok_riskLevelElevated';
const RISK_LEVEL_ELEVATED_CC = '4000000000009235';
const RISK_LEVEL_ELEVATED_LAST4 = '9235';
const RISK_LEVEL_ELEVATED_DESC = 'Charge succeeds with a risk_level of elevated and placed into review.';
const CHARGE_DECLINED_TOKEN = 'tok_chargeDeclined';
const CHARGE_DECLINED_CC = '4000000000000002';
const CHARGE_DECLINED_LAST4 = '0002';
const CHARGE_DECLINED_DESC = 'Charge is declined with a card_declined code.';
const CHARGE_DECLINED_MESSAGE = 'Your card was declined.';
const CHARGE_DECLINED_FRAUDULENT_TOKEN = 'tok_chargeDeclinedFraudulent';
const CHARGE_DECLINED_FRAUDULENT_CC = '4100000000000019';
const CHARGE_DECLINED_FRAUDULENT_LAST4 = '0019';
const CHARGE_DECLINED_FRAUDULENT_DESC = 'Charge is declined with a card_declined code and a fraudulent reason.';
const CHARGE_DECLINED_FRAUDULENT_MESSAGE = 'Your card was declined.';
const CHARGE_DECLINED_INCORRECT_CVC_TOKEN = 'tok_chargeDeclinedIncorrectCvc';
const CHARGE_DECLINED_INCORRECT_CVC_CC = '4000000000000127';
const CHARGE_DECLINED_INCORRECT_CVC_LAST4 = '0127';
const CHARGE_DECLINED_INCORRECT_CVC_DESC = 'Charge is declined with an incorrect_cvc code.';
const CHARGE_DECLINED_INCORRECT_CVC_MESSAGE = 'Your card\'s security code is incorrect.';
const CHARGE_DECLINED_EXPIRED_CARD_TOKEN = 'tok_chargeDeclinedExpiredCard';
const CHARGE_DECLINED_EXPIRED_CARD_CC = '4000000000000069';
const CHARGE_DECLINED_EXPIRED_CARD_LAST4 = '0069';
const CHARGE_DECLINED_EXPIRED_CARD_DESC = 'Charge is declined with an expired_card code.';
const CHARGE_DECLINED_EXPIRED_CARD_MESSAGE = 'Your card has expired.';
const CHARGE_DECLINED_PROCESSING_ERROR_TOKEN = 'tok_chargeDeclinedProcessingError';
const CHARGE_DECLINED_PROCESSING_ERROR_CC = '4000000000000119';
const CHARGE_DECLINED_PROCESSING_ERROR_LAST4 = '0119';
const CHARGE_DECLINED_PROCESSING_ERROR_DESC = 'Charge is declined with a processing_error code.';
const CHARGE_DECLINED_PROCESSING_ERROR_MESSAGE = 'An error occurred while processing your card. Try again in a little bit.';
const CHARGE_DECLINED_INCORRECT_NUMBER_CC = '4242424242424241';
const CHARGE_DECLINED_INCORRECT_NUMBER_LAST4 = '4241';
const CHARGE_DECLINED_INCORRECT_NUMBER_DESC = 'Charge is declined with an incorrect_number code as the card number fails the Luhn check.';
const VISA_TOKEN = 'tok_visa';
const VISA_CC = '4242424242424242';
const VISA_LAST4 = '4242';
const VISA_DESC = 'Visa';
const VISA_BRAND = 'Visa';
const VISA_DEBIT_TOKEN = 'tok_visa_debit';
const VISA_DEBIT_CC = '4000056655665556';
const VISA_DEBIT_LAST4 = '5556';
const VISA_DEBIT_DESC = 'Visa (debit)';
const VISA_DEBIT_BRAND = 'Visa';
const MASTERCARD_TOKEN = 'tok_mastercard';
const MASTERCARD_CC = '5555555555554444';
const MASTERCARD_LAST4 = '4444';
const MASTERCARD_DESC = 'Mastercard';
const MASTERCARD_BRAND = 'Mastercard';
const MASTERCARD_DEBIT_TOKEN = 'tok_mastercard_debit';
const MASTERCARD_DEBIT_CC = '5200828282828210';
const MASTERCARD_DEBIT_LAST4 = '8210';
const MASTERCARD_DEBIT_DESC = 'Mastercard (debit)';
const MASTERCARD_DEBIT_BRAND = 'Mastercard';
const MASTERCARD_PREPAID_TOKEN = 'tok_mastercard_prepaid';
const MASTERCARD_PREPAID_CC = '5105105105105100';
const MASTERCARD_PREPAID_LAST4 = '5100';
const MASTERCARD_PREPAID_DESC = 'Mastercard (prepaid)';
const MASTERCARD_PREPAID_BRAND = 'Mastercard';
const AMEX_TOKEN = 'tok_amex';
const AMEX_CC = '378282246310005';
const AMEX_LAST4 = '0005';
const AMEX_DESC = 'American Express';
const AMEX_BRAND = 'American Express';
const DISCOVER_TOKEN = 'tok_discover';
const DISCOVER_CC = '6011000990139424';
const DISCOVER_LAST4 = '9424';
const DISCOVER_DESC = 'Discover';
const DISCOVER_BRAND = 'Discover';
const DISCOVER_2_CC = '6011111111111117';
const DISCOVER_2_LAST4 = '1117';
const DISCOVER_2_DESC = 'Discover';
const DISCOVER_2_BRAND = 'Discover';
const DINERS_TOKEN = 'tok_diners';
const DINERS_CC = '30569309025904';
const DINERS_LAST4 = '5904';
const DINERS_DESC = 'Diners Club';
const DINERS_BRAND = 'Diners Club';
const JCB_TOKEN = 'tok_jcb';
const JCB_CC = '3530111333300000';
const JCB_LAST4 = '0000';
const JCB_DESC = 'JCB';
const JCB_BRAND = 'JCB';
const VISA_2_CC = '4012888888881881';
const VISA_2_LAST4 = '1881';
const VISA_2_DESC = 'Visa';
const VISA_2_BRAND = 'Visa';
const AMEX_2_CC = '371449635398431';
const AMEX_2_LAST4 = '8431';
const AMEX_2_DESC = 'American Express';
const AMEX_2_BRAND = 'American Express';
const DINERS_2_CC = '38520000023237';
const DINERS_2_LAST4 = '3237';
const DINERS_2_DESC = 'Diners Club';
const DINERS_2_BRAND = 'Diners Club';
const JCB_2_CC = '3566002020360505';
const JCB_2_LAST4 = '0505';
const JCB_2_DESC = 'JCB';
const JCB_2_BRAND = 'JCB';
const VALID_CC_NUMBERS = [
[
'token' => StripeToken::VISA_TOKEN,
'number' => StripeToken::VISA_CC,
'last4' => StripeToken::VISA_LAST4,
'brand' => StripeToken::VISA_BRAND
],
[
'token' => StripeToken::VISA_DEBIT_TOKEN,
'number' => StripeToken::VISA_DEBIT_CC,
'last4' => StripeToken::VISA_DEBIT_LAST4,
'brand' => StripeToken::VISA_DEBIT_BRAND
],
[
'token' => StripeToken::MASTERCARD_TOKEN,
'number' => StripeToken::MASTERCARD_CC,
'last4' => StripeToken::MASTERCARD_LAST4,
'brand' => StripeToken::MASTERCARD_BRAND
],
[
'token' => StripeToken::MASTERCARD_DEBIT_TOKEN,
'number' => StripeToken::MASTERCARD_DEBIT_CC,
'last4' => StripeToken::MASTERCARD_DEBIT_LAST4,
'brand' => StripeToken::MASTERCARD_DEBIT_BRAND
],
[
'token' => StripeToken::MASTERCARD_PREPAID_TOKEN,
'number' => StripeToken::MASTERCARD_PREPAID_CC,
'last4' => StripeToken::MASTERCARD_PREPAID_LAST4,
'brand' => StripeToken::MASTERCARD_PREPAID_BRAND
],
[
'token' => StripeToken::AMEX_TOKEN,
'number' => StripeToken::AMEX_CC,
'last4' => StripeToken::AMEX_LAST4,
'brand' => StripeToken::AMEX_BRAND
],
[
'token' => StripeToken::DISCOVER_TOKEN,
'number' => StripeToken::DISCOVER_CC,
'last4' => StripeToken::DISCOVER_LAST4,
'brand' => StripeToken::DISCOVER_BRAND
],
[
'token' => StripeToken::DINERS_TOKEN,
'number' => StripeToken::DINERS_CC,
'last4' => StripeToken::DINERS_LAST4,
'brand' => StripeToken::DINERS_BRAND
],
[
'token' => StripeToken::JCB_TOKEN,
'number' => StripeToken::JCB_CC,
'last4' => StripeToken::JCB_LAST4,
'brand' => StripeToken::JCB_BRAND
],
];
/**
* Get a random valid cc array
* @return mixed
*/
public static function randomValidCC(){
return static::VALID_CC_NUMBERS[array_rand(static::VALID_CC_NUMBERS, 1)];
}
}