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 8447487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:11:17+00:00 2026-06-10T10:11:17+00:00

I’m using the In App Billing sample app to add this feature to my

  • 0

I’m using the In App Billing sample app to add this feature to my application.
After I finished adding it to my app, and tested all working, I noticed the comment in this Security class:

Security-related methods. For a secure implementation, all of
this code should be implemented on a server that communicates with
the application on the device. For the sake of simplicity and
clarity of this example, this code is included here and is executed
on the device. If you must verify the purchases on the phone, you
should obfuscate this code to make it harder for an attacker to
replace the code with stubs that treat all purchases as verified.

As Google suggests, I do the purchase verification on the server side so I really don’t need the Security class in my project.
The problem is, I can’t figure out how to remove the BillingService class dependency in the Security class.

I started by deleting the Security class and following the errors in the BillingService and most places it’s being used I can remove easily, except in one place:

private void purchaseStateChanged(int startId, String signedData, String signature) {
        ArrayList<Security.VerifiedPurchase> purchases;
        purchases = Security.verifyPurchase(signedData, signature);
        if (purchases == null) {
            return;
        }

        ArrayList<String> notifyList = new ArrayList<String>();
        for (VerifiedPurchase vp : purchases) {
            if (vp.notificationId != null) {
                notifyList.add(vp.notificationId);
            }
            ResponseHandler.purchaseResponse(this, vp.purchaseState, vp.productId,
                    vp.orderId, vp.purchaseTime, vp.developerPayload);
        }
        if (!notifyList.isEmpty()) {
            String[] notifyIds = notifyList.toArray(new String[notifyList.size()]);
            confirmNotifications(startId, notifyIds);
        }
    }

Would love if someone can share his/hers purchaseStateChanged method (based on the in app billing sample app) without the use of the Security class.

  • 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-10T10:11:19+00:00Added an answer on June 10, 2026 at 10:11 am

    So here’s what I did. First the calls to BillingService occur on the applications main thread, so you need to issue your server calls in a background thread. I chose to finish up processing on the main thread, since I wasn’t sure what impact calling methods like ‘confirmNotifications’ on a background thread might have.

    I created a callback interface VerifyTransactionCompletion which could be dispatched back to the main thread after the remote call completed.

    I keep around the Security class and have it manage the call to the server now, instead of what it originally performed in the sample. So when you see the call to Security, that’s where I call out to my server and perform signature validation.

    /**
     * Callback interface to <em>finish</em> processing a transaction once the remote
     * servers have processed it.
     */
    public interface VerifyTransactionCompletion {
        public void transactionVerified(List<Security.VerifiedPurchase> purchases);
    }
    
    private void purchaseStateChanged(final int startId, String signedData, String signature) {
        // verifyPurchase issues remote call to server (in a background thread), then
        // calls transactionVerified on the main thread to continue processing.
        Security.verifyPurchase(signedData, signature, new VerifyTransactionCompletion() {
    
            @Override
        public void transactionVerified(List<VerifiedPurchase> purchases) {
                if (purchases == null) {
                    return;
                }
    
                ArrayList<String> notifyList = new ArrayList<String>();
                for (VerifiedPurchase vp : purchases) {
                    if (vp.notificationId != null) {
                        notifyList.add(vp.notificationId);
                    }
                    ResponseHandler.purchaseResponse(BillingService.this, vp.purchaseState, vp.productId,
                            vp.orderId, vp.purchaseTime, vp.developerPayload);
                }
                if (!notifyList.isEmpty()) {
                    String[] notifyIds = notifyList.toArray(new String[notifyList.size()]);
                    confirmNotifications(startId, notifyIds);
                }
            }
    
    });        
    

    }

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,

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.