How to create Stripe customer (Getting error [Stripe error: No such customer])

Using the Bubble.io developed Stripe plugin, the action Charge the current user gives me this error:

Stripe error: No such customer 'cus_XXXXXXX'

Of course there’s no such customer, I’ve never created any customers! But then how do I create a customer? I don’t see any action in the Bubble plugin to create a customer. I tried Charge the current user but that actually generates the exact same error message.

So my questions:

  1. Do you have to create a customer before you can charge them?
    1A: If so, how do you create the customer
    1B: If not, what am I doing wrong that’s making Stripe look for a nonexistent customer?

The most likely explanation is that you’ve previously created a Customer in Stripe for that particular user, maybe without even realising it (which stored the Stripe Customer ID into a built-in field on the User datatype in your app), and then subsequently deleted that customer from your Stripe account…

So Bubble is sending the stored Customer ID to Stripe, but it doesn’t exist there hence the error message…

Unfortunately there’s no way to change or delete the built-in Customer ID in your Bubble app, so the only thing you can do is delete the User and create a new one…

If that’s not the case, then you’ll need to reach out to Bubble support to find out what’s going on…

3 Likes

I’m in a test environment so deleting users is no problem. Are you talking about deleting a Stripe user or a Bubble user?

If Stripe… how? Stripe shows there are no users.

If Bubble… that’s pretty terrifying that any sort of error could potentially require deleting a Bubble user’s account, especially since this seems to have happened on accident… exactly how could I accidentally have done this and how can I avoid ever ever ever doing this on the live site?

I’m saying that you can’t change or delete a stored Stripe Customer ID on the User datatype in your Bubble App… (see this thread for more details: Remove Stripe Customer ID - Stripe Plugin by Bubble - Need help / Plugins - Bubble Forum

So you’ll need to delete the User in your Bubble app (Stripe doesn’t have Users, only Customers) - or use a different User…

that’s pretty terrifying that any sort of error could potentially require deleting a Bubble user’s account, especially since this seems to have happened on accident

I’d be inclined to agree… that’s one of many reasons I personally avoid using plugins for things like this, as you don’t have much control over the process…

exactly how could I accidentally have done this and how can I avoid ever ever ever doing this on the live site?

Well, obviously I can’t answer that, but most likely you reset your test data in your Stripe Developer dashboard, or in some other way removed the Customer…

The Customer must have existed at some point in your Stripe account for the customer ID to have been stored in your Bubble database… so at some point that customer has been removed from your Stripe account.

You might be able to search your Stripe account (using the Customer ID from Stripe), and still see some reference to the deleted Customer, and/or search your Stripe Logs to see how/when they were deleted. (if you’ve cleared all your test data then you probably won’t see anything)…

Faling that, if it’s still an issue then I’d probably suggest contacting Stripe Support, to see if there’s some other issue with your account…

Or contact Bubble Support to see if there’s some way to delete/change the stored Customer ID in your Bubble app…

1 Like

@adamhholmes thanks so much for your answers here. I am trying to get to the point where I can fully understand what you said. I’m having a hard time unpacking what this means:

I think the reason this confuses me is because I don’t have any Stripe ID fields on my User type… but it sounds like you’re implying that I do have a Stripe Customer ID on my User datatype? Is this something that happens automatically?

So trying to unpack this, I think you’re saying that somehow the Stripe ID is associated directly with the User, and whenever that User does anything, it always points to the same Stripe ID no matter what… and somehow on the Stripe side the corresponding Stripe Customer got messed up.

Could this happen by copying Live data into my Test/Development environment? If I’m doing development using a User that came from Live, is that the same User then, as far as Stripe is concerned? Or alternatively, if it’s not, if I copy from Live to Dev again, later, does that change the Bubble user and break things?

I’m starting to worry that using Live data on Dev in Bubble is causing these problems.

Yes that’s exactly correct… they are built-in fields (you can’t see them or edit them) they are part of the Bubble Stripe Plugin… the data is stored on the User datatype, and is accessible in the expression builder, just like any other User field (but they don’t show up in the database, or in your app data, so you can’t manually edit or delete them).

That’s one reason I prefer to handle all Stripe calls myself… so I can have full control over all the data being used.

So trying to unpack this, I think you’re saying that somehow the Stripe ID is associated directly with the User , and whenever that User does anything, it always points to the same Stripe ID no matter what… and somehow on the Stripe side the corresponding Stripe Customer got messed up.

Again, that’s exactly correct… once a User in your Bubble app has a Stripe customer ID (assigned by Stripe during the first interaction, and stored in the ‘hidden’ User field on your User datatype which is part of the Bubble Stripe Plugin, and can’t be edited), any further calls to Stripe via the plugin will use that Customer ID, and there’s no way to change or clear that.

So, if the customer no longer exists in Stripe, you’ll get the error message ‘No Such Customer cus_*********’

As I said, you might be able to see for yourself what’s going on in your Stripe account by simply searching for that customer (using their customer ID). The customer details should still show up, even if it’s been deleted (as will any log activity)… unless that is you’ve hit the ‘Clear All Test Data’ button (which may be the reason the customer has been deleted in the first place)… in which case I doubt there will be any record of the customer left in your Stripe account at all…

But, it’s still the very first thing I would do.

Could this happen by copying Live data into my Test/Development environment?

That is a possibility… although Stripe usually gives a different error in those circumstances (something like ‘this object exists in Live mode, but you’re using a test API key’)… although I’m not certain that applies to Customers as well (but it’s worth investigating… so just search both the live and test versions of your Stripe account).

3 Likes

Thanks again @adamhholmes I’m honing in on my understanding, and made some discoveries.

In Stripe, when I search by the email of the Bubble user that’s generating this error, a customer shows up which is deleted. As expected.

However, in Bubble when I look at the Stripe Customer ID of that same user… it’s a different customer ID.

And even weirder, when I search in Stripe for that different customer ID, nothing comes up! It doesn’t exist on Stripe, not even deleted.

I imported data from Live to Dev and the User had an empty ID… then I was able to register the account successfully.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.