#charisma2761

1 messages ยท Page 1 of 1 (latest)

cedar moonBOT
sterile badger
#

Hello ๐Ÿ‘‹
Do you have an example checkout session ID handy where items were bought with 100% off code?

trim girder
#

I have it but from test mode, is that okay?

sterile badger
#

yup thats fine

trim girder
#

Here promo_1O4pG1HT8rqbhhjQC7f9bUlZ

sterile badger
#

that's the promo code, I meant the checkout sessions

trim girder
#

That the id that is sent to the webhook when I use the 100% promo code

#
"id":"evt_1O2HhKHT8rqbhhjQ2bYqt26t",
"object":"event",
"api_version":"2022-08-01",
"created":1697566134,
"data":{
"object":{
"id":"promo_1O2HYyHT8rqbhhjQwAW4RHHD",
"object":"promotion_code",
"active":true,
"code":"Chris11",
"coupon":{
"id":"qVXGhGRA",
"object":"coupon",
"amount_off":null,
"created":1696515928,
"currency":null,
"duration":"forever",
"duration_in_months":null,
"livemode":false,
"max_redemptions":10,
"metadata":{
},
"name":"QA - All 100% Off No Min",
"percent_off":100,
"redeem_by":null,
"times_redeemed":4,
"valid":true
},
"created":1697565616,
"customer":null,
"expires_at":null,
"livemode":false,
"max_redemptions":null,
"metadata":{
},
"restrictions":{
"first_time_transaction":false,
"minimum_amount":null,
"minimum_amount_currency":null
},
"times_redeemed":1
},
"previous_attributes":{
"times_redeemed":0
}
},
"livemode":false,
"pending_webhooks":2,
"request":{
"id":"req_aJ8YdtVAix2dEq",
"idempotency_key":"e94bcd08-1557-4e10-9f5a-fbd1c45d19cb"
},
"type":"promotion_code.updated"
}```

This is the json sent to the webhook
sterile badger
trim girder
#

We were usually getting the checkout session id from the event (same structure as above) being event.data.object.id and then retrieve the line items from that session id, but its not same thing for no-cost orders

sterile badger
#

you're looking at the wrong event

#

you're looking at promotion_code.updated event

#

you should be looking at checkout.sessions.completed instead

trim girder
#

Does that apply even when it is a no-cost order?

#

I mean, are no-cost orders treated as checkout sessions?

sterile badger
#

This event was generated for that particular checkout session

trim girder
#

Ooh thank you, retrying and will let you know