I using two subscription plans monthly and yearly in my android app. If a user has subscribed monthly plan then I want to give the user an option to upgrade to a yearly plan. I have read an official document I need to use BillingFlowParams.ProrationMode but I am unable to figure out how should I implement this.
Here is the code sample:
BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSkuDetails(skuDetails)
.setOldSku(oldSku)
// I need to replace replaceSkusProrationMode to DEFERRED
// how do I get complete path to DEFERRED
.setReplaceSkusProrationMode(replaceSkusProrationMode)
.build()
int responseCode = billingClient.launchBillingFlow(activity, flowParams);
using this link I get the int value for DEFERRED is 4 but it's not a good idea to use hardcoded value.
How should I achieve this?
I was using an older version of billingclient upgrade to newer version solved my problem.
I changed to
implementation 'com.android.billingclient:billing:2.0.2'
From
implementation 'com.android.billingclient:billing:1.0'
then I get an option for setReplaceSkusProrationMode.
Here how I am using now:
BillingFlowParams flowParams1 = BillingFlowParams.newBuilder()
.setOldSku(monthly_test)
.setReplaceSkusProrationMode(BillingFlowParams.ProrationMode.DEFERRED)
.setSkuDetails(yearly_test)
.build();