Using the API connector with Stripe for subscriptions

Hi,
I’ve recently completed the course “Bubble x Stripe Part 2: Subscribing users (SaaS Payments Course)”.Part 1: Setup & pricing page | Bubble

Everything works great in development and stripe test mode.

I’m looking for directions on how to now go live.

Steps I’ve taken to this point.

  1. In stripe: I’ve migrated the test products to live
  2. In bubble, I added the live product IDs in the option sets
  3. In stripe: I’ve uploaded the webhooks from test-mode to live and removed the the “test-version” information in the URLs and made them the live URLs
  4. In bubble.io, I created a new API with live secret key and created Check-out session call, and updated the price ID to a live Price ID and in development I’ve initiated the call. Success
  5. I deployed to live I tried to Initialize the call in live mode but getting an error stating I didn’t provide my secret key (see below) I’ve checked several times and the live secret key is correct.

There was an issue setting up your call.
*Raw response for the API *
Status code 401
{

  • “error”: {*
  • “message”: “You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. ‘Authorization: Bearer YOUR_SECRET_KEY’). See https://stripe.com/docs/api#authentication for details, or we can help at Stripe: Help & Support”,*
  • “type”: “invalid_request_error”*
  • }*

Any direction would be greatly appreciated.

You don’t need to make a new API call for live. You should be having the live key in the same API call using a shared header. This will use the development key value in test, and the live value in live.

1 Like

Thank you George! much appreciated. That certainly made it easier to deploy :grinning:

There are a couple issues I still need to work through.
Working fine:

  1. payment was accepted and everything looks good in stripe
  2. I received confirmation and provided access to the customer
  3. charged the right amount and the right frequency (monthly)

Issues:
Issue #1: for some reason it sent two identical invoices back to bubble.io and appears in the customer’s account page.
Issue #2: for some reason stripe didn’t send back the plan the customer selected. It doesn’t appear in the subscription database.

It may be because I changed the “starter” plan that is in the API connector parameters. Since I tested with the starter plan and it has activity attached, Stripe doesn’t allow you to change the price and suggests creating a new product which I did but the API seems to work. However, it seems it may want to refer to the “starter” plan

I was going to see if I needed to change the “retrieve subscription” call to a new ID key and its value for the subscription id , and the “update customer” Key id and value of the customer ID. They both reference the “Starter” plan that I changed to a new product in Stripe.

I’m hesitate because everything else is working great.

Thanks, again!
Phil

You probably have a backend workflow set up to receive webhooks, but the payment completion causes multiple events to be fired → multiple webhooks received, hence duplicates. Is that right?

@georgecollier - Yes I have backend workflows set up to multiple webhooks.

It doesn’t happen in development but in the live version I receive two invoices.