#JCoDog - Webhook

1 messages ยท Page 1 of 1 (latest)

obtuse jungle
#

HI ๐Ÿ‘‹
What is the event you are receiving and what about it isn't what you expect?

mortal mortar
#

Turned out I was usinglive endpoint secret an key instead of test so it wasnt retrieving the checkout session or items

obtuse jungle
#

Okay yep, that'll do it

mortal mortar
#

Yes, all working now. Thanks

obtuse jungle
#

๐ŸŽ‰

#

Happy to hear it ๐Ÿ™‚

mortal mortar
#

I am however concerned that it isnt showing the price that the user paid in the database where I record payments

obtuse jungle
#

Okay so can you share an example event?

#

The ID preferrably

mortal mortar
#

item->price->unit_amount

#

cs_test_a1krVr1qrhsE8A0Vpg9nMouLO6pUGOhNVZQyeIg2GKjQq5uOkZeeEcA5ly

obtuse jungle
#

Event ids start with evt_

mortal mortar
#

evt_1LLqsMEOJsqRXL0RN329K9zU

obtuse jungle
#

Okay so we've got an amount_total of $5.00. Is tha tnot what you expect?

mortal mortar
#

yes

#

so i need to change item->price->unit_amount to amount_total?

obtuse jungle
#

I'm not sure what "item->price->unit_amount" is in reference to. What do you mean here?

mortal mortar
#

it wass for a quantity amount pricing product

obtuse jungle
#

The price you specified for the checkout session is price_1LLqbDEOJsqRXL0RAya5ATgm

#

That price has the custom_unit_amount feature enabled

#

This means a user can pay what they want

#

The default is set to 5.00 GBP

mortal mortar
#

yes

#

how do i get the price that they paid?

obtuse jungle
#

But it could be any value between 1 GBP and 500 GBP

#

You can expand the Payment Intent that is returned with the Checkout Session in the checkout.session.completed event

mortal mortar
#

I do

obtuse jungle
#

So make a GET request for Payment Intent by that ID

mortal mortar
obtuse jungle
#

That is not the payment intent. those are line items

mortal mortar
#

Yes, thats how you get the price they pay yes?

obtuse jungle
#

Nope

#

Get the Payment Intent and the amount from that

#

A Payment Intent with status succeeded and an amount means the customer paid the amount in the Payment Intent

mortal mortar
#

Ah so $checout->amount

#

wait no...

obtuse jungle
#

It depends on when you see it. Because the price has a preset amount, then the Checkout session is created with that amount but it might not be what the customer ends up paying (because they can change it)

#

I still don't see any reference to the payment intent there

mortal mortar
#

So I would need to expand the payment intents and pull the amount from that?

obtuse jungle
#

Yes, that will give you the full amount the customer paid

mortal mortar
#

in in expand add payment_intent to the array?

obtuse jungle
#

Yes, you can just add 'payment_intent' to the expand array when retrieving the Checkout Session

mortal mortar
#

$intent = $checkout->payment_intent->data;

#

priceTotal=$intent->amount

#

So this?

obtuse jungle
#

You shouldn't need the data bit, since there's only one payment intent. The data property is Stripe convention for lists of objects.

mortal mortar
#

it didnt store in the database

obtuse jungle
#

Okay, can you log the itent object?

mortal mortar
#

Yes, logged and turned out that I just needed to redo the event check for the correct product ID

#

all working now, thanks.