Documentation ¶
Index ¶
- Variables
- func AddChangeStudentEmailRow(teachableId string, name string, oldEmail string, newEmail string, ...) error
- func CancelSubscription(c *stripe.Customer) (*stripe.Subscription, error)
- func ChangeStudentEmail(oldEmail string, newEmail string, teachableId string) error
- func GetBillingRowByEmail(email string) ([]spreadsheet.Cell, error)
- func GetBillingSpreadsheet() (*spreadsheet.Sheet, error)
- func GetCancellationSpreadsheet() (*spreadsheet.Sheet, error)
- func GetChangeEmailSpreadsheet() (*spreadsheet.Sheet, error)
- func GetEnrollmentRowByEmail(email string) ([]spreadsheet.Cell, error)
- func GetEnrollmentSpreadsheet() (*spreadsheet.Sheet, error)
- func GetFounderMigratedByEmail(email string) (bool, error)
- func GetFounderMigratedSpreadsheet() (*spreadsheet.Sheet, error)
- func GetMmTransactionsSpreadsheet() (*spreadsheet.Sheet, error)
- func GetSpreadsheet(sheetId string, sheetNum int, name string) (*spreadsheet.Sheet, error)
- func GetStripeIdByEmail(email string) (string, error)
- func HasActiveSubscription(c *stripe.Customer) bool
- func IsBillingComplete(c *stripe.Customer) bool
- func IsFounder(c *stripe.Customer) bool
- func IsFounderPlan(planIdOrName string) bool
- type StudentBillingPayment
- type StudentBillingStatus
- type StudentBillingSubscription
- type StudentStatus
Constants ¶
This section is empty.
Variables ¶
var AccountStatuses = [6]string{"active", "past_due", "canceling", "canceled", "unknown", "complete"}
These are what stripe uses:
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:
var ArtBundleCount = 12 // months
var BillingSpreadsheetCancelCol = 16
var BillingSpreadsheetCompleteCol = 1
var BillingSpreadsheetEmailCol = 3
var BillingSpreadsheetEndedCol = 0
Billing spreadsheet https://docs.google.com/spreadsheets/d/1p_tRygUVmhDNK68fPkKkXZnlvq7D2sQjBmpJ6TwDJUs/edit?usp=sharing
var BillingSpreadsheetFounderCol = 15
var BillingSpreadsheetId = "1p_tRygUVmhDNK68fPkKkXZnlvq7D2sQjBmpJ6TwDJUs"
var BillingSpreadsheetLtvCol = 9
var BillingSpreadsheetPaymentsCol = 8
var CancellationSpreadsheetEmailCol = 2
Cancellation spreadsheet
var CancellationSpreadsheetId = "1EKg0vqz2eaYqL31W1IqkdxuoqZ1FXtGEVXOC_lyfh5E"
var ChangeEmailSpreadsheetAcIdCol = 5
var ChangeEmailSpreadsheetId = "1ZeLSi3-IwVbRiMbPFAvW0et7bjhpwc0yYqTD5xYx8KI"
var ChangeEmailSpreadsheetNameCol = 1
var ChangeEmailSpreadsheetNewEmailCol = 3
var ChangeEmailSpreadsheetOldEmailCol = 2
var ChangeEmailSpreadsheetSourceCol = 7
var ChangeEmailSpreadsheetStripeIdCol = 4
var ChangeEmailSpreadsheetTeachableIdCol = 0
Change email spreadsheet
var ChangeEmailSpreadsheetTimestampCol = 6
var EnrollmentSpreadsheetCancelCol = 18
var EnrollmentSpreadsheetEmailCol = 2
var EnrollmentSpreadsheetId = "1wRHucYoRuGzHav7nK3V5Hv2Z4J67D_vTZN5wjw8aa2k"
Spreadsheet constants
var EnrollmentSpreadsheetNameCol = 1
var EnrollmentSpreadsheetStripeIdCol = 13
Spreadsheet columns (starts from 0) Enrollment/Signup spreadsheet https://docs.google.com/spreadsheets/d/1wRHucYoRuGzHav7nK3V5Hv2Z4J67D_vTZN5wjw8aa2k/edit?usp=sharing
var EnrollmentSpreadsheetUpgradeCol = 19
var FounderMigratedSpreadsheetEmailCol = 2
var FounderMigratedSpreadsheetId = "13xE8UGR03CBEjB0othGm4abv8vDi_d8wD7U1FF2BWUg"
var FounderMonthlyPrice = float32(29.00)
var MmTransactionsSpreadsheetAmountCol = 3
var MmTransactionsSpreadsheetEmailCol = 6
Membermouse transactions spreadsheet https://docs.google.com/spreadsheets/d/1sra-kv8f2ZVLmO9QK3MCfE0IIDIIWm61t2HQcMTdCf8/edit?usp=sharing
var MmTransactionsSpreadsheetId = "1sra-kv8f2ZVLmO9QK3MCfE0IIDIIWm61t2HQcMTdCf8"
var MonthlyPrice = float32(36.00)
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.
var StripeAccountActiveStatuses = []string{"active", "trialing", "unpaid"} // rest are inactive
Stripe account statuses for SJ
Functions ¶
func CancelSubscription ¶
func CancelSubscription(c *stripe.Customer) (*stripe.Subscription, error)
func ChangeStudentEmail ¶
func GetBillingRowByEmail ¶
func GetBillingSpreadsheet ¶
func GetBillingSpreadsheet() (*spreadsheet.Sheet, error)
func GetCancellationSpreadsheet ¶
func GetCancellationSpreadsheet() (*spreadsheet.Sheet, error)
func GetChangeEmailSpreadsheet ¶
func GetChangeEmailSpreadsheet() (*spreadsheet.Sheet, error)
func GetEnrollmentRowByEmail ¶
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 ¶
Find founder by email address in migrated spreadsheet
func GetFounderMigratedSpreadsheet ¶
func GetFounderMigratedSpreadsheet() (*spreadsheet.Sheet, error)
func GetMmTransactionsSpreadsheet ¶
func GetMmTransactionsSpreadsheet() (*spreadsheet.Sheet, error)
func GetSpreadsheet ¶
* Functions
func GetStripeIdByEmail ¶
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 ¶
Types ¶
type StudentBillingPayment ¶
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 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)