Get started with PayPal API for brizy

Preview demo

How do I get started with PayPal APIs and SDKs?

You need to create a page where users can go through a list of items, select then and put into the checkout page with stripe/PayPal ?

BrizyCloud does not allow the creation of e-commerce sites. Maybe they will update this feature in the future. But with Blog + Javascript + Popup + Paypal, we can create a simple e-commerce site on BrizyCloud platform.

With Brizy cloud's Blog CMS we can create a simple e-commerce website. It worked on this webtricks blog of mine

You don't need to know the code. Just follow the steps below:

  1. Register a new Paypal business: Register the following referral link https://www.paypal.com
  2. Login to https://developer.paypal.com/developer/accounts page to get "Client ID"
  3. Add id: product-description to element product description
  4. and id: selling-price to element product selling price

CODE:

This content has been hidden.

Please Donate or Complete Survey (advertisement) to unlock free.

HTML

<div id="smart-button-container">
   <div style="text-align: center;">
    <div id="paypal-button-container"></div>
   </div>
  </div>


Javascript

<script src="https://www.paypal.com/sdk/js?client-id=your_paypal_ID&enable-funding=venmo&currency=USD" data-sdk-integration-source="button-factory"></script>
<script>
var selling_price=document.querySelector("#selling-price").innerText.match(/\d+/g).join(".");
var product_description=document.getElementById("product-description").innerText;
  function initPayPalButton() {
   paypal.Buttons({
    style: {
     shape: 'rect',
     color: 'gold',
     layout: 'vertical',
     label: 'paypal',
    },
    createOrder: function(data, actions) {
     return actions.order.create({
      purchase_units: [{"description":product_description,"amount":{"currency_code":"USD","value":selling_price}}]
     });
    },

    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>';
      function fnv32a( str ) {
      // Or go to another URL: actions.redirect('thank_you.html');
       
     });
    },

    onError: function(err) {
     console.log(err);
    }
   }).render('#paypal-button-container');
  }
  initPayPalButton();
 </script>

How to use it

Download file demo.zip, upload to Brizy. Done (Then you can see the css code from here)

  1. Click download demo.zip
  2. To import, go to a page >> click on "add a new block" >> select "saved" tab >> click on "import new block" >> Upload your zip file >> Completed.
  3. Customize to your fancy. Watch the video tutorial here

*Note: License Pro is required for the functions to work

Key word:

PayPal Javascript SDK, PayPal Javascript SDK Integration, PayPal Integration with brizycloud