Stripe Variable Subscription cost based on unique data

187 views
Skip to first unread message

Tyler Welker

unread,
Dec 12, 2021, 4:57:55 PM12/12/21
to Stripe API Discussion
Hello, 

I am not a developer so bear with me. I am designing and will be building software specific to the hotel industry. while there will be a subscription charge, I want it to be variable for each hotel based on their ADR (Average Daily (room) Rate). Because hotels fluctuate in and out of season, this means prices fluctuate as well, so I think this is a good idea to reduce churn during off season times. 

I want to pull their ADR from Booking.com, and charge them 1.5x their ADR for their subscription cost, with a max charge of $400/month. 

For instance, if in January their ADR at their property was $149/night, the monthly subscription would be $223.50 for that month. When the hotel is off-season and room ADR drops to $89/night, I don't want to charge him this same $223.50, but it would change to $133.50/month. Is this possible using stripe? I would like to think that a webhook could take care of this, but i'm not positive. 

Thank you!

Remi J.

unread,
Dec 12, 2021, 5:08:05 PM12/12/21
to api-d...@lists.stripe.com
Hello Tyler,

The flow you describe is definitely doable through some of our APIs though that will require custom development on your end. Based on what you describe, you want to change the amount you charge your subscribers each month based on some other system's data. To do this you have to "modify" the Invoice that will be created each month for their subscription.

Since the price is "dynamic", you'll want to start them on a $0/month base subscription just to have a billing cycle running and each month you can modify their invoice to add the correct fee for this month.

Using a webhook would be the best way in that case and your intuition was right. Each month, when a new cycle starts for that specific subscription, we will send the `invoice.created` event to your webhook endpoint. At that point, you can then look up the amount to charge them in your database based on Booking.com's data that you cached for example. At that point, you can add an invoice item via the API as documented here [1] for this month's amount.

It's also important to note that the first invoice behaves a bit differently and can't be modified. We finalize and attempt to charge that first invoice upfront so you can't just wait for the event for that one. In that case, when you create the Subscription for that $0/month Price, make sure to also pass this month's expected amount as a separate invoice item in the `add_invoice_items` parameter [2].

This will require some custom code on your end, both for the subscription creation and the webhook handler so if you haven't built something like this before, you might need to hire a freelancer.

Hope this helps!
Remi


--
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.
Reply all
Reply to author
Forward
0 new messages