Python付款详情paypal

时间:2017-01-02 18:45:54

标签: python paypal

我是Paypal SDK的新手,我想从交易ID中获取付款详情,我的代码如下:

import libs.paypalrestsdk as Paypals

api = Paypals.configure({
    "mode": "sandbox",
    "client_id": "MY-CLIENT_ID",
    "client_secret": "MY-SECRET"
})

payment = Paypals.Payment.find("5LA50068PM345884U")
  1. 如何执行?

  2. 如何通过我的client_id和秘密在交易中使用?

2 个答案:

答案 0 :(得分:1)

我使用 PayPal Classic API 来获取PayPal交易详情:

pip install paypal

from paypal import PayPalInterface

paypal_api = PayPalInterface(
    API_USERNAME    = username,
    API_PASSWORD    = secret,
    API_SIGNATURE   = signatur,
    API_ENVIRONMENT = environment,
    DEBUG_LEVEL=0,
    HTTP_TIMEOUT=30
    )

transaction_details = paypal_api._call(
    'GetTransactionDetails',
    TRANSACTIONID=transaction_id
    )

并回答你的问题:

  1. 您是通过 Paypals.Payment.find(...)
  2. 执行的
  3. 您无需传递它,因为只需连接一次 Paypals.configure(...)

答案 1 :(得分:1)

pip install paypalrestsdk

    import paypalrestsdk
    sdk_mode = 'sandbox'
    paypal_client_id = "paypal_client_id"
    paypal_client_secret = "paypal_client_secret"
    paypal_api = paypalrestsdk.Api({
      'mode': sdk_mode,
      'client_id': paypal_client_id,
      'client_secret': paypal_client_secret})
    payment = paypalrestsdk.Payment.find("pay-xxx1233", api=paypal_api)