Paypal v2 API 如何获取交易数据以及如何退款
我的问题如下: 我有一个企业贝宝帐户,其中有我的客户进行的交易列表(在我的网页上购买产品)。我通过 paypal IPN 存储他们的订单信息,该 IPN 只向我发送订单的交易 ID。因此,我将此事务 ID 与其他基本数据一起存储在我的数据库中。 现在我需要两件事:
- 通过 php 代码检索交易数据。
- 也可通过 php 代码对任何交易进行退款。
我认为 Paypal API v2 是推荐的,因为 v1 将被放弃。我正在使用 Checkout-PHP-SDK: https://github.com/paypal/Checkout-PHP-SDK
但我'我仅在尝试获取任何交易数据时遇到问题。我读到,为了获取数据,我不能使用交易 ID,而是使用订单 ID。但是如何使用我忽略的订单 ID?因为从 paypal IPN 我只收到交易 ID,而这只是我所拥有的。那么如何从这个交易id中获取订单id呢?我知道我可能混淆了术语,所以提前抱歉。
My problem is as follows:
I have a business paypal account where I have a list of transactions made by my clients (buying products on my webpage). I store their orders info via paypal IPN which only sends me the transaction ID of the order. So I store this transaction ID on my database among other basic data.
Now I need 2 things:
- Retrieve the transaction data via php code.
- Make refunds of any transaction also via php code.
I see Paypal API v2 is the recommended as the v1 is gonna be abandoned. I'm using Checkout-PHP-SDK:
https://github.com/paypal/Checkout-PHP-SDK
But I'm facing problems only trying to get any transaction data. I read that in order to get the data i cannot use the transaction ID but the order ID instead. But how can use an order ID that I ignore?, because from paypal IPN I only receive transaction ID and that's only what I have. So how can I get the order id from this transaction id?. I know I'm probably confusing terms so sorry in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您捕获订单时,即时 API 响应已包含有关交易的所有信息 - 包括
purchase_units[0]. payments.captures[0].id
处的交易 ID。无需使用旧的 IPN 服务。您的集成不应以任何方式依赖 IPN,这是糟糕的设计。如需退款,请将该交易(捕获)ID 与 v2/ payments API
When you capture an order, the immediate API response already contains all information about the transaction -- including the transaction ID at
purchase_units[0].payments.captures[0].id
. There is no need to use the old IPN service. Your integration should not depend on IPN in any way, that is bad design.For refunds, use that transaction (capture) id with the v2/payments API