【发布时间】:2021-11-30 03:31:51
【问题描述】:
我试图调试与使用订单 ID(之前存储的)退款 Paypal 订单(在沙盒环境中)相关的问题。每次我尝试退款时,Paypal API 都会返回一个INVALID_RESOURCE_ID 错误,这意味着不存在这样的订单。经过多次调试,我对存储该订单ID时的初始过程做出了启示。以下方法是我检索和存储所述订单 ID 的方式:
const onApprove = (data, actions) => {
// Redux method of saving checkout in backend with order ID via using data.orderID
dispatch(saveCheckout(data.orderID);
return actions.order.capture();
}
<PayPalButton
amount={totalPrice}
currency= "AUD"
createOrder={(data, actions) => createOrder(data, actions)}
onApprove={(data, actions) => onApprove(data, actions)}
options={{
clientId: "<placeholder>",
currency: "AUD"
}}
/>
我正在使用文档中推荐的 data.orderID,但是,在检查网络选项卡时,显示以下内容:
{"id":"5RJ421191B663801G","intent":"CAPTURE","status":"COMPLETED","purchase_units":[{"reference_id":"default","amount":{"currency_code":"AUD","value":"24.00"},"payee":{"email_address":"sb-sg4zd7438633@business.example.com","merchant_id":"EJ7NSJGC6SRXQ"},"shipping":{"name":{"full_name":"John Doe"},"address":{"address_line_1":"1 Cheeseman Ave Brighton East","admin_area_2":"Melbourne","admin_area_1":"Victoria","postal_code":"3001","country_code":"AU"}},"payments":{"captures":[{"id":"7A2856455D561633D","status":"COMPLETED","amount":{"currency_code":"AUD","value":"24.00"},"final_capture":true,"seller_protection":{"status":"ELIGIBLE","dispute_categories":["ITEM_NOT_RECEIVED","UNAUTHORIZED_TRANSACTION"]},"create_time":"2021-10-11T00:40:58Z","update_time":"2021-10-11T00:40:58Z"}]}}],"payer":{"name":{"given_name":"John","surname":"Doe"},"email_address":"sb-432azn7439880@personal.example.com","payer_id":"KMEQSKCLCLUZ4","address":{"country_code":"AU"}},"create_time":"2021-10-11T00:40:48Z","update_time":"2021-10-11T00:40:58Z","links":[{"href":"https://api.sandbox.paypal.com/v2/checkout/orders/5RJ421191B663801G","rel":"self","method":"GET"}]}
onApprove保存的id是5RJ421191B663801G,但是captures和id下还有一个ID是7A2856455D561633D。这是我需要保存的 实际 订单 ID,以便以后进行退款。但是,我正在努力如何检索该值,因为该 id 值似乎只能通过网络看到。通过 onApprove 和 action.order.get() 方法返回的对象只返回第一个“假”id。任何建议将不胜感激。
【问题讨论】:
标签: reactjs paypal paypal-sandbox