Card payments
- Card Number: Any 16-digits card number starting with ‘4’ (VISA) or ‘5’ (Mastercard) that passes the LUHN test
- Security Code: The validation follows the scheme of the card used, so any 3 digits for VISA/MC, or 4 digits for Amex
- Expiration Date:
- 01/2030 - SUCCESS payment
- 02/2030 - FAILED payment and INSUFFICIENT_FUNDS reason
- 03/2030 - FAILED payment and SOFT_DECLINE reason
- 04/2030 - FAILED payment and HARD_DECLINE reason
- 12/2030 - ERROR mandate
- 01/2028 - SUCCESS payment with 3DS redirection (This should be tested when implementing the server-2-server flow)
- 02/2028 - FAILED payment with 3DS redirection (This should be tested when implementing the server-2-server flow)
Sample PHP code to generate fake card numbers
<?php
function isLuhnNum($num, $length=null) {
if (empty($length)) {
$length = strlen($num);
}
$tot = 0;
for($i = $length - 1; $i >= 0; $i--) {
$digit = substr($num, $i, 1);
if ((($length - $i) % 2) == 0) {
$digit = $digit*2;
if ($digit > 9) {
$digit = $digit-9;
}
}
$tot += $digit;
}
return (($tot % 10) === 0);
}
function getCardNumber () {
$cardNumber = str_pad('4'.rand('10', '99').date('U'), 15, '0', STR_PAD_RIGHT);
for ($i=0; $i<10; $i++) {
if (isLuhnNum($cardNumber.$i)) {
return $cardNumber.$i;
}
}
return null;
}
print getCardNumber() . "\n";