【发布时间】:2020-06-24 13:44:19
【问题描述】:
使用 PayPal 付款。但是,我发现很难返回交易 ID 以及支付给我的控制器的金额。
这是我的贝宝代码。
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
// Configure environment
env: 'sandbox',
client: {
sandbox: 'AZE8rjV6EqzKFAcEx6f7L7ZZwDsSLR5bBQOQN5pj3gAwghAivl0VUt-e0SkETWrcoesYXGbxO292vYZ3',
production: 'AUO3T8Mto5rojZl9Ff6nuYw1cLFjgF-4TPh6v1FhXyNdQsjxvdLTACn3xlv3EqwvPLJmmozl4_1pufFl'
},
// Set up the transaction
createOrder: function(data, actions) {
var amount = $("#amount").val();
var name = '<?php echo($email); ?>';
return actions.order.create({
redirect_urls:{
return_url:'http://localhost/escort/success'
},
purchase_units: [{
amount: {
value: amount,
currency: 'USD'
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.request.post('Home/AddPayment/', {
paymentID: data.paymentID,
payerID: data.payerID,
email: email,
amount: amount
})
.then(function(response) {
// 3. Show the buyer a confirmation message.
if (response.error == 'false') {
console.log('Payment Completed');
}
else{
console.log('Error');
}
});
}
}).render('#paypal-button-container');
</script>
我的问题很简单。在确认付款后,我需要想办法将交易 ID 和金额发送给控制器。
【问题讨论】:
标签: jquery codeigniter paypal payment-gateway paypal-sandbox