首页 > 解决方案 > 如何传递订单 ID 或任何自定义 ID 以进行跟踪?

问题描述

我正在使用 vue 和这个 npm 库https://www.npmjs.com/package/paypal-checkout

假设我想将记录存储到数据库中,并且我想要一个可以与我的用户 ID 或我的数据库中的订单 ID 相关联的 ID。我不知道如何在“渲染”功能块中传递任何自定义 ID。

这是我的贝宝按钮的相关代码块:

paypal.Button.render({
  env: 'sandbox',
  client: {
    sandbox: 'yyyyyyy',
    production: 'xxxxxxxxx'
  },
  commit: true,

  payment: function (data, actions) {

    return actions.payment.create({
      payment: {
        transactions: [
          {
            amount: {
              total: '1.00',
              currency: 'USD'
            },
          }
        ]
      },
      experience: {
        input_fields: {
          no_shipping: 1
        }
      }
    })
  },
  onAuthorize: function (data, actions) {
    console.log('onAuthorize:' + JSON.stringify(data, null, 2))

    // Get the payment details
    return actions.payment.get()
      .then(function (paymentDetails) {

        console.log(JSON.stringify(paymentDetails, null, 2))
      })
  },
}, '#paypal-button-container');

这是我收到的付款详情:

{
  "id": "PAYID-L55D0123998RG7601237",
  "intent": "sale",
  "state": "created",
  "cart": "35W055448123",
  "create_time": "2020-08-04T07:08:12Z",
  "payer": {
    "payment_method": "paypal",
    "status": "VERIFIED",
    "payer_info": {
      "email": "sb-123@personal.example.com",
      "first_name": "John",
      "middle_name": "John",
      "last_name": "Doe",
      "payer_id": "XXXX",
      "country_code": "US"
    }
  },
  "transactions": [
    {
      "amount": {
        "total": "1.00",
        "currency": "USD"
      },
      "related_resources": []
    }
  ]
}

标签: paypalpaypal-buttons

解决方案


推荐阅读