Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:39:30+00:00 2026-06-11T05:39:30+00:00

I have been recently studying code for In-App-Billing v2. And have found some issues

  • 0

I have been recently studying code for In-App-Billing v2. And have found some issues with it.
I have earlier implemented In-App-Billing but wish to upgrade to subscription. On my research I found that Purchase token is recieved along with the JSON(Signed data) on successful purchase for subscription.

The demo’s Security.java on successful verification of signature parses Json however the parsing of element Purchase-token is missing here.

            JSONObject jElement = jTransactionsArray.getJSONObject(i);
            int response = jElement.getInt("purchaseState");
            PurchaseState purchaseState = PurchaseState.valueOf(response);
            String productId = jElement.getString("productId");
            String packageName = jElement.getString("packageName");
            long purchaseTime = jElement.getLong("purchaseTime");
            String orderId = jElement.optString("orderId", "");
            String notifyId = null;
//          purchaseToken part that I have added
            String purchaseToken = jElement.optString("purchaseToken", "");

I haven’t yet run the code since subscription doesn’t have test product-ids and requires actual purchase.What I want to know is this token be parsed here or is the sample code provided has this part correctly implemented.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:39:32+00:00Added an answer on June 11, 2026 at 5:39 am

    Vincent, that is correct. You have to modify Security.java as well as BillingService.java and ResponseHandler.java if you need the purhcaseToken to be validated.

    Here it is:

    Security.java:

    public PurchaseState    purchaseState;
    public String           notificationId;
    public String           productId;
    public String           orderId;
    public long             purchaseTime;
    public String           developerPayload;
    public String           purchaseToken;
    public String           packageName;
    
    public VerifiedPurchase(PurchaseState purchaseState, String notificationId, String productId, String orderId, long purchaseTime,
            String developerPayload, String purchaseToken, String packageName) {
        this.purchaseState = purchaseState;
        this.notificationId = notificationId;
        this.productId = productId;
        this.orderId = orderId;
        this.purchaseTime = purchaseTime;
        this.developerPayload = developerPayload;
        this.purchaseToken = purchaseToken;
        this.packageName = packageName;
        }
    }
    

    Now in VerifyPurchase:

    String developerPayload = jElement.optString("developerPayload", null);
    // VK: Changes to parse the purchaseToken
    String purchaseToken = jElement.optString("purchaseToken", null);
    

    BillingService.java:

    In purchaseStateChanged, modify:

    ResponseHandler.purchaseResponse(this, vp.purchaseState, vp.productId, vp.orderId, vp.purchaseTime, vp.developerPayload, vp.purchaseToken, vp.packageName);
    

    ResponseHandler.java:

    Finally, change the definition of purchaseResponse to:

    public static void purchaseResponse(final Context context, final PurchaseState purchaseState, final String productId, final String orderId, final long purchaseTime, final String developerPayload, final String purchaseToken,final String packageName)
    

    Here you can make your app related logic changes as you here will have the purchaseToken.

    If everything works, please accept!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently been rewriting some of my iphone app because a couple of
i've been following the code examples in the pickaxe book but have been recently
I've recently been studying TDD, attended a conference and have dabbled in few tests
I have been studying python for quite sometime now and very recently I decided
I have been recently testing my app in a strict mode to detect disk
I have been recently going through my database code trying to improve on my
I've been working on some solutions for some questions that have been recently posted
I have recently been introduced to EasyMock and have been asked to develop some
I've recently been studying Qt, and have the following questions: What is the difference
I've been studying Python 3 recently and I have come across a conundrum: I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.