预填写信用卡的 PayPal 账单详细信息

问题描述 投票:0回答:1

尝试根据https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/预先填写卡付款的一些详细信息。但示例 https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/ 不起作用,因为 json 不适合“@paypal/paypal-js”中的类型": "^4.1.0".

所以我调整了它 --> https://developer.paypal.com/docs/api/orders/v2/#definition-payer 另请参阅:@paypal\paypal-js ypes pis\orders.d.ts

但是现在出现以下错误:

{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"10a838ea45721","details":[{"field":"/payer/phone/phone_number","location":"body","issue":"MALFORMED_REQUEST_JSON","description":"The request JSON is not well formed."}]

我的配置:

 paypal
          .Buttons({
            createOrder: (data: UnknownObject, actions: CreateOrderActions) => {
              // This function sets up the details of the transaction, including the amount and line item details.
              return actions.order.create({
                application_context: {
                  shipping_preference: 'NO_SHIPPING',
                },
                payer: {
                  payer_id: '1',
                  birth_date: '2021-01-01',
                  tax_info: {
                    tax_id: '1',
                    tax_id_type: 'string',
                  },
                  email_address: '[email protected]',
                  phone: {
                    phone_number: '45465',
                  },
                  name: {
                    given_name: 'PayPal',
                    surname: 'Customer',
                  },
                  address: {
                    address_line_1: '123 ABC Street',
                    address_line_2: 'Apt 2',
                    admin_area_2: 'San Jose',
                    admin_area_1: 'CA',
                    postal_code: '95121',
                    country_code: 'US',
                  },
                },
                purchase_units: [
                  {
                    amount: {
                      value: '0.01',
                      currency_code: 'EUR',
                    },
                  },
                ],
              });
            },
...

我尝试了不同的phone_number 值,但总是出现相同的错误。有什么问题吗?

谢谢, 麦克。

angular paypal paypal-adaptive-payments
1个回答
3
投票

编辑:这个答案已经过时,因为 application_context 和付款人密钥已被弃用。使用 payment_source.paypal

根据 文档,phone_number 必须有

national_number
键。 请勿包含
payer_id
或无效的
tax_info
对象。

              {
                application_context: {
                  shipping_preference: 'NO_SHIPPING',
                },
                payer: {
                  birth_date: '2021-01-01',
                  email_address: '[email protected]',
                  phone: {
                    phone_number: {
                        national_number: '4543433243',
                    }
                  },
                  name: {
                    given_name: 'PayPal',
                    surname: 'Customer',
                  },
                  address: {
                    address_line_1: '123 ABC Street',
                    address_line_2: 'Apt 2',
                    admin_area_2: 'San Jose',
                    admin_area_1: 'CA',
                    postal_code: '95121',
                    country_code: 'US',
                  },
                },
                purchase_units: [
                  {
                    amount: {
                      value: '0.01',
                      currency_code: 'EUR',
                    },
                  },
                ],
              }
© www.soinside.com 2019 - 2024. All rights reserved.