Secure Payment Gateway integration using Xamarin wrapper for iOS & Android apps
Why our client wanted a Xamarin wrapper?
Being a Market leader, our client delivers tailor-made promotional, insurance & rewards solutions to brands and agencies for helping achieve their business goals. The company has developed a Xamarin Mobile App for one of its cutting-edge promotional initiatives. It had to integrate a payment gateway utility functionality, called Braintree, with its Xamarin App. However, its in-house development team lacked development capabilities to add this secure payment utility to their app and so the client fervently looked for Xamarin development partner, who can help them solve this challenge.
What is Braintree?
Braintree provides the global commerce tools for companies to enable commerce, accept payments and build business. It's the easiest & simplest way to execute secure payment transactions across any device and using any payment method, such as Credit card payment, Apple pay or PayPal; with recurring billing, international payments, and PCI compliance solutions. Businesses can just plug-in this payment gateway with their shopping carts, analytics services, ecommerce platforms, and billing applications to enable secure payments easily. Braintree payment SDK is available in native environment – in Java / Kotlin for Android and Objective C / Swift for iOS.
The Approach and Implementation
Our Xamarin experts went through the existing complete development cycle. They had to study the existing app architecture through source code to get clear understanding of the app functionality. With the proven expertise in developing Xamarin apps for various enterprise customers, Saviant team of Xamarin developers were able to solve the client’s problem with a Xamarin wrapper/Nuget solution. As Xamarin framework allows to convert any native platform specific SDKs to .Net framework, converting the Briantree Native SDKs into a wrapper was the perfect solution, in order to, add payment gateway utility to the existing Xamarin mobile app easily & quickly.
Xamarin provides the binding library projects for both Android and iOS platforms to create a wrapper. These binding library projects consume the *.Jar / *.aar files for Xamarin Android and *.framework / *.a files for Xamarin iOS; which are then converted into Xamarin wrapper / Nuget.
Implementation steps to consume Native SDK in Xamarin binding library project:
Get the native SDK of Braintree for Android and iOS to create the Xamarin wrapper.
Convert / generate *.Jar / *.aar files for Android and *.framework / *.a file for iOS form Braintree payment gateway native SDK.
Create platform specific Binding Library projects in Xamarin.
Add Native *.Jar / *.aar files for Android and *.framework / *.a file for iOS in platform specific binding library project.
Add the dependencies and references based on the platform ex: Supported Nuget, files etc.
Convert / customize Braintree SDK code into .Net and Xamarin Android / iOS specific code.
Build the project and create the Xamarin Wrapper / Nuget from the library project.
Steps to configure Payment gateway Nuget/Xamarin wrapper:
Add the Xamarin wrapper/Nuget package to the mobile app created in Xamarin.
Implement the Braintree native dependencies in Xamarin Android and Xamarin iOS project.
Initiate the Payment gateway SDK in Xamarin native projects. Check the code snippet below.
Implement the classes and its methods into the app. Check the code snippet below.
Get the Payment data and process it further using the developed Xamarin wrapper for the app.
Our Xamarin team’s dedicated effort resulted in many client benefits including:
Painless integration of secure payment gateway utility, Braintree, with the existing Xamarin app.
Quick go-to-market with the Xamarin Wrapper/Nuget solution for iOS & Android.
Better market access with new secure payment gateway enabled Xamarin app to generate new revenue streams.