Smart buttons randomly failing to capture payments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have recently tried implementing smart buttons using code based on the code generated from the smart buttons code generator. I was previously using the old pay now button. I am getting a lot of refused payments, especially if my customer is using a PayPal account. This includes customers I have dealt with who have known good accounts. I appear to be losing roughly 30% of my transactions. Here is an example of my code:
Near the start of my page:
<script src="https://www.paypal.com/sdk/js?client-id={ID removed}¤cy=GBP"></script>
This code is called after my customer agrees to terms and conditions:
paypal.Buttons({
style: {
shape: 'rect',
color: 'silver',
layout: 'vertical',
label: 'pay',
},
createOrder: function(data, actions) {
JL().info("Creating order");
return actions.order.create({
purchase_units: [{
amount: {value: '60'},
custom_id: '38539',
}],
});
},
onApprove: function(data, actions) {
JL().info("Approving order 38539");
JL().info(data);
showLoading();
try{
return actions.order.capture().then(function(details) {
JL().info(details);
JL().info("Success");
appender.sendBatch();
alert("Transaction completed successfully");
window.location.href = 'somewhere';
});
}catch(err)
{
JL().info(actions);
hideLoading();
alert(err.message);
throw(err);
}
}
}).render('#paypal-button-container');
The JL stuff is jsnlog which I put in later to try to debug the problem. showLoading and hideLoading show/hide a progress throbber.
When the transaction fails I get an exception that contains the really helpful message "Script error"
- Labels:
-
PayPal HTML Buttons
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Receiving a PAYMENT.SALE.COMPLETED webhook notification - how can I trace the parent Subscription in REST APIs
- “This payment cannot be processed because there was an error with the capture order API call”. in REST APIs
- User is asked for shipping address when creating a credit card order in REST APIs
- Need help to integrate PayPal Standard Checkout with Shopify in PayPal Payments Standard
- API TRANSACTION_REFUSED in Sandbox when Capturing Payment in REST APIs