#Hazim

1 messages · Page 1 of 1 (latest)

rancid stagBOT
viral portal
#

Hello, what difficulties are you facing here?

robust vault
#

I can't find in the doc some way how to do it

#

const setupIntent = await stripe.setupIntents.create({
customer: customerId,
payment_method_types: ["card"],
});

#

I can't find a property t add to make this as the default payment for the customer

viral portal
#

Not sure if you can set this on the SetupIntent, will check in to that and get back to you

#

You may have to make the API call to update the customer after

robust vault
#

I tried to use webhooks when I listen to the event setup_intent.succeeded

#

but I can't seem to find in the documentation somewhere where I can see the response

viral portal
#

What are you looking for in the response?

#

Or are you looking for an example response?

robust vault
#

Oh i see

#

payment_method: 'pm_1MoXyWLbt4FtkpWaou9U6EwQ',

#

in the response I have this

viral portal
#

Yes, that is the ID you can use

#

Good catch!

robust vault
#

I can use it to attach to the customer right ?

#

const paymentMethod = await stripe.paymentMethods.attach(
'pm_1MoCr4Lbt4FtkpWaO88V6etD',
{customer: 'cus_NCTvR8ird2GyaZ'}
);

#

but in the event , do I have the customer id ?

viral portal
#

If you set the customer ID on the SetupIntent it should show up in the event

#

Otherwise it won't show up.

robust vault
#

Okay if it shows in the event of the webhok thats all I need

#

can I have the structure of the response please

#

is it the link ?

viral portal
#

I don't think we provide an example event in our docs. I just created one by triggering a setup_intent.succeed event with the stripe CLI if this helps

  "object": {
    "id": "seti_1MoYG0Jmquaq3LbplkKQIPaM",
    "object": "setup_intent",
    "application": null,
    "automatic_payment_methods": null,
    "cancellation_reason": null,
    "client_secret": "seti_1MoYG0Jmquaq3LbplkKQIPaM_secret_NZhfiDIhzJfHVmn0nizAaXu8qOFB8NH",
    "created": 1679516860,
    "customer": null,
    "description": "(created by Stripe CLI)",
    "flow_directions": null,
    "last_setup_error": null,
    "latest_attempt": "setatt_1MoYG0Jmquaq3LbpMQV5SSDf",
    "livemode": false,
    "mandate": null,
    "metadata": {
    },
    "next_action": null,
    "on_behalf_of": null,
    "payment_method": "pm_1MoYG0Jmquaq3Lbpu3CoL5ka",
    "payment_method_options": {
      "card": {
        "mandate_options": null,
        "network": null,
        "request_three_d_secure": "automatic"
      }
    },
    "payment_method_types": [
      "card"
    ],
    "single_use_mandate": null,
    "status": "succeeded",
    "usage": "off_session"
  }
}```
#

It looks like it didn't use a customer but that would be under a customer property in the the object if it did

rancid stagBOT