Skip to content

Fix Amazon IAP: UI thread execution and post-purchase delivery#6

Draft
Copilot wants to merge 29 commits intov13.12-amazonfrom
copilot/verify-amazon-iap-functionality
Draft

Fix Amazon IAP: UI thread execution and post-purchase delivery#6
Copilot wants to merge 29 commits intov13.12-amazonfrom
copilot/verify-amazon-iap-functionality

Conversation

Copy link

Copilot AI commented Feb 13, 2026

Changes proposed in this pull request:

  • Run all PurchasingService calls on the UI thread — Amazon IAP SDK requires main thread execution, but Cordova's execute() runs on a background WebCore thread. Only registerListener() was wrapped in runOnUiThread(); purchase(), getProductData(), notifyFulfillment(), and getPurchaseUpdates() were not. This caused the purchase dialog to silently fail on first launch.

  • Add post-purchase flush mechanism — When onPurchaseResponse fires, the WebView is typically still paused (Amazon overlay transitioning away), so emitToListener() queues the data. Previously, queued purchases were only flushed on onResume, requiring a full minimize/resume cycle. Now schedules 5 retry flushes at 1s intervals after purchase completion. Also fixes flushPendingPurchases() to re-queue data if the listener is still not ready, instead of silently dropping it.

// Before: called from background thread — purchase dialog never appears
PurchasingService.purchase(productId);

// After: runs on UI thread as Amazon SDK requires
cordova.getActivity().runOnUiThread(() ->
    PurchasingService.purchase(productId));

To test this pull request with cordova:

# 1: Uninstall the plugin (if already installed)
cordova plugin rm cordova-plugin-purchase

# 2: Install from github
cordova plugin add "https://github.com/CatLabInteractive/cordova-plugin-purchase.git#copilot/verify-amazon-iap-functionality"

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

j3k0 and others added 27 commits December 27, 2024 15:39
…cuts

fix(docs): update namespace usage recommendations to avoid minificati…
Handle subscription expiration dates for determining ownership.
…onitor

Note: Only check local receipts for expiry if no validator is configured
…tions

(googleplay) Fix cancelled subscriptions not properly reflected in owned flag
Add support for multi-quantity purchases on Android
This change addresses Issue j3k0#1638 by:
1. Adding isAcknowledged and isConsumed properties to the VerifiedPurchase interface
2. Enhancing the Store.finish() method to check if a transaction has already been
   acknowledged or consumed according to the receipt validator
3. Skipping the native finish operation when server validation confirms the transaction
   has already been processed

When a receipt verification API acknowledges or consumes purchases on the backend,
the plugin will now detect this and avoid duplicate finish operations that would
otherwise cause errors. For subscriptions, verified purchases are implicitly
acknowledged unless explicitly marked as not acknowledged.

This change maintains backward compatibility with existing validators while enabling
validator implementations to include consumption/acknowledgment status in their responses.

Fixes: j3k0#1638
The most probable way to potentially prevent this from the plugin side is to
strictly ensure launchBillingFlow is executed on the main UI thread.
Allow external code to register custom adapters without modifying the
core library. This enables third-party platform support via the new
Adapters.registerAdapter() static method.
- Update billing library from 7.1.1 to 8.3.0
- Use PendingPurchasesParams API (required in 8.x)
- Enable auto service reconnection for better reliability
- Enable pending purchases for one-time products and prepaid plans
- Add support for one-time product offers (v12.0 format with InAppOffer)
- Handle new QueryProductDetailsResult API in ProductDetailsResponseListener
- Requires minSdkVersion 23 or higher
Copilot AI and others added 2 commits February 13, 2026 00:10
Co-authored-by: daedeloth <1168599+daedeloth@users.noreply.github.com>
…t-purchase flush mechanism

- Wrap all PurchasingService calls (getProductData, purchase, notifyFulfillment,
  getPurchaseUpdates) in runOnUiThread() - Amazon SDK requires UI thread execution
- Add post-purchase flush mechanism that retries delivering queued purchases
  to the WebView for 5 seconds after purchase completion, eliminating the need
  for a full app minimize/resume cycle
- Fix flushPendingPurchases to re-queue purchases if listener is not yet ready

Co-authored-by: daedeloth <1168599+daedeloth@users.noreply.github.com>
Copilot AI changed the title [WIP] Verify Amazon IAP support in the latest changes Fix Amazon IAP: UI thread execution and post-purchase delivery Feb 13, 2026
Copilot AI requested a review from daedeloth February 13, 2026 00:19
@daedeloth daedeloth changed the base branch from master to v13.12-amazon February 13, 2026 00:22
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.

3 participants