[英]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!');
});
}
我現在正在使用沙盒選項,但是我會知道如何為用戶提供有關交易的更多詳細信息。
我看到函數中有一個“數據”參數,有交易明細嗎? 如果是,我如何閱讀它們以便稍后向用戶顯示?
操作的結果傳遞給回調函數,並可以通過以下方式訪問:
.then( function(result) {
console.log(result); // Logs all the stuff that gets back from Paypal
});
根據文檔 :
// 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.
});
}
成功的響應將返回對交易的確認,帶有批准狀態和交易ID,或者您可以在此處看到
// 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!');
});
});
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.