#BilalSaeedAlam
1 messages · Page 1 of 1 (latest)
I am using this documentation for future card payment and i have customer id and setup intent id as well
https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=checkout#create-checkout-session
At step 4 ia m retriving setup intent object as well
const setupIntent = await stripe.setupIntents.retrieve('seti_1EzVO3HssDVaQm2PJjXHmLlM');
So now i want to charge customer so whcih will be paramaters to pass like customer id etc in which api, can you help please
?
This is covered in this documentation page: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
i have a lot of test payment ids how i can select which will be the payment id like
By using this i have an object and in this object there is list of data
- Code which i did used
const paymentMethods = await stripe.paymentMethods.list({
customer: '{{CUSTOMER_ID}}',
type: 'card',
});
In return list of objects in data
{
id: 'pm_1KILIk7JIXd7TyawpLetOKUTC',
object: 'payment_method',
billing_details: [Object],
card: [Object],
created: 1686130407,
customer: 'cus_O08vi5vdgirVPd',
livemode: false,
metadata: {},
type: 'card'
},
So should i pick up on the zero postion object or is there other way
If you want the customer to choose, then show all payment method to the customer, and let them select the one they want.
If you want to chose, then it's completely up to you which one you chose.
Alright i have to use it myself i think latest one will be fine
And further i have ACH future too so what will the machnisim to charge that like you gave me link to charge card, can you please help in this too?
ACH is a payment method, so it's exactly the same process.
so here at the position of card what i should paste
const paymentMethods = await stripe.paymentMethods.list({
customer: setupIntent.customer,
type: "card",
});
In the type variable
us_bank_account I think.
Happy to help 🙂
What didn't work? Can you share a request ID (req_xxx)?
How to get this please guide me
No worries and thaks
Please share the request ID and I will take a look.
This one is successful
Okay should i sgive you that where i get an error
Check this one please
req_mGfyJFL6Okydhz
There's an extra space in the name: type: "us_bank_account ",
oh okay lemme check
Perfect found no entry
And working well
Thanks man
Just last question
When i charge with card success and failure of payment will be get on the spot. And for ACH payment will charge like 2 to 4 days and how i can get response can you please tell me about all this
You will get a webhook: https://stripe.com/docs/api/events/types#event_types-payment_intent.payment_failed
Sorry for delay, it is busy today.
For all payment method types
No worries
All right, but i was curious like if after 4rth day payment ger declined then how i will know so this link will help me in this way
Is your app listening to any other webhook events?
Nope
Please read this guide: https://stripe.com/docs/webhooks
You should only perform post-purchase business logic (fulfill orders) using webhooks, otherwise you might loose some payments (if the customer closes the browser before the page loads)
No i am charging customer through future payments like customer only enter ACH or CARD details through Stripe elements and then i will store stripe_intent and after a monthe or 7 days i will charge hime according to orders payment, so thats why i am using CARD and ACH future payment methods.
So will it be easy for me to write logic for handling like payment is made or not so that i can update database according to that.
Exactly because ACH takes long to succeed (or fail) you need to listen to webhook notifications from Stripe. It will notify your app that the status have changed.
Alright man, it was really great to understand all the things and thanks for your time and kind response.