Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Paypal verify Card details for make payment

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 389
    Comment on it

    Hello guys,
    Its really helpful for integration Paypal in PHP to verify card details.
    To integrate it, first you have to download the PHP-Paypal SDK, below is the direct link
    https://github.com/paypal/PayPal-PHP-SDK/releases

    // 1. Autoload the SDK Package. This will include all the files and classes to your autoloader

    require __DIR__  . '/PayPal-PHP-SDK/autoload.php';
    

    // 2. Provide your Secret Key. Replace the given one with your app clientId, and Secret
    // https://developer.paypal.com/webapps/developer/applications/myapps

    $apiContext = new \PayPal\Rest\ApiContext(
        new \PayPal\Auth\OAuthTokenCredential(
            'AVv47dfPLzgZR4AJqOM4ch60p5vkJDekn09o9QaFp123vl7Dl96Tcz-RQJRJ83m1gIF12Uve2gOxqGz6',     // ClientID
            'EJfrUYfyf8yoXfeqyswaMmyP54exKT5L2jjhJOjJHbRkmR4-TdPBvHzOkydy8HKhTLpQNMThTp5HVL1f'      // ClientSecret
        )
    );

    // 3. Lets try to save a credit card to Vault using Vault API mentioned here
    // https://developer.paypal.com/webapps/developer/docs/api/#store-a-credit-card

    $creditCard = new \PayPal\Api\CreditCard();
    $creditCard->setType("visa")
        ->setNumber("4417119669820331")
        ->setExpireMonth("11")
        ->setExpireYear("2019")
        ->setCvv2("012")
        ->setFirstName("Joe")
        ->setLastName("Shopper");

    // 4. Make a Create Call and Print the Card

    try {
        $creditCard->create($apiContext);
        echo $creditCard;
    }
    catch (\PayPal\Exception\PayPalConnectionException $ex) {
        // This will print the detailed information on the exception. 
        //REALLY HELPFUL FOR DEBUGGING
    
        echo $ex->getData();
    }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: