paypal结帐JavaScript错误 - this20.getParentTemplate是不是一个功能
问题描述:
我正在实施paypal快速结账按钮到我开发的wordpress插件。paypal结帐JavaScript错误 - this20.getParentTemplate是不是一个功能
我有一个编辑订单页面,里面有一个“确认订单”按钮,其中一个弹出式模式消息用于确认结算按钮的呈现总额。
$("#mdp-order-button").click(function(e){
e.preventDefault();
mdp_render_confirm_modal();
});
function mdp_render_confirm_modal(){
if (!$("#mdp_upload_image")[0].files[0]){
alert("please upload an image first");
}else{
if(mdp_check_overlap()){
alert("the block is either out of the grid or overlapped with other block, please place it again");
}else{
var current_block = $('.current_block');
var cost = current_block.width() * current_block.height();
$('#mdp-show-size').html("Your block is "+current_block.width()+"px X "+current_block.height()+"px");
$('#mdp-show-cost').html("Total: "+cost);
$('#mdp-modal').show();
$('#mdp-close').click(function(){
$('mdp-modal').hide();
})
mdp_render_paypal_button(cost)
}
}
}
function mdp_render_paypal_button(charge) {
paypal.Button.render({
env: 'sandbox', // Or 'sandbox'
commit: true, // Show a 'Pay Now' button
client: {
sandbox: 'censored xxxxx'
},
payment: function() {
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: {
total: charge,
currency: 'USD'
}
}
]
});
},
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function(response) {
console.log(response);
});
}
}, '#paypal-button');
}
当我点击结帐按钮,PayPal的窗口弹出和关闭直线距离,并显示在控制台错误
checkout.js:4225 ppxo_xc_ppcheckout_destroy Object {timestamp: 1494405598944, windowID: "53bb903148", pageID: "84e2908f4a", host: "www.sandbox.paypal.com", path: "/webapps/hermes/button"…}
checkout.js:2021 Uncaught Error: _this20.getParentTemplate is not a function
TypeError: _this20.getParentTemplate is not a function
at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9346:40)
at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62)
at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29)
at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18)
at Function.syncPromiseTry [as try] (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1170:42)
at DelegateComponent.openContainer (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9342:55)
at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:8556:35)
at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62)
at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29)
at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18)
at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9346:40)
at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62)
at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29)
at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18)
at Function.syncPromiseTry [as try] (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1170:42)
at DelegateComponent.openContainer (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:9342:55)
at Object.onSuccess (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:8556:35)
at _loop2 (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1077:62)
at SyncPromise.dispatch (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1107:29)
at SyncPromise.then (https://www.paypalobjects.com/api/checkout.js?ver=4.7.4:1125:18)
at Object._RECEIVE_MESSAGE_TYPE.(anonymous function) [as postrobot_message_response] (https://www.paypalobjects.com/api/checkout.js:2021:118)
at receiveMessage (https://www.paypalobjects.com/api/checkout.js:1929:73)
at messageListener (https://www.paypalobjects.com/api/checkout.js:1949:13)
我试图在网络上搜索,但我没有发现类似的问题也没有文件,我真的不知道为什么会发生这种情况。
在此先感谢您的帮助,完全STA
答
谢谢你这么多@bluepnume帮助。
这是wordpress如何加载脚本的问题,默认情况下,该脚本会将一个查询字符串?ver ='current_wordpress_version'添加到已加载的脚本中,禁用了该脚本,现在它获取最新版本的checkout.js
,而不是仅仅
wp_enqueue_script('paypal_checkout', 'https://www.paypalobjects.com/api/checkout.js');
现在
wp_enqueue_script('paypal_checkout', 'https://www.paypalobjects.com/api/checkout.js',array(),null);
你是如何加载checkout.js?你正在加载一个特定的版本?你可以尝试在你的控制台上输入'paypal.version',让我知道我 – bluepnume
加载它从贝宝提供的URL直接推荐...我会检查一次我回家 –
这很可能“https://开头WWW。 paypalobjects.com/api/checkout.js“,因为我复制了示例代码并对其进行了修改,但我会检查并确保 –