Skip to content

Commit

Permalink
Implement new argument in purchase() method in SubscriptionsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
nalcalag committed Jan 24, 2025
1 parent 00dee76 commit 258f1d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ interface SubscriptionsManager {
suspend fun getSubscriptionOffer(): List<SubscriptionOffer>

/**
* Launches the purchase flow for a given plan id
* Launches the purchase flow for a given combination of plan id and offer id
*/
suspend fun purchase(
activity: Activity,
planId: String,
offerId: String? = null,
)

/**
Expand Down Expand Up @@ -747,6 +748,7 @@ class RealSubscriptionsManager @Inject constructor(
override suspend fun purchase(
activity: Activity,
planId: String,
offerId: String?,
) {
try {
_currentPurchaseState.emit(CurrentPurchase.PreFlowInProgress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ interface PlayBillingManager {
activity: Activity,
planId: String,
externalId: String,
offerId: String? = null,
)
}

Expand Down Expand Up @@ -173,6 +174,7 @@ class RealPlayBillingManager @Inject constructor(
activity: Activity,
planId: String,
externalId: String,
offerId: String?,
) = withContext(dispatcherProvider.io()) {
if (!billingClient.ready) {
logcat { "Service not ready" }
Expand All @@ -183,7 +185,7 @@ class RealPlayBillingManager @Inject constructor(

val offerToken = productDetails
?.subscriptionOfferDetails
?.find { it.basePlanId == planId }
?.find { it.basePlanId == planId && it.offerId == offerId }
?.offerToken

if (productDetails == null || offerToken == null) {
Expand Down

0 comments on commit 258f1d0

Please sign in to comment.