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

Refactor method to get product ID including plan ID in android purchases #2708

Merged
merged 1 commit into from
Jun 26, 2023
Merged
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
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