Stripe SetupIntent and attach card to customer

I’m trying to save a credit card for future payment.

The payment method is created, but it is not attached to the customer at stripe.

I am using Create Setup Intent and it is returning:

And on success of the Setup created dynamic event, I am executing a Create Payment Method:
Screen Shot 2021-04-07 at 8.28.16 AM

The payment method is created, but customer is null. There is not place to bind the client secret to the other actions, so I’m assuming Wappler is doing this?

Ideas on why this doesn’t work?

Did you pass a customer Id to the create setup intent?

You should first lookup or create the stripe customer then pass its id to the create setup intent action

Yep, triple checked that a valid customer id is being passed.

Screen Shot 2021-04-07 at 9.46.58 AM


Well according to the stripe docs it should get attached:

Try to output it with set value just before the create setup intent to be sure it has a value.

Should have provided this earlier…the customer is shown as being set on the Create Setup Intent output:

Screen Shot 2021-04-07 at 9.53.41 AM

@George do I have the proper logic here?

On the front end I have:

Stripe object that calls createPaymentMethod after success of Setup Intent:

What is your goal? To just let the user enter credit card and save it?

Then the flow is exactly the same as:

But instead of payment intent you are creating setup intent to just save the credit card.

Thanks, that is where I started…but do I still convert the form to a Stripe checkout form even though I’m not checking out?

And yes, that is the use case.

Yes just use stripe checkout form, even if you are not paying anything.

It is just used to submit info to your server side and there you decide if you want to charge - then create payment intent, or just save tge payment info then create setup intent.

You can event charge and save in a single action as well.

Still not working @George.

I have tested a PAYMENT intent and it works fine.

Here is what Wappler is sending to Stripe:

When doing a SETUP intent, this is what Wappler is sending:

Screen Shot 2021-04-07 at 10.58.02 AM

Here is the form I am using:

        <form id="form_add_card" method="post" is="dmx-stripe-checkout-form" action="../dmxConnect/api/stripe/add_credit_card.php">
            <div class="form-group">
                <label for="input1">Stripe Card</label>
                <dmx-stripe-card id="input1"></dmx-stripe-card>
            <button id="btn3" class="btn btn-primary" type="submit">Add Payment

And the contents of add_credit_card.php

In 2 minutes the PAYMENT intent works fine, and the same config for SETUP intent does not.

Are you saying this works for you?

Well my understanding is that it should work like this.

Check the events log in stripe to verify and maybe ask stripe online support why the payment isn’t attached.

They have a great online chat support.

Let’s keep trying @George. :slight_smile:

This is what I’m following:

And when I do this step:

I get this error:

It seems the process is to:

  • Create the setup intent
  • pass the secret from the intent to the confirmCardSetup method

It sure seems like Wappler is not attaching the client_secret value to the confirmCardSetup.

Would you mind taking a look at that?

Ah did you return the client secret from your server connect action?

Yep, that is returned

If you use the “create setup intent template” this will be auto generated for you, just like when using the “create payment intent template” action as described in tge docs.

Well if it is returned then it should be picked up.

Otherwise @patrick can check it out.

Do you see it in devtools in the response of the server action?

As maybe there is an error occurring and you will see the error.