Smart Payment Button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I added the code for smart buttons for payment of an item to my site and when clicked, it goes to the sandbox site for paypal. How do I make it accept payments?
Then I try to create a buy now button, normal one, and i get an error on the page.
- Labels:
-
SDK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I logged in to Paypal. Went to the buttons page, selected the first one, smart button and clicked that. Then a page comes up with a form to fill out, you fill it out and then copy the code. No where on this page does it have any instructions. No where does it say I have to edit the code. Just gives me the code, which tells me just paste it in my page and it will work. So please tell me why there are no directions on that page like you are telling me?
I could ignore all this nonsense if the buy now button was working, but I get an error on Paypal when I try to get one of these buttons.
I just don't understand why Paypal is giving you buttons that do not work unless you have a degree in coding. Quite ridiculous to expect average users to all of a sudden become coders.
Here is the code and none of what you claim s even in the code.
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'pill',
color: 'blue',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"Through the Tears USB Drive Album","amount":{"currency_code":"USD","value":43.5,"breakdown":{"item_total":{"currency_code":"USD","value":40},"shipping":{"currency_code":"USD","value":3.5},"tax_total":{"currency_code":"USD","value":0}}}}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to get an API key. From your dashboard, select App Center, then scroll down to API credentials. Once you have the API key, it will appear in the generated code where it currently says client-id=sb, replacing sb with your key. Or you can just replace the sb with your key copied from the creds section.
There may be a delay in going live - I think the site has to be verified before moving from the sandbox.

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
- Something went wrong. Contact the merchant for help. in PayPal Payments Standard
- Website Payment Button in PayPal Payments Standard
- use the payment button code with variable price in REST APIs
- Paypal buttons and redirects in PayPal Payments Standard