反应贝宝托管现场签发订单未处于已批准状态
您好,目前我正在使用 React https://www.npmjs.com/package /@paypal/react-paypal-js ->托管字段库 但正如库文档中所指定的,我正在使用下面的代码
我正在使用unirest从rest API(后端侧)创建订单
.body("{\n "意图": "捕获",\n "购买单位": [\n {\n "金额": {\n "货币代码": "美元",\n "价值" : "100.00"\n }\n }\n ],\n "application_context": {\n "return_url": "https://abcd.com",\n "cancel_url": "https://abcd.com"\n }\n}")
然后在捕获时我使用下面的代码并再次调用后端 api捕获金额,但这不起作用,因为订单未处于以下代码的批准状态。
const SubmitHandler = () =>; { if (!typeof HostedFields.submit !== "function") return; // 在使用之前验证 `submit()` 是否存在 托管字段 。提交({ // 卡中显示的全名和帐单地址 持卡人姓名:“John Wick”, }) .then((顺序) => { 拿来( “/您的服务器端集成端点/捕获支付信息” ) .then((响应) => response.json()) .then((数据) => { // 在数据里面你可以找到所有与支付相关的信息 }) .catch((错误) => { // 处理任何错误 }); }); };
在调用后端(捕获订单)API 之前,需要在步骤 2. 中将订单状态设置为已批准。所以,从后端我可以捕获订单
Hi currently i am using react https://www.npmjs.com/package/@paypal/react-paypal-js -> hostedFields library
but as specified in library doc i am using below code
i am creating an order from rest API(Backend side) using unirest
.body("{\n "intent": "CAPTURE",\n "purchase_units": [\n {\n "amount": {\n "currency_code": "USD",\n "value": "100.00"\n }\n }\n ],\n "application_context": {\n "return_url": "https://abcd.com",\n "cancel_url": "https://abcd.com"\n }\n}")
then on capture time i am using below code and calling again backend api to capture amount but that is not working because order is not in approved state from below code.
const submitHandler = () => { if (!typeof hostedFields.submit !== "function") return; // validate that `submit()` exists before using it hostedFields .submit({ // The full name as shown in the card and billing address cardholderName: "John Wick", }) .then((order) => { fetch( "/your-server-side-integration-endpoint/capture-payment-info" ) .then((response) => response.json()) .then((data) => { // Inside the data you can find all the information related to the payment }) .catch((err) => { // Handle any error }); }); };
need to make an order status as approved inside step - 2. before calling backend(capture order)API. so, from backend i can capture an order
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论