#BilalSaeedAlam
1 messages ยท Page 1 of 1 (latest)
Can you tell me about what you are trying to do?
Yes
Payment Methods don't have amounts assosciated with them. Only payment objects like Payment Intents have amounts
Basically i am using ACH future payment functionality. At the backend side i am creating Customer id and then setup intent. In the setup intent i am passing customer id as well so in console i can see customer is attached with that setup intent.
But when i process this function , should i need to pass customer as well here:
.collectBankAccountForSetup({
clientSecret,
params: {
payment_method_type: 'us_bank_account',
payment_method_data: {
billing_details: {
name: accountHolderNameField.value,
email: emailField.value,
},
},
},
expand: ['payment_method'],
})
Becuase if i am not passing it so during creation of payment intent customer is always null
I am geting setup intent and creating payment intent like this
const setupIntent = await stripe.setupIntents.retrieve(
merchant[0].stripe_setup_intent
);
console.log(setupIntent);
const paymentMethod = await stripe.paymentMethods.retrieve(
setupIntent.payment_method
);
console.log(paymentMethod);
So in the payment method customer always null
๐ stepping in here
So you don't need to pass the Customer ID client side
As long as you pass it on the SetupIntent creation on your Server then the PaymentMethod will be attached to the Customer after successful client-side confirmation.
Can you provide an example SetupIntent ID where you tried to retrieve the PaymentMethod and got null?
Yes
I am sharing things one by one
1- I have setup intent id in my database to charge customer in future
So first i am calling this function to retrive setup intent object
const setupIntent = await stripe.setupIntents.retrieve(
merchant[0].stripe_setup_intent
);
console.log(setupIntent);
In the console i am getting this object:
{
id: 'seti_1NGOOOJIXd7TyawpVLWu3ohK',
object: 'setup_intent',
application: null,
automatic_payment_methods: null,
cancellation_reason: null,
client_secret: 'seti_1NGOOOJIXd7TyawpVLWu3ohK_secret_O2TLQnVwDE3Gi1ge5pgfNFnKii4SP2A',
created: 1686152124,
customer: 'cus_O08vi5vdgirVPd',
description: null,
flow_directions: null,
last_setup_error: null,
latest_attempt: null,
livemode: false,
mandate: null,
metadata: {},
next_action: null,
on_behalf_of: null,
payment_method: 'pm_1NGOPyJIXd7TyawpLS9tkgfF',
payment_method_options: {
us_bank_account: {
financial_connections: [Object],
verification_method: 'automatic'
}
},
payment_method_types: [ 'us_bank_account' ],
single_use_mandate: null,
status: 'requires_confirmation',
usage: 'off_session'
}
So you can see customer is attached with this setup intent object
Now i am retriving payment Intent:
const paymentMethod = await stripe.paymentMethods.retrieve(
setupIntent.payment_method
);
console.log(paymentMethod);
In th console you can see customer is null:
{
id: 'pm_1NGOPyJIXd7TyawpLS9tkgfF',
object: 'payment_method',
billing_details: {
address: {
city: null,
country: null,
line1: null,
line2: null,
postal_code: null,
state: null
},
email: 'alam@mediacarry.com',
name: 'Bilal',
phone: null
},
created: 1686152222,
customer: null,
livemode: false,
metadata: {},
type: 'us_bank_account',
us_bank_account: {
account_holder_type: 'individual',
account_type: 'checking',
bank_name: 'STRIPE TEST BANK',
financial_connections_account: 'fca_1NE8dvJIXd7TyawpkSyW8lv6',
fingerprint: 'zT2dXrkrwiEJcCV0',
last4: '6789',
networks: { preferred: 'ach', supported: [Array] },
routing_number: '110000000',
status_details: {}
}
}
An in the end when i am getting payment method list then i am getting nop payment method in this way:
const paymentMethods = await stripe.paymentMethods.list({
customer: setupIntent.customer,
type: "us_bank_account", // card
});
console.log(paymentMethods);
console is :
{
object: 'list',
data: [],
has_more: false,
url: '/v1/payment_methods'
}
I hope you will get my point, everything is setup but again i am not getting any payment method list but when i use future card payment there is list of card details into data array. So i am confuse why i am not getting ach details
Thanks, let me look for a moment
For sure, take your time ๐
Okay so yeah
This is because the PaymentMethod hasn't actually completed confirmation/verification at this point yet.
See how the status above is requires_confirmation
You need to actually confirm the SetupIntent client-side and that will attach the PaymentMethod to the Customer
Then you can retrieve it and the Customer will be present
I am using this on the frontend side
stripe
// eslint-disable-next-line react/prop-types
.collectBankAccountForSetup({
clientSecret,
params: {
payment_method_type: 'us_bank_account',
payment_method_data: {
billing_details: {
name: accountHolderNameField.value,
email: emailField.value,
},
},
},
expand: ['payment_method'],
})
// eslint-disable-next-line no-shadow
.then(async ({ setupIntent, error }) => {
On success i am just updating setup intent id
should anything will be inside this setupIntent object?
That i need to update
No after you do that you should pass the SetupIntent or PaymentMethod ID back to your backend and retrieve
yes i am sending this like this way
const responseData = await setupIntentToken(setupIntent.id);
What should i do at the backend, means what will the next step because after getting this id at backend i am just storing it to database
Yeah so I think the issue here is simply that you aren't actually confirming and going through the flow on your frontend.
Look at the above SetupIntent in your Dashboard: https://dashboard.stripe.com/test/setup_intents/seti_1NGOOOJIXd7TyawpVLWu3ohK
You can see it is still Incomplete
It has never been confirmed
Ahhh sorry
You are only doing collectBankAccountForSetup above
You need to also call confirmUsBankAccountSetup()
You are missing this step of the flow: https://stripe.com/docs/payments/ach-debit/set-up-payment?platform=web#web-collect-mandate-and-submit
This is additional step after getting success to previous function of stripe on frontend?
Yes
๐คญ adain need more work ๐
Okay thanks man i really appreciate your help i will do this stuff, if i need any help i will ping you back in group.
Sounds good!
Are you there?
I want to know this in my applicaiton there are two payment methods one is ACH and second is CARD. And everytime user can delete and update its payment method so i delete setup intetnt from my databse but when he create new account like if he select ACH or CARD way so when i retrive payment metods it looks like this
{
object: 'list',
data: [
{
id: 'pm_1NGPIUJIXd7TyawpTgIqYKec',
object: 'payment_method',
billing_details: [Object],
created: 1686155603,
customer: 'cus_O08vi5vdgirVPd',
livemode: false,
metadata: {},
type: 'us_bank_account',
us_bank_account: [Object]
},
{
id: 'pm_1NGP7yJIXd7TyawpPIyKWkC3',
object: 'payment_method',
billing_details: [Object],
created: 1686154950,
customer: 'cus_O08vi5vdgirVPd',
livemode: false,
metadata: {},
type: 'us_bank_account',
us_bank_account: [Object]
}
],
has_more: false,
url: '/v1/payment_methods'
}
Could be possible to delete old one like i am deleting it from databse
Yeah you want to use https://stripe.com/docs/api/payment_methods/detach
That essentially deletes the PaymentMethod
Alright, ia m looking into it