如何从新的Paypal Sync Api获取销售ID

时间:2019-07-15 13:40:14

标签: java paypal paypal-rest-sdk

我正在使用新的Paypal Sync Api在一段时间内获取所有交易。我也需要能够退款。 由于我们所有的交易都是销售,因此我需要销售ID来退还https://developer.paypal.com/docs/integration/direct/payments/refund-payments/#set-up-your-development-environment中所述的交易 不幸的是,我在交易响应中找不到任何可以用作销售ID的信息

{
    "transaction_details": [

        {
            "transaction_info": {
                "paypal_account_id": "6EN7PS8P9DV6J",
                "transaction_id": "05P62542TL3758730",
                "transaction_event_code": "T0006",
                "transaction_initiation_date": "2019-07-04T12:49:55+0000",
                "transaction_updated_date": "2019-07-04T12:53:09+0000",
                "transaction_amount": {
                    "currency_code": "USD",
                    "value": "10.00"
                },
                "fee_amount": {
                    "currency_code": "USD",
                    "value": "-0.49"
                },
                "transaction_status": "S",
                "ending_balance": {
                    "currency_code": "USD",
                    "value": "0.00"
                },
                "available_balance": {
                    "currency_code": "USD",
                    "value": "0.00"
                },
                "protection_eligibility": "01"
            },
            "payer_info": {
                "account_id": "6EN7PS8P9DV6J",
                "email_address": "paypaltester3@test.de",
                "address_status": "Y",
                "payer_status": "Y",
                "payer_name": {
                    "given_name": "Tester Three",
                    "surname": "Tester Three",
                    "alternate_full_name": "Tester Three Tester Three"
                },
                "country_code": "DE"
            },
            "shipping_info": {
                "name": "Tester Three, Tester Three",
                "address": {
                    "line1": "Teststreet. 1",
                    "city": "SomeCity",
                    "country_code": "DE",
                    "postal_code": "23434"
                }
            },
            "cart_info": {
                "item_details": [
                    {
                        "item_quantity": "1",
                        "item_unit_price": {
                            "currency_code": "USD",
                            "value": "10.00"
                        },
                        "item_amount": {
                            "currency_code": "USD",
                            "value": "10.00"
                        },
                        "total_item_amount": {
                            "currency_code": "USD",
                            "value": "10.00"
                        }
                    }
                ]
            },
            "store_info": {},
            "auction_info": {},
            "incentive_info": {}
        }
    ],
    "account_number": "96B45RCG6AX3E",
    "start_date": "2019-07-03T00:00:00+0000",
    "end_date": "2019-07-04T16:00:00+0000",
    "last_refreshed_datetime": "2019-07-15T08:59:59+0000",
    "page": 1,
    "total_items": 15,
    "total_pages": 1,
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2019-07-03T00%3A00%3A00Z&end_date=2019-07-04T16%3A00%3A00Z&fields=all&page_size=500&page=1",
            "rel": "self",
            "method": "GET"
        }
    ]
}

我测试了带有transactionId和invoiceId的退款电话,但都返回了“ INTERNAL_SERVICE_ERROR”。

客户完成付款后,是否可以通过API获取销售ID?还是在创建付款后必须将销售ID保存在数据库中?

谢谢

1 个答案:

答案 0 :(得分:0)

使用T0006,很幸运,这是一个简单的PayPal Checkout APIs.事务,使用T0002会更困难。无论如何,没有响应包含更多数据。示例如下。 您可以在invoice_numberinvoice_id中找到它。如果只有您在付款创建过程中拥有此数据。

"transaction_details":[ 
      { 
         "transaction_info":{ 
            "paypal_account_id":"HHHHH",
            "transaction_id":"040404040404040",
            "transaction_event_code":"T0006",
            "transaction_initiation_date":"2019-10-31T06:21:37+0000",
            "transaction_updated_date":"2019-10-31T06:31:02+0000",
            "transaction_amount":{ 
               "currency_code":"AUD",
               "value":"96.90"
            },
            "fee_amount":{ 
               "currency_code":"AUD",
               "value":"-4.08"
            },
            "shipping_amount":{ 
               "currency_code":"AUD",
               "value":"17.90"
            },
            "transaction_status":"S",
            "transaction_subject":"Full License",
            "ending_balance":{ 
               "currency_code":"AUD",
               "value":"92.82"
            },
            "available_balance":{ 
               "currency_code":"AUD",
               "value":"92.82"
            },
            "invoice_id":"1110-US1",
            "protection_eligibility":"01"
         },
         "payer_info":{ 
            "account_id":"HHHHH",
            "email_address":"test@paypal.com",
            "address_status":"Y",
            "payer_status":"Y",
            "payer_name":{ 
               "given_name":"First",
               "surname":"Last",
               "alternate_full_name":"First Last"
            },
            "country_code":"GB"
         },
         "shipping_info":{ 
            "name":"Shaun Smith",
            "address":{ 
               "line1":"123, Some Road",
               "line2":"Shop 4",
               "city":"Melbourne",
               "country_code":"AU",
               "postal_code":"3185"
            }
         },
         "cart_info":{ 
            "item_details":[ 
               { 
                  "item_name":"Full License",
                  "item_description":"Full License",
                  "item_quantity":"1",
                  "item_unit_price":{ 
                     "currency_code":"AUD",
                     "value":"79.00"
                  },
                  "item_amount":{ 
                     "currency_code":"AUD",
                     "value":"79.00"
                  },
                  "total_item_amount":{ 
                     "currency_code":"AUD",
                     "value":"79.00"
                  },
                  "invoice_number":"1110-US1"
               }
            ]
         },
         "store_info":{ 

         },
         "auction_info":{ 

         },
         "incentive_info":{ 

         }
      },