Skip to content

Commit

Permalink
Add DEFERRED replacement mode (#1751)
Browse files Browse the repository at this point in the history
### Description
Deferred replacement mode was removed in V7 of the SDK. This brings it
back.
  • Loading branch information
tonidero authored Jun 27, 2024
1 parent 2dbed95 commit 36ddd19
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static void check(final GoogleReplacementMode mode) {
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 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 @@ -669,6 +669,7 @@ private enum class LegacyProrationMode {
IMMEDIATE_WITH_TIME_PRORATION,
IMMEDIATE_AND_CHARGE_FULL_PRICE,
IMMEDIATE_AND_CHARGE_PRORATED_PRICE,
DEFERRED,
}

private val GoogleReplacementMode.asLegacyProrationMode: LegacyProrationMode
Expand All @@ -677,4 +678,5 @@ private val GoogleReplacementMode.asLegacyProrationMode: LegacyProrationMode
GoogleReplacementMode.WITH_TIME_PRORATION -> LegacyProrationMode.IMMEDIATE_WITH_TIME_PRORATION
GoogleReplacementMode.CHARGE_FULL_PRICE -> LegacyProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE
GoogleReplacementMode.CHARGE_PRORATED_PRICE -> LegacyProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE
GoogleReplacementMode.DEFERRED -> LegacyProrationMode.DEFERRED
}
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),
;

override fun describeContents(): Int {
Expand Down

0 comments on commit 36ddd19

Please sign in to comment.