【发布时间】:2021-02-01 15:38:33
【问题描述】:
我正在尝试使用以下文档通过 PAYPAL REST API 集成 Paypal 订阅 https://developer.paypal.com/docs/subscriptions/integrate/(基础集成)
第 1 步(自动化成功) 第 2 步(成功创建产品) 第 3 步(成功创建计划)
第 4 步(创建订阅失败)
它看起来像是通过 JavaScript SDK 中的 Smart Payment Buttons 工作的。但是通过 REST API
curl -v -k -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions \
-H "Accept: application/json" \
-H "Authorization: Bearer Access-Token" \
-H "PayPal-Request-Id: SUBSCRIPTION-21092020-001" \
-H "Prefer: return=representation" \
-H "Content-Type: application/json" \
-d '{
"plan_id": "P-4ML8771254154362WXNWU5BC",
"start_time": "2020-11-01T00:00:00Z",
"quantity": "20",
"shipping_amount": {
"currency_code": "USD",
"value": "10.00"
},
"subscriber": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "customer@example.com",
"shipping_address": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
},
"application_context": {
"brand_name": "example",
"locale": "en-US",
"shipping_preference": "SET_PROVIDED_ADDRESS",
"user_action": "SUBSCRIBE_NOW",
"payment_method": {
"payer_selected": "PAYPAL",
"payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
},
"return_url": "https://example.com/returnUrl",
"cancel_url": "https://example.com/cancelUrl"
}
}'
我明白了
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"ec6f365217c37","details":[{"field":"/name","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field is missing."},{"field":"/payment_preferences","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field is missing."},{"field":"/billing_cycles","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field is missing."},{"field":"/product_id","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field is missing."}],"links":[{"href":"https://developer.paypal.com/docs/api/v1/billing/subscriptions#INVALID_REQUEST","rel":"information_link","method":"GET"}]}
我以所有可能的方式绑定,但我不知道如何调试问题以及我在创建订阅请求中缺少什么。谢谢!
【问题讨论】:
-
遇到同样的问题,我什至从那个 API 文档中复制粘贴代码。但没有运气
-
stackoverflow.com/questions/68979690/… 这可能会有所帮助。
标签: paypal