func (sp *stripePayment) GetManagementLink(
	organization *models.Organization,
) (url string, err error) {
	params := &stripe.BillingPortalSessionParams{
		Customer:  stripe.String(organization.CustomerID),
		ReturnURL: stripe.String(fmt.Sprintf("https://%s/", constants.Domain)),
	}
	ps, err := portalsession.New(params)
	if err != nil {
		return "", err
	}
	url = ps.URL
	return url, nil
}
GetManagementLink returns a URL to a management page, for the user
to cancel their subscription.
package payment
import (
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"strconv"
	"strings"
	"time"
	stripe "github.com/stripe/stripe-go/v72"
	portalsession "github.com/stripe/stripe-go/v72/billingportal/session"
	"github.com/stripe/stripe-go/v72/checkout/session"
	"github.com/stripe/stripe-go/v72/customer"
	"github.com/stripe/stripe-go/v72/invoice"
	"github.com/stripe/stripe-go/v72/sub"
	"github.com/stripe/stripe-go/v72/usagerecord"
	"github.com/stripe/stripe-go/v72/webhook"
	"github.com/wearedevx/keystone/api/internal/constants"
	"github.com/wearedevx/keystone/api/pkg/models"
)
var stripeKey string
var stripeWebhookSecret string
var stripeSubscriptionPrice string
var (
	ErrorNotAStripeEvent = errors.New("not a stripe event")
)
func init() {
	stripe.Key = stripeKey
}
type stripePayment struct {
}
func NewStripePayment() Payment {
	return new(stripePayment)
}
func (sp *stripePayment) StartCheckout(
	organization *models.Organization,
	seats int64,
) (sessionID, customerID, url string, err error) {
	organizationID := strconv.FormatUint(uint64(organization.ID), 10)
	name := organization.Name
	email := organization.User.Email
	var cus *stripe.Customer
	var ses *stripe.CheckoutSession
	successUrl := fmt.Sprintf("https://%s/checkout-success?session_id={CHECKOUT_SESSION_ID}", constants.Domain)
	cancelUrl := fmt.Sprintf("https://%s/checkout-cancel?session_id={CHECKOUT_SESSION_ID}", constants.Domain)
	sessionParams := stripe.CheckoutSessionParams{
		SuccessURL:         stripe.String(successUrl),
		CancelURL:          stripe.String(cancelUrl),
		PaymentMethodTypes: stripe.StringSlice([]string{"card"}),
		Mode:               stripe.String(string(stripe.CheckoutSessionModeSubscription)),
		LineItems: []*stripe.CheckoutSessionLineItemParams{
			{
				Price: stripe.String(stripeSubscriptionPrice),
			},
		},
		Params: stripe.Params{
			Metadata: map[string]string{
				"seats":        strconv.FormatInt(seats, 10),
				"organization": organizationID,
			},
		},
	}
	if organization.CustomerID == "" {
		customerParams := stripe.CustomerParams{
			Name:  stripe.String(name),
			Email: stripe.String(email),
		}
		cus, err = customer.New(&customerParams)
		if err != nil {
			goto done
		}
		customerID = cus.ID
	} else {
		customerID = organization.CustomerID
	}
	sessionParams.Customer = stripe.String(customerID)
	sessionParams.ClientReferenceID = stripe.String(
		strconv.FormatUint(uint64(organization.ID), 10),
	)
	ses, err = session.New(&sessionParams)
	if err != nil {
		goto done
	}
	sessionID = ses.ID
	url = ses.URL
done:
	return sessionID, customerID, url, err
}