I have tried to implement PayPal smart button from https://www.paypal.com/buttons/. In the end of the it shows "Something went wrong. We'll take you back to checkout so you can try again" error. I could not figure it out where I am making the mistake.
I have tested it with sandbox account - Success.
With live credentials it shows the error.
The code I am using is the very basic code provided from PayPal it self. You can check it out below.
<div id="paypal-button-container"></div>
<script src="https://www.paypal.com/sdk/js?client-id=[MY_LIVE_ID_HERE]¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '1'
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
Any help will be appreciated.
(2025 edit: there are other possible error messages now, so this answer is outdated)
That is the only error that the black "Debit or Credit Card" button ever shows. It will be shown in cases of normal declines. Live payments can be declined for very many possible reasons, for example if the card is refused, or if PayPal detects you are paying yourself which is not permitted.
(Sometimes the error will always happen as soon as the button is clicked, before the card fields are shown and before card details are entered. This usually means the receiving PayPal account is not able to receive card payments, perhaps due to the type of business. PayPal's customer service can advise on this.)