Skip to content

fix(payments): credit gems before marking IAP receipt consumed & add retry #15459

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Hafizzle
Copy link

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.
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.

1 participant