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

PurchasesOrchestrator: also get Storefront from SK1 #2629

Merged
merged 1 commit into from
Jun 13, 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
8 changes: 7 additions & 1 deletion Sources/Purchasing/Purchases/PurchasesOrchestrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ extension PurchasesOrchestrator: StoreKit2TransactionListenerDelegate {
_ listener: StoreKit2TransactionListener,
updatedTransaction transaction: StoreTransactionType
) async throws {
let storefront = await transaction.storefrontOrCurrent
let storefront = await self.storefront(from: transaction)

_ = try await Async.call { completed in
self.transactionPoster.handlePurchasedTransaction(
Expand All @@ -845,6 +845,12 @@ extension PurchasesOrchestrator: StoreKit2TransactionListenerDelegate {
}
}

private func storefront(from transaction: StoreTransactionType) async -> StorefrontType? {
return await transaction.storefrontOrCurrent
// If we couldn't determine storefront from SK2, try SK1:
?? self.paymentQueueWrapper.sk1Wrapper?.currentStorefront
}

}

@available(iOS 15.0, tvOS 15.0, macOS 12.0, watchOS 8.0, *)
Expand Down