#emilevl_api

1 messages ¡ Page 1 of 1 (latest)

dawn treeBOT
#

👋 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/1460276321228951563

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

noble tusk
#

Hello
I don't believe you can limit a coupon to a Subscription. You generally associate a coupon to "product" objects instead.

Those product objects are listed under applies_to parameter - https://docs.stripe.com/api/coupons/object#coupon_object-applies_to

On a Subscription, the product should be listed under items[].price.product param

true rivet
#

Yes, sorry wront terms, I was talking about products.

Ok this is helping already.
I tried to get all the coupons with that :

`$stripe = new StripeClient(config('cashier.secret'));

        try {
            // This one doesn't give much information
            $promotionCodes = $stripe->promotionCodes->all([
                'code' => $couponCode,
                'active' => true,
                'limit' => 1,
              ]);
              Log::info('Promotion code lookup', [
                  'coupon_code' => $couponCode,
                  'found_count' => count($promotionCodes->data),
              ]);

            // This one gives way more info
            $found = $stripe->coupons->all();
            
            Log::info("FOUND COUPONS", ['coupons' => $found->data]);`

and I got the array of coupons, but the info of applies_to is not shown. Am I mistaken ?
{
"coupons": [
{
"Stripe\Coupon": {
"id": "12",
"object": "coupon",
"amount_off": null,
"created": 1768224332,
"currency": null,
"duration": "once",
"duration_in_months": null,
"livemode": false,
"max_redemptions": null,
"metadata": [],
"name": "12 ON Advanced",
"percent_off": 12.0,
"redeem_by": null,
"times_redeemed": 0,
"valid": true
}
},
...
]

noble tusk