Smart Payment Buttons give error but transaction is done.
nick_developer
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Sep-24-2019
05:25 AM
Hi,
I've integrated the Smart Payment Buttons in my website. All the payment procedure goes ok, but sometimes it gives an Error while the transaction is processed correctly by PayPal.
the /paypal_transaction_check/ function get the response and make a check if $data['data']['status'] from the PayPal response si "COMPLETED".
Sometimes the page goes in /checkout/payment_error but the transaction si successful passing "COMPLETED" in the response.
It happens also on live environments and only on some cases
Can be a Timeout error ?
here is the client code
paypal.Buttons({
style: {
layout: 'vertical',
color: 'gold',
shape: 'rect',
label: 'pay',
tagline: false
},
createOrder: function(data, actions) {
// Set up the transaction
return actions.order.create({
application_context:{
brand_name: 'Test Store',
locale:'it-IT',
shipping_preference:'NO_SHIPPING',
user_action:'PAY_NOW'
},
intent: "CAPTURE",
purchase_units: [{
reference_id: '<?= $order_reference_id ?>',
description: 'Cool item',
custom_id:'<?= $order_reference_id ?>',
amount: {
currency_code: 'EUR',
value: '99.00'
}
}],
});
},
onApprove: function(data, actions) {
// Capture the funds from the transaction
$('#paypal-button-container').hide();
$('#payment-wait').show();
return actions.order.capture().then(function(details) {
fetch('/paypal_transaction_check/', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
data: details,
order_id: '100100100'
})
}).then(response => {
if(response.status == 200) {
window.location.href = "/checkout/paypal_success/<?= $order_reference_id ?>";
} else {
window.location.href = "/checkout/payment_error";
}
});
});
},
onCancel: function (data) {
// Show a cancel page, or return to cart
window.location.href = "/checkout/payment";
},
onError: function (err) {
window.location.href = "/checkout/payment_error";
}
}).render('#paypal-button-container');
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Zettle reporting within PayPal Transaction Detail Report Specification in PayPal Reporting
- How to add a second parameter onto the PayPal standard payment code block? in PayPal Payments Standard
- Cannot forward buyer to url after purchase in PayPal Payments Standard
- I need help with Sandbox Testing for my website in PayPal Payments Standard
- Sandbox testing has beaten me !! in Sandbox Environment