Smart Button wont work if cart contains more than six items *****SEEMS TO BE WORKING NOW!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I have incorporated Smart Buttons into my shopping cart and they work perfectly up to a maximum of 5 items in the cart. However if I go above that number the PayPal browser opens momentarily then closes again. My button code is as follows:
<script> function initPayPalButton() { paypal.Buttons({ style: { shape: 'pill', color: 'gold', layout: 'vertical', label: 'paypal', size: 'responsive', label: 'checkout', }, createOrder: function(data, actions) { /* tpvar gets the $total_price amount from the Cart*/ var tpvar = <?php echo json_encode($total_price); ?>; var descrvar = <?php echo json_encode($description); ?>; return actions.order.create({ purchase_units: [{"description":"Your FalnaMusic Order","amount":{"currency_code":"GBP","value":tpvar}}] }); }, onApprove: function(data, actions) { return actions.order.capture().then(function(orderData) { // Full available details console.log('Capture result', orderData, JSON.stringify(orderData, null, 2)); actions.redirect('https://www.fmtest.info/after_payment.php'); }); }, onError: function(err) { console.log(err); } }).render('#paypal-button-container'); } initPayPalButton(); </script>
I have tried this in production and sandbox environments but the result is the same in both. I have also tested with different total prices to see if there was a limit on that, but it doesn't make any difference. The problem therefore seems to be with the actual number of items in the cart, but the Smart Button doesnt access this, only the total cost of the transaction, so I'm baffled.
Could anyone help with this please?
*******EDIT******
Now I've returned to my computer after a break of around 4 hours and would you believe it, it all seems to be working normally now, even though I haven't changed anything in the code during that time. If it stops working again I'll come back to this, but hopefully I wont need to trouble you any more!
- Labels:
-
SDK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you for posting to the PayPal Sandbox Community.
Over the last few months, PayPal has been migrating the Sandbox Community. As a result from time to time there are some errors.
Most likely your issue was related to the Sandbox migration.
Thank you for confirming that the issue is currently resolved.
Thank you,
Jennifer
MTS
PayPal

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- "System error. Please try again later" when connecting to paypal sandbox account with my android app in Sandbox Environment
- Things don’t appear to be working at the moment in PayPal Payments Standard
- Something went wrong. Contact the merchant for help. in PayPal Payments Standard
- p is not a function error using the example downloaded from Paypal in SDKs
- How to prompt a "thank you" after using donate button on a website in PayPal Payments Standard