Reputation: 45
I've stored the first_name and last_name from a previous forms on my website.
When I open the popup form the PAYPAL API, the first name is filled correctly, but the second one it's not.
this is my code:
payment: function (data, actions) {
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
}
}*/
});
},
the result is a full error page in the console because it's not accepting my "last_name";
-- When I erase the last_name the code works perfectly but the result it's this:
var fullname = data[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",
}
}
}]
},
Upvotes: 0
Views: 214
Reputation: 1263
The recipient_name
field is split by a space when pre-filling the form. In your second example there's no space.
shipping_address: {
recipient_name: fullname + ' ' + l_fullname,
line1: "line1",
line2: "line2",
city: "PT",
country_code: "PT",
postal_code: "shipToZip",
phone: "011862212345678",
state: "shipToState",
}
Upvotes: 1