我已经将以前表格中的名字和姓氏存储在我的网站上。
当我从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 fullname = data [0]; var l_fullname = data 1;
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",
}
}
}]
},
答案 0 :(得分: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",
}