#nitesh_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1369191027444813906
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- nitesh_api, 15 hours ago, 30 messages
Hello
i follow this documentation to implement ACH
https://docs.stripe.com/payments/ach-direct-debit/accept-a-payment?web-or-mobile=web&payments-ui-type=elements
my use case is
Frontend load the ACH model and payment should have then call the my backend API after success to send some additional data
Hi! Sorry so what is the issue that you are facing?
i read the doc
i've already mention above
on step 4 i have to create payment intent in my backend right??
and that payment intent api frontend will call before payment confirmation right?
I am not sure what you mean by this but if you are asking if the payment confirmation will happen on the frontend then yes, that is correct.
yes the payment confirmation will happen in frontend
but before that Fronted will call the payment intent API right to get client secret?
step 4 in doc
If you look at Step 5, it shows the fetching of the client secret under // Create the PaymentIntent and obtain clientSecret
yes your are absolutely right
but you can see closely
the API calling with amount , customerId right??
Are you referring to this:
app.post('/create-intent', async (req, res) => {
const intent = await stripe.paymentIntents.create({
// To allow saving and retrieving payment methods, provide the Customer ID.
customer: customer.id,
amount: 1099,
currency: 'usd',
});
res.json({client_secret: intent.client_secret});
});
yes
What about this can I help you with?
You will need to create a customer: https://docs.stripe.com/api/customers/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
What exactly are you referring to in Step 5? And which payload?
in step 5 frontend calling /create-intent API with any payload
didn't mention in doc
in which step i should i create customer
That will be up to you if you wish to pass any data to your backend for the creation of the Payment Intent.
i am getting this error
You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method or ConfirmationToken.
Are you passing the element when confirming the payment intent?
const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
the above error coming from when i am creating payment intent
Are you passing the confirm parameter when creating the payment intent?
https://docs.stripe.com/api/payment_intents/create#create_payment_intent-confirm
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
no
i am using this same no additional parameter i am using
Can you share your code please?
yes sure
async achPaymentIntent(
amount: number,
customerId: string,
connectedAccountId: string,
serviceFee: number,
) {
const { stripe } = await this.getStripeInstance();
const paymentIntent = await stripe.paymentIntents.create(
{
amount: amount,
currency: 'usd',
customer: customerId,
payment_method_types: ['us_bank_account'],
application_fee_amount: serviceFee,
confirm: true,
mandate_data: {
customer_acceptance: { type: 'online', online: { ip_address: '127.0.0.1', user_agent: 'Mozilla/5.0' } },
},
},
{ stripeAccount: connectedAccountId },
);
return paymentIntent;
}
In your stripe.paymentIntents.create you do have confirm: true,. You need to remove it.
ok
let me remove it
Thanks the payment intent API working now
right now i am checking on frontend
i have one more question
are you there?
Yeap
i created the setup intent
async createBankSetupIntent(email: string, connectedAccountId: string) {
const { stripe, config } = await this.getStripeInstance(connectedAccountId);
const customers = await stripe.customers.list(
{ email: email.toLocaleLowerCase(), limit: 1 },
{ stripeAccount: connectedAccountId },
);
let customerInfo = null;
let customerInfo2 = null;
if (customers.data.length > 0) {
customerInfo = customers.data[0];
} else {
customerInfo = await stripe.customers.create({ email: email }, { stripeAccount: connectedAccountId });
customerInfo2 = await stripe.customers.create({ email: email });
}
const data = await stripe.setupIntents.create(
{ customer: customerInfo2?.id, payment_method_types: ['us_bank_account'], usage: 'on_session' },
// { stripeAccount: connectedAccountId },
);
return {
customerId: customerInfo?.id,
customerId2: customerInfo2?.id,
transaction_id: data.id,
clientSecret: data.client_secret,
publishableKey: config['publicKey'],
};
}
based on this two keys frontend will load the ACH model
is this right?
way to load ACH model UI?
What 2 keys are you referring to?
I need to understand what key are you referring to.
clientSecret: data.client_secret,
publishableKey: config['publicKey'],
You need the publishable key on your checkout.js page. You need the client secret to confirm the payment intent.
should i create the setup intent of not?
I cannot answer this question without more context. What are you trying to do specifically?
backend using this
const paymentIntent = await stripe.paymentIntents.create(
{
amount: amount,
currency: 'usd',
customer: customerId,
payment_method_types: ['us_bank_account'],
// payment_method: bankAccountId,
application_fee_amount: serviceFee,
// confirm: true,
// mandate_data: {
// customer_acceptance: { type: 'online', online: { ip_address: '127.0.0.1', user_agent: 'Mozilla/5.0' } },
// },
},
{ stripeAccount: connectedAccountId },
);
frontend using this
const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
i am getting error from confirmPayment
not such paymentIntent
like this No such payment_intent: 'pi_3RLfomJRoJfA1S160SxMsNRS'"
Sorry can we roll back a little. Are you working on creating a setup intent or payment intent?
right now payment intent
Is this the correct Payment Intent created from your backend?
If a payment intent is on the connected account via Stripe-account header and is confirmed it on the platform account, you will get this error. I see you used Stripe account header for the payment intent creation. You need to ensure you do the same for the confirmation.
you have any example?
const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
should i pass connected account id in this method?
You should add it where your publishable key is like how it's shown here https://docs.stripe.com/connect/authentication?create-client=js#adding-the-connected-account-id-to-a-client-side-application
const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
},
{ stripeAccount: connectedAccountId }
);
like this?
or not
You add the connected account where you initialise Stripe.js: https://docs.stripe.com/js/initializing
the connected account should be changes based on use case
You will need to ensure that you pass the relevant connected account ID each time.
in initializing or in this method?
Hi. I'm taking over from my colleague. Please, give me a moment to catch up.
As my colleague suggested above, on initializing Stripe.js
const paymentIntent = await stripe.paymentIntents.create(
{
amount: amount,
currency: 'usd',
customer: customerId,
payment_method_types: ['us_bank_account'],
application_fee_amount: serviceFee,
},
{ stripeAccount: connectedAccountId },
);
return { ...paymentIntent, stripeAccountId: connectedAccountId };
}
this is my backend code to create payment intent
with connected account
This is fronted code for confirm payment
const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
the problem is payment intent created with connected account
and confirm happing i think platform account that way we getting this error
No such payment_intent: 'pi_3RLfomJRoJfA1S160SxMsNRS'
Yes, the problem is clear.
Are you setting stripeAccount header when initializing Stripe.js, as my colleague suggested?
https://docs.stripe.com/connect/authentication#adding-the-connected-account-id-to-a-client-side-application
the problem is connected account will change based on use case
the connected account is not fixed
no
You mean you will need to use different Stripe accounts on the same frontend session?
should i not pass the connected account directly in confirm payment method??
Yes, as the documentation states.
can you please show me the example?
You can see the example in the guide I shared โ๏ธ
Not sure what else do you want to see.
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
i want to make confirm payment into directely connected account
do you mean Direct Charges?
yes