Updating a customer's card - Stripe

I’m trying to allow users to update their cards. I successfully built the functionality that allows users to create a subscription, but now I’m trying to change their default card used for the subscription.

Step 1 - User clicks ‘Update card’ button after filling in the relevant forms (this step is registering correctly and not causing an error.

Step 2 - run ‘Update a customer’s default card’ action - their customer ID is the ID I save when they initially create a subscription, and the source is the same token created by the card. This workflow is only triggered when ‘Stripetoken update’ for a card has been created.

Step 3 - When I try to run the update action, it returns this error:

Blockquote Raw error from Stripe.js - Platform - Update a customer’s default card: {
“error”: {
“type”: “invalid_request_error”,
“message”: “No such source: tok_1BROufGtyr5kcLCPpjg27nuU”,
“param”: “source”

Not sure why the token source is incorrect - am I missing something simple?

I tried a few other things – first I tried to create a new card and then update the customer’s card, but the ‘update a customer’s card’ still kept failing.

I’ve contacted the plugins team who have not been able to diagnose this and recommend that I book in a 1-2-1 session, so I will do that if I can’t find any other solutions.

Thanks all!

Hey @pc001,

It looks like you’re using a token (“tok_”) to update the customer’s default card, whereas it should be a card token (“card_”). Tokens generated by the client-side library are for one-time use only and are not the same as card tokens. Give that a go and let us know if something else turns up, we’d be happy to help. :slightly_smiling_face:

Thanks, yeah you’re right, it’s picking up tok_. So I guess I need to change the (body) source for updating a user’s default card - I thought that ‘This Stripetoken’s card token’ would’ve been ‘card_’ but I guess not!

I can’t work out what to put in the ‘Source’ field

Is my Step 1 in my first post correct (Converting card into Stripetoken)?

Thanks for the help, if it’s not fixable here I’ll have to book in a session next week!

You should be using the Platform - Create a card call to create a card for a customer and use the resulting Card ID for the Source field. If you need more clarification on the Stripe architecture or how to handle platform payments in general, check out our Platform Payments course! :wink:

1 Like

Ah, I was so close! I had added the ‘Create a card’ step but couldn’t get it working, so I removed it.

I’ve set it up now, in addition to another step which is a ‘delete a card’ step, so that the user only has the one card attached. Works great!

The only issue is the slow load time. Not sure if it’s because I’m on the free plan - loading the user’s active card takes about 15 seconds (I know it has to connect to Stripe, but that’s still a long wait), and when I submit the card change or create a new card + subscription with a new account, it still takes about 8 seconds after I click the ‘Join/Update’ button.

I can live with that I suppose (it’s only an MVP), I’ll just need to work on getting a spinner to appear so that users aren’t just waiting (I don’t feel like the load bar at the top of the screen is obvious enough for most users).

Anyhow, thanks for your help - I still have more Stripe things to create so it’s likely I’ll be booking a session next week. Eagerly awaiting your course (I did enquire yesterday) and will purchase it on Saturday :slight_smile:

@pc001 @copilot

Hey Guys,

Would you mind enumerating the steps or posting screen shots here for updating a card, specifically where you’re pulling the card ID token from and adding a subscription? I’m running into a similar error here when I try to use the ‘Create a new card’ function. I basically reasoned the same unsuccessful logic that pc001 explained here (which I thought was pretty sound), before realizing that this is not quite as intuitive as I thought. I have the same end goal.


Per the debugger, on button click:
I’ve successfully created a Stripe customer and saved the Customer ID to the user on the Bubble side for future reference, per your notes in the last thread, then converted the card into a Stripe Token.

When Stripe token is created, I use a Platfrom - create a card
Cust ID: Stripe Cust ID saved to database (This is referenced accurately.)
Source: This StripeToken’s ID number (This is empty/null per debugger.)

Is the Card ID your talking about different than the ID number token shown in the dropdown in your graphic above?

Hey @sharifa,

Stripe’s Card object requires a card token, so make sure you’re referencing Stripe token’s card token. :slightly_smiling_face:

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