我有一个使用Paypal构建的系统,并且在启动Paypal界面时运行的功能内,我没有得到适当的刷新。
createOrder: function(data, actions) {
checkCurr();
if(x==1){
x=0;
location.reload();
}
console.log("x is "+x);
// This function sets up the details of the transaction, including the amount and line item details.
return actions.order.create({
purchase_units: [{
amount: {
value: total
}
}]
});
x++; },
当用户单击“贝宝”支付选项时,将调用createOrder并加载一个值以发送给贝宝。我们的网站上有一个货币选项可以设置为USD或CAD,因此,当用户选择cad / usd时,它将更新paypal src脚本以将其设置为特定货币:
function checkCurr(){
if(currentCurrency=="CAD"){
document.getElementById("paypalScript").src= "https://www.paypal.com/sdk/js?client-
id=sb¤cy=CAD";
}
if(currentCurrency=="USD"){
document.getElementById("paypalScript").src= "https://www.paypal.com/sdk/js?client-
id=sb¤cy=USD";
}
}
通过时间返回action.order.create({被称为,它应该更改货币,但是我重新加载页面的if语句只能工作一次,并且是一个不好的解决方案。如果有人知道我可以在一个完整的createOrder函数周期后刷新页面,而不会中断它,谢谢。