I am doing an integration of PayPal but i do have an issue: in the code below, if the $("#DonorEmailID").val() is empty, the form is not rendered anymore
paypal.Buttons({
style: {
layout: 'vertical',
shape: 'rect',
height: 36
},
createOrder: function (data, actions) {
return actions.order.create({
//https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/
payer: {
email_address: $("#DonorEmailID").val(),
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "14082508100"
}
}
},
application_context: {
shipping_preference: 'NO_SHIPPING'
},
purchase_units: [{
description: getPurchaseDescription(),
amount: {
value: $("#Amount").val()
}
}]
});
},
Demo video: https://www.screencast.com/t/xdENMuUbcbWu Is there any way to add the email_address property conditionally to payer? Or do you have another solution to this issue?
Thanks.
paypal.Buttons({
style: {
layout: 'vertical',
shape: 'rect',
height: 36
},
createOrder: function (data, actions) {
var order = {
//https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/
payer: {
phone: {
phone_type: "MOBILE",
phone_number: {
national_number: "14082508100"
}
}
},
application_context: {
shipping_preference: 'NO_SHIPPING'
},
purchase_units: [{
description: getPurchaseDescription(),
amount: {
value: $("#Amount").val()
}
}]
};
var email = email_address: $("#DonorEmailID").val();
if(email) order.payer.email_address = email;
return actions.order.create(order);
},