Reputation: 10207
In my Ruby on Rails SaaS application users can subscribe to monthly or yearly plans. I am using Stripe as a payment processor. Stripe also handles all the subscriptions and re-bills users on a monthly (or yearly) basis.
I am also a member of an affiliate network which gets notified about every new subscription / charge that a user makes, so that the advertiser may get rewarded (if there is one). This works great for new subscriptions because Stripe instantly notifies me if a payment went through or not.
But what about recurring subscription payments? I have to (and want to) inform my affiliate network about those too, however, in my web application I can't really detect whether a recurring payment has been made. I can assume that it will be made, say, on the 24th of each month but that's not for sure.
Is there a better way for a web app to detect when a recurring subscription payment has been successfully processed by Stripe? My affiliate network requires me to show some little Javascript snippet on the frontend whenever a charge has been made.
Thanks for any help.
Upvotes: 4
Views: 333
Reputation: 2359
As Zico said, yes use webhooks. Here is a good tutorial of how to set up webhooks.
https://www.truespotmedia.com/testing-webhooks-in-stripe-with-php/
Upvotes: 0
Reputation: 2447
Yes, you can easily do it by using webhooks
Use webhooks to be notified about events that happen in a Stripe account. You have to do the following for successful recurring subscription payment notification.
charge.succeeded
)"data"->"object"
which will contain the charge
objectUpvotes: 8