payment = Payment({
"intent": "sale",
"application_context": {
"locale": "en_IN",
"user_action": "commit",
"shipping_preference": "NO_SHIPPING",
"landing_page": "billing"
},
# Set payment method
"payer": {
"payment_method": "paypal",
"payer_info": {
"email": email,
"first_name": first_name,
"last_name": last_name,
"shipping_address": {
"phone": phone,
}
}
},
# Set redirect URLs
"redirect_urls": {
"return_url": "example.com/confpayment/",
"cancel_url": "examplecom/payment_fail/"
},
# Set transaction object
"transactions": [{
"amount": {
"total": str(amount),
# "total": "1",
"currency": "INR"
},
"description": "payment description"
}]
})
我收到传入的JSON请求未映射到API请求
错误:
{'name': 'MALFORMED_REQUEST', 'message': 'Incoming JSON request does not map to API request', 'information_link': 'https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST', 'debug_id': '51397a89429bd'}
除手机号码外,其他所有东西都已预先填写。 请帮我解决这个问题。
我不确定API格式是否正确。
答案 0 :(得分:0)
编辑预览代码错误:
此处payer
属性的文档(链接已更正为V2):
https://developer.paypal.com/docs/api/orders/v2/?mark=payer#definition-payer
错误,请删除多余的逗号:"phone": "",
"payer_info": {
...
"shipping_address": {
"phone": ""
}
}
此代码错误:
将phone
移到shipping_address
之外:
"payer_info": {
...
"shipping_address": {
...
},
"phone": ""
}