diff --git a/handlers/stripe.go b/handlers/stripe.go index a118439feb..667ec01722 100644 --- a/handlers/stripe.go +++ b/handlers/stripe.go @@ -30,6 +30,7 @@ func StripeCreateCheckoutSession(w http.ResponseWriter, r *http.Request) { var req struct { Price string `json:"priceId"` AddonQuantity int64 `json:"addonQuantity"` + PromotionCode string `json:"promotionCode"` } if err := json.NewDecoder(r.Body).Decode(&req); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -159,6 +160,14 @@ func StripeCreateCheckoutSession(w http.ResponseWriter, r *http.Request) { } } + if req.PromotionCode != "" { + params.Discounts = []*stripe.CheckoutSessionDiscountParams{ + { + Coupon: stripe.String(req.PromotionCode), + }, + } + } + s, err := session.New(params) if err != nil { logger.WithError(err).Error("failed to create a new stripe checkout session")