这是我当前的贝宝脚本
<script language="javascript" type="text/javascript">
function populatePayPalButtons() {
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
description: 'Center Court Hire',
amount: { value: '30.00' }
}]
});
},
// --------- onApprove ---
onApprove: function(data, actions) {
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
// Call your server to save the transaction
var url = 'http://localhost:50678/testPP.aspx';
return fetch(url, {
method: 'post',
body: 'OrderData=30.00|Center Court|4698.01|4563' +'|' + data.orderID,
headers: { 'Content-type': 'application/x-www-form-urlencoded' }
});
});
},
// --------- onCancel ---
onCancel: function(data, actions) {
// Show a cancel page, or return to cart
},
// --------- onError ---
onError: function(err) {
// Show an error page
alert('An error has occurred');
}
}).render('#paypal-button-container');
}
</script>
该按钮显示在ASPxPopupControl中。我有一个脚本将关闭该ASPxPopupControl,我需要的是一种在上方onApprove函数中作为最终调用执行该脚本的方法。
如果这不可能,是否有事件我可以使用/调用来关闭ASPxPopupControl,而无需用户单击按钮。
似乎没有一种方法可以在ASPxPopupControl中检测到PayPal已完成处理。
答案 0 :(得分:0)
这有效:
<script language="javascript" type="text/javascript">
function populatePayPalButtons() {
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
description: 'Court 4 Hire',
amount: { value: '50.00' }
}]
});
},
// --------- onApprove ---
onApprove: function(data, actions) {
var url = 'http://localhost:50678/testPP.aspx';
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
// Call your server to save the transaction
CloseAndReturnToParentPage();
return fetch(url, {
method: 'post',
headers: { 'Content-type': 'application/x-www-form-urlencoded' },
body: 'OrderData=50.00|Court 4|4731.01|4563' +'|' + data.orderID,
});
});
},
// --------- onCancel ---
onCancel: function(data, actions) {
// Show a cancel page, or return to cart
},
// --------- onError ---
onError: function(err) {
// Show an error page
alert('PayPal: An error has occurred! ');
}
}).render('#paypal-button-container');
}
</script>
在被叫页面上:
function CloseAndReturnToParentPage() {
var parentWindow = window.parent;
parentWindow.SelectAndClosePopup('Finished');
}
在通话页面上:
function SelectAndClosePopup(value) {
if (value == "Finished")
popupControlGetPayment.Hide();
else { }
cbPanel.PerformCallback('PayPalCompleted|Paid')
}