Skip to content

Instantly share code, notes, and snippets.

View biancadanforth's full-sized avatar

Bianca Danforth biancadanforth

View GitHub Profile
@biancadanforth
biancadanforth / proration_formula.md
Created June 10, 2021 17:08
Formula for computing a prorated upgrade charge amount in Stripe

If upgrading (say from a $10/month to a $20/month plan 3 days into the subscription):

  1. Calculate the fraction of the period used to this point under the previous plan, x.
3 days /30 days = 0.1 = x

Note: This is approximate, since months can have different numbers of days, there are leap years, etc.

  1. Multiply x by the previous plan's billing amount, amount_prev to get how much to credit the customer back, credit.
@biancadanforth
biancadanforth / temp-fxa-3907-script.ts
Created September 20, 2021 14:53
FXA-3907 exploration: How many users are affected by off-session SCA?
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { AuthLogger } from 'fxa-auth-server/lib/types';
import { ACTIVE_SUBSCRIPTION_STATUSES } from 'fxa-shared/subscriptions/stripe';
import { StatsD } from 'hot-shots';
import stripe from 'stripe';
import Container from 'typedi';
import { CurrencyHelper } from '../lib/payments/currencies';
@biancadanforth
biancadanforth / article-ruleset.js
Created January 5, 2022 23:08
Fathom article webpage ruleset
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable max-len, arrow-body-style */
import {linearScale} from "fathom-web/utilsForFrontend";
import {dom, out, rule, ruleset, score, type} from "fathom-web";
const coefficients = {
"paragraph": [
@biancadanforth
biancadanforth / fxa-4418-unknown.diff
Last active January 11, 2022 12:37
FXA-4418 chore(auth): set state as "unknown" if it can't be determined
diff --git a/packages/fxa-auth-server/lib/payments/stripe.ts b/packages/fxa-auth-server/lib/payments/stripe.ts
index 23ef5812a..84be94e75 100644
--- a/packages/fxa-auth-server/lib/payments/stripe.ts
+++ b/packages/fxa-auth-server/lib/payments/stripe.ts
@@ -833,24 +833,9 @@ export class StripeHelper {
customerId: string;
postalCode: string;
country: string;
- }): Promise<boolean> {
- try {