#Hazim
1 messages · Page 1 of 1 (latest)
Hello, what difficulties are you facing here?
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
You can update the customer so that its invoice_settings.default_payment_method is the newly created Payment Method https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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
What are you looking for in the response?
Or are you looking for an example response?
Yes like the customer Id or something so that I can use to turn it to default
Oh i see
payment_method: 'pm_1MoXyWLbt4FtkpWaou9U6EwQ',
in the response I have this
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 ?
If you set the customer ID on the SetupIntent it should show up in the event
Otherwise it won't show up.
To set it you can provide the customer Id when creating the setup intent https://stripe.com/docs/api/setup_intents/create#create_setup_intent-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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 ?
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
You can try confirming one with your test mode setup and looking at the event it creates in your dashboard if you want an example that is closer to what you are doing https://dashboard.stripe.com/test/events/
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.