gpt4 book ai didi

javascript - 将变量值传递给 paypal API - first_name 和 last_name

转载 作者:太空宇宙 更新时间:2023-11-03 16:21:42 24 4
gpt4 key购买 nike

我已经在我的网站上存储了以前表格中的名字和姓氏。

当我打开 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”;

--当我删除 last_name 时,代码可以完美运行,但结果是这样的:

var 全名 = 数据[0]; var l_fullname = 数据 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",
}
}
}]
},

enter image description here

最佳答案

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",
}

关于javascript - 将变量值传递给 paypal API - first_name 和 last_name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53291248/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com