#hash_api

1 messages ยท Page 1 of 1 (latest)

dark pawnBOT
#

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

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

manic crest
#

I'm making subscription and i want to delete some items for it but keep them active for the current period. Is it possible to do this?
You mean, you want to delete that item for the current period or for the next period ?

lime locust
#

i want to delete for the next period. Since the user is going to pay for the end of the month i want it to still be active but the subscription update i receive doesn't have the item anymore.
The AI was writing that if i add the Deleted to true, it will send the subscription object on the update with the item still inside until the end of the period and i will receive another update for the next period where the object will not be there anymore

manic crest
#

i want to delete for the next period.
You should use Subscription Schedule then

lime locust
#

so i need to make sure the phases are done at the end of the billing, the management of the date must be done from my side?

manic crest
#

Yes, you have all the control on these dates

lime locust
#

yeah tho i don't want to fuck up the custome subscription, i'll try to read a bit more my goal is just to have an added item to be invoiced immediately and in case he deselect it. Remove it on the next billing period since he would have paid. And in case he select again just add it again without any payment done again and keep it again on the next billing period

#

but it seems that this management requires to use a lot of different part of the billing i guess with those phases

manic crest
#

What you did in the request req_x6BZFgxLzjaqBD is correct too between, when no impact use proration none and when you want to invoice use invoice always as proration

#

but using Subscription Shceduler will give you just more flexibility

lime locust
#

but i need to modify the whole code somehow because this is a new kind of object from what i understand. I admit its a part where i'm a bit worried since its the money of the customer and the ai is sometime giving me code that doesn't seems to work with the golang library xD. But i suppose i need to understand this a bit more.
Basically tho instead of using subscription like i did before i will need to use the subscriptionSchedule right?

manic crest
#

Yeah that's the straightforward path

dark pawnBOT
lime locust
vast pumice
#

hey there, i'm taking over for @manic crest who needed to step away. Catching up...

lime locust
#

no problem, sorry for all my question. I'm trying to build a subscription system where user can add and remove items during the month with the only downside being once they add an item

#

there is proration paid for the rest of the month

#

and if they delete it only delete for the next period

#

and basically i used a normal susbscription item at first and removed payment with none when there was a deletion but since i wasn't using phases it was deleting for the current period as well

vast pumice
vast pumice
lime locust
#

my problem is that i'm dependend on the webhook to update my items and since the webhook updating with the item being immediatly deleted the app is removing the item for the current month too

#

because there are some items that are really cheap and when the user add them i don't immediatly charge for exemple but leave the proration for next period however i still let the user use those new items added

#

i feel like my payment strategy is complex but i wanted to give lots of flexibility for the end user

vast pumice
lime locust
#

yeah to update the customer information on what he is allowed to use the code is based on the subscription.update hook and just loop in the items that exist

#

when i was using the doc with ai it told me that at the end of the period when items gets deleted an update is sent again

vast pumice
#

yea you'd have to manage that differently if you're removing items

lime locust
#

but i use the phase i can use it the same way? i will receive a new update at the end of the period right?

#

if*

vast pumice
lime locust
vast pumice
#

So you can look into setting that up if the item existing is important to your systems

#

Glad you tested it ๐Ÿ™‚

lime locust
#

yeah its the part i'm trying to be extremely careful about, if user lose money or find it weird there. My company is dead i guess xD

vast pumice
#

Just be prepared for some more complexity with schedules and also test thoroughly

lime locust
#

yeah its just it was basically // Delete items that are not in the request first if len(stripeSubscriptionItemsToDelete) > 0 { stripeSubParams := &stripe.SubscriptionParams{ Items: stripeSubscriptionItemsToDelete, PaymentBehavior: stripe.String("default_incomplete"), ProrationBehavior: stripe.String("none"), } stripeSubscription, err = subscription.Update(legalSubscription.SubscriptionID, stripeSubParams) if err != nil { h.Log.Error("retrieve-stripe-subscription", zap.String("part", "subscription"), zap.Error(err)) return ctx.Status(500).JSON(fiber.Map{"error": "InternalError"}) } }
This part but now i can use that params := &stripe.SubscriptionScheduleParams{ FromSubscription: stripe.String("{{SUBSCRIPTION_ID}}"), } result, err := subscriptionschedule.New(params) that is in the doc to actually change the update to that kind of thing. Tho is it upgrading the whole subscription to a new object or i can still use the nomal subscription items for other purpose?

vast pumice
#

the subscription still exists, the schedule is a layer on top for managing changes over time

#

When the clock reaches the phase transition, the subscription is updated according to the items you specify (eg, in your case, the second phase would have the to-be-deleted item removed).

lime locust
#

yeah i'm thinking of using that result, err := subscriptionschedule.New(params) when i'm in my function so i can verify what is in the current phase and the next one and then modify accordingly probably

#

my problem being mostly billing appearing for small items but well i'll cehck that after i guess

vast pumice
#

Also, i would suggest you think about how this provisioning is happening. Your Stripe integration already seems correct for how you want to invoice the customer, the issue is on your provisioning side reacting to the item removal

#

Instead of making your billing system more complex unnecessarily, you could change the way you manage provisioning

lime locust
#

mmmh its just my source of truth is suppose to be stripe. but if i don't have the information there i feel it can lead to some mixup later

#

thats why i decided not to hold too much data about items on my backend side

#

so that later i could also just use some scrript to reset items from the stripe side but well i admit it does make it a bit complex to manage the phases this way

vast pumice
#

Yep, you can go down the SubscriptionSchedule path if you want, it'll work the way you say you want it to, then. It's more complex but if it gets you what you need so be it.

#

Just to sketch out an alternative you could track in your system:

  • current period access
  • recurring access
    and you only remove items from the recurring access, but leave items in the current access alone, only update that when the billing cycle renews