#Constant

1 messages ยท Page 1 of 1 (latest)

timber briarBOT
tacit bronze
#

๐Ÿ‘‹ happy to help

#

would you mind moving your other message here

hard prairie
#

Thank you! I'll post the checkout code right now.

tacit bronze
#

no need for code

#

would you mind sharing your account id, an event id or any request id so I could take a look

#

it's most probably a mis-configuration of the webhook endpoint

hard prairie
#

Here is the eventId that should've triggered the webhook: evt_1MMSYsCDFIRPxuIJq5Rex9lb

#

Thanks for your help!

tacit bronze
#

taking a look

#

the event you sent is not made on the connected account but rather on your platform account

#

that's why you're not receiving it

hard prairie
#
 const session = await stripe.checkout.sessions.create({      line_items: [        {          name: "Event Ticket",          amount: price * 100,          currency: currency,          quantity: 1,        },      ],      payment_intent_data: {        application_fee_amount: 0, // price * 100 * 0.1,        on_behalf_of: stripeAccountId,        transfer_data: {          destination: stripeAccountId,        },      },      customer: customerId,      metadata: { email: email },      mode: "payment",      success_url: successUrl,      cancel_url: successUrl,    });

#

Sorry for the formatting. This is how I create the checkout. The stripeAccountId is that of the connected account.

tacit bronze
#

I'm not saying your code is wrong I'm just saying that the event you sent is related to a checkout session that was created on your platform

hard prairie
#

Is the code above the correct way for creating a checkout for a connected account?

tacit bronze
#

Ok so there are 3 types of Charges and depending on the type of Charge objects get created either on the platform or on the connect account

#

Direct Charges for example create all objects on the connect account

#

while Destination Charges (including also the obo) create the objects on the Platform level

hard prairie
#

Ah I see. If I create a DirectCharge I only get a paymentIntent. How do I then return a checkoutUrl from that intent?

tacit bronze
hard prairie
#

So I only need to add the stripeAccountId header to the above code?

tacit bronze
#

and remove the payment_intent_data

hard prairie
#

How do I then set the platform charge? Say 5% of the payment.

tacit bronze
#

oh yes you're right, then you just keep the payment_intent_data.application_fee_amount

hard prairie
#

So I've tried this```

const session = await stripe.checkout.sessions.create( { line_items: [ { name: "Event Ticket", amount: price * 100, currency: currency, quantity: 1, }, ], payment_intent_data: { application_fee_amount: 0, // price * 100 * 0.1, }, customer: customerId, metadata: { email: email }, mode: "payment", success_url: successUrl, cancel_url: successUrl, }, { stripeAccountId: stripeAccountId } );

#

But I'm getting an error message, is the stripeAccountId header in the correct location?

tacit bronze
hard prairie
#

There doesn't seem to be a request id.

#

This is the error in my logs: Unhandled error Error: Stripe: Unknown arguments

#

If a place the stripeAccountId inside the create header I get this requestId: req_RwU442UOzlJU3v

tacit bronze
#

I'm terribly sorry but the code is not formatted and I'm having a bit of trouble reading it

#

just give me a sec

hard prairie
#

Thank you. Apologies for the bad format. New to discord.

tacit bronze
#

no worries

#

in the request you shared I saw that you still have the stripeAccount as part of your request body

#

you just need to remove that and keep it in the header

#

and you should be fine

hard prairie
#

Sorry for a very dumb question. What do you mean keep it in the header? I've moved it outside the request body, but then get an Unknown arguments error.

tacit bronze
#

just give me a second I'm checking one thing for you

hard prairie
#

Thank you. Really appreciate the help.

tacit bronze
#

so basically your code has stripeAccountId: stripeAccountId instead of stripeAccount: stripeAccountId which might be the reason why it's not working

hard prairie
#

Ahh let me check!

tacit bronze
#
    {
      line_items: [
        {
          name: "Event Ticket",
          amount: price * 100,
          currency: currency,
          quantity: 1,
        },
      ],
      payment_intent_data: {
        application_fee_amount: 0,
      },
      customer: customerId,
      metadata: { email: email },
      mode: "payment",
      success_url: successUrl,
      cancel_url: successUrl,
    },
    { stripeAccount: stripeAccountId }
  );
hard prairie
#

That worked! Thank you so much.

tacit bronze
#

no worries ๐Ÿ™‚

hard prairie
#

If you have some time can I ask you another question?

tacit bronze
#

yes sure

hard prairie
#

In the checkout object I've added some metadata. But in the webhook event the metadata is empty. Any idea why?

tacit bronze
#

what webhook event are you listening to?

hard prairie
#

charge.succeeded

tacit bronze
#

that's not the correct event to listen to

#

you should be listening to checkout.session.completed

hard prairie
#

Thank you! I'll give it a try

#

Worked like a charm. Once again, thank you for your support. All the best for 2023!

tacit bronze
#

sure thing ๐Ÿ™‚

#

same to you