贝宝 REST API - 'An internal service error has occurred'

PayPal REST API - 'An internal service error has occurred'

我在我的 iOS 应用程序上安装并使用了 PayPal 移动 SDK。 我通过应用程序处理单笔付款,然后将 post-sale PayPal 确认字典传递到我的服务器进行确认(按照 PayPal 的指示)

然而,当我尝试在服务器上确认销售时,我收到 'An internal service error has occurred'。

这是贝宝确认JSON:

"paypalConfirmation" : {
"response" : {
  "id" : "APAYPALSALECONFIRMATIONID",
  "state" : "approved",
  "create_time" : "2016-03-21T15:18:36Z",
  "intent" : "sale"
},
"client" : {
  "environment" : "mock",
  "product_name" : "PayPal iOS SDK",
  "paypal_sdk_version" : "2.14.0",
  "platform" : "iOS"
},
"response_type" : "payment"
}

这是我服务器上的 node.js 代码:

//I am using the PayPal Node.js SDK
paypal.sale.get("APAYPALSALECONFIRMATIONID", function (error, sale) {


    if (error) {

        console.log(error);
        context.fail('There was an error confirming the payment');

    } else {


        console.log('Verifying sale...');
        compareSaleWithPost(order, sale, context); 


    }


});

错误如下:

{ [Error: Response Status : 500]
response: 
 { name: 'INTERNAL_SERVICE_ERROR',
 message: 'An internal service error has occurred',
 information_link: 'https://developer.paypal.com/docs/a/#INTERNAL_SERVICE_ERROR',
 debug_id: '***********',
 httpStatusCode: 500 },
httpStatusCode: 500 }

我知道还有其他关于此错误的问题,但他们指的是信用卡付款以及他们的号码或负面测试设置的问题。

我关闭了负面测试,这是针对 PayPal 账户交易而非信用卡交易。我正在使用 SANDBOX 模式

原来我用错了请求。我应该一直使用 paypal.payment.get 而不是 paypal.sale.get。像这样:

paypal.payment.get("APAYPALSALECONFIRMATIONID", function (error, payment) {


    if (error) {

        console.log(error);
        context.fail('There was an error confirming the payment');

    } else {


        console.log('Verifying payment...');
        compareSaleWithPost(order, payment, context); 


    }
}