从PayPal应用程序检索所有付款信息 [英] Retrieving all Payment info from PayPal App

查看:100
本文介绍了从PayPal应用程序检索所有付款信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在尝试编写Python脚本来自动提取与促进者帐户相关联的PayPal应用所支付或接收的所有付款.我正在使用该应用程序中的client_id和client_secret以及官方的Python API库.

I've recently been trying to write a Python script to automatically fetch all the payments made or received by a PayPal app, tied to a facilitator account. I'm using the client_id and client_secret from the app, and the official Python API library.

import paypalrestsdk
import logging
logging.basicConfig(level=logging.INFO)

paypalrestsdk.configure({
    "mode": "sandbox",
    "client_id": CLIENT_ID,
    "client_secret": CLIENT_SECRET})

payment_history = paypalrestsdk.Payment.all({"count": 10})
print(payment_history.payments)

不幸的是,未打印任何内容(payment_history返回NoneType).日志打印

Unfortunately, None is printed (payment_history returns a NoneType). The logging prints

INFO:root:Request[POST]: https://api.sandbox.paypal.com/v1/oauth2/token
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1):  api.sandbox.paypal.com
INFO:root:Response[200]: OK, Duration: 0.937975s.
INFO:root:Request[GET]: https://api.sandbox.paypal.com/v1/payments/payment?count=10
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.sandbox.paypal.com
INFO:root:Response[200]: OK, Duration: 1.19636s.
None

因此,client_id和client_secret可能适合登录.在PayPal的沙盒帐户上,我已经从协调人那里接收和发送了付款,都没有输出.

so the client_id and client_secret are probably fine for logging in. On the sandbox account for PayPal, I've both received and sent payments from the facilitator, none of which are output.

话虽这么说,我做错了什么吗?这是我第一次使用PayPal API,因此任何帮助都会很棒!

That being said, is there anything I'm doing incorrectly? This is the first time I'm using the PayPal API, so any help would be great!

推荐答案

我在任何地方都没有看到此文档,但是在我看来,REST API仅返回通过新API创建的付款.

I haven't seen this documented anywhere, but it looks to me like the REST API only returns payments that were created via the new API.

您可能必须使用难看得多的Classic API,该API在 https://上有一个不错的Python客户端. github.com/duointeractive/paypal-python ,您可以像这样使用它:

You may have to use the much uglier Classic API, which has a decent Python client at https://github.com/duointeractive/paypal-python, which you can use like:

from paypal import PayPalInterface
paypal_api = PayPalInterface(API_USERNAME="xxx_xxx_apix.xxx.com",
                             API_PASSWORD="xxxxxxxxxx",
                             API_SIGNATURE="xxxxxxxxxxxxxxxxxxxxxxxx",
                             DEBUG_LEVEL=0,
                             HTTP_TIMEOUT=30)

transactions = paypal_api._call('TransactionSearch',
                                STARTDATE='2014-01-01T00:00:00Z',
                                STATUS="Success")

我正在研究一个将TransactionSearch封装在快捷方式中的分支,并将NVP响应解析为python字典列表.仍在进行中,但您可以在 https://github.com/jlev/paypal-python .欢迎补丁和请求请求!

I'm working on a fork that wraps TransactionSearch in a shortcut method and also parses the NVP response into a list of python dictionaries. Still in progress, but you can check it out at https://github.com/jlev/paypal-python. Patches and pull-requests welcome!

这篇关于从PayPal应用程序检索所有付款信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