Solved

RevenueCat and Stripe one-time purchases

  • 22 September 2022
  • 1 reply
  • 291 views

Badge +3
  • New Member
  • 0 replies

I am struggling to get RevenueCat to automatically sync/recognise one-time purchases from Stripe Checkout.

I have a Flutter app for both iOS and web (Firebase backend), and after significant work (writing custom conditional code for the Web logic...) have subscriptions working for both iOS and Web, integrated with RevenueCat. Customers can subscribe either as an IAP on iOS or using Stripe if on the Web app, and the subscription entitlement is managed by RevenueCat.

But… user’s also need the ability to make one-time purchase of consumable credits. On iOS this is handled as an IAP that RevenueCat syncs, pushing the successful transaction event to my Firestore Function so I can track the credit balance.

For one-time purchases via the Web app, Stripe Checkout successfully completes yet ReveneCat appears unaware of the transaction! Unlike for Stripe-managed subscription transactions there does not seem to be any automatic syncing or notification to RC of the one-time purchase.

So far I have tried:

  • Explicitly adding the Stripe Webhook Endpoint - but this DOES NOT respond to checkout transactions. I tried adding the Stripe event “checkout.session.completed” but this is rejected by the RC end-point.
  • Various combinations of Stripe product IDs (prod_xxxx) or price IDs (price_xxxx) without success - it doesn’t appear that RC is even aware that a transaction has completed.
  • Manually making a POST request to https://api.revenuecat.com/v1/receipts with the Stripe checkout session, which DOES work, triggering RC to retrieve the transaction from Stripe. HOWEVER, my infrastructure is server-less (isn't this one of the very problems RC is meant to solve???) so to have my app now explicitly notify RC of a successful one-time Stripe purchase adds another two-steps to the app-transaction-credit_increase cycle. 
    • ie. I now need another custom Firestore function that is either called by the client app or itself responds to a Stripe webhook (because RC seems unable to??!) that then pushes the checkout session to RC, which retrieves the Stripe receipt, and then (so as to keep infrastructure similar for both Web and iOS clients) pushes the ‘successful one-time purchase’ event back to another Firestore function for my app to track credit balances.

Have I misunderstood this? Is there a way for RC to directly respond to one-time Stripe Checkout purchases without needing an intermediary to pull and push between the two systems (ie. Stripe & RevenueCat)?

I have already written a reasonable amount of custom code to handle the Web-side of transactions because RevenueCat’s Flutter library  purchases_flutter explicitly does not support Web (arghhh) - to now have to engineer custom backend infrastructure to handle more of the transaction workflow for ONE payment platform really undermines a key benefit of using RevenueCat.

Thanks for your help!

icon

Best answer by Jens 6 October 2022, 11:18

View original

1 reply

Userlevel 5
Badge +7

Hi @djo , you are correct that you need some piece of code (in your frontend or backend) that posts the Stripe subscription ID / checkout session ID to the RevenueCat REST API. The reason for this (and the reason we don’t simply consume e.g. the customer.subscription.created webhook) is that we need to know which Subscriber (app_user_id) to associate the subscription / purchase with.

Reply