Skip to content

Conversation

Hafizzle
Copy link
Contributor

Previously we marked the IAP receipt consumed in the DB before attempting
to credit gems. If crediting failed (e.g. transient DB/network error),
the token was "burned" and the Android/iOS client would consume it on
their side, making retries impossible and causing players to pay without
receiving gems.

This change:

  • Introduces "safeBuySkuItem" in googlePlay.js/apple.js with a 3-attempt
    exponential-backoff wrapper around payments.buySkuItem.
  • Swaps the order in verifyPurchase/noRenewSubscribe: first call
    'safeBuySkuItem', then 'IapPurchaseReceipt.create' only on success.
  • Ensures any failure bubbles up before the receipt is marked consumed.

Now purchases are retried on transient failures and receipts are only
burned once delivery succeeds.

…retry

Previously we marked the IAP receipt consumed in the DB before attempting
to credit gems. If crediting failed (e.g. transient DB/network error),
the token was "burned" and the Android/iOS client would consume it on
their side, making retries impossible and causing players to pay without
receiving gems.

This change:
- Introduces "safeBuySkuItem" in googlePlay.js/apple.js with a 3-attempt
  exponential-backoff wrapper around payments.buySkuItem.
- Swaps the order in verifyPurchase/noRenewSubscribe: first call
  'safeBuySkuItem', then 'IapPurchaseReceipt.create' only on success.
- Ensures any failure bubbles up before the receipt is marked consumed.

Now purchases are retried on transient failures and receipts are only
burned once delivery succeeds.
@SabreCat
Copy link
Member

SabreCat commented Jun 24, 2025

Cleaned up various lint issues for ya ... not entirely sure what to make of the no-promise-executor-return issue. Possibly we can use the sleepAsync function from the shared code?

Edit: possibly need to use Promise.resolve? https://eslint.org/docs/latest/rules/no-promise-executor-return

@Hafizzle
Copy link
Contributor Author

Going to close this in lieu of of a cleaner/simpler approach on another upcoming PR

@Hafizzle Hafizzle closed this Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants