#zeke_error

1 messages ยท Page 1 of 1 (latest)

dire isleBOT
#

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

cinder magnetBOT
#

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.

dire isleBOT
bitter fable
#

What type of connected account are you using? Standard, Express or Custom?

north cosmos
#

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

bitter fable
north cosmos
#

What if I have a bunch of users should I just put {{CONNECTED+ACCOUNT_ID}}?

bitter fable
#

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?

north cosmos
#

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?

north cosmos
#

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

bitter fable
#

Can you share the full code how you add the stripeAccount to your Checkout Session creation request?

north cosmos
#

yes give me on sec

north cosmos
#

Ok

#

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,
        },
      },
    });
bitter fable
#

I don't see stripe.checkout.sessions.create() in your code. stripeAccount should be added in await stripe.checkout.sessions.create() function

north cosmos
#

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

bitter fable
#

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}}',
  }
);
north cosmos
#

Ok!

#

Im going to bed ill try it tommorow but thank you so much I understand what is happening!