条带 billing_cycle_anchor 标签的时区问题 [英] Timezone issue with stripe billing_cycle_anchor tag

查看:29
本文介绍了条带 billing_cycle_anchor 标签的时区问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将每月的最后一天用于订阅,以便根据创建的订阅按比例收取费用.我使用下面的代码来计算最后一天的月份:

I want to to give last day of the month to subscription, so that prorated amount is charged based on subscription created. I am using below code to calculate the month last day:

var date = new Date();
var lastDay = Date.UTC(date.getFullYear(), date.getMonth() + 1, 0);
var monthLastDay = Math.floor(lastDay/1000);

我在 IST 时区,所以我得到的 monthLastDay 为 1527724800,等于:05/31/2018 @ 12:00am (UTC)上面的代码在按比例分配的情况下工作正常,但订阅存在问题.我正在 2018 年 5 月 11 日创建订阅.因此按比例计算的金额是从 2018 年 5 月 11 日到 2018 年 5 月 31 日计算的.但是订阅是从 2018 年 5 月 31 日创建的.

I am in IST time zone so I am getting monthLastDay as 1527724800 which is equal to: 05/31/2018 @ 12:00am (UTC) Above code is working fine with prorated amount, but there is an issue with the subscription. I am creating subscription on 5/11/2018. So prorated amount is calculating from 5/11/2018 to 5/31/2018. But subscription is created from 5/31/2018.

我希望将订阅安排在 2018 年 6 月 1 日.谁能帮助我并指出我哪里出错了.

I want subscription to be scheduled on 6/1/2018. Could anyone help me and point out where I am going wrong.

注意:我正在将日期转换为 UTC 时区以避免不同的时区问题.

NOTE: I am converting date to UTC time zone to avoid different timezone issue.

推荐答案

值得指出的是,计费锚点应指定为 UTC 时区.如果您在本地时区中指定它,它将无法按预期工作.因此无法根据您的客户或您自己的时区续订订阅.

It is worth pointing out that the billing anchor should be specified in UTC timezone. If you specify this in your local timezone, it will not work as expected. So there is no way to renew subs according to your customer's or your own timezone.

我们在 3 月 1 日为 NZDT 的客户指定了它,但 Stripe 将其转换为 2 月 28 日(格林威治标准时间),因此随后的发票以当月 28 日为锚点创建.

We specified it for our customers in NZDT, on the 1st of March, but Stripe turned this into the 28th of Feb (GMT) and as a result subsequent invoices were created with the 28th of the month as anchor.

您是否使用 moment 与此问题无关,如果 Stripe 更好地记录这一点并建议使用哪个时区,将会有所帮助.

Whether you use moment or not has no bearing on this issue, it would be helpful if Stripe documented this a bit better and advised what timezone to use.

这篇关于条带 billing_cycle_anchor 标签的时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