Paypal Integration Client Side

Ehrgein
Contributor
Contributor

Hello!

 

As far as I found lately, the add to cart and buy now buttons have been deprecated. However, I checked the documentation for the Smart Buttons sdk here: https://developer.paypal.com/sdk/js/reference/ and I had a couple of questions regarding it.

 

1. For example, in the "Create order" function, I can see that both there is Backend and Frontend. Do I need to integrate a backend with node js? or can I expose this on the client (frontend) itself? 


This is the code that I'm referring to (I'm not sure if this functions are the ones that are deprecated):

 

 

function initPayPalButton() {
  paypal
    .Buttons({
      style: {
        shape: "rect",
        color: "gold",
        layout: "vertical",
        label: "paypal",
      },

      createOrder: function (data, actions) {
        return actions.order.create({
          purchase_units: [{ amount: { currency_code: "USD", value: 10 } }],
        });
      },

      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>";
        });
      },

      onError: function (err) {
        console.log(err);
      },
    })
    .render("#paypal-button-container");
}
initPayPalButton();

 

 
PS: I'm sorry if some of my questions are silly, or "dumb", I'm still learning!

Thanks in advance. 😄

Login to Me Too
2 REPLIES 2

vaishnavib
Moderator
Moderator

Good day @Ehrgein,

 

Thank you for posting to the PayPal community.

 

To clarify, the code that you have mentioned should be utilized on the client side, specifically in the front end. This means that it should be implemented on the user interface that is visible to your customers.

 

If you still facing the issue, please create an MTS ticket via - https://www.paypal-support.com/s/?language=en_US  with the detailed information and error details.

 

Sincerely,

Vaishnavi

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Frankie300
New Community Member

I have come accross many posts about "buy now buttons being deprecated". If it is of any help to anyone else looking into this issue, if you already have an existing PayPal payment button on your website, you can still View, Edit, or Duplicate these buttons. So, you do not have to start learning the new way to edit or create a Buy Now for your website. Thank goodness! Go to Technical Support and type in 'How do I add or edit a PayPal payment button?' where it tells you to:

  • Go to Account Settings.
  • Click Website payments.
  • Click Update next to "PayPal Buttons."
  • Select the button you'd like to create or click View your saved buttons to edit a button.
  • Click Open next to the button you want to edit and select Edit button.

 

 

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.