Solving Payment Issues with Google Play Billing RTDN for Initial Purchase
As an online product-based service provider, we understand the importance of providing a seamless payment channel for our users. We integrate our service with multiple payment options to make it easier for our users to choose their preferred payment channel. One of these options is integration with Google Play Billing for our Android apps.
In this blog post, we will discuss how we solved payment issues with Google Play Billing by using Real Time Developer Notification (RTDN) for initial purchases.
The MVP
As an Agile company, we built the integration of Google Play Billing with a Minimum Viable Product (MVP) that required users to be eligible to watch the premium content they purchase. The first implementation involved the following process:
The Problem
Although we successfully integrated with Google Play Billing, we received reports of issues from users. Users complained that they did not receive their subscription after purchasing it in our app using Google Play Billing. These complaints increased significantly during major events on our platform, putting a lot of pressure on our on-call team member, as they had to process each report individually.
This happened because our server did not receive the purchase notification from our app.
There were a few factors that caused this issue, such as problems with the user's connection to the server or other issues within our app.
The Solution
To improve the platform and make it more user-friendly, we needed to use Real-Time Developer Notifications for initial purchases. This was because there was a reliable connection between the servers during these transactions.
The problem with using RTDN for our initial purchase was that we didn't know the connection between the purchase receipt and the user who was purchasing the subscription. In our initial process, the connection with the user was the user session on our app when it gave a purchase notification to our server.
So we gave ourselves time to scrutinize the RTDN and Google Play Developer API documentation to find a way to establish the receipt's connection to the user who purchased it.
What we found was that there were certain attributes on the receipt that had to be explicitly defined on the purchase process on the client app to give information about the user. The attributes were obfuscatedExternalAccountId.
This attribute could be filled with the identifier of our user, and it was defined using the setObfuscatedAccountId method in the BillingFlowParams.Builder class in the Google Play Billing Client API.
The Process
The overview process of using Real Time Developer Notification (RTDN) for initial purchase was as follows:
The Result
The use of RTDN for initial purchases improved our service by ensuring that the user gets their subscription after purchasing it. By filling in the obfuscatedExternalAccountId attribute with the user's identifier, we had a way to identify the user who made the purchase. This made it easier for our servers to process the purchase notification and connect the receipt to the user.
In conclusion, by using Real Time Developer Notification (RTDN) for initial purchases, we solved payment issues with Google Play Billing. This improved our service and made it more user-friendly. We hope that this solution will help other service providers facing similar issues with Google Play Billing.