贝宝 - 商人取消交易
我是贝宝集成的新手。我在node.js中有一个应用程序,我的客户要求贝宝集成。到目前为止,我已经完成的工作:
- 呼叫/v1/oauth2/token获取令牌
- 呼叫/v2/checkout/订单,以获取批准链接
- 重定向到第2步中获得的URL,
- 请按照paypal上的步骤付款,以付费
- 。 ,我想一切都奏效了
:钱不会交给商人。有时,它们是从我的卡中取出的,几分钟后,他们会带回消息:商人取消您的交易。有时钱不是从我的卡上拿走的。 我正在使用Live Client_id和秘密。
有人有这个问题吗?
I'm new to PayPal integrations. I have an application in node.js and my client asked for PayPal integration. What I've done so far :
- call /v1/oauth2/token to obtain the token
- call /v2/checkout/orders to obtain the approve link
- redirect to the url obtained at step 2
- follow the steps on paypal to pay
- the success_url is called, I suppose everything worked fine
Problem: the money does not go to the merchant. Sometimes they are taken from my card and and after few minutes they are send back with the message: merchant cancel your transaction. Sometimes the money are not taken from my card.
I'm using a live client_id and secret.
Does anybody have this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
,但是过程尚未完成。付款人批准了该订单,但是在您捕获订单之前,没有付款。您缺少捕获API步骤。当使用此类重定向集成时,可以预期您的“ success_url”(尽管API参数为“ redirect_url”)应显示一个订单审核页面,当给出最终确认时,您的系统应执行v2 /结帐/订单捕获API调用,完成付款,并显示此捕获API调用的成功(谢谢)或失败(有错误)结果。
此外,从您的网站上重定向是旧网站的旧贝宝集成流。当前 paypal结帐集成集成不使用重定向。根本。
而是在服务器上进行2条路线(URL路径),一个用于“创建订单”,另一条用于“捕获顺序”。这两种路线都应仅返回JSON数据(无HTML或文本)。在第二路线内,当捕获API成功时,您应该验证金额正确,并将其由此产生的付款详细信息存储在您的数据库中(尤其是
paskuy_units [0] .payments.payments.captures.captures [0] .id
,这是PayPal交易ID),并在将返回json转发给前端呼叫者之前,请立即执行任何必要的业务逻辑(例如发送确认电子邮件或保留产品)。如果错误向前转发JSON的详细信息,因为前端必须处理此类情况。将这两条路线与此前端批准流配对: https:https:https:///developer.paypaler.paypal。 com/demo/beckout/#/tatter/server 。 (如果您需要将客户端从客户端发送任何其他数据发送到服务器,例如项目数组或选定的选项,请添加一个
body
参数,并以JSON字符串或对象的值将其添加到获取的值)由于您使用了节点,因此第一个链接在节点中具有完整的堆栈示例。只需确保使用完整的客户端错误处理(请参阅第二个链接)扩展Onapprove函数,因为该节点示例目前还不包括该级别的详细信息。
You suppose, but the process is not complete. The payer approved the order, but no payment takes place until you capture the order. You are missing the capture API step. When using such a redirect integration, it is expected that your "success_url" (as you call it, though the API parameter is "redirect_url") should show an order review page, and when final confirmation is given your system should then execute a v2/checkout/orders Capture API call, to complete the payment, and show the success (thank you) or failure (there was an error) result of this capture API call.
Moreover, redirecting away from your website is an old PayPal integration flow, for old websites. Current PayPal Checkout integrations use no redirects. At all.
Instead, make 2 routes (url paths) on your server, one for 'Create Order' and one for 'Capture Order'. Both of these routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should verify the amount was correct and store its resulting payment details in your database (particularly
purchase_units[0].payments.captures[0].id
, which is the PayPal transaction ID) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller. In the event of an error forward the JSON details of it as well, since the frontend must handle such cases.Pair those 2 routes with this frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server . (If you need to send any additional data from the client to the server, such as an items array or selected options, add a
body
parameter to the fetch with a value that is a JSON string or object)Since you're using node, the first link has a full stack example in node. Just be sure to extend the onApprove function with full client-side error handling (see second link) as the node sample doesn't include that level of detail at the moment.