Search code examples
javaandroidin-app-billing

Guidance Needed for Implementing In-App Billing and Server Verification in Android Java


I'm working on implementing in-app billing for subscriptions in my Android app using Java, but I'm encountering some difficulties, particularly with server-side verification.

What I've Done So Far:

  • Followed the official Google Play Billing Library documentation closely.
  • Successfully implemented the client-side purchase flow.
  • Encountering challenges with verifying subscriptions on the server-side.
  • Limited testing to internal testing, but I'm struggling to retrieve meaningful logs for troubleshooting.
  • Most tutorials I’ve found are outdated or don’t cover the newer version (V3) comprehensively.

Issues I'm Facing:

  • Server-Side Verification: I’m unsure how to correctly implement the server-side verification for subscriptions.
  • Testing: How can I effectively test the subscription flow and server-side logic without being restricted to internal testing only?
  • Resources: Looking for up-to-date tutorials or guidance that align with the latest Google Play Billing Library (V3).

What I Need Help With:

  • A clear explanation or example of how to implement server-side verification for subscriptions using Java.

  • Best practices for testing in-app billing, especially for subscriptions.

  • Any resources or tutorials that are current and focus on the latest version of the Google Play Billing Library.

Any guidance or corrections would be greatly appreciated, as well as any tips on avoiding common pitfalls with in-app billing implementation.


Solution

  • Android In-App Billing Library v4+

    A simple implementation of the Android In-App Billing API.

    Getting Started

    ● Add the dependency in your app's build.gradle file:

    dependencies {
        implementation 'com.github.moisoni97:google-inapp-billing:1.0.5'
    }
    

    ● Create an instance of BillingConnector class. Constructor will take 2 parameters:

     ● Context
     ● License key from *Play Console*
    
    billingConnector = new BillingConnector(this, "license_key")
                    .setConsumableIds(consumableIds)
                    .setNonConsumableIds(nonConsumableIds)
                    .setSubscriptionIds(subscriptionIds)
                    .autoAcknowledge()
                    .autoConsume()
                    .enableLogging()
                    .connect();
    

    More Info. on Github :- https://github.com/Mahadev-code/Android-inApp-Billing