Это работает:
<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')
}