Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEFERRED replacement mode #1751

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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

Check warning on line 681 in purchases/src/main/kotlin/com/revenuecat/purchases/common/Backend.kt

View check run for this annotation

Codecov / codecov/patch

purchases/src/main/kotlin/com/revenuecat/purchases/common/Backend.kt#L681

Added line #L681 was not covered by tests
}
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