Using Google Pay API for Seamless Checkout
We all know that e-commerce is growing at a tremendous rate. However, online conversion is still a big problem. Long checkout forms often lead to frustration, especially as customers increasingly turn to their mobile devices for various e-commerce activities.
It's no surprise that 69% of users today drop out of the checkout process before the purchase has been completed.
With Google Pay API, you can make your checkout experience easier, allowing users to pay with many forms of payments stored in their Google account, including credit and debit cards, whether your customers are shopping at a physical store or online in your apps.
Today there are hundreds of millions of payment methods, billing and shipping addresses saved to Google accounts.
Users have stored this information when making purchases on apps like the Play Store, YouTube or shopping the web using Chrome.
They're called ready to pay users. Google Pay API enables you to call up their information in a secure way and allow your customers to check out with the click of a button.
Having customers who are just a tap away from performing a financial transaction is not only convenient but also sets the merchant up to take on smart technologies such as Google Home or other connected devices preparing your app for voice power transactions.
The Google Pay API can be implemented in just under a week and it works with your existing payments processing stack, making this integration really simple. There are also no additional charges added to your standard processor fees.
Now let's have a quick look at how the Google Pay API works. Once a user clicks on the Google Pay button, the Google Pay API initiates a request to Google servers. With this request your app passes the name of your processor among other parameters.
Google uses the processor's public key to encrypt the response and sends a chargeable payment token back to you for use with your processor. Now that the processor has the payment information, it can use it the same way as if it came from the user's input directly.
To summarise, with Google Pay API, hundreds of millions of customers around the world who saved their payment information with Google can now pay on your apps with the click of a button.
Your customer's payment data is end to end encrypted from Google servers to your payment processor. This means Google Pay simplifies how you handle this otherwise sensitive data.
Customers can check out using any device or platform. The integration of the API is simple and can be completed in just a few days.
With the Google Pay API for Android, you can facilitate payment transactions for your users, making the checkout experience in your app more convenient.
Join other businesses like yours who are using Google Pay today to drive user growth, increase conversions, and reduce data exposure and transactional vulnerabilities.
Google Pay API
Here's how you can integrate Google Pay on your Android application in four simple steps.
- Configure your project.
- Determine readiness to pay
- Show the Google Pay button.
- Create a payment data request object.
Configure Your Project
First, add the Google Pay library to the list of dependencies in your application module. Make sure to review the documentation to check the latest version available.
You also need to enable the Google Pay API in your manifest. As soon as you are ready, open the activity where you plan to show the Google Pay button and obtain a new instance of the payments client inside of your on create method.
You should note that the get payments client method takes a wallet options parameter. Use the definitions in this class to specify the environment in which you want to operate, test, or production.
For the test environment, you don't need to register with Google. You can play with the API yourself and integrate into your app.
In this case, you can use real payment information. However, whenever a selection is made, we return you a non-chargeable token.
Remember, your real card details are never used when in the test environment, but you must add at least one chargeable card to your Google account before you proceed.
Once you complete the integration and you are ready to handle real payments, register through the self-service portal and then flip the environment to production.
Is Ready to Pay
Now that you have your payments client constructed, the first API you need to call is, Is Ready to Pay, with Is Ready to Pay you can determine whether the user has a valid payment method on file and is capable of completing a transaction on a supported device.
This request takes parameters that specify the API version targeted in your call, as well as the payment methods allowed for this transaction.
If Is Ready to Pay returns false, we highly recommend that you do not show the Google Pay button.
Show the Button
Now that you know that the user is ready to make a payment using Google pay, you can make the button visible to the user.
We recommend that you ensure the Google Pay branding is used correctly per the guidelines.
In this bundle, you will find drawable and layout resources that adapt to different screen sizes and resolutions as well as translations into multiple languages for the text in the button.
Load Payment Data
Once the user taps on the button, you call the load payment data request to open up the payment sheet
You can construct the payment data request object, which is a set of payments configurations used for this particular transaction.
You can request additional information like a shipping address and email address in addition to the payment credentials, we recommend that you collect as little information as necessary to prevent users from typing additional information which might not be stored in their accounts.
One more point to call out in this object is the payment requests tokenization parameters. Google encrypts information about a user's selected card for secure processing by a merchant's gateway or directly on a merchant secured servers.
Be sure to check your processes integration guidelines to find out what they need to finalise the payment. Now that you've constructed the request object, you can pass it to load payment data, an asynchronous task which opens the payments sheet.
Once the user makes a selection, we return to you a payment data object as an activity result which consists of metadata about the user's selection.
It also includes the payment token, which you can use to complete the transaction.
Now you can send the final production ready application to Google for a final test.
Google tests the app with real cards and informs you if everything is correct. The app is then cleared to launch.