fix(iap): acknowledge Google Play purchases only after the entitlement is persisted
This commit is contained in:
parent
1eb22af1f3
commit
957e136789
6 changed files with 667 additions and 144 deletions
|
|
@ -416,3 +416,24 @@ export async function verifyGooglePlaySubscription(
|
|||
ownsExpiredPurchaseToken,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Play Developer API adapter for the purchase-application use case
|
||||
* (structurally satisfies GooglePlayPurchaseApi in google-play-apply.ts).
|
||||
*/
|
||||
export function createGooglePlayPurchaseApi(fetchImpl: typeof fetch = fetch): {
|
||||
verify(
|
||||
userId: string,
|
||||
productId: string,
|
||||
purchaseToken: string,
|
||||
ownsExpiredPurchaseToken: (expiredPurchaseToken: string) => Promise<boolean>,
|
||||
): Promise<NormalizedGooglePlayPurchase>
|
||||
acknowledge(productId: string, purchaseToken: string): Promise<void>
|
||||
} {
|
||||
return {
|
||||
verify: (userId, productId, purchaseToken, ownsExpiredPurchaseToken) =>
|
||||
verifyGooglePlaySubscription(userId, productId, purchaseToken, fetchImpl, ownsExpiredPurchaseToken),
|
||||
acknowledge: (productId, purchaseToken) =>
|
||||
acknowledgeGooglePlaySubscription(productId, purchaseToken, fetchImpl),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue