Trying the "Smart Payment Button" but how ot edit it after you logout?

molecom
Contributor
Contributor

I'm using the "Smart Payment Button" and it works, but my problem is I can't find the way to make changes to in after logout. Right now I would have to create the button again if I want to make changes to the description and pricing. I'm NOT talking about the regular buttons, I'm taking about the "Smart Payment Button"; any help will be appreciated. Thank you.

Login to Me Too
1 REPLY 1

angelleye
Advisor
Advisor

Those values are in the code that it gives you.  For example, I just generated smart button code from my sandbox account and it gave me this:

 

<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=AfDRarIYpaffeXRArUxdaNvyo9xTj8rIHcrNA3rjGEe1mwe5YHS8_y63KHySLjkYtBlndiPcPHYNu7H4&enable-funding=venmo&currency=USD" data-sdk-integration-source="button-factory"></script>
  <script>
    function initPayPalButton() {
      paypal.Buttons({
        style: {
          shape: 'rect',
          color: 'gold',
          layout: 'vertical',
          label: 'paypal',
          
        },

        createOrder: function(data, actions) {
          return actions.order.create({
            purchase_units: [{"description":"This is the item description.","amount":{"currency_code":"USD","value":110,"breakdown":{"item_total":{"currency_code":"USD","value":100},"shipping":{"currency_code":"USD","value":5},"tax_total":{"currency_code":"USD","value":5}}}}]
          });
        },

        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>

 

Inside of that you'll find the createOrder element, which looks like this:

 

        createOrder: function(data, actions) {
          return actions.order.create({
            purchase_units: [{"description":"This is the item description.","amount":{"currency_code":"USD","value":110,"breakdown":{"item_total":{"currency_code":"USD","value":100},"shipping":{"currency_code":"USD","value":5},"tax_total":{"currency_code":"USD","value":5}}}}]
          });
        },

 

That is where you can adjust your description, item pricing, shipping, tax, etc.

 

Hope that helps!

 

 

Angell EYE - www.angelleye.com
PayPal Partner and Certified Developer - Kudos are Greatly Appreciated!
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.