|
|
@@ -3123,6 +3123,7 @@ func createTrialSubscription(cid string) (*stripe.Subscription, error) { |
|
|
|
} |
|
|
|
subscriptionParams.AddExpand("latest_invoice.payment_intent") |
|
|
|
s, err := subscription.New(subscriptionParams) |
|
|
|
|
|
|
|
|
|
|
|
return s, err |
|
|
|
} |
|
|
@@ -3217,6 +3218,7 @@ func subscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
// existing instance if possible. It's main purpose is to supply a |
|
|
|
// client secret used for sending billing information to stripe. |
|
|
|
func trialSubscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
stripe.Key = os.Getenv("STRIPE_SECRET_KEY") |
|
|
|
claims, err := getClaims(r) |
|
|
|
user, err := queryUser(db, claims.Id) |
|
|
|
|
|
|
@@ -3258,6 +3260,7 @@ func trialSubscribe(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
user.Sub.Start = int(s.CurrentPeriodStart) |
|
|
|
user.Sub.ClientSecret = s.LatestInvoice.PaymentIntent.ClientSecret |
|
|
|
user.Sub.PaymentStatus = string(s.LatestInvoice.PaymentIntent.Status) |
|
|
|
user.Sub.Status = string(s.Status) |
|
|
|
|
|
|
|
// Inserting from here is unnecessary and confusing because |
|
|
|
// new subs are already handled by the stripe hook. It remains for |
|
|
|