#danial-subscription-trialend

1 messages ยท Page 1 of 1 (latest)

bold sentinelBOT
muted sleet
flat hornet
#

danial-subscription-trialend

#

can you give me the request id req_123 for that specific request you are looking at?

muted sleet
#

is it safe to give here ?

flat hornet
#

yes

muted sleet
#

req_MeoqhtgLximCOr

#

looks like somehow it needs atleast one day trial day

flat hornet
#

Okay so your code is passing trial_end: "1674845831" for that request. That timestamp maps to 2023-01-27 2023 18:57:11 UTC but the request you made was at 2023-01-27 2023 18:57:13 UTC so 2 seconds after that timestamp
You can not pass a timestamp in the past for trial_end

muted sleet
#

thats true. But I dont understand same thing when I do on production does not throw error. It must be something with my local setup timestamp

#

but anyways, Thanks for this help ๐Ÿ™‚

flat hornet
#

ah yeah a common problem is if your local laptop's clock is running a bit behind

#

so you think you have a trial that ends in 5 minutes, but for us that time is already past

muted sleet
#

ahaaan. Exactly. Hahahahaha

#

so it just is whole request taking time of 2 seconds to complete, or something like that. we cannot match the clocks exactly in these cases

#

right?

flat hornet
#

I mean it doesn't make sense to pass trial_end to like this current timestamp or a second later. What are you really trying to do?

muted sleet
#

I am just not passing trial. Just using laravel cashier and when I add -newSubscription()->trialDays(0)

#

Like I dont want trial days. So I think laravel is triying to put the same datetime when the request is made to try to end the trial and then the clock doesnt sync

flat hornet
#

I mean Cashier must be passing trial_end and you need to figure out a way to tell it not to do that

muted sleet
#

yeah

flat hornet
#

what happens if you don't pass trialDays(0)?

muted sleet
#

but it does not happen on server computer staging or production. only locally

#

oh then it works

#

just problems with local computer time when laravel does Carbon::now()->adDays(0)
From Laravel cashier documentation:

/**
 * Specify the number of days of the trial.
 *
 * @param  int  $trialDays
 * @return $this
 */
public function trialDays($trialDays)
{
    $this->trialExpires = Carbon::now()->addDays($trialDays);

    return $this;
}
#

aanyhow, works on server

flat hornet
#

Awesome!

muted sleet
#

Why does it only happen on local btw. Any idea? Same reaosn? I'm getting nerd at it. Sorry :p

flat hornet
#

your computer locally has a different time than the computer your code run on in production

muted sleet
#

Ok ๐Ÿ™‚