#Raman-promotion code

1 messages ยท Page 1 of 1 (latest)

queen sail
ornate jewel
#

Thank you. And 1 more question. We are use the checkout session payments with enabled promotion codes. Can I retrieve the promotion code in this session by any callback?

#

So I need to know did user use the promotion code or not, and if he used, what the code?

noble cloud
#

@ornate jewel let me look

ornate jewel
#

But now i receive only the discount amount instead the discount id. How I can set up to retrieve the discount id?

#

This is checkout.session.completed callback

noble cloud
#

that's expected, the information inside breakdown is not included by default, you have to explicitly expand it. You can read more about expand here: https://stripe.com/docs/expand
So when you get the event you need to retrieve the Session and pass expand: ['total_details.breakdown']

ornate jewel
#

Ohh, ok, I will try. Thank you

ornate jewel
#

Can I expand multiple parameters like expand: [
'total_details.breakdown',
'total_details.breakdown.discounts.promotion_code'
] ??

noble cloud
#

yes

#

(easiest is to try really :p)

ornate jewel
#

I have tried but it doesn't works, and maybe I doing something wrong))

noble cloud
#

yeah but that's expected

#

expansion works based off of the API layer

#

total_details -> breakdown -> discounts -> discount -> promotion_code

#

you can't just pass promotion_code after discounts, there's a layer in between

#

sadly, the maximum is 4 deep so you won't be able to reach promotion code

ornate jewel
#

Ohh, yep, I see ๐Ÿ™‚ So thank you ๐Ÿ™‚

noble cloud
#

sure! Expand is super easy once you grasp it fully but it takes a while to resonate ๐Ÿ˜ฆ