#simo_simo-checkout-chargeid
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/1266069064971980831
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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?
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?
Are you attempting to refund the payment associated with this Checkout Session?
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
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
Since I'm using Stripe Connect, I would like to refund a transaction, not just giving back the money not relating to a transaction
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.
switch (event.type) {
case 'checkout.session.completed': {
const session = event.data.object;
So in here I need to check in session?
like session.payment_intent
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.
Thank you so much for the response!
I'll try