In-App Purchase After Purchasing Buyer Email After Purchase

Is there a way to get buyer email after purchase using google wallet,

I am using IabHelper.launchSubscriptionPurchaseFlow and after a successful purchase (subscription) only two objects are fetched (IabResult and Purchase), but unfortunately none of them contain the buyer's email address.

Senario is, if a user has more than one email connected to his Android device and has a credit card connected to one of his additional emails, I need to get the email that was used for the purchase in order to use it on the server side.

I hope to find someone helping me with this issue because I spend a lot of time on this problem and unfortunately I haven't found a solution.

Regards

+3


source to share


1 answer


I think that in a successful purchase reply you may not be able to receive the buyer's email.

So it is possible using the AccountManager class , which you simply call with the following method in onIabPurchaseFinished .

public static String getemailId(Activity act){
        Pattern emailPattern = Patterns.EMAIL_ADDRESS;
        Account[] accounts= AccountManager.get(act).getAccounts();
        String userEmailId="";
        for (Account account : accounts) {
            if (emailPattern.matcher(account.name).matches()) {
                userEmailId = account.name;

            }
        }
        return userEmailId;
}

      



This method will return the email_id of the customer for future use.

Hope this helps you.

-1


source







All Articles