#abbascoder51_api
1 messages ยท Page 1 of 1 (latest)
๐ 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/1408062646334259403
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
Hi Soma
how did you add the coupon? when you created the Subscription?
Found this: https://dashboard.stripe.com/test/logs/req_7KRucXd1nLAO5m, where you set 3 discounts
yes that's correct
I use the endpoint to update the subscription
public function update($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/subscriptions/%s', $id), $params, $opts);
}
and that API call generated this Invoice: https://dashboard.stripe.com/acct_1MHIPCLyqQB1PUwH/test/invoices/in_1RyWOeLyqQB1PUwHW0LdVe9f
there I see the 3 discounts:
yes that's correct
if (isset($data['shipping_price_id'])) {
$parameters['add_invoice_items'][] = [
'price' => $data['shipping_price_id'], // One-off shipping cost
];
}
I've added the delivery price as an invoice item, would this make a difference if I don't apply the discount to the subscription itself and inside the 'add_invoice_items' property?
looking into this
Thank you
Hi, taking over as my teammate needs to step away. Let me catch up.
Hey, yeah sure that's fine. Hi pgskc ๐
It looks like you updated the subscription with prorate set to none but you did pass billing cycle anchor to now: https://docs.stripe.com/billing/subscriptions/billing-cycle#reset-the-billing-cycle-to-the-current-time to reset it.
You also passed the discounts to apply to the entire subscription and not within the invoice items. I think what you'd want is to add to the to the specific line items: https://docs.stripe.com/api/subscriptions/object?api-version=2025-06-30.basil#subscription_object-items-data-discounts
Can you share what you're trying to achive exactly here? Which items are you intending to offer for free and what is the expected total amount to be paid by the customer?
https://dashboard.stripe.com/acct_1MHIPCLyqQB1PUwH/test/logs/req_EVjxilz4CxNMvd
I think I've figured it out, we have to add discounts to the 'add_invoice_items' property as I've added a product to the 'add_invoice_items' property. Applying the discount directly to the subscription doesn't work, as I believe I've restricted the promo code to only work with specific products (delivery products). This is probably the reason why I'm getting really weird behaviour with the prices
yeah I found this earlier and it works
Thank you, this resolved my issue.