
How to Integrate Google Pay Service Into Your Android App and Why You Need It
By Andrii Zhumela
The right choice of a payment method proposed to the client is an important condition of success in the e-commerce. When talking about mobile apps, the statistic says you may lose up to 80 % of your clients just because the payment service is inconvenient or untrustworthy. Just think of all those attempts to enter all data with the help of a touchscreen — not to mention multiple shifts and fear of data leaks. In this situation, the integration of Google Pay service is a win-win solution for all parties.
Business Advantages of Google Pay
Google Pay (previously known as Android Pay) enables mobile payments just in two steps. The users registered in Google, when it comes to payment, tap the button «Buy with G Pay», choose one of their payment cards, and submit. Shipping mode being attached once, they dispose of necessity to enter the same contact data again and again.
No wonder that such an easy payment method is really popular among the users: as at September 2018, Google Pay app was downloaded 100 mln times. What are the business benefits? AirBnB after the service integration reported 11 times increase in the number of online payments. Google does not charge for the service use, so everything you get from integration is the growth in conversions and income.
Google Pay is available for all goods and services providers in the countries where the service is supported. It’s a perfect way to connect the user with several dozens of payment systems all over the world by means of a unified interface. It is easily integrated into the Android app. How? Read further to learn in details.
Google Pay Integration
The first thing you need to do is to import a library. In the project file gradle, you need to add a dependency: implementation 'com.google.android.gms:play-services-wallet:$play_service_wallet_version'
where $play_service_wallet_version
is a version of the library we are going to use. The current version is 16.0.0. The more detailed instruction for the library importation and information about Google Pay Services libraries can be found here.
Assuming the product or the service has already been formed and everything is ready for it to pass into your ownership. What we still need is adjusting the purchase process itself. For this, let’s initialize the payment client:
For PAYMENTS_ENVIRONMENT
, we will specify the environment type WalletConstants.ENVIRONMENT_TEST
.
Next, I propose first to check the possibility of purchasing with Google Pay:
Depending upon the result, we need either to display or to hide the button:
Payment methods are specified in advance:
Google Pay In the Android App: Further Steps of Integration
We have gone through all preparatory stages related to our payment systems usage. Now we have come to the most complicated stage, payment committing:
An important note: most of payment systems use the minimal possible currency value. Consequently, in the case of a kopeck or penny, for example, when indicating the write-off sum equal 17852, we confirm that we want to write off 178.52.
The currency type:
Next, prepare the transaction. Don’t forget to indicate the currency type:
Form the request. Right away add the specifications for the merchant and the website link:
Next, the request itself. Here, specify all the necessary fields and ordering parameters. For example, we may specify if we need to request a phone number, an e-mail, and whether we need a delivery option at all. Here and now, we also specify countries where the goods can be delivered, payment options, and payment systems (VISA, MASTERCARD):
So, the request is formed. Next, we need to process the result of this request:
Then goes the transaction processing. Here, a lot of various logic can be added, including screen shifts, congratulations of just service-based data, but in our version, we will just check the result and show it. This is just a trial version, so, we will not dwell into the business logic:
Integration Outcome: What the User Sees
As a result, the users at the checkout stage will see the Google Pay button:

Let’s Sum It Up
Google Pay is a handy and safe payment service for the mobile app with the possibility of integration of numerous payment systems. It makes purchases easier for clients and boosts online sales for the merchants. With the help of the algorithm described above, you will easily integrate Google Pay into your Android app.
Originally published at stfalcon.com.