Skip to content

Commit

Permalink
Add DEFERRED replacement mode (#1751)
Browse files Browse the repository at this point in the history
Deferred replacement mode was removed in V7 of the SDK. This brings it
back.
  • Loading branch information
tonidero committed Jul 1, 2024
1 parent 9c134d6 commit 466b830
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static void check(final GoogleProrationMode mode) {
case IMMEDIATE_WITH_TIME_PRORATION:
case IMMEDIATE_AND_CHARGE_FULL_PRICE:
case IMMEDIATE_AND_CHARGE_PRORATED_PRICE:
case DEFERRED:
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.revenuecat.apitester.java;

import com.revenuecat.purchases.models.GoogleReplacementMode;

@SuppressWarnings({"unused"})
final class GoogleReplacementModeAPI {
static void check(final GoogleReplacementMode mode) {
switch (mode) {
case WITHOUT_PRORATION:
case WITH_TIME_PRORATION:
case CHARGE_FULL_PRICE:
case CHARGE_PRORATED_PRICE:
case DEFERRED:
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ private class GoogleProrationModeAPI {
GoogleProrationMode.IMMEDIATE_WITH_TIME_PRORATION,
GoogleProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE,
GoogleProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
GoogleProrationMode.DEFERRED,
-> {}
}.exhaustive
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ private class GoogleReplacementModeAPI {
GoogleReplacementMode.WITH_TIME_PRORATION,
GoogleReplacementMode.CHARGE_FULL_PRICE,
GoogleReplacementMode.CHARGE_PRORATED_PRICE,
GoogleReplacementMode.DEFERRED,
-> {}
}.exhaustive
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ enum class GoogleProrationMode(
* On May 1st, Samwise is charged $36 for his new subscription tier and another $36 on May 1 of each year following.
*/
IMMEDIATE_AND_CHARGE_PRORATED_PRICE(BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE),

/**
* Replacement takes effect when the old plan expires, and the new price will be charged at the same time.
*
* Example: Samwise's Tier 1 subscription continues until it expires on April 30. On May 1st, the
* Tier 2 subscription takes effect, and Samwise is charged $36 for his new subscription tier.
*/
DEFERRED(BillingFlowParams.ProrationMode.DEFERRED)
;

/**
Expand All @@ -71,6 +79,7 @@ enum class GoogleProrationMode(
GoogleProrationMode.IMMEDIATE_WITH_TIME_PRORATION -> GoogleReplacementMode.WITH_TIME_PRORATION
GoogleProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE -> GoogleReplacementMode.CHARGE_FULL_PRICE
GoogleProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE -> GoogleReplacementMode.CHARGE_PRORATED_PRICE
GoogleProrationMode.DEFERRED -> GoogleReplacementMode.DEFERRED
}

override fun describeContents(): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ enum class GoogleReplacementMode(
* On May 1st, Samwise is charged $36 for his new subscription tier and another $36 on May 1 of each year following.
*/
CHARGE_PRORATED_PRICE(BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE),

/**
* Replacement takes effect when the old plan expires, and the new price will be charged at the same time.
*
* Example: Samwise's Tier 1 subscription continues until it expires on April 30. On May 1st, the
* Tier 2 subscription takes effect, and Samwise is charged $36 for his new subscription tier.
*/
DEFERRED(BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.DEFERRED),
;

/**
Expand All @@ -67,6 +75,7 @@ enum class GoogleReplacementMode(
GoogleReplacementMode.WITH_TIME_PRORATION -> GoogleProrationMode.IMMEDIATE_WITH_TIME_PRORATION
GoogleReplacementMode.CHARGE_FULL_PRICE -> GoogleProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
GoogleReplacementMode.CHARGE_PRORATED_PRICE -> GoogleProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
GoogleReplacementMode.DEFERRED -> GoogleProrationMode.DEFERRED
}

override fun describeContents(): Int {
Expand Down

0 comments on commit 466b830

Please sign in to comment.