提供空值时不呈现 PayPal 借记卡或信用卡
PayPal Debit or Credit Card not render when empty value is provided
我正在集成 PayPal,但我确实遇到了一个问题:在下面的代码中,如果 $("#DonorEmailID").val() 为空,则不再呈现表单
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()
}
}]
});
},
演示视频:https://www.screencast.com/t/xdENMuUbcbWu
有什么办法可以有条件地将 email_address 属性 添加到付款人中吗?或者您对此问题有其他解决方案吗?
谢谢。
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);
},
我正在集成 PayPal,但我确实遇到了一个问题:在下面的代码中,如果 $("#DonorEmailID").val() 为空,则不再呈现表单
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()
}
}]
});
},
演示视频:https://www.screencast.com/t/xdENMuUbcbWu 有什么办法可以有条件地将 email_address 属性 添加到付款人中吗?或者您对此问题有其他解决方案吗?
谢谢。
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);
},