Search code examples
javaandroidgoogle-apigoogle-payin-app-subscription

Receiving error after setObfuscatedProfileId/setObfuscatedAccountId


For my android app, I am setting up subscription/in-app purchases. Before launching the billing flow, I use setObfuscatedProfileId/setObfuscatedAccountId to specify a specific id for the purchase. However, when I do so, I receive the following error message/popup before the user attempts to make a payment:

Error
Something went wrong on our end. Please try again.

When I remove the setObfuscatedProfileId/setObfuscatedAccountId parameter, I do not get the error. I have also tried clearing data/cache from google play services and play store.

This is the code:

BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
                .setSkuDetails(sku)
                .setObfuscatedProfileId(profileId) // when this is removed, there is no error
                .build();
        BillingResult result = billingClient.launchBillingFlow(this.activity, billingFlowParams);

In short, why would setObfuscatedProfileId/setObfuscatedAccountId cause an error?


Solution

  • Your question is not clear, because it is not known what value profileId has.

    Trying to set the same (unique) profileId twice likely would also not work out.

    As the documentation states:

    If you pass this value, Google Play can use it to detect irregular activity, such as many devices making purchases on the same account in a short period of time. Do not use this field to store any Personally Identifiable Information (PII) such as emails in cleartext. Attempting to store PII in this field will result in purchases being blocked. Google Play recommends that you use either encryption or a one-way hash to generate an obfuscated identifier to send to Google Play.