PayPal在SandBox中创建计费协议JSON请求返回INTERNAL_SERVICE_ERROR

时间:2019-01-05 23:30:45

标签: json paypal asp-classic paypal-sandbox

我尝试根据此处https://developer.paypal.com/docs/subscriptions/integrate/integrate-steps/#3-create-an-agreement给出的示例进行简单的请求,以创建PayPal Biling协议。服务器响应始终为:“ INTERNAL_SERVICE_ERROR”,“发生内部服务错误”。

我使用经典的ASP代码:

sRequest  =  " {""name"": ""Magazine Subscription"", ""description"": ""Monthly agreement with a regular monthly payment definition"", ""start_date"": ""2019-01-09T07:41:38Z"", ""plan"": {""id"": ""P-7S816327W1048253XEAEXK6I""}, ""payer"": {""payment_method"": ""paypal""}} "

var_json = GetPayPal(PAYPAL_API_ENDPOINT() & "v1/payments/billing-agreements/", "POST", "", sHttpStatus)    

因此,结果JSON请求为:

{"name": "Magazine Subscription", "description": "Monthly agreement with a regular monthly payment definition", "start_date": "2019-01-08T07:41:38Z", "plan": {"id": "P-7S816327W1048253XEAEXK6I"}, "payer": {"payment_method": "paypal"}}

Windows curl请求返回相同的错误,直到我在屏幕上引用如下:

curl -v -X POST https://api.sandbox.paypal.com/v1/payments/billing-agreements/ -H "Content-Type: application/json" -H "Authorization: Bearer AccessToken" -d "{\"name\": \"Magazine Subscription\", \"description\": \"Monthly agreement with a regular monthly payment definition\", \"start_date\": \"2019-01-07T17:41:38Z\", \"plan\": {\"id\": \"P-7S816327W1048253XEAEXK6I\"}, \"payer\": {\"payment_method\": \"paypal\"}}"

我不知道如何在沙箱中的经典ASP上创建正确的REST请求以创建PayPal计费协议。


我创建了获取访问令牌的请求,然后使用它来创建计费方案并将其状态设置为ACTIVE。所有请求已成功结束。唯一的区别是,没有必要使用JSON筛选以前的curl测试查询中的引号来获取结果。 例如,更新计费计划卷曲:

curl -v -X PATCH https://api.sandbox.paypal.com/v1/payments/billing-plans/P-5S2563434M1564209CROHHLY -H "Content-Type: application/json" -H "Authorization: Bearer A21AAFF3tgbustGBIsrje-lmJHXYJOBUVhi4QmU6ZP21i8YKHBfaECpgUkNMujGCG629RSO3d9G3sM3pq9eOTIo44Yd575w2g" -d '[{"op": "replace","path": "/","value":{"state": "ACTIVE"}}]'

以及经典的ASP代码:

strRequest =  " [{""op"": ""replace"",""path"": ""/"",""value"":{""state"":""" & sState & """}}] "
var_json = GetPayPal(PAYPAL_API_ENDPOINT() & "v1/payments/billing-plans/" & sBillingPlanID & "/", "PATCH", strRequest, sHttpStatus)

0 个答案:

没有答案