Integrate PayPal Payment Gateway Without Extension Or Server File

:wave: Hello everyone

Today we are going to learn, How to Integrate PayPal Payment Gateway Without using any extension or hosting any file on server. We are going to use the Paypal Payment link API method where we need to make three API requests to the Paypal server to process our payment. Don’t worry the method is super simple and you can easily understand it.

Please note that we are going to perform the testing in Sandbox mode. Also, I’m assuming that you already have a sandbox account for testing.

:sunny: I have made a detailed step-by-step guide available on my website.

Get PayPal Credentials

Visit the Paypal developer dashboard and log in/register to your account. Hereunder REST API apps Create a new app or you can use the older one too. Now choose the app and get the Client ID and Secret . Use the Authorization tool to get the Basic Authorization token .

Designer Part

Here we are going to take 3 Web components. 1st to generate an access token. 2nd generate payment links & 3rd to process the payment and verify it.

Also, a web viewer is used to load the payment page so user can access their PayPal account and approve the payment. And a button to initiate the payment process.

Blocks Part

On button click, We have to make an API request to /v1/oauth2/token to generate an access token.

Post Request Body

{"intent": "sale","payer": {"payment_method": "paypal"},"transactions": [{"amount": {"total": "30.00","currency": "USD","details": {}},"invoice_number": "invoice_48787589672","payment_options": {"allowed_payment_method": "INSTANT_FUNDING_SOURCE"},"item_list": {}}],"redirect_urls": {"return_url": "","cancel_url": ""}}

Post Request URL

  • Sendbox Mode:
  • Live Mode:

Steps Explained
Follow blocks from top to bottom,

  • Created a global variable for API URL
  • On button click, We have to make an API request to /v1/oauth2/token to generate an access token.
  • Now we’ll use the generated Authorization Bearer token to make another API request on /v1/payments/payment to generate the payment link.
  • Note that the invoice_number must be unique each time.
  • From the response, we’ll get the payment id & execute_url and put this in another global variable.
  • From the same response, we’ll get approval_url and load this URL in WebViewer.
  • Also, we’ll use a clock component to keep checking the current URL of the webpage loading in web viewer.
  • Once the user completes the payment process and PayPal redirects the user to either redirect_url or cancel_url that we defined earlier.
  • If PayPal redirects the user to redirect_url we’ll simply hide the Web viewer and extract the PayerID from the query parameter of the current URL.
  • With this PayerID we’ll make a POST request on execute_url to complete the payment process and get a response.
  • From the response (JSON) of this API request, we’ll simply get the state key and check if it is approved.
  • If the state = approved payment success else payment failed.

Please note that, if the user cancels the payment. Paypal redirects it to cancel_url which we’ll easily detect as we are checking the current URL of the web viewer at a certain interval and set the status to Payment canceled by the user.

All Blocks Screenshot

The total number of blocks is 182. you can modify blocks to reduce/optimize them.

If you like this guide then do hit :heart: button and if you have any queries or suggestions feel free to comment below.

:arrow_down: Download demo AIA file: Paypal.aia (7.5 KB)


Awesome guide with clear explanation thanks so much

So useful guide @tanishraj :grinning:

Thank you so much for this type of guide :+1::smiling_face_with_three_hearts::smiling_face_with_three_hearts:

1 Like

Out standing sir, but please a make a guide on direct recieve payment to any upi like phonepe upi, amazon pay upi, gpay, etc.

Is same for razorpay

Yup… You should serach in community first.

1 Like

Well @tanishraj this is nice and great guide but I would like to know one thing! will this work with a personal account or it is limited to Business account?

1 Like

Useful guide. :heart: :heart:

1 Like

Awesome @tanishraj sir :ok_hand::ok_hand: