如何解决Javascript函数迭代器逻辑
我有一个使用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函数周期后刷新页面,而不会中断它,谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。