Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to renew subscription manually using Play Billing Library?

I'm using Play Billing Library v1.0 for In-app Billing support in Android app and would like to allow users to renew a subscription manually during its active period to extend it by the appropriate period.

It can be handy for different sales (Black Friday, New Year, etc.), when users can extend their subscriptions with discount.

According to the official documentation, this behavior really can be achieved. But I found no information how to implement it.

I'm using the following standard code to buy a subscription:

BillingFlowParams.Builder builder = BillingFlowParams.newBuilder()
        .setSku(skuId).setType(SkuType.SUBS);
int responseCode = mBillingClient.launchBillingFlow(activity, builder.build());

If I try to buy the same subscription again, the

"You're already subscribed to XXXXX [OK]"

error message appears.

I also tried to use .addOldSku() builder method and pass the same sku here, but it does not help either.

like image 515
Alexander Bilchuk Avatar asked Dec 11 '17 16:12

Alexander Bilchuk


People also ask

How does Google Play billing work?

Google Play's billing system is a service that enables you to sell digital products and content in your Android app. You can use Google Play's billing system to sell a one-time product or subscriptions on a recurring basis.


2 Answers

With the In-app Billing API, users can renew a subscription during its active period even if the subscription is not set to automatically renew. If the user purchases a subscription while the subscription is active, it is extended by the appropriate period at the current rate.

For example, Achilles has a subscription to the Modern Hoplite app. His subscription is currently due to expire on August 1. On July 10, he purchases a 1-month subscription at the current rate. This one month is added to his existing subscription, so the subscription now expires on September 1.

It is up to the app to convey this with an appropriate UI. For example, if a user does not have an active subscription, the app might have a buy button, but if the user has a subscription the button might say renew.

Please check more details about In-App refer below link:

https://developer.android.com/google/play/billing/billing_subscriptions.html

like image 63
Jyubin Patel Avatar answered Nov 15 '22 22:11

Jyubin Patel


Please upgrade your Play Billing Library v1.0 Play Billing Library v5

In the latest version of In-app Billing,

  • A user can manually extend an existing subscription. The subscription is extended by the appropriate amount of time.

  • A user can upgrade or downgrade a subscription while it is active. The old subscription is canceled, and the unused portion is applied on a pro-rata basis to the new subscription.

Read the version note

like image 37
Fenil Patel Avatar answered Nov 15 '22 21:11

Fenil Patel