How to check if a credit card is valid or not for PayPal

I need to take the user's credit card information for payment via paypal. The first time a user enters card details, payment is made through paypal pro. If the card is invalid, payment will not be made. Payment will be made only if the card is valid.

The first time a user enters valid card information and makes a payment, if such a user changes their credit card details at this time, I need to check again whether the card is valid for PayPal or not.

So, are there any APIs that only check credit card information and do not process any payment?

I am running php and mysql.

Thank.

Avinash

+3
source share
3 answers

With Paypal, your options are very limited. If you use Paypal Pro, you can check if the card exists and is legal by making authorization for only $ 0.00. If you use other payment methods offered by Paypal, you cannot do this.

, , . , , Luhn. , . , , . , CVV Visa, MasterCard Discover American Express.

, , , .

EDIT ( Luhn PHP):

function passes_luhn_check($cc_number) {
    $checksum  = 0;
    $j = 1;
    for ($i = strlen($cc_number) - 1; $i >= 0; $i--) {
        $calc = substr($cc_number, $i, 1) * $j;
        if ($calc > 9) {
            $checksum = $checksum + 1;
            $calc = $calc - 10;
        }
        $checksum += $calc;
        $j = ($j == 1) ? 2 : 1;
    }
    if ($checksum % 10 != 0) {
        return false;
    }
    return true;
}

:

$valid_cc = passes_luhn_check('4427802641004797'); // returns true
$valid_cc = passes_luhn_check('4427802641004798'); // returns false
+4

Paypal, , - API , $0.00, , .

PCI .

0

, . - , , . , ( ).

, .

( ), 0,00. , . Not Paypall, . , , , .

0

Source: https://habr.com/ru/post/1730507/


All Articles