#shruti_api

1 messages ยท Page 1 of 1 (latest)

eager capeBOT
#

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

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

plucky gyro
#

Sorry, I don't understand your question. What is it you're trying to do?

bronze tundra
#

I want to generate an invoice for the current month on the last day of the month

plucky gyro
#

Will allow you to configure the anchor to the last day of the month

bronze tundra
#

I have tried with 'BillingCycleAnchor', 'BillingCycleAnchorConfig' properties to change the the date. it changes the date but bills for next month. i want it to work like this (e.g. creates a subscription on 2024/10/09. generate an invoice on 2024/10/31 for the period of 2024/10/09 to 2024/10/31)

plucky gyro
#

That's not possible really. The period will respect the interval configured on the item(s) (i.e. monthly)

bronze tundra
#

is there any way to workaround

#

is there any way to achieve this

#

or if we can change the invoice template to not show the billing period

plucky gyro
#

Can you share an example request where you used the billing_cycle_anchor_config param?

bronze tundra
#

// Calculate the timestamp for the last day of the current month at 23:59:59
DateTime lastDayOfMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month), 23, 59, 59);
long billingCycleAnchor = ((DateTimeOffset)lastDayOfMonth).ToUnixTimeSeconds();

        var options = new SubscriptionCreateOptions
        {
            Customer = CustomerId,
            DefaultPaymentMethod = PaymentMethodId,
            //TrialPeriodDays = _stripeSettings.Value.TrialPeriodDays,
            Coupon = string.IsNullOrEmpty(tStripeCouponId) ? "" : StripeCouponId,
            ProrationBehavior = "none",
            Items = subscriptionItems,
            BillingCycleAnchor = lastDayOfMonth
            //BillingCycleAnchorConfig = new SubscriptionBillingCycleAnchorConfigOptions
            //{
            //    DayOfMonth = 31,
            //},
        };
plucky gyro
#

Your code above doesn't even pass the param (it's commented out)

bronze tundra
#

I have tried with BillingCycleAnchorConfig param too. still the billing cycle did not change

#

only bill date changes

plucky gyro
#

Can you please share some API requests so I can see the actual parameters passed and the response

#

No idea what 'bill date' is โ€“ please reference actual API fields

bronze tundra
#

Bill date means invoice generation date

plucky gyro
#

Ok, well until you share some object or request IDs I can't really help beyond that

bronze tundra
#

let me share

#

DateTime lastDayOfMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month), 23, 59, 59);
long billingCycleAnchor = ((DateTimeOffset)lastDayOfMonth).ToUnixTimeSeconds();

        var options = new SubscriptionCreateOptions
        {
            Customer = CustomerId,
            DefaultPaymentMethod = PaymentMethodId,
            ProrationBehavior = "none",
            Items = subscriptionItems,
            BillingCycleAnchorConfig = new SubscriptionBillingCycleAnchorConfigOptions
            {
                DayOfMonth = 31,
            },
        };

        var service = new SubscriptionService();
        Subscription subscription = service.Create(options);
plucky gyro
#

You're just sharing the same code โ€“ I want to see the actual API request that your code creates

bronze tundra
#

Subscription Request Obj

plucky gyro
#

FWIW, the subscription creation will always generate an initial invoice immediately. That is unavoidable. We bill at the beginning of the period unless metered/usage billing

bronze tundra
#

response

plucky gyro
#

For reference, all we need is the ID (sub_xxx). We can see all this detail in our internal systems

bronze tundra
#

sub_1Q7y68CG6BBG59bw1YUfZU8E

plucky gyro
bronze tundra
#

We have a quantity-based product in subscription. Which will be increased/decreased in a month. So we want to charge per quantity once it is increased. no matter we want to charge once in a month if added new quantity even if it is deleted mid month.

#

that is why we want to charge in the month end for the total added quantity. and will decrease the quantity once the invoice is paid through scheduler

plucky gyro
#

Yep, understand that. But it's not possible

#

Maybe you can model that to your business

bronze tundra
#

What will Usage-based model exactly do

plucky gyro
#

Read the doc I linked, should outline it. But it's the only way to invoice at the end of a period which is what you want

bronze tundra
#

let me check. please stay a while

#

thank you for the support

#

Can you please add me as a friend so that i can contact you

plucky gyro
#

Anything you need to ask you can ask here ๐Ÿ™‚

eager capeBOT
bronze tundra
#

how can i increase this quantity with usage based product

muted sable
#

hi! I'm taking over this thread.

bronze tundra
#

Can you explain with my model how can i integrate this model. We have a quantity-based product in subscription. Which will be increased/decreased in a month. So we want to charge per quantity once it is increased. no matter we want to charge once in a month if added new quantity even if it is deleted mid month.
that is why we want to charge in the month end for the total added quantity. and will decrease the quantity once the invoice is paid through scheduler

#

hello

muted sable
#

then yes a Metered subscription can work. Just make sure to send a record usage every time some "uses" a quantity. and at the end of the month, if the customer used 3 things, then pay 3 x amount.

bronze tundra
#

how can i do it with existing subscription with c# .net

#

I could not find proper way in documentations