将变量值传递给 paypal API - first_name 和 last_name
Posted
技术标签:
【中文标题】将变量值传递给 paypal API - first_name 和 last_name【英文标题】:passing variables values to paypal API - first_name and last_name 【发布时间】:2019-04-16 21:22:53 【问题描述】:我已经在我的网站上存储了以前表单中的名字和姓氏。
当我打开 PAYPAL API 的弹出窗口时,第一个名称填写正确,但第二个名称不正确。
这是我的代码:
支付:功能(数据、操作)
var retrievePersonalInfo = localStorage.getItem('personalInfoData');
var data = JSON.parse(retrievePersonalInfo);
var first_name = data[0];
var last_name = data[1];
return actions.payment.create(
payment:
transactions: [
amount:
total: '0.01',
currency: 'EUR'
,
item_list:
shipping_address:
recipient_name: first_name,
last_name: last_name,
line1: "line1",
line2: "line2",
city: "PT",
country_code: "PT",
postal_code: "shipToZip",
phone: "011862212345678",
state: "shipToState",
]
,
/*experience:
input_fields:
no_shipping: 1,
address_override: 1
*/
);
,
结果是控制台中的完整错误页面,因为它不接受我的“姓氏”;
-- 当我删除 last_name 时,代码运行良好,但结果是这样的:
var 全名 = 数据[0]; var l_fullname = data1;
return actions.payment.create(
payment:
transactions: [
amount:
total: '0.01',
currency: 'EUR'
,
item_list:
shipping_address:
recipient_name: fullname + l_fullname,
line1: "line1",
line2: "line2",
city: "PT",
country_code: "PT",
postal_code: "shipToZip",
phone: "011862212345678",
state: "shipToState",
]
,
【问题讨论】:
【参考方案1】:recipient_name
字段在预填表单时被空格分隔。在您的第二个示例中,没有空间。
shipping_address:
recipient_name: fullname + ' ' + l_fullname,
line1: "line1",
line2: "line2",
city: "PT",
country_code: "PT",
postal_code: "shipToZip",
phone: "011862212345678",
state: "shipToState",
【讨论】:
非常感谢你的朋友!以上是关于将变量值传递给 paypal API - first_name 和 last_name的主要内容,如果未能解决你的问题,请参考以下文章