#zeke_error
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/1268416226523086848
๐ 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.
- zeke_code, 10 hours ago, 18 messages
- zeke_best-practices, 20 hours ago, 6 messages
- zeke_code, 1 day ago, 16 messages
- zeke_code, 1 day ago, 18 messages
- zeke_error, 2 days ago, 10 messages
- zeke_best-practices, 2 days ago, 8 messages
What type of connected account are you using? Standard, Express or Custom?
Sorry I lost connection here is my code:
function calculateApplicationFee(productPrice: number): number {
let fee = productPrice * 0.10; // Step 1: Calculate 10% of the product price
fee = Math.round(fee * 10) / 10; // Step 2: Round to the nearest tenth
let feeInCents = Math.round(fee * 100); // Step 3: Convert to integer by multiplying by 100
return feeInCents;
}
const applicationFeeAmount = filteredProducts.reduce((total, product) => {
return total + calculateApplicationFee(product.price);
}, 0);
const stripeSession = await stripe.checkout.sessions.create({
success_url: `${process.env.NEXT_PUBLIC_SERVER_URL}/thank-you?orderId=${order.id}`,
cancel_url: `${process.env.NEXT_PUBLIC_SERVER_URL}/cart`,
payment_method_types: ["card"],
mode: "payment",
metadata: {
userId: user.id,
orderId: order.id,
},
line_items: line_items,
payment_intent_data: {
application_fee_amount: applicationFeeAmount,
},
});
I am using standard
For Standard connected account, Stripe-Account header with connected account ID should be included for Direct Charges: https://docs.stripe.com/api/connected-accounts?lang=node, so that application_fee_amount can be used as explained in the error message
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 if I have a bunch of users should I just put {{CONNECTED+ACCOUNT_ID}}?
For Direct Charges, it only supports one connected account, i.e. one payment for one connected account
Can you share what you would like to achieve here? Why are multiple connected accounts needed for a single payment?
Oh Sorry! Ive been reading stripe docs for like 2 weeks so I mixed things up in my head ๐
Im building a marketplace and was thinking about connect onboarding which I did earlier
I understand now!
So I need to pass the connect account user through the stripeSession?
Hey so this is what I tried
I add this to the Stripe Session:
{
stripeAccount: user.stripeAccountId, // Pass the connected account ID in options
});
const user = ctx.user as unknown as User; // Cast ctx.user to User type
// Define the User type with stripeAccountId
type User = {
id: string;
stripeAccountId: string; // Add stripeAccountId property
};
I ended up getting the same error in the logs req_B7T5PHzgo5MsKK
Can you share the full code how you add the stripeAccount to your Checkout Session creation request?
yes give me on sec
Ok
metadata: {
userId: user.id,
export const paymentRouter = router({
createSession: privateProcedure
.input(z.object({ productIds: z.array(z.string()) }))
.mutation(async ({ ctx, input }) => {
const { user } = ctx;
const { productIds } = input;
if (productIds.length === 0) {
throw new TRPCError({ code: "BAD_REQUEST" });
}
const payload = await getPayloadClient();
try {
const { docs: products } = await payload.find({
collection: "products",
where: {
id: {
in: productIds,
},
},
});
I don't see stripe.checkout.sessions.create() in your code. stripeAccount should be added in await stripe.checkout.sessions.create() function
its here If you would like me to give you my repo I can on github and Ill give you the file name!
const stripeSession = await stripe.checkout.sessions.create({
success_url: ${process.env.NEXT_PUBLIC_SERVER_URL}/thank-you?orderId=${order.id},
cancel_url: ${process.env.NEXT_PUBLIC_SERVER_URL}/cart,
payment_method_types: ["card"],
mode: "payment",
metadata: {
userId: user.id,
orderId: order.id,
},
line_items: line_items,
payment_intent_data: {
application_fee_amount: applicationFeeAmount,
},
stripe_account: user.stripeAccountId, // Include the connected account ID
}, {
stripeAccount: user.stripeAccountId, // Pass the connected account ID in options
});
Your github code doesn't set stripeAccount in the stripe.checkout.sessions.create. I'd recommend checking the example code to see how the stripeAccount should be set in a Checkout Session: https://docs.stripe.com/connect/direct-charges?platform=web&ui=stripe-hosted#create-checkout-session
More specifically:
const session = await stripe.checkout.sessions.create(
{
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 1000,
},
quantity: 1,
},
],
payment_intent_data: {
application_fee_amount: 123,
},
mode: 'payment',
success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
},
{
stripeAccount: '{{CONNECTED_ACCOUNT_ID}}',
}
);