#nitesh_api

1 messages ยท Page 1 of 1 (latest)

native haloBOT
#

๐Ÿ‘‹ 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.

stark wharf
#

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

broken niche
#

Hi! Sorry so what is the issue that you are facing?

stark wharf
#

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?

broken niche
stark wharf
#

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

broken niche
#

If you look at Step 5, it shows the fetching of the client secret under // Create the PaymentIntent and obtain clientSecret

stark wharf
#

yes your are absolutely right

#

but you can see closely
the API calling with amount , customerId right??

broken niche
#

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});
});

stark wharf
#

yes

broken niche
#

What about this can I help you with?

stark wharf
#

from where i get customerId

#

and in step 5 why api calling without any payload??

broken niche
broken niche
stark wharf
#

in step 5 frontend calling /create-intent API with any payload

stark wharf
#

in which step i should i create customer

broken niche
stark wharf
broken niche
stark wharf
#

the above error coming from when i am creating payment intent

broken niche
stark wharf
#

no

stark wharf
broken niche
#

Can you share your code please?

stark wharf
#

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;

}

broken niche
#

In your stripe.paymentIntents.create you do have confirm: true,. You need to remove it.

stark wharf
#

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?

broken niche
#

Yeap

stark wharf
#

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?

broken niche
stark wharf
#

we get error if we not use this 2 keys

#

should i share the fronted function?

broken niche
#

I need to understand what key are you referring to.

stark wharf
#

clientSecret: data.client_secret,
publishableKey: config['publicKey'],

broken niche
#

You need the publishable key on your checkout.js page. You need the client secret to confirm the payment intent.

stark wharf
#

should i create the setup intent of not?

broken niche
#

I cannot answer this question without more context. What are you trying to do specifically?

stark wharf
#

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'"

broken niche
#

Sorry can we roll back a little. Are you working on creating a setup intent or payment intent?

stark wharf
#

right now payment intent

broken niche
#

Is this the correct Payment Intent created from your backend?

stark wharf
#

yes

#

is there problem with connected account??

broken niche
#

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.

stark wharf
#

you have any example?

broken niche
stark wharf
#

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?

broken niche
stark wharf
#

const {error} = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
},
{ stripeAccount: connectedAccountId }
);

like this?

#

or not

broken niche
stark wharf
#

the connected account should be changes based on use case

broken niche
#

You will need to ensure that you pass the relevant connected account ID each time.

stark wharf
native haloBOT
calm mirage
#

Hi. I'm taking over from my colleague. Please, give me a moment to catch up.

calm mirage
stark wharf
#

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

#

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'

calm mirage
#

Yes, the problem is clear.

stark wharf
#

can you please tell me how to pass connected account in confirm payment method

#

?

calm mirage
stark wharf
#

the problem is connected account will change based on use case
the connected account is not fixed

calm mirage
#

You mean you will need to use different Stripe accounts on the same frontend session?

stark wharf
#

should i not pass the connected account directly in confirm payment method??

calm mirage
#

Yes, as the documentation states.

stark wharf
#

can you please show me the example?

native haloBOT
calm mirage
lilac copper
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

stark wharf
#

i want to make confirm payment into directely connected account

lilac copper
#

do you mean Direct Charges?

stark wharf
#

yes

lilac copper