Skip to content

Commit

Permalink
enhancement(replacement-mode): Remove deprecation of proration mode (#…
Browse files Browse the repository at this point in the history
…2761)

We need to enhance proration modes for android. 

Currently we will have Replacement modes. 

Im create a basic example for change request

If everything good here, im could continue and also welcome to
collaborate :)
  • Loading branch information
bataevvlad authored Jun 11, 2024
1 parent 36e8c9f commit dec0774
Showing 1 changed file with 25 additions and 31 deletions.
56 changes: 25 additions & 31 deletions android/src/play/java/com/dooboolab/rniap/RNIapModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -504,19 +504,14 @@ class RNIapModule(
if (obfuscatedProfileId != null) {
builder.setObfuscatedProfileId(obfuscatedProfileId)
}
if (prorationMode != -1) {
if (prorationMode
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
) {
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
when (prorationMode) {
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE -> {
subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode(
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE,
)
if (type != BillingClient.ProductType.SUBS) {
val debugMessage =
(
"IMMEDIATE_AND_CHARGE_PRORATED_PRICE for proration mode only works in" +
" subscription purchase."
)
"IMMEDIATE_AND_CHARGE_PRORATED_PRICE for proration mode only works in subscription purchase."
val error = Arguments.createMap()
error.putString("debugMessage", debugMessage)
error.putString("code", PROMISE_BUY_ITEM)
Expand All @@ -526,31 +521,30 @@ class RNIapModule(
promise.safeReject(PROMISE_BUY_ITEM, debugMessage)
return@ensureConnection
}
} else if (prorationMode
== BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION
) {
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION,
}
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITHOUT_PRORATION -> {
subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode(
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITHOUT_PRORATION,
)
} else if (prorationMode == BillingFlowParams.ProrationMode.DEFERRED) {
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
BillingFlowParams.ProrationMode.DEFERRED,
}
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.DEFERRED -> {
subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode(
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.DEFERRED,
)
} else if (prorationMode
== BillingFlowParams.ProrationMode.IMMEDIATE_WITH_TIME_PRORATION
) {
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION,
}
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITH_TIME_PRORATION -> {
subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode(
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITH_TIME_PRORATION,
)
} else if (prorationMode
== BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
) {
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE,
}
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_FULL_PRICE -> {
subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode(
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_FULL_PRICE,
)
} else {
subscriptionUpdateParamsBuilder.setReplaceProrationMode(
BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY,
}
else -> {
subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode(
BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.UNKNOWN_REPLACEMENT_MODE,
)
}
}
Expand Down

0 comments on commit dec0774

Please sign in to comment.