Xamarin with PayPal
Alright, today we're going to see what happen with PayPal Payment Option inside our Xamarin Forms Application
For this implementation you must need a Paypal account, so you can create it here.
Once you've created you account go to PayPal Developers Portal
At REST API apps section you'll find a button that says Create App, click to it and fill the data, just after that you see in your API Apps section the app name that you created previously. Click on the name and copy the Client ID, this is the key that we're going to use for testing please copy that key.
Open the ShellDemo project which we worked previously.
First go to Manage NuGet Packages for Solution and search for PayPal.Forms, install the latest version, in my case is 2.18.3
After that go to ShellDemo.Android proyect and Open MainActivity.cs.
Just below the LoadApplication(new App()); add this code:
IMPORTANT: CHANGE IN CONFIG THE PARAMETER FOR YOUR KEY OR CLIENT ID.
Then Add this methods below the Oncreate() method:
Paypal Service is now configured, go to ShellDemo portable proyect and add a new Content Page inside the Views folder with this name: PayPalPage.
Replace all the content of PayPalPage.xaml for this:
Go to PayPalPage.xaml.cs and replace all the content for this lines of code:
You've finished, just go to AppShell.xaml file and just below this lines of code:
Add this:
Finally go to ShellDemo.Android properties and Enable MultiDex Option, Clean the Solution and Rebuild.
I've commented the OpenLoadingPopUpPage method in AppShell.xaml.cs
Alright let's test our app !!!
Results
Related Links
Nuget for Xamarin: Paypal.Forms
Nuget Documentation: Paypal.Forms Documentation
PayPal Portal: Paypal
Developers PayPal Portal: Developers Paypal
Completed Solution: Azure DevOps Repo