#Rohit89

1 messages · Page 1 of 1 (latest)

peak novaBOT
maiden loom
#

The paymentIntent or charge object doesn't carry the information about item quantity, you should listen to checkout.session.completed events instead

dark summit
#

Ok, I have checked the checkout.session.completed webhook response too. It also wont have line_items details

maiden loom
dark summit
#

Ok. Can we expand line_items in charge object after charge is succesfull or it can only be expanded for checkout.session completed?

maiden loom
#

There's not line_items in a charge object.

dark summit
#

ok so that can be expanded in checkout.session objec

#

Is there any documentation where I can see what are expandable in charge object and checkout session

#

?

maiden loom
#
dark summit
#

Thank you so much! Let me check

#

Does the charge object include info about any promo code used? any discount?

maiden loom
#

No it doesn't, but you can find them in a checkout session object

dark summit
#

Sure. And is there way to change the description that I can see under recent activity when I view customer.

Payment for US$316.00 was successful

Is it possible to change or customise this?

maiden loom
dark summit
#

Awesome. Last thing, is there any doc where I can see the list of events that happen in order when I do payment mode can be payment or subscription.

maiden loom
#

Are you asking a list of events related to checkout session?

dark summit
#

Yes. Mode can be payment or subscription.

maiden loom
dark summit
#

It just all have events but not in order. Which one initiated first and so on

maiden loom
dark summit
#

Ah ok. but checkout.session.completed will always be initiated in end after charge is successful charge.succeeded. Correct?

maiden loom
#

Not necessary.

#

checkout.session.completed simply means the checkout session is completed. For payment method which result can't be confirmed immediately, the payment_intent's status can be pending when checkout.session.completed happens

#

So you should listen to payment_intent.succeeded and payment_intent.payment_failed event to get notified about the payment result

dark summit
#

oh, line items info can be get from payment_intent.succeeded ??

Basically our customers do one time payment. I just want to capture the quantity and amount when payment is succeeded.

maiden loom
#

No, the line_items are available in checkout session, not payment_intent.

dark summit
#

Oh. Checkout Session will be completed with payment pending

maiden loom
#

Here's my suggestion.

You listen to payment_intent.succeeded, and pass the payment_intent ID to the List Checkout Session API to retrieve the checkout session object https://stripe.com/docs/api/checkout/sessions/list?lang=ruby#list_checkout_sessions-payment_intent

And from there you can expand the line_items

dark summit
#

let me check

#

Stripe::Checkout::Session.retrieve(
'cs_test_a1vWwiWdNK9WSAG9nXUU6n9iNvzsYVGd245R2oxyqdqHHGXOiBlg6dyKRD',
)

If this is way to reterive checkout session, how we can pass payement_intent_id

maiden loom
#

You should call the list API, not retrieve API

Stripe::Checkout::Session.list({payment_intent: 'YOUR_PI'})```
dark summit
#

Ok. This should work? Stripe::Checkout::Session.list({payment_intent: 'pi_3MRRegLv5rdhLZWU01sMYtom', expand: ['line_items']})

expand line items

maiden loom
#

Yup, you can do this as well

dark summit
#

I am getting

#

Stripe::InvalidRequestError: This property cannot be expanded (line_items).

maiden loom
#

expand: ['data.line_items']}

dark summit
#

[25] pry(main)> Stripe::Checkout::Session.list({payment_intent: 'pi_3MRRegLv5rdhLZWU01sMYtom', expand: ['line_items']})

Stripe::InvalidRequestError: This property cannot be expanded (line_items). You may want to try expanding 'data.line_items' instead.

maiden loom
#

change to data.line_items

dark summit
#

yeah. Thanks

#

checkout session will have info related promo code as well. Correct?

maiden loom
dark summit
#

Thank you so much for help

maiden loom
#

Oh, remember to expand the breakdown field, it's not included by default

dark summit
#

Yeah.

#

Adding a description to checkout create object will update the description here?

maiden loom
#

You mean setting a description to charge/payment_intent object?

dark summit
#

i want to change Payment for US$316.00 was successful

#

ohk