studiojourney

package
v0.0.0-...-93fa170 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccountStatuses = [6]string{"active", "past_due", "canceling", "canceled", "unknown", "complete"}

These are what stripe uses:

View Source
var AccountStatusesHuman = map[string]string{
	"active":         "Active",
	"past_due":       "Overdue",
	"canceled":       "Canceled",
	"pending_cancel": "Canceling",
	"unknown":        "Unknown",
	"complete":       "Complete",
}

These are what we use mapped to human strings:

View Source
var ArtBundleCount = 12 // months
View Source
var BillingSpreadsheetCancelCol = 16
View Source
var BillingSpreadsheetCompleteCol = 1
View Source
var BillingSpreadsheetEmailCol = 3
View Source
var BillingSpreadsheetEndedCol = 0

Billing spreadsheet https://docs.google.com/spreadsheets/d/1p_tRygUVmhDNK68fPkKkXZnlvq7D2sQjBmpJ6TwDJUs/edit?usp=sharing

View Source
var BillingSpreadsheetFounderCol = 15
View Source
var BillingSpreadsheetId = "1p_tRygUVmhDNK68fPkKkXZnlvq7D2sQjBmpJ6TwDJUs"
View Source
var BillingSpreadsheetLtvCol = 9
View Source
var BillingSpreadsheetPaymentsCol = 8
View Source
var CancellationSpreadsheetEmailCol = 2

Cancellation spreadsheet

View Source
var CancellationSpreadsheetId = "1EKg0vqz2eaYqL31W1IqkdxuoqZ1FXtGEVXOC_lyfh5E"
View Source
var ChangeEmailSpreadsheetAcIdCol = 5
View Source
var ChangeEmailSpreadsheetId = "1ZeLSi3-IwVbRiMbPFAvW0et7bjhpwc0yYqTD5xYx8KI"
View Source
var ChangeEmailSpreadsheetNameCol = 1
View Source
var ChangeEmailSpreadsheetNewEmailCol = 3
View Source
var ChangeEmailSpreadsheetOldEmailCol = 2
View Source
var ChangeEmailSpreadsheetSourceCol = 7
View Source
var ChangeEmailSpreadsheetStripeIdCol = 4
View Source
var ChangeEmailSpreadsheetTeachableIdCol = 0

Change email spreadsheet

View Source
var ChangeEmailSpreadsheetTimestampCol = 6
View Source
var EnrollmentSpreadsheetCancelCol = 18
View Source
var EnrollmentSpreadsheetEmailCol = 2
View Source
var EnrollmentSpreadsheetId = "1wRHucYoRuGzHav7nK3V5Hv2Z4J67D_vTZN5wjw8aa2k"

Spreadsheet constants

View Source
var EnrollmentSpreadsheetNameCol = 1
View Source
var EnrollmentSpreadsheetStripeIdCol = 13

Spreadsheet columns (starts from 0) Enrollment/Signup spreadsheet https://docs.google.com/spreadsheets/d/1wRHucYoRuGzHav7nK3V5Hv2Z4J67D_vTZN5wjw8aa2k/edit?usp=sharing

View Source
var EnrollmentSpreadsheetUpgradeCol = 19
View Source
var FounderMigratedSpreadsheetEmailCol = 2
View Source
var FounderMigratedSpreadsheetId = "13xE8UGR03CBEjB0othGm4abv8vDi_d8wD7U1FF2BWUg"
View Source
var FounderMonthlyPrice = float32(29.00)
View Source
var MmTransactionsSpreadsheetAmountCol = 3
View Source
var MmTransactionsSpreadsheetEmailCol = 6

Membermouse transactions spreadsheet https://docs.google.com/spreadsheets/d/1sra-kv8f2ZVLmO9QK3MCfE0IIDIIWm61t2HQcMTdCf8/edit?usp=sharing

View Source
var MmTransactionsSpreadsheetId = "1sra-kv8f2ZVLmO9QK3MCfE0IIDIIWm61t2HQcMTdCf8"
View Source
var MonthlyPrice = float32(36.00)
View Source
var OverdueGracePeriodDays = 21 // 3 weeks

Cancel after overdue grace period ends (as set in Stripe dashboard) TODO Load this from Stripe dashboard settings? Note this is different now. We retry 3 times and then it goes to AC automation for a few days.

View Source
var StripeAccountActiveStatuses = []string{"active", "trialing", "unpaid"} // rest are inactive

Stripe account statuses for SJ

Functions

func AddChangeStudentEmailRow

func AddChangeStudentEmailRow(teachableId string, name string, oldEmail string, newEmail string, stripeId string, acId string, timestamp string, source string) error

func CancelSubscription

func CancelSubscription(c *stripe.Customer) (*stripe.Subscription, error)

func ChangeStudentEmail

func ChangeStudentEmail(oldEmail string, newEmail string, teachableId string) error

func GetBillingRowByEmail

func GetBillingRowByEmail(email string) ([]spreadsheet.Cell, error)

func GetBillingSpreadsheet

func GetBillingSpreadsheet() (*spreadsheet.Sheet, error)

func GetCancellationSpreadsheet

func GetCancellationSpreadsheet() (*spreadsheet.Sheet, error)

func GetChangeEmailSpreadsheet

func GetChangeEmailSpreadsheet() (*spreadsheet.Sheet, error)

func GetEnrollmentRowByEmail

func GetEnrollmentRowByEmail(email string) ([]spreadsheet.Cell, error)

Note: These are read-only functions since they don't return the sheet. Find Stripe customer ID in SJ_Student_Signups spreadsheet

func GetEnrollmentSpreadsheet

func GetEnrollmentSpreadsheet() (*spreadsheet.Sheet, error)

func GetFounderMigratedByEmail

