#abbascoder51_api

1 messages ยท Page 1 of 1 (latest)

flint flumeBOT
#

๐Ÿ‘‹ 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.

wide elk
#

hi there!

restive bane
#

Hi Soma

wide elk
#

how did you add the coupon? when you created the Subscription?

restive bane
#

using the api to update a subscription

#

let me find the call, 2 secs

wide elk
restive bane
#

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);
}

wide elk
#

there I see the 3 discounts:

restive bane
#

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?

wide elk
#

looking into this

restive bane
#

Thank you

flint flumeBOT
slim hollow
#

Hi, taking over as my teammate needs to step away. Let me catch up.

restive bane
#

Hey, yeah sure that's fine. Hi pgskc ๐Ÿ‘‹

slim hollow
#

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?

restive bane
#

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

#

Thank you, this resolved my issue.