when using stored card in Paypal Vault it return INTERNAL SERVICE ERROR

276 Views Asked by At

What is issue in my code:Using Vault api in paypal credit card information saved but when i using saved card then get error

function paypalPaymentViaStoredCreditCard_post()
{
    $access_token = "XXXXXXXX";
    $ch = curl_init();
    $data = '{
        "intent": "sale",
        "payer": {
          "payment_method": "credit_card",
          "funding_instruments":[
            {
              "credit_card_token": {
                "credit_card_id": "CARD-6F0009583J819301DK5DO5JA",
                "payer_id": "BAAAA"
              }
            }
          ]
        },
        "transactions":[
          {
            "amount":{
            "total":"100.00",
            "currency":"USD"
            },
            "description": "This is the payment transaction description."
          }
        ]
      }';


     curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment");
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     "Content-Type:application/json",
     "Authorization: Bearer " . $access_token,
     "Content-length: " . strlen($data))
     );


    curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: Some-Agent/1.0");
    $result = curl_exec($ch);
    print_r($result);die;
    if (empty($result)) die("Error: No response.");
    else {
          $json = json_decode($result);
          print_r($json);
          die;
          return $json;
    }
    curl_close($ch);
} 

OUTPUT Here

{"name":"INTERNAL_SERVICE_ERROR","information_link":"https://api.sandbox.paypal.com/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"b33db4a496dfc"}
1

There are 1 best solutions below

0
On BEST ANSWER

As I didn't get any solution from anybody so I dug into my code step by step and found solution.there is no bug in my code only credit card no and negative testing issue.i follow following post on stackoverflow and get get success

PayPal Sandbox API endpoint returning 503 "Internal Service Error" error

PayPal Sandbox returning Internal Service Error