func GetFounderMigratedByEmail(email string) (bool, error)

Find founder by email address in migrated spreadsheet

func GetFounderMigratedSpreadsheet

func GetFounderMigratedSpreadsheet() (*spreadsheet.Sheet, error)

func GetMmTransactionsSpreadsheet

func GetMmTransactionsSpreadsheet() (*spreadsheet.Sheet, error)

func GetSpreadsheet

func GetSpreadsheet(sheetId string, sheetNum int, name string) (*spreadsheet.Sheet, error)

* Functions

func GetStripeIdByEmail

func GetStripeIdByEmail(email string) (string, error)

func HasActiveSubscription

func HasActiveSubscription(c *stripe.Customer) bool

func IsBillingComplete

func IsBillingComplete(c *stripe.Customer) bool

Checks the 'sj_billing_complete' metadata field in Stripe

func IsFounder

func IsFounder(c *stripe.Customer) bool

Checks the 'sj_founder' metadata field in Stripe

func IsFounderPlan

func IsFounderPlan(planIdOrName string) bool

Types

type StudentBillingPayment

type StudentBillingPayment struct {
	Amount      float32 `json:"amount"`
	IsRefund    bool    `json:"is_refund"`
	Description string  `json:"description"`
	Date        string  `json:"date"`
	Source      string  `json:"source"`
}

type StudentBillingStatus

type StudentBillingStatus struct {
	MmId                    string  `json:"mm_id"`
	Email                   string  `json:"email"`
	Name                    string  `json:"name"`
	Phone                   string  `json:"phone"`
	Country                 string  `json:"country"`
	StripeId                string  `json:"stripe_id"`
	IsFounder               bool    `json:"is_founder"`
	IsComplete              bool    `json:"is_complete"`
	IsMigratedFounder       bool    `json:"is_migrated_founder"`
	LifeTimeValue           float32 `json:"ltv"`
	ExpectedLifeTimeValue   float32 `json:"expected_ltv"`
	RemainingLifeTimeValue  float32 `json:"remaining_ltv"`
	PaymentCount            int32   `json:"payment_count"`
	RemainingPaymentCount   int32   `json:"remaining_payment_count"`
	HasPackagePayment       bool    `json:"has_package_payment"`
	HasPaymentsRemaining    bool    `json:"has_payments_remaining"`
	HasActiveSubscription   bool    `json:"has_active_subscription"`
	HasCanceledSubscription bool    `json:"has_canceled_subscription"`

	Payments           []StudentBillingPayment     `json:"payments"`
	ActiveSubscription *StudentBillingSubscription `json:"active_subscription"`
}

Student payment data for Studio Journey

func GetBillingStatus

func GetBillingStatus(email string) (*StudentBillingStatus, error)

type StudentBillingSubscription

type StudentBillingSubscription struct {
	Amount      float32 `json:"amount"`
	Description string  `json:"description"`
	CreatedDate string  `json:"created_date"` // MM is just an estimate
}

type StudentStatus

type StudentStatus struct {
	Email                   string `json:"email"`
	FirstName               string `json:"first_name"`
	LastName                string `json:"last_name"`
	Plan                    string `json:"plan"`
	PlanHuman               string `json:"plan_human"`
	Status                  string `json:"status"`
	StatusHuman             string `json:"status_human"`
	IsFounder               bool   `json:"is_founder"`
	IsPackage               bool   `json:"is_package"`
	IsRecurring             bool   `json:"is_recurring"`
	IsPaymentPlan           bool   `json:"is_payment_plan"`
	IsRefunded              bool   `json:"is_refunded"`
	IsOverdue               bool   `json:"is_overdue"`
	IsBillingComplete       bool   `json:"is_billing_complete"`
	IsBillingActive         bool   `json:"is_billing_active"`
	RecurringPrice          uint64 `json:"recurring_price"`
	BillingCycleAnchor      int64  `json:"billing_cycle_anchor"`
	BillingCycleAnchorHuman string `json:"billing_cycle_anchor_human"`
	DaysUntilDue            uint64 `json:"days_until_due"`
	Created                 int64  `json:"created"`
	Start                   int64  `json:"start"`
	Ended                   int64  `json:"ended_at"`
	PeriodStart             int64  `json:"period_start"`
	PeriodEnd               int64  `json:"period_end"`
	DaysUntilEndOfPeriod    uint64 `json:"days_until_end_of_period"`
	NextBillHuman           string `json:"next_bill_human"`
	BillingInterval         string `json:"billing_interval"`
	BillingIntervalCount    uint64 `json:"billing_interval_count"`
	GracePeriodDaysLeft     uint64 `json:"grace_period_days_left"`
	Canceled                int64  `json:"canceled_at"`
	CancelAtEndOfPeriod     bool   `json:"cancel_at_end_of_period"`
	EnrolledDuration        int64  `json:"enrolled_duration"`
	EnrolledDurationHuman   string `json:"enrolled_duration_human"`
	CustomerId              string `json:"customer_id"`
	TrialEnd                int64  `json:"trial_end"`
	TrialStart              int64  `json:"trial_start"`
	IsTrial                 bool   `json:"is_trial"`
	TrialDaysLeft           uint64 `json:"trial_days_left"`
	DefaultCardLastFour     string `json:"default_card_last_four"`
	DefaultCardBrand        string `json:"default_card_brand"`
	IsDelinquent            bool   `json:"is_delinquent"`
	BusinessVatId           string `json:"business_vat_id"`
}
  • Student data structures

Json Header of customer SJ status response for billing portal

func GetAccountStatus

func GetAccountStatus(stripeId string) (*StudentStatus, error)

func GetStripeCustomerAccountStatus

func GetStripeCustomerAccountStatus(c *stripe.Customer) (*StudentStatus, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL