通过URL将用户付款信息传递到我需要的另一个网页是否安全?我只能从一个网页中检索它,但是我需要在单击按钮并进行检查后将其传递到另一网页。我听说ajax更安全,但我根本不知道该怎么做。
这些是我需要帮助将用户数据传递到另一页的以下几行。
onAuthorize: function (data, actions) {
console.log('onAuthorize (data): ', JSON.stringify(data, 0, 2));
return paypalCheckoutInstance.tokenizePayment(data, function (error, tokenizePayload) {
console.log('onAuthorize (tokenizePayload): ', JSON.stringify(tokenizePayload, 0, 2));
if (error) {
console.log('onAuthorize (error): ', JSON.stringify(error, 0, 2));
} else {
var currentUrl = window.location.protocol + '//' + window.location.host + window.location.pathname;
var cancelUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/')) + '/EXAMPLE4.php?paypalData=' + tokenizePayload.nonce + '&email=' +tokenizePayload.details.email;
window.location.href = cancelUrl;
}
});
这是下面的完整代码。
braintree.client.create({
authorization: '<?php echo $clientToken; ?>'
}, function (clientErr, clientInstance) {
braintree.paypalCheckout.create({
client: clientInstance
}, function (paypalCheckoutErr, paypalCheckoutInstance) {
paypal.Button.render({
env: 'sandbox',
commit: false,
payment: function () {
return paypalCheckoutInstance.createPayment({
flow: 'checkout',
amount: 1000.00,
currency: 'USD',
locale: 'en_US',
enableShippingAddress: false,
displayName: 'SomeSite.com'
});
},
onAuthorize: function (data, actions) {
console.log('onAuthorize (data): ', JSON.stringify(data, 0, 2));
return paypalCheckoutInstance.tokenizePayment(data, function (error, tokenizePayload) {
console.log('onAuthorize (tokenizePayload): ', JSON.stringify(tokenizePayload, 0, 2));
if (error) {
console.log('onAuthorize (error): ', JSON.stringify(error, 0, 2));
} else {
var currentUrl = window.location.protocol + '//' + window.location.host + window.location.pathname;
var cancelUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/')) + '/EXAMPLE4.php?paypal=' + tokenizePayload.nonce + '&email=' +tokenizePayload.details.email;
window.location.href = cancelUrl;
}
});
},
onCancel: function (data, actions) {
return actions.redirect();
},
onError: function (error) {
return alert(error);
}
}, '#paypal-button').then(function () {
});
});
});