我想知道如何从PayPal API v2获取交易ID。
我已经通过PayPal API v2(https://developer.paypal.com/docs/api/orders/v2/)创建了一个订单,并成功捕获了它。订单状态为“已完成”,并且该订单已出现在我的PayPal沙箱帐户中的“活动”中。现在,我想获取捕获交易的交易ID(参见图片),但我无法获取它。
我可以通过PayPal API获取订单的详细信息,但是只获取了订单ID和捕获ID。 API响应中缺少在图像上标记的交易ID。我需要怎么做才能获得交易ID?非常感谢。
{
"statusCode": 200,
"result": {
***************************************************************
"id": "91K02466UY433503E", <= ORDER ID
***************************************************************
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "PZ755454789",
"amount": {
"currency_code": "EUR",
"value": "48.10",
"breakdown": {
"item_total": {
"currency_code": "EUR",
"value": "32.06"
},
"shipping": {
"currency_code": "EUR",
"value": "9.95"
},
"handling": {
"currency_code": "EUR",
"value": "0.00"
},
"tax_total": {
"currency_code": "EUR",
"value": "6.09"
},
"insurance": {
"currency_code": "EUR",
"value": "0.00"
},
"shipping_discount": {
"currency_code": "EUR",
"value": "0.00"
},
"discount": {
"currency_code": "EUR",
"value": "0.00"
}
}
},
"payee": {
"email_address": "XXXXXXXXXXXXXXX",
"merchant_id": "HE3H3VSFV3Q5G"
},
"description": "PZ755454789",
"custom_id": "PZ755454789",
"items": [
{
"name": "Calvin Klein Euphoria for Women Eau De Parfum 100 ml (woman)",
"unit_amount": {
"currency_code": "EUR",
"value": "32.06"
},
"tax": {
"currency_code": "EUR",
"value": "6.09"
},
"quantity": "1",
"sku": "24837"
}
],
"shipping": {
"name": {
"full_name": "XXXXXXXXX"
},
"address": {
"address_line_1": "XXXXXXX",
"admin_area_2": "XXXXX",
"postal_code": "XXXXX",
"country_code": "XX"
}
},
"payments": {
"captures": [
{
*******************************************************
"id": "40J088343X584271G", <= CAPTURE ID
*******************************************************
"status": "COMPLETED",
"amount": {
"currency_code": "EUR",
"value": "48.10"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"seller_receivable_breakdown": {
"gross_amount": {
"currency_code": "EUR",
"value": "48.10"
},
"paypal_fee": {
"currency_code": "EUR",
"value": "1.26"
},
"net_amount": {
"currency_code": "EUR",
"value": "46.84"
}
},
"custom_id": "PZ755454789",
"links": [
{
"href": "https:\/\/api.sandbox.paypal.com\/v2\/payments\/captures\/40J088343X584271G",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.sandbox.paypal.com\/v2\/payments\/captures\/40J088343X584271G\/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https:\/\/api.sandbox.paypal.com\/v2\/checkout\/orders\/91K02466UY433503E",
"rel": "up",
"method": "GET"
}
],
"create_time": "2019-08-14T12:44:13Z",
"update_time": "2019-08-14T12:44:13Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "XXXXXX",
"surname": "XXXXXXX"
},
"email_address": "XXXXXXXXXXXX",
"payer_id": "SS5Q2CS6CKX5L",
"phone": {
"phone_number": {
"national_number": "0111111111"
}
},
"address": {
"country_code": "XX"
}
},
"update_time": "2019-08-14T12:44:13Z",
"links": [
{
"href": "https:\/\/api.sandbox.paypal.com\/v2\/checkout\/orders\/91K02466UY433503E",
"rel": "self",
"method": "GET"
}
],
"status": "COMPLETED"
},
"headers": {
"": "",
"Date": "Fri, 16 Aug 2019 06",
"Server": "Apache",
"paypal-debug-id": "557573ed4e5b2",
"HTTP_X_PP_AZ_LOCATOR": "sandbox.slc",
"Paypal-Debug-Id": "557573ed4e5b2",
"Set-Cookie": "X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00",
"Vary": "Authorization",
"Content-Length": "2339",
"Connection": "close",
"Content-Type": "application\/json"
}
}
答案 0 :(得分:1)
有两个交易ID,一个用于卖方,一个用于买方。作为API调用者,您只能看到卖方交易ID(捕获ID),而看不到买方。
您出于任何原因需要显示买方的transaction_id?