我正在开发一个WordPress插件,我接受PayPal Express Checkout。我能够成功获得PaymentID和PayerID。但我不知道如何验证付款。 另外,我可以从payerID或PaymentID获得付款人详细信息吗?
以下是我用来创建付款按钮的脚本。
<script>
paypal.Button.render({
env: 'sandbox',
// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: 'AfI6d9wTxV519v5OI08omQE7HX9XI6-h3AopzKAiP5Yk2nO6brKaTJH8DyeAwpRpLI0CjGtQVSS737eS',
production: 'AfI6d9wTxV519v5OI08omQE7HX9XI6-h3AopzKAiP5Yk2nO6brKaTJH8DyeAwpRpLI0CjGtQVSS737eS'
},
// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,
// payment() is called when the button is clicked
payment: function(data, actions) {
// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: <?php echo $_SESSION['trip-cost'];?>, currency: 'USD' },
custom: '1452'
}
]
}
});
},
validate: function(actions) {
// var fields = jQuery(".wp-travel-engine-billing-details-wrapper").find("select, input").serializeArray();
// console.log(fields);
// jQuery.each(fields, function(i, field) {
// if (!field.value)
// alert(field.name + ' is required');
// });
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.location = '<?php echo $wp_travel_engine_confirmation_page; ?>?paymentid='+data.paymentID+"&payerID="+data.payerID+"&token="+data.paymentToken+"&pid=1";
});
}
}, '#paypal-button-container');
</script>
谢谢。
答案 0 :(得分:0)
我能够使用ipnlistener做到这一点。