I would like to retrieve information about each item sold in a PayPal transaction. They were loaded into a Transaction object at the point of sale: $transaction->setItemList($itemList);
, but were not stored on a local database.
I only have access to sale and payment ID's. Using the PayPal API, how can I get the list of items back?
Maybe I'm not looking at the API docs hard enough, but I can't seem to find any info about this.
Yes you can retrieve the item list details(assuming that you passed to the PayPal) using the Payment ID's via the Look Up API call . You can check the below link for the API call:
https://developer.paypal.com/webapps/developer/docs/api/#look-up-a-payment-resource
I have included the call to one of my Payment ID in sandbox account :
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"
}
]
}