Paypal:订单 API 与付款 API,以及寻找更好的文档 [英] Paypal: Orders API vs Payments API, and finding better documentation

查看:98
本文介绍了Paypal:订单 API 与付款 API,以及寻找更好的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全迷失在 PayPal 的 API 文档中.我一直在使用订单 API 和 PayPal Checkout SDK 尝试为项目设置付款.在尝试破译 Orders v2 API 参考时,为了使用针对先前授权的订单总额进行多次捕获,我发现了一堆似乎更有用的文档,而不是讨论 Payments API.我无法理解两者之间的区别,或者我应该使用哪个或用于什么.

I am completely lost among PayPal's API documentation. I have been working with the orders API and the PayPal Checkout SDK trying to set up payments for a project. In trying to decipher the Orders v2 API reference, for the use of making multiple captures towards a previously authorized total for an order, I found a bunch of what seemed to be more useful documentation discussing the Payments API instead. I'm having trouble understanding what the difference between the two are or which I should be using or for what.

Orders API 参考如下:

订单代表两方或多方之间的付款.使用 Orders API 创建、更新、检索、授权和捕获订单.

An order represents a payment between two or more parties. Use the Orders API to create, update, retrieve, authorize, and capture orders.

虽然 Payments API 参考 是这样说的:

调用 Payments API 进行支付授权,获取授权付款,退还已捕获的付款,并显示支付信息.将 Payments API 与订单 API.如需了解详情,请参阅 PayPal Checkout 概览.

Call the Payments API to authorize payments, capture authorized payments, refund payments that have already been captured, and show payment information. Use the Payments API in conjunction with the Orders API. For more information, see the PayPal Checkout Overview.

他们都描述了做几乎完全相同的事情,并且 Payments API 说它应该与 Orders API 结合使用,但实际上没有提供任何关于如何一起使用它们的指导.结帐概览"给出的链接指向带有 Orders API 的智能按钮指南,但实际上从未提及 Payments API.

They are both describing doing almost the exact same things and the Payments API says it should be used in conjunction with the Orders API without actually providing any guidance for how they should be used together. The "Checkout Overview" link given goes to the guide for Smart Buttons with the Orders API and doesn't actually ever mention the Payments API.

所以我的主要问题如下:

So my main questions are as follows:

  • 这两个 API 之间有什么区别?
  • 我需要使用哪个 API 来支持多次捕获?似乎 Payments 是唯一一个支持多次捕获的,但我已经拥有仅使用 Orders API 来创建 intent=AUTHORIZE 交易的基础设施,并发送 order_id发送给客户端,以便可以弹出 PayPal 并授权订单,以及接收该授权通知的网络钩子.我现在可以使用 Payments API 来捕获吗?我什至需要吗?我在订单文档中找不到与多次捕获相关的任何内容.
  • 是否有其他优秀的文献描述了 Checkout SDK 和 Orders/Payments API 的所有移动部分如何组合在一起以实现较小规模的项目?PayPal 自己的指南随处可见,几乎没有描述不同部分如何交互或何时需要一个 API 与另一个 API.
  • What is the difference between the two APIs?
  • Which API do I need to use to support multiple captures? It seems like Payments is the only one which supports multiple captures but I already have infrastructure in place using only the Orders API to create an intent=AUTHORIZE transaction, have the order_id sent to the client so that PayPal can be popped up and the order authorized, and a webhook to receive the notification for that authorization. Can I now use the Payments API just to capture from that? Do I even need to? I can't find anything related to multiple captures in the Orders documentation.
  • Is there any other good literature describing how all of the moving parts of the Checkout SDK and the Orders/Payments API fit together for a smaller scale project? PayPal's own guides are all over the place and do very little to describe how the different parts interact or when you need one API vs the other.

推荐答案

v2/orders 用于付款人审批流程.使用 "intent":"authorize",成功的订单将产生一个 Authorization 对象供以后使用.

v2/orders is for the payer approval process. With "intent":"authorize", a successful order will result in an Authorization object for later use.

v2/payments 用于管理授权以及已完成的捕获.例如,扣款或作废授权,或退还扣款.

v2/payments is for managing authorizations as well as completed captures. For example, to capture or void an authorization, or to refund a capture.

您提到了 webhooks,这可能使事情过于复杂.最好的集成是在您的服务器上简单地制作两条路线,一条用于创建订单",另一条用于授权订单",此处记录.这些路由应该只返回 JSON 数据(没有 HTML 或文本).后者应该(成功时)在返回之前将付款详细信息存储在您的数据库中(特别是 purchase_units[0].payments.authorizations[0].id)

You mentioned webhooks, which is probably overcomplicating things. The best integration is to simply make two routes on your server, one for 'Create an Order' and one for 'Authorize an Order', documented here. These routes should return only JSON data (no HTML or text). The latter one should (on success) store the payment details in your database before it does the return (particularly purchase_units[0].payments.authorizations[0].id)

将这两条路线与以下审批流程配对:https://developer.paypal.com/demo/checkout/#/pattern/server

Pair those two routes with the following approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

这篇关于Paypal:订单 API 与付款 API,以及寻找更好的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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