我在结账时将此请求发送给PayPal:
Request >>>> {
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "2386.81",
"currency": "GBP",
"details": {
"subtotal": "1854.81",
"shipping": "532.00",
"tax": "0.00"
}
},
"item_list": {
"shipping_address": {
"recipient_name": "Johnny",
"type": "business",
"line1": "245",
"line2": "5th Avenue ",
"city": "Columbia -",
"country_code": "US",
"postal_code": "MO 65201",
"phone": "001 212 12345678"
}
},
"description": "907 items"
}
],
"redirect_urls": {
"return_url": "http://localhost:3000/payment/paypal-approved",
"cancel_url": "http://localhost:3000/payment/paypal-cancelled"
}
}
但是我收到以下错误:
{
"cause": {
"response": {
"name": "UNKNOWN_ERROR",
"message": "An unknown error has occurred",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR",
"debug_id": "b005dc4a36cc6",
"httpStatusCode": 400
},
"httpStatusCode": 400
},
"isOperational": true,
"response": {
"name": "UNKNOWN_ERROR",
"message": "An unknown error has occurred",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR",
"debug_id": "b005dc4a36cc6",
"httpStatusCode": 400
},
"httpStatusCode": 400
}
如果我将地址更改为除加拿大以外的任何其他国家/地区,则请求有效。
查看文档https://developer.paypal.com/docs/api/#address-object,只需要line1,city和country_code。
对于我可能错过的美国和加拿大,我有什么具体的遗漏吗?
答案 0 :(得分:0)
您的请求中似乎缺少州字段。由于加拿大和美国都有州,你需要通过它。 API请求:
{
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "2386.81",
"currency": "GBP",
"details": {
"subtotal": "1854.81",
"shipping": "532.00",
"tax": "0.00"
}
},
"item_list": {
"shipping_address": {
"recipient_name": "Johnny",
"type": "business",
"line1": "245",
"line2": "5th Avenue ",
"city": "Columbia",
"country_code": "US",
"state": "MO",
"postal_code": "65201",
"phone": "001 212 12345678"
}
},
"description": "907 items"
}
],
"redirect_urls": {
"return_url": "http://localhost:3000/payment/paypal-approved",
"cancel_url": "http://localhost:3000/payment/paypal-cancelled"
}
}
API响应:
{
"id": "PAY-4NK43903V190842KVLY5JA",
"create_time": "2015-05-16T18:38:28Z",
"update_time": "2015-05-16T18:38:28Z",
"state": "created",
"intent": "authorize",
"payer": {
"payment_method": "paypal",
"payer_info": {
"shipping_address": {}
}
},
"transactions": [
{
"amount": {
"total": "2386.81",
"currency": "GBP",
"details": {
"subtotal": "1854.81",
"shipping": "532.00"
}
},
"description": "907 items",
"item_list": {
"shipping_address": {
"recipient_name": "Johnny",
"line1": "245",
"line2": "5th Avenue ",
"city": "Columbia",
"state": "MO",
"phone": "001 212 12345678",
"postal_code": "65201",
"country_code": "US"
}
},
"related_resources": []
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-4NK43903V1908425XKVLY5JA",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-9XM291481W9678205",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-4NK43903V1908425XKVLY5JA/execute",
"rel": "execute",
"method": "POST"
}
]
}