I am using the Google Play Billing library version 4.0.0
I have followed the integration docs: https://developer.android.com/google/play/billing/integrate & created subscription plans in the Google Play console.
There are two monthly subscription plans:
- pro1_monthly (₹140.01)
- pro2_monthly (₹210.02)
I purchase pro1_monthly first normally like so:
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setSkuDetails(pro1MonthlySkuDetails)
.build();
// and launch the billing flow
billingClient.launchBillingFlow(this, billingFlowParams);
Next I purchase the pro2_monthly. Here only the IMMEDIATE_AND_CHARGE_PRORATED_PRICE & IMMEDIATE_AND_CHARGE_FULL_PRICE mode is working for me.
The other modes give the error with billing response code 5 which is described in the documentation as DEVELOPER_ERROR. I have attached the screenshot of the error. And this is the code for upgrade/downgrade:
// Retrieve a value for "skuDetails" by calling querySkuDetailsAsync().
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setSubscriptionUpdateParams(BillingFlowParams.SubscriptionUpdateParams.newBuilder()
.setOldSkuPurchaseToken(pro1MonthlyPurchaseToken)
.setReplaceSkusProrationMode(BillingFlowParams.ProrationMode.IMMEDIATE_WITH_TIME_PRORATION)
.build())
.setSkuDetails(pro2MonthlySkuDetails)
.build();
int responseCode = billingClient.launchBillingFlow(this, billingFlowParams).getResponseCode();
System.out.println("pro2_monthly: " + responseCode);
pro2_monthly: 5 // billing response code
Here is a link to a related post Cannot upgrade android in-app subscription. Error: "Something went wrong on our end. Please try again."
I am testing this from India region. I want to understand why IMMEDIATE_AND_CHARGE_PRORATED_PRICE & IMMEDIATE_AND_CHARGE_FULL_PRICE mode is working. Because these modes display the dialog to change the subscription and perform the upgrade with no issues.
But the other modes IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_WITHOUT_PRORATION, & DEFERRED do not work for upgrade/downgrade.
Lastly
I have verified the common issues like app version name, version code, APK signing, billing enabled, purchase token verification, acknowledging purchases, using queryPurchasesAsync oldSkuDetails(pro1MonthlySkuPurchaseToken) for subscription update, & enablingPendingPurchases.
Billing result debug message: The subscription can't have the first charge for free.
Subscription options set in play console:
- Monthly plan with free trial disabled
- Grace period 7 days
- Introductory price selected as none
- Resubscribe is enabled for all