Skip to content

Add custom PurchaseLogic support to presentPaywall/presentPaywallIfNeeded APIs#1630

Closed
rickvdl wants to merge 2 commits intorickvdl/add-purchase-logic-support-to-paywallviewfrom
rickvdl/add-purchase-logic-support-to-presentpaywall-apis
Closed

Add custom PurchaseLogic support to presentPaywall/presentPaywallIfNeeded APIs#1630
rickvdl wants to merge 2 commits intorickvdl/add-purchase-logic-support-to-paywallviewfrom
rickvdl/add-purchase-logic-support-to-presentpaywall-apis

Conversation

@rickvdl
Copy link
Member

@rickvdl rickvdl commented Feb 25, 2026

Summary

  • Extends the imperative presentPaywall() and presentPaywallIfNeeded() modal APIs to accept an optional purchaseLogic parameter, enabling custom purchase/restore handling
  • Adds native bridge support on both iOS and Android to create HybridPurchaseLogicBridge and communicate purchase/restore events back to JS via NativeEventEmitter
  • Adds example usage in the purchase tester app matching the Capacitor example pattern

Based on #1607 which added PurchaseLogic support to the PaywallView component.

Test plan

  • Tested presentPaywall() with purchaseLogic on Android (calling real Purchases.purchasePackage)
  • Test presentPaywall() with purchaseLogic on iOS
  • Test presentPaywallIfNeeded() with purchaseLogic on both platforms
  • Test presentPaywall() without purchaseLogic still works (no regression)
  • Test cancellation and error flows

🤖 Generated with Claude Code

@rickvdl rickvdl requested a review from a team as a code owner February 25, 2026 11:43
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense! Thank you!!

customVariables: customVariables,
purchaseLogic: {
performPurchase: async ({ packageToPurchase }) => {
console.log('[PurchaseLogic] performPurchase', packageToPurchase.identifier);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be good to mention that this is a "CustomPurchaseLogic"? Like

Suggested change
console.log('[PurchaseLogic] performPurchase', packageToPurchase.identifier);
console.log('[CustomPurchaseLogic] performPurchase', packageToPurchase.identifier);

If we do this, we should also change it for the restore below :)

@rickvdl rickvdl closed this Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants