如何从付款中获取transactionID

时间:2014-11-20 08:34:41

标签: python paypal

对于成功创建的以下付款:

res = requests.post(
    "https://svcs{}.paypal.com/AdaptivePayments/Pay/".format("" if settings.STAGE == "production" else ".sandbox"),
    headers=headers, data=params
)

data = res.json()

我如何获得TransactionID,我需要将其保存在我的数据库中?

1 个答案:

答案 0 :(得分:0)

您可以通过致电TransactionID -

来获取/AdaptivePayments/PaymentDetails/
params = OrderedDict()
params['requestEnvelope.errorLanguage'] = 'en_US'
params['payKey'] = pay_key
res = requests.post('https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails/', headers=headers, data=params)
transaction_id = res.json()['paymentInfoList']['paymentInfo'][0]['senderTransactionId']

以下是文档:https://developer.paypal.com/docs/classic/api/adaptive-payments/PaymentDetails_API_Operation/