Skip to content

Commit

Permalink
Refactor method to get product ID including plan ID in android
Browse files Browse the repository at this point in the history
  • Loading branch information
tonidero committed Jun 26, 2023
1 parent b36adf1 commit ec206fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/Identity/CustomerInfo+ActiveDates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension CustomerInfo {
.subscriptions
.lazy
.map { productID, subscription in
let key = Self.productID(productID: productID, purchase: subscription)
let key = Self.extractProductIDAndBasePlan(from: productID, purchase: subscription)
let value = subscription.expiresDate
return (key, value)
}
Expand All @@ -66,7 +66,7 @@ extension CustomerInfo {
.allPurchasesByProductId
.lazy
.map { productID, purchase in
let key = Self.productID(productID: productID, purchase: purchase)
let key = Self.extractProductIDAndBasePlan(from: productID, purchase: purchase)
let value = purchase.purchaseDate
return (key, value)
}
Expand All @@ -79,7 +79,8 @@ extension CustomerInfo {

private extension CustomerInfo {

static func productID(productID: String, purchase: CustomerInfoResponse.Subscription) -> String {
static func extractProductIDAndBasePlan(from productID: String,
purchase: CustomerInfoResponse.Subscription) -> String {
// Products purchased from Google Play will have a product plan identifier (base plan)
// These products get mapped as "productId:productPlanIdentifier" in the Android SDK
// so the same mapping needs to be handled here for cross platform purchases
Expand Down

0 comments on commit ec206fc

Please sign in to comment.