Skip to content

Commit

Permalink
tmp: fixed billing cycle for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelecerati committed Jun 28, 2023
1 parent 600ff45 commit f3411bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/controllers/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ app.post("/webhook", async (req, res) => {
if (payAsYouGoPlans.includes(user.stripeProductId)) {
let usage = await getBillingUsage(
user.id,
invoice.period_start,
invoice.period_end
1685311200000, //invoice.period_start, // TMP Fixed billing cycle to test usage
1687989600000 //invoice.period_end // TMP Fixed billing cycle to test usage
);
let overUsage = await calculateOverUsage(user.stripeProductId, usage);

Expand Down
1 change: 1 addition & 0 deletions packages/api/src/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async function getOrCreateSubscription(
});
return await stripe.subscriptions.create({
cancel_at_period_end: false,
backdate_start_date: 1685311200, // TEMPORARY BACKDATE TO TEST BILLING
customer: stripeCustomerId,
items: prices.data.map((item) => ({ price: item.id })),
expand: ["latest_invoice.payment_intent"],
Expand Down
4 changes: 2 additions & 2 deletions packages/www/components/UsageSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const UsageSummary = () => {
};

const doGetUsage = async (fromTime, toTime, status) => {
fromTime = fromTime * 1000;
toTime = toTime * 1000;
fromTime = 1685311200000; // fromTime * 1000; // TMP Fixed billing cycle to test usage
toTime = 1687989600000; // toTime * 1000; // TMP Fixed billing cycle to test usage

if (status === "canceled") {
const now = new Date();
Expand Down
4 changes: 2 additions & 2 deletions packages/www/pages/dashboard/usage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ const Usage = () => {
toTime: any,
status: any
) => {
fromTime = fromTime * 1000;
toTime = toTime * 1000;
fromTime = 1685311200000; // fromTime * 1000; // TMP fixed billing cycle
toTime = 1687989600000; // toTime * 1000; // TMP fixed billing cycle

// if subscription is cancelled, get current month data
if (status === "canceled") {
Expand Down

0 comments on commit f3411bc

Please sign in to comment.