提供空值时,PayPal 借记卡或信用卡不呈现
Posted
技术标签:
【中文标题】提供空值时,PayPal 借记卡或信用卡不呈现【英文标题】:PayPal Debit or Credit Card not render when empty value is provided 【发布时间】:2022-01-12 16:09:55 【问题描述】:我正在集成 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 属性添加到付款人?或者您对此问题有其他解决方案吗?
谢谢。
【问题讨论】:
【参考方案1】: 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 借记卡或信用卡不呈现的主要内容,如果未能解决你的问题,请参考以下文章