#zeke_checkout-morequestions

1 messages Β· Page 1 of 1 (latest)

mystic streamBOT
burnt mountainBOT
#

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.

mystic streamBOT
#

πŸ‘‹ Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1261088096901005313

πŸ“ Have more to share? Add details, code, screenshots, videos, etc. below.

gentle heron
#

Hello Koopajah! im back lets figure this out!

#

πŸ‘‹

#

BTW in the same code I showed yesterday I relized that this was at the bottom and I did not show you!

// Add createPaymentIntent
createPaymentIntent: privateProcedure
.input(
z.object({
amount: z.number(),
currency: z.string(),
accountId: z.string(),
})
)
.mutation(async ({ input }) => {
const paymentIntent = await stripe.paymentIntents.create({
amount: input.amount,
currency: input.currency,
application_fee_amount: Math.round(input.amount * 0.1), // 10% fee
transfer_data: {
destination: input.accountId,
},
});

  return paymentIntent;
}),

});

astral moth
#

I'm happy to help but I'm working with other people on complex questions. Can you please ask an exact clear question all in one message and not many short sentences?
What do you need help with?

gentle heron
#

You were asking me questions yesterday about my code because it was not showing connected accounts on my stripe logs.

Checkout Zeke_checkout-questions

astral moth
#

yeah I remember, but I help many people all the time in parallel. So I'm asking you to try and ask me what you need now. The code you shared seems irrelevant to using Checkout. It wouldn't make any sense for you to create a PaymentIntent to accept a payment if you are using Checkout.

#

zeke_checkout-morequestions

gentle heron
#

Yes so I run a marketplace were other people need to be able to post products so I guess I have two questions.

  1. How can i with connect have users connect accounts with stripe so they can get paid for the products they post on my application. I have some code that I thought would have worked but I dont know where to look to test it because I dont think it shows up in logs.

  2. The PaymentIntent is so my application can make a profit. I am trying to take 10% of every product sold. I added it to my Paymentrouter.ts which is were StripeSession is created. Should it not be there? should it be in my server.ts?

astral moth
#

Yeah I'm sorry I'm worried because you have done many many threads over the past few days but it unfortunately still looks like you are mixing up most concepts together entirely.
You really should consider hiring a freelancer to build this all for you at this point. I hope it's okay to say this because of all the back and forth for hours you had with my team.

Ultimately: there's absolutely no reason for you to create a PaymentIntent at all so that entire code should be deleted. You need to configure the Checkout Session to be specific to Connect + Checkout + Direct Charges here: https://docs.stripe.com/connect/enable-payment-acceptance-guide?payment-ui=stripe-hosted

gentle heron
#

ok so are you saying that should all be in one file or spread out in connecting files

gentle heron
#

which leads me to get confused about what code should be implemented into my code.

astral moth
#

yes but based on past back and forth it won't really help

#

Adding yet another guide and having you add even more code won't help if you don't take the time to understand things first

#

You are a platform. You have Standard accounts. You are using Direct Charges

What this means is that, as a developer, you are supposed to make all the request directly on the connected account. That's true for creating a Product, a Price, a Checkout Session, etc.
You were not doing that at all when we talked yesterday at least.
I recommend pausing and taking a few minutes to watch https://www.youtube.com/watch?v=dCL9adgdP0A
Don't focus on the code since it's about PaymentIntents but focus about the flow of funds and what's explained.

Once you have done that, reply to this thread and give me an exact connected account id that you are testing with (not your own) and I'll show you what to do next

gentle heron
#

Ok I watched the video! I understand the flow.

Just to make sure im doing things right this is how I got the connected account id:

#

Dashboard -> Connect -> connected accounts -> acct_1PajOI09PDa209NJ

astral moth
#

Perfect! Looking at that account I see in the logs that you tried to create a Checkout Session yesterday on it but it errored because you used the transfer_data parameter (which is incompatible)

#

Okay, now share with me the code that creates your Checkout Session. Don't share a picture, share text

gentle heron
#

its a lot

astral moth
#

yeah I'm sorry you really need to stop dumping dozens of lines of code

gentle heron
#

sorry

astral moth
gentle heron
#

ill delete

astral moth
#

Your code is clearly doing a ton of things.

gentle heron
#

yes, yes it is

astral moth
#

Let me drastically simplify your code to hardcode values. You can make it more advanced later but right now you have some weird complex product filtering and line items dyanmic creation

#

just hardcode a damn id πŸ™‚

#

give me a frw minutes

gentle heron
#

ok thank you

#

Im using payload cms for people to create products so thats why there is all those filters

astral moth
#

yeah but you are doing way too many things at once

#

you really need to focus on small steps

