PayPal - 美国和加拿大地址的错误 400 [英] PayPal -error 400 for US and Canada addresses
问题描述
我在结账时向 PayPal 发送此请求:
I am sending this request to PayPal in my checkout:
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
}
如果我将地址更改为加拿大以外的任何其他国家/地区,则该请求有效.
if I change the address to any other country, except Canada, the request works.
看文档,https://developer.paypal.com/docs/api/#address-object,只需要line1,city和country_code.
looking at the documentation, https://developer.paypal.com/docs/api/#address-object, only line1, city and country_code are required.
对于美国和加拿大,我可能遗漏了什么特定的东西吗?
is there anything specific i am missing, for USA and Canada that i may have missed?
推荐答案
您的请求中似乎缺少 state 字段.由于加拿大和美国有 state 字段,您需要通过它.API 请求:
It seems that you are missing state field in your request . Since Canada and US have state field , you need to pass it . API 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",
"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"
}
]
}
这篇关于PayPal - 美国和加拿大地址的错误 400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!