#wsnookum_api

1 messages ¡ Page 1 of 1 (latest)

plain shuttleBOT
#

👋 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/1272434867979816981

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

lofty compass
obtuse token
#

I tried this but it hasn't charged/created an invoice for the current billing period. I had to set the billing anchor date to the next billing cycle and invoice was created starting from there. I still could not set it to today if the time is a previous date. I get an exception.. Here is a snippet of the implementation.

#

public async Task<Subscription> CreateSubscriptionNow(string customerId, string planId, DateTime anchorDate)
{
var options = new SubscriptionCreateOptions
{
Customer = customerId,
Items = new List<SubscriptionItemOptions>
{
new() {
Price = planId
}
},
BackdateStartDate = anchorDate,
BillingCycleAnchorConfig = new SubscriptionBillingCycleAnchorConfigOptions
{
Month = anchorDate.Month + 3,
DayOfMonth = anchorDate.Day,
Hour = anchorDate.Hour,
Minute = anchorDate.Minute,
Second = anchorDate.Second,
},
ProrationBehavior = "none"
};

        return await subscriptionService.CreateAsync(options);
    }
#

the hour, minute, and second are set to an earlier time than now. Also, if I keep the month to today's month, exception occurs

lofty compass
obtuse token
#

This is the request for when exception occurs: req_jaGdOZHe7hBw3R

#

This is the request for when it didn't charge on the first cycle:
req_zKowyBENFJnwSG

lofty compass
#

Ok, so yes the billing_cycle_anchor must be a future date

#

If you don't want proration, you can always turned it off by setting ProrationBehavior = "none"

obtuse token
#

I tried that but it didn't charge for the first cycle. It started charging only from the future billing cycle anchor. Is it not possible then to set an earlier subscription start time and not prorate the fee?

#

How do you achieve migration of existing subscriptions to stripe?

#

I assume you retain their subscription start dates or is this not the case?

lofty compass
#

subscription start date and billing_cycle_anchor are different dates. Is your objective setting the start_date to a past date?

obtuse token
#

no, setting the billing anchor date such that the time is between 12mn and 5am

#

so if the subscription was done later in the day, it still sets to recur at the earlier hours. however, the fee should not be prorated.

#

I assume that on migration the subscription start date is the same as the billing anchor date, as in the case when no billing anchor date is defined. i.e. it is set to now..

lofty compass
#

Why do you want to set billing_cycle_anchor to a past date? There's no way to create a invoice in a past date.

obtuse token
#

I want the billing time to be done in the first 5 hrs of the day.

#

it's not the date but the time.

lofty compass
#

Can you share with me a concrete example to help me understand what you want to achieve?

obtuse token
#

If user registers at any time after 5am, the billing anchor time is set to any time between 12mn and 5am. All recurring invoices then get issued within 12mn and 5am.

#

The initial invoice should still reflect the full fee and not prorated.

lofty compass
#

Ok, let me explain how billings work with an example.

#

So your customer visited your website and subscribed your service at 6am 12 Aug 2024, you set the billing_cycle_anchor to 5am 12 Sep 2024, with ProrationBehavior = none

#

The subscription and its first invoice were created at 6am 12 Aug 2024.

#

One month later, the subsequent invoice will be created at 5am 12 Sep 2024, based on the billing_cycle_anchor that you speciried earlier.

#

One month later, another invoice will be created at 5am 12 Oct 2024

#

This would continue until the subscripiont is cancelled.

obtuse token
#

I tried this in req_zKowyBENFJnwSG. The interval is quarterly (every 3months). I didn't get an invoice for aug to nov. The first cycle was from november. This is with proration = none. However, if I don't set proration, the first cycle is from aug to nov, but the fee is slighly more expensive than the monthly fee.

#

This is the request for the 2nd trial: req_r3Ahr4o043clcY

#

Updated the request ID.

#

Is it a bug for stripe when proration is none?

#

I expect it to behave the same as the 2nd trial without proration.

lofty compass
#

Just want to make sure that I understand you, are you expecting req_r3Ahr4o043clcY not to create invoice like req_zKowyBENFJnwSG ?

obtuse token
#

I expect it to behave like req_r3Ahr4o043clcY but not have prorated fees. Or for req_zKowyBENFJnwSG to charge on the cycle of aug to nov. The fee should still be the standard fee (no proration).

lofty compass
#

Or can you tell me what you are trying to achieve? backdate a subscription with or without charging a customer?

obtuse token
#

Purpose is just to charge within 12mn to 5am daily. All recurring invoices should be issued within this time frame. If a user registers after 5am, it should be set to recur at a random time between 12mn and 5am. There are no other changes in the way that the subscription is handled. The fee is still the same, no proration.

#

The problem with proration = none is that stripe doesn't charge for the current billing period. It charges from the future date from the billing anchor.

#

On the other hand, if proration is set, stripe adds as few cents to the price of the subscription which is what we don't want.

lofty compass
#

So it's a daily subscription, not a quarterly subscription?

obtuse token
#

No. It's a quarterly subscription. The 12am to 5am is just the range that all subscriptions need to set the billing anchor time. I mention time here and not date because the cycles are still defined by the interval and interval count.

lofty compass
#

Ok, I thought it's daily because you said "12mn to 5am daily."

obtuse token
#

So all subscriptions should issue invoices within this period (12am to 5am) regardless of the interval or interval count.

#

That's all that I want to achieve.

#

"The problem with proration = none is that stripe doesn't charge for the current billing period. It charges from the future date from the billing anchor." >> Is this a bug on stripe?

#

Or is there another way to do this?

#

This is the current implementation:

lofty compass
obtuse token
#

public async Task<Subscription> CreateSubscriptionNow(string customerId, string planId, DateTime anchorDate)
{
var options = new SubscriptionCreateOptions
{
Customer = customerId,
Items = new List<SubscriptionItemOptions>
{
new() {
Price = planId
}
},
BackdateStartDate = anchorDate,
BillingCycleAnchorConfig = new SubscriptionBillingCycleAnchorConfigOptions
{
Month = anchorDate.Month + 3,
DayOfMonth = anchorDate.Day,
Hour = anchorDate.Hour,
Minute = anchorDate.Minute,
Second = anchorDate.Second,
},
//ProrationBehavior = "none"
};

        return await subscriptionService.CreateAsync(options);
    }
#

Is there a way to implement the feature that we need?

lofty compass
#

One sec, let me test out something

#

OK, I think I have a solution. You need to use subscription schedule.

#

So basically you need to phases

    {
      items:[
        {
          price: YOUR_PRICE
          quantity:1
        }
      ],
      end_date: THE_DESIRED_BILLING_CYCLE_ANCHOR_IN_FUTURE
      
    },{
      billing_cycle_anchor: 'phase_start',
      items:[
        {
          price: YOUR_PRICE,
          quantity:1
        }
      ],
      proration_behavior: 'none'
    }
  ]
#

In this way the schedule will set the billing_cycle_anchor, and subscription generates invoices without prorations

#

You can try it out in test mode with test clock

obtuse token
#

Will try this now. Thanks!

#

Does the SubscriptionScheduleService() replace the SubscriptionService() when creating the subscription?

lofty compass
#

These two are different services.