#
  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: [
    {
      price: "price_1PVJAM05fNcBdPQgDEu0sfqT",
      quantity: 1,
    }
  ]
});
console.log("I have now created the Checkout Session ", checkoutSession.id);```
gentle heron
#

yes sir

astral moth
#

run this code instead

gentle heron
#

ok

astral moth
#

show me the log you get back!

gentle heron
#

req_buJ7fsz6T647aU

#

I had to change a little because of conficts with other files sorry that took so long!

astral moth
#

Okay so that's step one: Checkout works on your own account, without anything Connect related.

gentle heron
#

yes sir it did before too but yes it works

#

step 1 βœ…

astral moth
#

Now let's try to create the same Checkout Session on the connected account. All you need to do is explicitly tell us which connected account to make the request on. This is done with the API feature documented here: https://stripe.com/docs/connect/authentication#stripe-account-header

So now take the code you tweaked, and add an extra option as a parameter to the Checkout Session creation:

  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: [
    {
      price: "price_1PVJAM05fNcBdPQgDEu0sfqT",
      quantity: 1,
    }
  ]
},
{
  stripeAccount: 'acct_1PajOI09PDa209NJ',
}
);
console.log("I have now created the Checkout Session ", checkoutSession.id);```

This code **will fail**, it's expected. Just try it and tell me what error you get
gentle heron
#

ok so ive added the code. the only thing that has changed is the line_items

astral moth
#

I mean did you explicitly add that stripeAccount part?

#

show me your current code after the change

gentle heron
#

req_UlGYG5TlC2Yz99

#

yes i did

#

here is the error: resource_missing - line_items[0][price]
No such price: 'price_1PVJAM05fNcBdPQgDEu0sfqT'

astral moth
#

Success

gentle heron
#

Nice!

#

the only time ive felt great about an errorπŸ˜‚

astral moth
#

So now you, as a developer have made a real Connect request. The problem is that you are telling Stripe "Please create a Checkout Session for the Price price_1PVJAM05fNcBdPQgDEu0sfqT on the connected account acct_1PajOI09PDa209NJ"

and Stripe says "well I'm sorry but I have never heard of the Price price_1PVJAM05fNcBdPQgDEu0sfqT on acct_1PajOI09PDa209NJ"

gentle heron
#

yes

astral moth
#

And now you are getting at the root of Direct Charges. You are a platform but you make requests on a different Stripe account. And you have to make sure that you reference object ids from that Stripe account, not from your own

#

Does that make sense?

gentle heron
#

yes i believe I understand

astral moth
#

Cool, so now the next step is to create a Product and a Price on that connected account.
You wouldn't do this for each Checkout Session. The connected account is selling certain products and you would have another part of your code/set up that would create all of those for you.

Do you have something like this already?

gentle heron
#

Yes i probably do what am I looking for specifically

astral moth
gentle heron
#

I did in the old code but i deleted it let me go to my repo rq

astral moth
#

well would be easier to do this as a one off

gentle heron
#

yeah

#

do you mean something like this?

line_items.push({
price: "price_1OCeBwA19umTXGu8s4p2G3aX",
quantity: 1,
adjustable_quantity: {
enabled: false,
},

#

this is not my price anymore btw this is an old ID

astral moth
#

lol you're back with your line_items.push() I explicitly try to remove πŸ˜‚

gentle heron
#

OPS

#

lets not us that code then

#

πŸ˜‚

#

We can just get rid of it

astral moth
#

You are a developer, you are writing lots of code. This is going to take you weeks

What I am saying is right now we need a real Price id price_123 on that connected account. Later you will write an entire feature to import someone's products from their own product catalog.

Right now all you need to do is write code that you will use once to create a Product and a Price on that connected account

gentle heron
#

ok

#

let me go get a new price_id

astral moth
#

yep once you have one, give it to me and I can check that you created it properly

gentle heron
#

here

#

price_1PbWnT05fNcBdPQgyf8DdBrd

astral moth
#

nope this is wrong

gentle heron
#

product or price id?

astral moth
#

I mean you didn't really internalize what I explained for the past 2 hours πŸ˜…

#

as far as I can tell you went in your own Dashboard and manually created a Price in your own Stripe account. Is that correct?

gentle heron
#

yes I went to product -> create a new product and made a new one

astral moth
#

and Stripe says "well I'm sorry but I have never heard of the Price price_1PVJAM05fNcBdPQgDEu0sfqT on acct_1PajOI09PDa209NJ"```
gentle heron
#

I thought thats how it worked?

astral moth
#

I explicitly explained this in heavy details and I assume you didn't understand that part at all yet

gentle heron
#

O

#

OOOOOO

astral moth
#

I'm sorry, this is getting... unwieldy. Those are really simple concepts and if you don't grasp those (which really is totally fine and not your fault) you are going to spent months on this basic feature. You really need to hire a professional to do this for you πŸ˜…

gentle heron
#

NO I read that wrong the first time around!

#

Im dyslexic please excuse me I read stuff wrong some times!

#

when I read too quick I missunded stand things im with you know!

astral moth
#

all good, just explaining that this is getting tricky overall. My team helps hundreds of developers a month and we unfortunately can't spend dozens of hours 1:1 with people.

gentle heron
#

So how does one create a price_id for a connected account? its not like I can access someones connect account right?

burnt mountainBOT
astral moth
#

I explained that concept in details on the previous part of the conversation.

#

You use that feature to make any API Request on a connected account.

gentle heron
#

Listen sir if you dont want to help me I totally understand.

#

its up to you!

astral moth
#

I am actively helping you. It's been 90 minutes non stop. But I do need you to try and do some of the debugging/understanding too.
So I explained before how to do this, so what part is unclear?

gentle heron
#

Ok sir im going to log off now! I really appreciate your help and sitting here with me! ill stop spamming you guys! thanks.