预先填写信用卡的 PayPal 账单详细信息
Posted
技术标签:
【中文标题】预先填写信用卡的 PayPal 账单详细信息【英文标题】:Pre-fill PayPal Billing details for credit card 【发布时间】:2021-12-14 15:10:57 【问题描述】:尝试根据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\types\apis\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: 'customer@domain.com',
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 尝试了不同的值,但总是出现相同的错误。有什么问题?
谢谢, 迈克。
【问题讨论】:
【参考方案1】:根据the documentation,phone_number 必须有一个national_number
键。不要包含payer_id
或无效的tax_info
对象。
application_context:
shipping_preference: 'NO_SHIPPING',
,
payer:
birth_date: '2021-01-01',
email_address: 'customer@domain.com',
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',
,
,
],
【讨论】:
PayPal 应该只预填充这些字段...验证应该稍后进行。我从客户资料中获取这些值......电话号码的格式总是略有不同。所以总会有错误......导致不渲染视图。 只接受有效值。不要提供无效值。以上是关于预先填写信用卡的 PayPal 账单详细信息的主要内容,如果未能解决你的问题,请参考以下文章
Paypal - 我可以跳过信用卡付款的帐单地址和电话号码信息吗?
PayPal Checkout (Orders v2) 自动填写账单地址