贝宝休息 API。为什么未设置协议 ID
PayPal Rest API. Why Agreement Id IS not Set
我正在使用 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"}}
漂亮的请求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"
}
您将在执行付款时获得 ID,在 paypal 上作为您的付款类型。
- 创建Billing Agreement。您将获得一个 EC-Token,并且 URL
- 在 Success, Execute Billing Agreement 和
您可以使用 PayPal-PHP-SDK 运行 samples attached,在自己实现代码之前进行尝试。此外,大部分示例代码都可以复制粘贴以轻松上手。
以下是示例的屏幕截图:
1. 创建协议。使用 URL 指向的深黑色线
2. 已执行的协议。如您所见,它具有协议 ID。
我正在使用 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"}}
漂亮的请求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"
}
您将在执行付款时获得 ID,在 paypal 上作为您的付款类型。
- 创建Billing Agreement。您将获得一个 EC-Token,并且 URL
- 在 Success, Execute Billing Agreement 和
您可以使用 PayPal-PHP-SDK 运行 samples attached,在自己实现代码之前进行尝试。此外,大部分示例代码都可以复制粘贴以轻松上手。
以下是示例的屏幕截图:
1. 创建协议。使用 URL 指向的深黑色线