Bring Android Pay to Your Apps with Stripe

Avatar

Jon

Android Pay + Stripe Android Pay has just launched, and Xamarin has everything you need to get your apps ready. The Google Play Services – Wallet NuGet adds the necessary APIs for Android Pay integration.

We’re also proud to announce that the Xamarin Stripe Component is Android Pay compatible! We’ve updated the sample to show you just how easy it is to process Android Pay transactions through Stripe.

After installing the Google Play Services – Wallet NuGet package and the Xamarin Stripe Component, start by initializing the Google API client in your Activity with the appropriate API:

Google provides the SupportWalletFragment class, which will display a branded Purchase button within the fragment:

The MaskedWalletRequest class is used to build a new purchase request. You could use any payment gateway that can accept EMVCO Network Tokens, or in this case set up your Stripe account as the payment gateway with some configuration options:

Android Pay UI Flow

Once the request has been built, it needs to be assigned to the wallet fragment. This will cause the request to be used when the user taps the Payment button:

When the Buy button is tapped, your MaskedWalletRequest will be executed. At this point, Google will handle asking the user which account and payment method they’d like to use, as well as their shipping address (if you requested one) by presenting them with the necessary dialogues.

Eventually when the user has entered the required information, your activity’s OnActivityResult will be called. At this point you can use the result to create a FullWalletRequest to finalize the transaction:

Once the request to load a full wallet completes, your activity’s OnActivityResult will once again be called with the results. You can parse the Stripe Token object from these results:

The stripeToken is what you will send to your server, which is responsible for communicating the actual payment request to Stripe’s servers.

For the complete example of integrating Android Pay and Stripe in your app, check out the sample in the Xamarin Stripe Component.

Note: you may continue to see ‘Google Wallet’ branding until Android Pay is fully rolled out.

Avatar
Jon Dick

Follow Jon   

No Comments.