简体   繁体   English

为什么在 PayPal 交易后 paymentID 是 null?

[英]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.

相关问题 PayPal React 集成未创建事务 - PayPal React Integration not creating transaction 为什么state设置后还是null? - Why is the state still null even after setting it? 如何在 React.js 中的两个用户之间进行 PayPal 交易? - How to do PayPal transaction between two users in React.js? PayPal 沙盒交易成功,即使付款人账户有 0.00 余额 - PayPal sandbox transaction success even if payer account has 0.00 balance 如何获取 paypal node.js 中的事务 ID 反应? - How to get the transaction ID in paypal node.js react? PayPal:检查订阅者是否为订阅付费 - PayPal: After Check whether subscriber is paid for subscription 为什么语句在数据库事务之前执行? - Why statement executes before db transaction? 为什么在 firebase.auth().createUserWithEmailAndPassword() 调用之后 useRef() 挂钩设置为 null? - why useRef() hook is setting to null after firebase.auth().createUserWithEmailAndPassword() call? 为什么调用 useState 定义的 setter function 后,state 立即设置为 null? - Why is state set to null immediately after setter function defined by useState is called? 虽然this.state是一个Javascript对象,但即使将状态传递给有数据的状态,为什么状态也为null? - while this.state is a Javascript object , why is state null even after passing into it a state that has data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM