#stripe-connect-platform_api

1 messages · Page 1 of 1 (latest)

sacred archBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1387422835932401718

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

young torrent
#

Hi there 👋 you are correct that you can't restrict a Coupon based on a Price, you can only specify Product IDs in applies_to.products when creating the Coupon.

Can you help me understand where you're stuck now, so I can try to advise how to proceed?

slow ember
#

API call to get coupon to confirm the product id it applies_to

young torrent
slow ember
#

coupon_id = "coupon_50_OFF_FIRST_MONTH"

#

coupon = Stripe::Coupon.retrieve(coupon_id)

#

#<Stripe::Coupon:0x1afcc id=coupon_50_OFF_FIRST_MONTH> JSON: {
"id": "coupon_50_OFF_FIRST_MONTH",
"object": "coupon",
"amount_off": null,
"created": 1750856868,
"currency": null,
"duration": "once",
"duration_in_months": null,
"livemode": false,
"max_redemptions": null,
"metadata": {},
"name": "50% Off First Month",
"percent_off": 50.0,
"redeem_by": null,
"times_redeemed": 0,
"valid": true
}

#

?

#

applies_to?

#

I want to have the code to set and get applies to

#

then i need to move to promo code and create a new one that has the same product restriction. Do i ALSO need to set it on the promo code or only on the coupon?

young torrent
slow ember
#

😦

young torrent
#

Only on the Coupon. Promotion Codes don't support Product-restrictions themselves, they inherit that from the associated Coupon.

slow ember
#

where are the docs that show the expand params on coupoins

young torrent
#

There aren't docs specific to that, because the use of expand is the same for all API requests.

slow ember
#

😦

#

expand: ['customer', 'payment_intent.customer'],

#

How would one know wtf to pass in?

#

that there is a hidden secret "applies_to" option?????

young torrent
#

You read the section about how expand works where we tell you to put the name of the field that you want to include/expand int he response.

slow ember
#

where do the coupon docs say there is a secret "applies_to" field????

young torrent
#

While I agree currently do a bad job of distinguishing between includable and expandable fields (I've been complaining about this internally for a while now) the presence of the expandable tag in our API ref is a pretty good indication that you may need to use expand.

#

It's not secret?

slow ember
#

write an applies to retrieve. I cannot

young torrent
#

What do you have currently?

slow ember
#

Stripe’s current API does not support an applies_to or product expansion on the Coupon object.

Product restrictions live only on Promotion Codes, not Coupons.

young torrent
#

And what is the error you're seeing when you run it?

slow ember
#

probably a hallucination

#

strip.value

#

value = value.strip # raise error for invalid byte sequences

#

oops hold on

#

3.2.2 :063 > coupon_id
=> "coupon_50_OFF_FIRST_MONTH"

#

3.2.2 :065 > request = Stripe::Coupon.retrieve(coupon_id, expand: ["applies_to"])
(irb):65:in <main>': undefined method strip' for ["applies_to"]:Array (NoMethodError)

#

OK got it. ChatGPT thinks its not supported but ok

#

OK to create a coupon with an applies_to via the API?

#

where is the doc on that?

#

OK, can I make an API and confirm that the promo code is restricted to a given product? Or how do i do so? chedck the promo code, then the related coupo, then the applies to field??? For an rspec test.

#

Q: Can you confirm that a promo code is restricted to a specifc product? If yes, how?

#

via API

#

for rspec test

young torrent
slow ember
#

ok thank you

#

goodbye