如何解决 Paypal 金库信用卡充值失败问题

How to troubleshoot Paypal vault credit card charge failure

我正在尝试使用 Paypal 沙盒向 Paypal 金库信用卡付款,但我无法弄清楚。似乎没有办法解决错误。它要么有效要么无效,我还没有体验过它有效。

我可以提取卡片列表,我可以检索特定卡片,但我无法向其中任何一张付款。

我正在使用 PHP 贝宝 SDK。这是 Paypal 看到的我的请求。

{
    "body": {
        "intent": "sale",
        "payer": {
            "payment_method": "credit_card",
            "funding_instruments": [
                {
                    "credit_card_token": {
                        "credit_card_id": "CARD-6XP216179L970340WK6BNY5A",
                        "payer_id": "1"
                    }
                }
            ]
        },
        "transactions": [
            {
                "amount": {
                    "currency": "USD",
                    "total": "26.01"
                }
            }
        ]
    },
    "header": {
        "x-pp-silover": "name\u003dSANDBOX3.API.1\u0026silo_version\u003d1880\u0026app\u003dplatformapiserv\u0026TIME\u003d1702332759\u0026HTTP_X_PP_AZ_LOCATOR\u003d",
        "content-length": "233",
        "paypal-request-id": "323223593916288146862657311204",
        "x-slr-retry": "SLR-RETRY-EMPTY",
        "accept": "*/*",
        "client-auth": "No cert",
        "host": "api.sandbox.paypal.com",
        "user-agent": "PayPalSDK/PayPal-PHP-SDK 1.7.3 (platform-ver\u003d5.6.23-2+deb.sury.org~xenial+1; bit\u003d64; os\u003dLinux_4.4.0-21-generic; machine\u003dx86_64; crypto-lib-ver\u003d1.0.2h; curl\u003d7.47.0)",
        "x-slr-nobounce": "true",
        "x-slr-orig-script_uri": "https://api.sandbox.paypal.com/v1/payments/payment",
        "x-pp-corrid": "793fa20aaec8b",
        "pp_remote_addr": "99.99.99.1",
        "content-type": "application/json",
        "authorization": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl4S0"
    },
    "additional_properties": {},
    "method": "POST"
}

我将 IP 修改为不同于我当前分配的 IP。不知道发布有没有安全问题,不保密

我正在使用的代码如下所示。

$apiContext = new \PayPal\Rest\ApiContext(
            new \PayPal\Auth\OAuthTokenCredential(
                $clientId,
                $secret
                )
            );

        $cardToken = new CreditCardToken();
        $cardToken->setCreditCardId($paymentMethod->getProcessorId());
        $cardToken->setPayerId("1");

        $fi = new FundingInstrument();
        $fi->setCreditCardToken($cardToken);

        $payer = new Payer();
        $payer->setPaymentMethod("credit_card")
        ->setFundingInstruments(array($fi));
        $amount = new Amount();
        $amount->setCurrency("USD")
        ->setTotal("26.01");

        $transaction = new Transaction();
        $transaction->setAmount($amount);

        $payment = new Payment();
        $payment->setIntent("sale")
        ->setPayer($payer)
        ->setTransactions(array($transaction));
        print_r($payment);

            $payment->create($apiContext);
            if ($payment->getState() == 'approved') {
                return TRUE;
            }
            return FALSE;
        } catch (Exception $ex) {
            print_r($ex);
        }

$paymentMethod->getProcessorId() 是一个有效的信用卡保险库 ID,我可以从 Paypal 的沙箱中检索它。

这是 Paypal 的回复。

{
    "status": 500,
    "duration_time": 135,
    "body": {
        "message": "An internal service error occurred.",
        "information_link": "https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR",
        "name": "INTERNAL_SERVICE_ERROR",
        "debug_id": "793fa20aaec8b"
    },
    "additional_properties": {},
    "header": {
        "Content-Length": "209",
        "Content-Language": "*",
        "X-SLR-RETRY": "500",
        "CORRELATION-ID": "793fa20aaec8b",
        "Date": "Fri, 15 Jul 2016 23:53:39 GMT",
        "Connection": "close",
        "Paypal-Debug-Id": "793fa20aaec8b",
        "PROXY_SERVER_INFO": "host\u003dslcsbplatformapiserv3001.slc.paypal.com;threadId\u003d569",
        "Content-Type": "application/json"
    }
}

据我了解,内部错误仅表示某些地方不对,但并没有说明哪里不对。使用起来很烦人,它们在故障排除响应中没有给您任何有用的信息,而且显然没有日志可通过 Paypal SB 仪表板检查。

这是一个内部错误,因此它不会传达出了什么问题。很难在这里收到回复。

从 PayPal 获得回复的最佳方式是在 https://www.paypal-techsupport.com/ 和post 那边跟debug_id 同样的问题。 (单击站点页脚中的“联系支持”)。他们会告诉你这是什么类型的错误。我有从他们那里获得帮助的成功记录。

如果他们的回复花费的时间比在发生内部错误的情况下获得帮助的第二个最佳位置是 https://github.com/paypal/PayPal-PHP-SDK 还有 post debug_id 那边。