#psi_unexpected

1 messages ยท Page 1 of 1 (latest)

fading magnetBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

atomic plank
#

hi! can you share an example request ID where you ran into this?

granite elm
#

sure: req_f0atMDFfTxjlf7

#

btw, I first tried to just set the discount for the whole phase. But then only the subscription items got the discount, not the items in add_invoice_item.

atomic plank
#

it's been a bit since i've worked with discounts in the context of a subscription schedule, lemme see if i can figure out what's going on here...

granite elm
#

thank you, appreciated

#

Oh, I just saw that the discount was actually applied to the add_invoice_item items! (The invoice just got out.)

This has been the case from an earlier try where I specify the discount for the whole phase.

Still, the question remains why the API does not let me do it for individual add_invoice_items although the documentation allows it. However, my original use case works now, so it's not that important for me to find out, haha.

atomic plank
#

ooo good to know that you're unblocked! but yeah i'm still working on reproducing everything... if this isn't allowed then our docs should definitely be updated

granite elm
#

If I can help with reproducing, just ask. But I guess you can see everything you need.

atomic plank
#

yeah, i'm just going a little slow at the moment. subscription schedules are complicated and my attention span is waning towards the end of my work day ๐Ÿ˜…

#

ok, i was just able to successfully modify my own subscription schedule successfully but i did it a little differently than you... using python here's what my code looks like

        subscription_schedule.id,
        phases=[
            
            {
                "add_invoice_items": [
                    {
                        "price": "price_1QHvrELFIO5qXQOWDKQXDSpH",
                        "quantity": 1,
                        "discounts": [
                            {
                                "coupon": "cwHzGMSm",
                            },
                        ],
                    },
                ],
                "items": [
                    {
                        "price": get_price_id("basic_monthly"),
                        "quantity": 1,
                    },
                ],
                "iterations": 1,
                "start_date": "now",
            },
        ]
    )```
#

trying to figure out what we're doing differently now

granite elm
#

you use a coupon. and you do not specify the phase-wide discount

#

I did not specify the coupon code but the discount-id

atomic plank
#

yeah, which theoretically should have the same effect. let me try it with a discount ID to be sure though.

granite elm
#

maybe phase-wide discount PLUS individual discounts at the same time could be a problem. Although it is just redundant information.

atomic plank
#

ok yep, i'm able to do it even when applying the coupon at both the phase level and the add_invoice_items level. trying with discount ID now

granite elm
#

API version is another thing that comes to mind. My request is at 2022-11-15. No idea if that matters.

#

But I did not find anything related to that in the API release notes

atomic plank
#

yeah i just tried updating that and got the same result. i am honestly a little unfamiliar with discounts as an object, i haven't had much exposure to them yet. still working on setting one up...

granite elm
#

Ah that might be a difference... coupon code is not tied to a specific subscription right?

atomic plank
#

can you actually try on your end to just swap it out for a coupon code and see if that works?

#

yeah, coupon codes can be pretty general purpose. the one i'm using is literally just 50% off anything, no product or redemption count limits

fading magnetBOT
granite elm
#

Hmm.. Yeah, I could try that. Would destroy my use-case though. Because I want the discount to be valid for one year. If I change the subscription schedule after say 6 months, then I fear that the discount timer gets reset.

#

So I want a discount to be tied to a subscription.

atomic plank
#

one thing i just noticed is that it looks like the price ID you're using price_1R3hVrQUormLcH2JR44Xbvuf is non-recurring and the coupon code bI8jpdoD (which your discount points to) is for recurring payments... wondering if that might have something to do with this?

#

ok nope, i just went spelunking into the code and it looks like we specifically code against that param being used here...

#

so i think our docs might just be wrong

granite elm
#

That might be the case.... I don't know. I also just noticed that in phase[1] of my request is an item with quantity=0; probably would have generated another error, maybe unrelated.

#

Oh cool! Then it seems to be a solved issue.

atomic plank
#

yep, i think i will sanity check that the docs are wrong and then file a doc update ticket. thank you for your patience as i worked through this!

granite elm
#

Thanks for looking at this.

atomic plank
#

yep of course!

#

i'm gonna go ahead and close the thread out but feel free to make another one if anything else comes up