Smart Payment Button

nodantheman
Contributor
Contributor

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.

Login to Me Too
3 REPLIES 3

6OzzMonroy9
New Community Member
In the code, did you replace the following values: 1. YOUR_CLIENT_ID with your client ID. 2. YOUR_PLAN_ID with the plan ID returned from the Create Plan API call. Once your sure the above values are set correctly load the webpage to see the payment buttons. Once refreshed you should see the payment button go ahead and select the PayPal button on the page. Use the sandbox personal login information from the Developer Dashboard to log in and simulate the buyer making a purchase. In the Checkout window, notice the purchase amount in the upper right corner. USD is the default currency. You can customize the PayPal JavaScript SDK by adding a different currency code. (Remember JavaScript SDK onShippingChange function is not compatible with Subscriptions.) Select the pull-down arrow next to the purchase amount. The subscription details are available for the buyer to review. Select the test credit card as the payment method and select Continue. Select Agree & Subscribe to agree to the terms of the subscription. Select OK to close the pop-up window that acknowledges the subscription. Now confirm the movement of the funds from buyer account by using the sandbox personal account you used to complete the purchase to log in to https://www.sandbox.paypal.com/myaccount/autopay/connect/. The URL should take you to the automatic payments page in the sandbox personal account. Confirm the subscription appears in the active automatic payment list. Select the active automatic payment to see the details of the subscription. Finally log out of the account and you should be good if not call support
Login to Me Too

nodantheman
Contributor
Contributor

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&currency=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>

Login to Me Too

Rokhi2
Contributor
Contributor

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.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.