#pooja-checkout-promotioncode
1 messages · Page 1 of 1 (latest)
Can you share an example where this was used that you're trying to retrieve?
I'm assuming this was applied during a checkout session?
I am using stripe hosted checkout, and I need to get the payment detail of user. For that I am using session.completed.checkout event and then making API calls to get session object and the coupon object.
Where are you getting the coupon from?
I think you want to expand total_details.breakdown.discounts.discount
to look at the Discount object which has promotion_code
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-total_details-breakdown-discounts-discount
If you give me a few minutes I can test that to confirm myself
I've already applied this param in checkout session API
Yeah, sure.
Ok yea you can use expand[]=total_details.breakdown then find the promo code in the discount object
I don't need that, user has not applied that code, user has applied for example TEST10. I need that code
You'd need to separately retrieve the Promotion Code object by ID to get the human-readable code if you need that
because it exists at a path too deep for expansion
(limit is four levels)
It's not event in that API response
{ "id": "promo_1NKcmCDPAH7QIF0ajpVeeDyM", "object": "promotion_code", "active": false, "code": "J4UVIFOC", "coupon": { "id": "w0JyBc1y", "object": "coupon", "amount_off": null, "created": 1687160700, "currency": null, "duration": "forever", "duration_in_months": null, "livemode": false, "max_redemptions": null, "metadata": {}, "name": "10% Off", "percent_off": 100.0, "redeem_by": null, "times_redeemed": 0, "valid": false }, "created": 1687160728, "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": 0 }
"code": "J4UVIFOC",
No, that is not the code, user is applying
Then it must be a different promo code. Can you share the example session id?
cs_test_b1HcTZijTi0yIq7R2A4glgqNAeyPj482kKddVLroq3ry4nLtMtDqvYaOQK
Hmm when/how is the customer applying this?
I don't see a request on that session to use a promo code, but I do see the discount being applied
Customer is applying the code on checkout flow.
I am doing the testing and manually applying the code while checkout
Is there somewhere I can access your test mode pricing table online?
To try the TEST10 promo code myself?
TSET10 was for example, the actual promo code I applied was DOQIT10.
pricing-table-id="prctbl_1NJypzDPAH7QIF0a1WzpjPIr"
oh, ok. i do see that, then
Can you sere in in the response object here?
https://dashboard.stripe.com/test/logs/req_gLEAwsP0TlrpTX
And if you expand the total_details.breakdown for cs_test_b1HcTZijTi0yIq7R2A4glgqNAeyPj482kKddVLroq3ry4nLtMtDqvYaOQK what does that look like?
(I can't see GET request response body, so please share)
Get Stripe Session API response
Ok, thank you
That looks right
And if you retrieve promo_1NKeLiDPAH7QIF0aG15e2cai you will see it has code=doqit10
Sorry, But I can't see code= doqit10
Did you retrieve the promo code?
I'd also suggest caching this data on your server if you only have a few promo codes, so you can directly look up promo_1NKeLiDPAH7QIF0aG15e2cai without a retrieval
This is the response
{ "id": "promo_1NKcmCDPAH7QIF0ajpVeeDyM", "object": "promotion_code", "active": false, "code": "J4UVIFOC", "coupon": { "id": "w0JyBc1y", "object": "coupon", "amount_off": null, "created": 1687160700, "currency": null, "duration": "forever", "duration_in_months": null, "livemode": false, "max_redemptions": null, "metadata": {}, "name": "10% Off", "percent_off": 100.0, "redeem_by": null, "times_redeemed": 0, "valid": false }, "created": 1687160728, "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": 0 }
Getting It. Thank you so much for your assistance.
That's a different promo code ID that doesnt match the doqit10 example
So just check the promo code ID you're retrieving