问题描述
- 我正在使用
load_profile_data
提供的REST APIs
将Paypal结帐功能集成到Android应用中,并且我的国家是印度,因此我关注PayPal的this guide。 - 我如何按照文档进行操作:
订单是这样创建的,我将href加载到webview中:
url
解决方法
我这样做:
-
客户成功完成付款后,将使用查询参数
return_url
和PayerID
( orderID )调用token
。届时,我们可以在数据库中更新用户的付款状态(由于尚未批准或捕获订单,因此尚未扣除金额。) -
此后,我们可以捕获我们的订单(确保发票编号不重复),否则状态将不会完成。
-
如果在截获时未批准订单,则会出现此类错误:
{ "name": "UNPROCESSABLE_ENTITY","details": [ { "issue": "ORDER_NOT_APPROVED","description": "Payer has not yet approved the Order for payment. Please redirect the payer to the 'rel':'approve' url returned as part of the HATEOAS links within the Create Order call or provide a valid payment_source in the request." } ],"message": "The requested action could not be performed,semantically incorrect,or failed business validation.","debug_id": "47af43e..","links": [ { "href": "https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_NOT_APPROVED","rel": "information_link","method": "GET" } ]
}
-
如果发票号重复,则捕获时会看到错误:
{ "name": "UNPROCESSABLE_ENTITY","details": [ { "issue": "DUPLICATE_INVOICE_ID","description": "Duplicate Invoice ID detected. To avoid a potential duplicate transaction your account setting requires that Invoice Id be unique for each transaction." } ],"debug_id": "86e0cc7f....","links": [ { "href": "https://developer.paypal.com/docs/api/orders/v2/#error-DUPLICATE_INVOICE_ID","method": "GET" } ]
}
如果存在基于货币的问题:
{
"name": "UNPROCESSABLE_ENTITY","details": [
{
"location": "body","issue": "CURRENCY_NOT_SUPPORTED","description": "Currency code is not currently supported. Please refer https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ for list of supported currency codes."
}
],"debug_id": "d666b5e5eb0c0","links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-CURRENCY_NOT_SUPPORTED","method": "GET"
}
]
}
如果成功捕获到状态为COMPLETED的订单:
{
"id": "8G0042477K865063U","status": "COMPLETED","purchase_units": [
{
"reference_id": "default","shipping": {
"name": {
"full_name": "John Doe"
},"address": {
"address_line_1": "10,east street","address_line_2": "first building","admin_area_2": "Mumbai","admin_area_1": "Maharashtra","postal_code": "400029","country_code": "NZ"
}
},"payments": {
"captures": [
{
"id": "4K670967VH2547504","status": "PENDING","status_details": {
"reason": "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"
},"amount": {
"currency_code": "NZD","value": "170.00"
},"final_capture": true,"seller_protection": {
"status": "ELIGIBLE","dispute_categories": [
"ITEM_NOT_RECEIVED","UNAUTHORIZED_TRANSACTION"
]
},"invoice_id": "INV-1234567888","links": [
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504","rel": "self","method": "GET"
},{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504/refund","rel": "refund","method": "POST"
},{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U","rel": "up","method": "GET"
}
],"create_time": "2020-10-31T13:35:58Z","update_time": "2020-10-31T13:35:58Z"
}
]
}
}
],"payer": {
"name": {
"given_name": "Sumit","surname": "Shukla"
},"email_address": "testg32@gmail.com","payer_id": "VW87TYSM2GMZ4","address": {
"address_line_1": "10,"country_code": "NZ"
}
},"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U","method": "GET"
}
]
}
之后,您可以将用户重定向到“谢谢”页面,并根据数据库值更新移动应用程序屏幕。