Nav

How to implement secure Payment gateway integration in Xamarin mobile apps

Published on 30 July 2018 | Virendra Thakur

build secure payment gateway C# Wrapper for Xamarin

What our client wanted?

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 - Xamarin wrapper for payment gateway integration

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, integrate payment gateway utility with 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:

  1. Get the native SDK of Braintree for Android and iOS to create the Xamarin wrapper.

  2. Convert / generate *.Jar / *.aar files for Android and *.framework / *.a file for iOS form Braintree payment gateway native SDK.

  3. Create platform specific Binding Library projects in Xamarin.

  4. Add Native *.Jar / *.aar files for Android and *.framework / *.a file for iOS in platform specific binding library project.

  5. Add the dependencies and references based on the platform ex: Supported Nuget, files etc.

  6. Convert / customize Braintree SDK code into .Net and Xamarin Android / iOS specific code.

  7. Build the project and create the Xamarin Wrapper / Nuget from the library project.

braintree architecture diagram

Steps to configure Payment gateway Nuget/Xamarin wrapper:

  1. Add the Xamarin wrapper/Nuget package to the mobile app created in Xamarin.

  2. Implement the Braintree native dependencies in Xamarin Android and Xamarin iOS project.

  3. Initiate the Payment gateway SDK in Xamarin native projects. Check the code snippet below.

  4. Implement the classes and its methods into the app. Check the code snippet below.

  5. Get the Payment data and process it further using the developed Xamarin wrapper for the app.

Code Snippet:

Xamarin wrapper code snippet

Value Delivered

iOS screen for payment gateway 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.

Quick-start your Xamarin implementation, today!

Talk to our Xamarin Specialist

Thoughtful Insights into IoT, Analytics, Mobility & Cloud

Machine Learning Implementation

Leading Entertainment organization goes Mobile with Xamarin apps

Customer Success Story Machine Learning Implementation
Machine learning solutions

Global Telecom Network Provider adopts Enterprise Mobility solution

Read how we did it Machine learning solutions
Analytics & Machine learning algorithms

Xamarin or Ionic - Which one should you opt for?

Read the Blog Analytics & Machine learning algorithms