#rivzer

1 messages · Page 1 of 1 (latest)

solar mothBOT
stray gorge
#

How are you placing orders? Are you using invoices? Those have items

dreamy tundra
#

No i'm making a payment link

#

and then after succes there is also a webhook and in that webhook i'm tying to get the items

stray gorge
#

The items will be on the checkout session object

dreamy tundra
#

i'm already doing that right?

stray gorge
dreamy tundra
#

{
id: 'pi_3NYruLErqXo2RifT0vt8WQid',
object: 'payment_intent',
amount: 999,
amount_capturable: 0,
amount_details: { tip: {} },
amount_received: 999,
application: null,
application_fee_amount: null,
automatic_payment_methods: null,
canceled_at: null,
cancellation_reason: null,
capture_method: 'automatic',
client_secret: 'pi_3NYruLErqXo2RifT0vt8WQid_secret_rXP2bmJ8qKJZKtLIL3E9bk9zv',
confirmation_method: 'automatic',
created: 1690555485,
currency: 'eur',
customer: null,
description: null,
invoice: null,
last_payment_error: null,
latest_charge: 'py_3NYruLErqXo2RifT0yvHHz4Z',
livemode: false,
metadata: {},
next_action: null,
on_behalf_of: null,
payment_method: 'pm_1NYruKErqXo2RifTbqkOdYEK',
payment_method_options: { bancontact: { preferred_language: 'en' } },
payment_method_types: [ 'bancontact' ],
processing: null,
receipt_email: null,
review: null,
setup_future_usage: null,
shipping: null,
source: null,
statement_descriptor: null,
statement_descriptor_suffix: null,
status: 'succeeded',
transfer_data: null,
t

#

no line items

#

i tried that before

stray gorge
#

That's not the checkout session object

#

That's the payment intent object

#

You need to listen to checkout.session.completed, which gives you the checkout session object

dreamy tundra
#

oh ok from the session event

stray gorge
#

yep

dreamy tundra
#

session.line_items is nothing

#

const items = session.line_items.data.map(item => {
return {
id: item.price.product.id,
quantity: item.quantity,
};
});

data undefined

stray gorge
#

You'll need to retrieve the session by id and expand line_items

dreamy tundra
#

aha got it now

#

ty