#matrix - Notifications

1 messages · Page 1 of 1 (latest)

mental turtle
high tusk
#

Hello

mental turtle
#

Hello! Can you provide more details? How are you using Stripe? How do you want to be notified?

high tusk
#

I have a checkout session for a single product and the product is associated to a price. I would like to use webhook and I see that there is a checkout.session.completed object but it does not include the reference to the product or the price

#

is there an event i can listen that tell me a certain product was purchased?

mental turtle
high tusk
#

thanks

#

is there an example of fetching the checkout session via node?

mental turtle
#

You would do that and add the expansion info.

#

It would look something like this:

const session = await stripe.checkout.sessions.retrieve('cs_test_123', {
  expand: [
    'line_items'
  ],
});
high tusk
#

great thanks

high tusk
#

@mental turtle is it correct to say that if i want to print the product in my console i just need to write console.log(‘product ID = ', session.line_items.data[0].price.product); ?

#

I only have one product in my checkout

mental turtle
#

Yeah, I think that will work. Have you tried it?

high tusk
#

will do

#

thanks

#

i get an error

#

Invalid checkout.session id: cs_test_xxx

#

do i need to autenticate in some way? i am using connect direct charge

mental turtle
#

Sounds like the Checkout Session ID you provided isn't correct. Are you using the correct API key?

#

Oh, so this is for a Checkout Session that exists on a connected account?

high tusk
#

yes

mental turtle
high tusk
#

I managed to get it work with this

#

const session = await stripe.checkout.sessions.retrieve(dataObject.id, { expand: [ 'line_items' ], stripeAccount: event.account, });

#

however i see this warning in my console

#

(node:1) Stripe: Options found in arguments (stripeAccount). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.
(Use node --trace-warnings ... to show where the warning was created)
(node:1) Stripe: Invalid options found (expand); ignoring.

mental turtle
#

Yeah, the stripeAccount value should be in a separate object supplied as the third argument.

high tusk
#

oh

#

ok thanks

mental turtle
#

Like this:

const session = await stripe.checkout.sessions.retrieve(dataObject.id, {
    expand: [
      'line_items'
    ],
  }, {
stripeAccount: event.account,
});
high tusk
#

thanks

#

tested and all good. many thanks for your help