php - 在 Paypal Vault 中使用存储卡时返回内部服务错误

标签 php curl paypal paypal-sandbox paypal-vault

我的代码有什么问题:在保存的 paypal 信用卡信息中使用 Vault api 但当我使用保存的卡时出现错误

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);
} 

在这里输出

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

最佳答案

因为我没有从任何人那里得到任何解决方案,所以我一步一步地深入研究我的代码并找到了解决方案。我的代码中没有错误只有信用卡号和负面测试问题。我在 stackoverflow 上关注以下帖子并获得获得成功

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

PayPal Sandbox returning Internal Service Error

关于php - 在 Paypal Vault 中使用存储卡时返回内部服务错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37461436/

相关文章:

javascript - 使用 JS Fetch API 的 PHP POST

php - 从字符串中删除欧元符号

php - CURL 和 HTTPS, "Cannot resolve host"

paypal - 在 PayPal 沙盒网站上启用 API 权限

php - Paypal 付款给多个收款人。自适应支付?

php - Yii Framework 2.0 GridView 和来自连接表的数据

php - session 管理 : PHP+MySQL

php - 如何安全连接以获得安全 cookie

macos - 在 OSX 上对 curl 的 SFTP 支持

asp-classic - msxml3.dll 错误 '80072f0c' 需要证书才能完成客户端身份验证