付款后显示贝宝交易详情
Showing paypal transaction details after payment
在我的网站上使用 Paypal 成功付款后,浏览器仅显示提示:
// Execute the payment
onAuthorize: function (data, actions) {
return actions.payment.execute()
.then(function () {
// Show a confirmation message to the buyer
window.alert('Compra realizada con éxito. Recibirá más detalles por email!');
});
}
我现在正在使用沙盒选项,但我会知道如何向用户提供有关交易的更多详细信息。
我看到函数里有一个'data'参数,有交易明细吗?如果是,我如何阅读它们以便稍后向用户展示?
操作的结果被传递给回调函数,并且可以这样访问:
.then( function(result) {
console.log(result); // Logs all the stuff that gets back from Paypal
});
根据the doc:
// Execute the payment:
// 1. Add an onAuthorize callback
onAuthorize: function(data, actions) {
// 2. Make a request to your server
return actions.request.post('/my-api/execute-payment/', {
paymentID: data.paymentID,
payerID: data.payerID
})
.then(function(res) {
// 3. Show the buyer a confirmation message.
});
}
成功响应returns交易确认,带有批准状态和交易ID,或者您可以看到here
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) {
// Get the payment details
return actions.payment.get().then(function(data) {
// Display the payment details and a confirmation button
var shipping = data.payer.payer_info.shipping_address;
// Execute the payment
return actions.payment.execute().then(function() {
// Show a thank-you note
window.alert('Compra realizada con éxito. Recibirá más detalles por email!');
});
});
});
}
在我的网站上使用 Paypal 成功付款后,浏览器仅显示提示:
// Execute the payment
onAuthorize: function (data, actions) {
return actions.payment.execute()
.then(function () {
// Show a confirmation message to the buyer
window.alert('Compra realizada con éxito. Recibirá más detalles por email!');
});
}
我现在正在使用沙盒选项,但我会知道如何向用户提供有关交易的更多详细信息。
我看到函数里有一个'data'参数,有交易明细吗?如果是,我如何阅读它们以便稍后向用户展示?
操作的结果被传递给回调函数,并且可以这样访问:
.then( function(result) {
console.log(result); // Logs all the stuff that gets back from Paypal
});
根据the doc:
// Execute the payment:
// 1. Add an onAuthorize callback
onAuthorize: function(data, actions) {
// 2. Make a request to your server
return actions.request.post('/my-api/execute-payment/', {
paymentID: data.paymentID,
payerID: data.payerID
})
.then(function(res) {
// 3. Show the buyer a confirmation message.
});
}
成功响应returns交易确认,带有批准状态和交易ID,或者您可以看到here
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) {
// Get the payment details
return actions.payment.get().then(function(data) {
// Display the payment details and a confirmation button
var shipping = data.payer.payer_info.shipping_address;
// Execute the payment
return actions.payment.execute().then(function() {
// Show a thank-you note
window.alert('Compra realizada con éxito. Recibirá más detalles por email!');
});
});
});
}