我正在使用PayPal REST API来创建协议。我想知道为什么在创建结算协议时响应中没有id。 return_url 中仅存在执行令牌。
创建付款时会返回ID。
请求
POST https://api.sandbox.paypal.com/v1/payments/billing-agreements HTTP/1.1
Content-Type: application/json
User-Agent: PayPalSDK/rest-sdk-dotnet 0.11.0 (core=1.6.0;lang=DOTNET;v=4.5;clr=4.0.30319.34014;bit=64;os=Microsoft Windows NT 6.2.9200.0)
Authorization: Bearer A015NObhWZJY-ZZHdSmMvYL7GFA6A-pY7pK4zV1J8wysWJE
PayPal-Request-Id: 98a56a18-2306-4301-a366-e53a5db54536
Host: api.sandbox.paypal.com
Content-Length: 246
Expect: 100-continue
{"name":"plan \"PN123\" subscription","description":"plan \"PN123\" subscription with payments every 12 months.","start_date":"2015-02-06T16:58:56z","payer":{"payment_method":"paypal"},"plan":{"id":"P-2Y404528U1543832BL7HBW6A"}}
Pretty Request Json
{
"name":"A plan \"PN123\" subscription",
"description":"plan \"PN123\" subscription with payments every 12 months.",
"start_date":"2015-02-06T16:58:56z",
"payer":{
"payment_method":"paypal"
},
"plan":{
"id":"P-2Y404528U1543832BL7HBW6A"
}
}
响应
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
PROXY_SERVER_INFO: host=slcsbplatformapiserv3001.slc.paypal.com;threadId=374466
Paypal-Debug-Id: 739b28e849ee7
SERVER_INFO: paymentsplatformserv:v1.payments.billing-agreements&CalThreadId=501225&TopLevelTxnStartTime=14b5fce3a78&Host=slcsbpaymentsplatformserv3001.slc.paypal.com&pid=22725
Content-Language: *
Date: Fri, 06 Feb 2015 16:52:05 GMT
Content-Type: application/json
Content-Length: 1174
来自回复的漂亮json
{
"name":"plan \"PN123\" subscription",
"description":"plan \"PN123\" subscription with payments every 12 months.",
"plan":{
"id":"P-2Y404528U1543832BL7HBW6A",
"state":"ACTIVE",
"name":"PN123",
"description":"plan \"PN123\" subscription",
"type":"INFINITE",
"payment_definitions":[
{
"id":"PD-8RD12495MY6350633L7HBW6I",
"name":"Regular Payments",
"type":"REGULAR",
"frequency":"Month",
"amount":{
"currency":"USD",
"value":"20"
},
"cycles":"0",
"charge_models":[
],
"frequency_interval":"12"
}
],
"merchant_preferences":{
"setup_fee":{
"currency":"USD",
"value":"0"
},
"max_fail_attempts":"0",
"return_url":"http://example.com/Subscription/Renew.aspx?result=ApproveAgreement",
"cancel_url":"http://example.com/Subscription/Renew.aspx?result=CancelAgreement",
"auto_bill_amount":"NO",
"initial_fail_amount_action":"CONTINUE"
}
},
"links":[
{
"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-4R936998H4630535M",
"rel":"approval_url",
"method":"REDIRECT"
},
{
"href":"https://api.sandbox.paypal.com/v1/payments/billing-agreements/EC-4R936998H4630535M/agreement-execute",
"rel":"execute",
"method":"POST"
}
],
"start_date":"2015-02-06T16:58:56z"
}
答案 0 :(得分:2)
付款执行后,您将获得此ID,以PayPal作为付款方式。
您可以使用PayPal-PHP-SDK运行samples attached,在自己实施代码之前尝试一下。此外,大多数示例代码都可以进行复制粘贴,以便轻松上手。
以下是样本的截图: 1.创建协议。使用深黑色线条指向的URL 2.执行协议。如您所见,它具有协议ID。