PayPal Payment Integration in Flutter Using WebView

PayPal Payment Gateway Integration in Flutter

Today when we talk about payment integration in the application we can’t ignore Paypal. Paypal is a world-leading payment gateway for business models.

In flutter currently, there is no Paypal SDK till now so after a lot of research I have successfully implemented Paypal using WebView. I have used some of Paypal’s available APIs for Payment which is officially available for integration in websites so I decided to try it in a flutter to accomplish my goal.

Now first we create our application on Paypal.

In this example, we are using mock values by Paypal for testing the payment integration which we call PayPal SandBox.

What is the PayPal sandbox?

The PayPal sandbox is a self-contained, virtual testing environment that simulates the live PayPal production environment. The sandbox provides a shielded space where you can initiate and watch while your apps process PayPal API requests without touching any live PayPal accounts.

Now let’s get to practical work.

First, go to the Paypal developer dashboard

Here you go to the sidebar you will find SANDBOX option from that you select the accounts you will get this screen.

PayPal Sandbox test account

by default, you will get personal and a business account created for you by PayPal if you want to create more accounts you just have to click on create an account.

Now it’s time to create an application. For application go to the My Apps & credentials from side bar you will get this screen.

Add Application to PayPal

from here click create an application.

Add App name and SandBox account

after creating the application successfully you have to get the secret id and client id for that click on the application detail

the client id and secret it

Now let's get to the Flutter part

packages we are using in our application

http_auth

http

webview_flutter

Its Coding Time

First, we will create a Transaction screen in which we will add our simple example UI and Navigation to pay the payment

Now we will create the services screen in which we will call the Paypal APIs, for now, will use this domain https://api.sandbox.paypal.com because we are testing If you want to make a real transaction then replace it with https://api.paypal.com.

Now it's time to make a payment screen in which we will send the order and payment detail to Paypal.

End results

End results

It's my first blog on medium if I had made any mistake kindly mention in response

Conclusion

We have successfully implemented the PayPal Payment integration in our flutter application using the WebView.

Thank you for reading the article so far, and please let me your feedback. Tell me if you want another article with a more complex example. You can find the above app from my GitHub. If you liked my article, Please do clap and follow me on LinkedIn and Twitter. Thanks…

Source Code

Flutter developer, Mechatronics Engineer, Cats lover