【问题标题】:Is there a way to get an ItemList back from a PayPal Sale ID?有没有办法从 PayPal 销售 ID 中获取 ItemList?
【发布时间】:2015-11-18 11:10:21
【问题描述】:

我想检索有关在 PayPal 交易中售出的每件商品的信息。它们在销售点被加载到一个 Transaction 对象中:$transaction->setItemList($itemList);,但没有存储在本地数据库中。

我只能访问销售和付款 ID。使用 PayPal API,我怎样才能获取项目列表?

也许我没有足够认真地查看 API 文档,但我似乎找不到任何关于此的信息。

【问题讨论】:

  • 您使用的是 Classic API 还是 REST API?
  • 我正在使用带有 PHP SDK 接口的 REST API

标签: php paypal e-commerce


【解决方案1】:

是的,您可以通过 Look Up API 调用使用付款 ID 检索项目列表详细信息(假设您已传递给 PayPal)。您可以查看以下 API 调用链接:

https://developer.paypal.com/webapps/developer/docs/api/#look-up-a-payment-resource

我已在沙盒帐户中包含对我的付款 ID 之一的调用:

GET https://api.sandbox.paypal.com/v1/payments/payment/PAY-9NS54822BJ985714GKQ5RH2Y

{
"id": "PAY-9NS54822BJ985714GKQ5RH2Y",
"create_time": "2014-10-12T23:51:07Z",
"update_time": "2014-10-12T23:57:54Z",
"state": "approved",
"intent": "sale",
"payer": {
"payment_method": "paypal",
"status": "VERIFIED",
"payer_info": {
"email": "XXXXXXX",
"first_name": "XXXX Personal Test",
"last_name": "Account",
"payer_id": "XXXXX",
"shipping_address": {
"line1": "cxas",
"line2": "asa",
"city": "FL",
"state": "FL",
"postal_code": "95616",
"country_code": "US",
"recipient_name": "XXXXXPersonal Test Account"
},
"phone": "408-767-7151"
}
},
"transactions": [
{
"amount": {
"total": "20.00",
"currency": "USD",
"details": {
"subtotal": "18.00",
"tax": "1.00",
"shipping": "1.00"
}
},
"description": "This is payment description.",
"item_list": {
"items": [
{
"name": "Hat",
"sku": "product12345",
"price": "2.00",
"currency": "USD",
"quantity": "3",
"description": "This is desc"
},
{
"name": "Hat",
"sku": "product12345",
"price": "2.00",
"currency": "USD",
"quantity": "3",
"description": "This is desc"
},
{
"name": "Hat",
"sku": "product12345",
"price": "2.00",
"currency": "USD",
"quantity": "3",
"description": "This is desc"
}
]
},
"related_resources": [
{
"sale": {
"id": "0P200860V96590012",
"create_time": "2014-10-12T23:51:07Z",
"update_time": "2014-10-12T23:57:54Z",
"amount": {
"total": "20.00",
"currency": "USD"
},
"payment_mode": "INSTANT_TRANSFER",
"state": "completed",
"protection_eligibility": "ELIGIBLE",
"protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
"parent_payment": "PAY-9NS54822BJ985714GKQ5RH2Y",
"transaction_fee": {
"value": "0.88",
"currency": "USD"
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/0P200860V96590012",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/sale/0P200860V96590012/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-9NS54822BJ985714GKQ5RH2Y",
"rel": "parent_payment",
"method": "GET"
}
]
}
}
]
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-9NS54822BJ985714GKQ5RH2Y",
"rel": "self",
"method": "GET"
}
]
}

【讨论】:

    猜你喜欢
    • 2015-03-01
    • 2019-11-24
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-05
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多