#simo_simo-checkout-chargeid

1 messages ยท Page 1 of 1 (latest)

oblique oasisBOT
#

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

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

cinder sorrel
#

Hi ๐Ÿ‘‹

Yes you need to provide the ID of the charge related to the funds you want to refund. What information are you starting with?

wanton rose
#
    mode: 'payment',
    line_items: [
      {
        price_data: {
          currency: 'eur',
          unit_amount: amount * 100,
          product_data: {
            name: 'Lezione con Tutor',
          },
        },
        quantity: 1,
      },
    ],
    metadata: {
      bookingData: JSON.stringify(bookingData),
      mailingData: JSON.stringify(mailingData),
    },
    payment_intent_data: {
      application_fee_amount: earning * 100,
      transfer_data: {
        destination: tutor!.connectedAccountId as string,
      },
    },
    success_url:
      process.env.NODE_ENV === 'development'
        ? `http://localhost:3000/payment/success`
        : process.env.DOMAIN_PREFIX + `/payment/success`,
    cancel_url:
      process.env.NODE_ENV === 'development'
        ? `http://localhost:3000/payment/cancel`
        : process.env.DOMAIN_PREFIX + `/payment/cancel`,
  });```
This is the code for the checkout, how can I retrieve the charge id?
cinder sorrel
#

Are you attempting to refund the payment associated with this Checkout Session?

wanton rose
#

yes

#

I actually want to retrieve the id from the checkout so I can store it in the database and use it later for the refund

cinder sorrel
#

Okay well the Checkout Session won't have a Charge ID until after the customer pays though.

#

So you can't get it right away

#

But you can listen for the checkout.session.completed webhook event. That will contain the Checkout Session that was just completed

#

You can look up the Payment Intent and the latest_charge to ge the Charge ID

wanton rose
#

Since I'm using Stripe Connect, I would like to refund a transaction, not just giving back the money not relating to a transaction

cinder sorrel
#

I would like to refund a transaction, not just giving back the money not relating to a transaction
I'm confused what you mean by this.

wanton rose
#

like session.payment_intent

cinder sorrel
#

session.payment_intent will have the ID of the PaymentIntent object associated with this Checkout Session. I am recommending you retrieve the Payment Intent using this ID and store the ID value in the latest_charge property to use later for refunds.

wanton rose