[英]Why paymentID is null after PayPal transaction?
I'm using PayPal in sandbox mode and @paypal/react-paypal-js in my React application and I'm using .NET 5 as my REST API. I'm using PayPal in sandbox mode and @paypal/react-paypal-js in my React application and I'm using .NET 5 as my REST API. Here is my payload when I want to create an order:
这是我想创建订单时的有效负载:
{
"totalAmount": 102,
"tax": 0,
"fee": 2,
"paymentMethod": 1,
"items": [
{
"amount": 100,
"reciver": "vala",
"phone": "0912351231",
"email": "vala@gmail.com",
"sender": "ali",
"count": 1
}
]
}
And here is part of my react code that call PayPal API:这是我调用 PayPal API 的反应代码的一部分:
<BoxPayment isRtl={isRtl}>
<Text as="h3">{translations.buyPage.paymentMethodTitle}</Text>
<Text as="p">{translations.buyPage.paymentMethodSubTitle}</Text>
<div style={{ 'paddingTop': '.5rem' }}>
<PayPalScriptProvider options={initialOptions}>
<PayPalButtons createOrder={(data, actions) => createOrder(data, actions)}
onApprove={(data, actions: any) => {
console.log('data', data);
console.log('actions', actions);
return actions.order.capture().then((details: any) => {
console.log('details', details);
const name = details.payer.name.given_name;
});
}} />
</PayPalScriptProvider>
</div>
</BoxPayment>
But after successful payment here's what I receive when I console.log data object:但是在成功付款后,当我 console.log 数据 object 时收到以下内容:
{
"orderID": "48G91901G2470590C",
"payerID": "NBPJH63GK5H5Q",
"paymentID": null,
"billingToken": null,
"facilitatorAccessToken": "A11VAJ-tUcUqKkJgAhnyfVGVYg6Z57SvqHfspQqB8vtUDjDzBMIBlvO6rDvwdIjW7aJwvQQYeMAGyWitChtVZ8LyBzCw"
}
What I am missing?我错过了什么?
Within onApprove
, the order hasn't been captured when you are printing that data.在
onApprove
中,打印该数据时尚未捕获订单。 Capture the order first.先抓订单。 When an order is captured, its transaction ID will be in the response's
purchase_units[0].payments.captures[0]
捕获订单后,其交易 ID 将在响应的
purchase_units[0].payments.captures[0]
If you need to do anything important with that ID, such as store it in a database, used a server-side integration ( not actions.order.capture nor actions.order.create, client-side code is not for database operations).如果您需要对该 ID 执行任何重要操作,例如将其存储在数据库中,请使用服务器端集成(不是actions.order.capture 或 actions.order.create,客户端代码不适用于数据库操作)。 See the optional step #5 in the 'Add and modify the code' section of the guide for Integrate Checkout , and be sure to use the client-side error handling code in its linked demo pattern example .
请参阅Integrate Checkout指南的“添加和修改代码”部分中的可选步骤 #5,并确保在其链接的演示模式示例中使用客户端错误处理代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.