Self-hosted in-product purchase (#21804)

* Self-hosted admins can purchase licenses in-app when `ServiceSettings,SelfHostedPurchase` is true (the default)
* Content Security Policy enables loading assets from `js.stripe.com/v3` when `ServiceSettings.SelfHostedPurchase` is true (the default).
* Add `hosted_customer` API subpath
* Add status of SelfHostedPurchase to telemetry config report.
* Support showing admins self-hosted invoices when `ServiceSettings.SelfHostedPurchase` is true (the default)

Co-authored-by: Conor Macpherson <116016004+ConorMacpherson@users.noreply.github.com>
Этот коммит содержится в:
Nathaniel Allred
2022-12-13 13:36:18 -06:00
коммит произвёл GitHub
родитель 6fd174a95f
Коммит a8fa3f29e9
16 изменённых файлов: 551 добавлений и 29 удалений

Просмотреть файл

@@ -33,7 +33,15 @@ type CloudInterface interface {
GetLicenseRenewalStatus(userID, token string) error
InvalidateCaches() error
// hosted customer methods
SelfHostedSignupAvailable() error
BootstrapSelfHostedSignup(req model.BootstrapSelfHostedSignupRequest) (*model.BootstrapSelfHostedSignupResponse, error)
CreateCustomerSelfHostedSignup(req model.SelfHostedCustomerForm, requesterEmail string) (*model.SelfHostedSignupCustomerResponse, error)
ConfirmSelfHostedSignup(req model.SelfHostedConfirmPaymentMethodRequest, requesterEmail string) (*model.SelfHostedSignupConfirmResponse, error)
ConfirmSelfHostedSignupLicenseApplication() error
GetSelfHostedInvoices() ([]*model.Invoice, error)
GetSelfHostedInvoicePDF(invoiceID string) ([]byte, string, error)
CreateOrUpdateSubscriptionHistoryEvent(userID string, userCount int) (*model.SubscriptionHistory, error)
HandleLicenseChange() error
}

Просмотреть файл

@@ -74,6 +74,43 @@ func (_m *CloudInterface) ConfirmCustomerPayment(userID string, confirmRequest *
return r0
}
// ConfirmSelfHostedSignup provides a mock function with given fields: req, requesterEmail
func (_m *CloudInterface) ConfirmSelfHostedSignup(req model.SelfHostedConfirmPaymentMethodRequest, requesterEmail string) (*model.SelfHostedSignupConfirmResponse, error) {
ret := _m.Called(req, requesterEmail)
var r0 *model.SelfHostedSignupConfirmResponse
if rf, ok := ret.Get(0).(func(model.SelfHostedConfirmPaymentMethodRequest, string) *model.SelfHostedSignupConfirmResponse); ok {
r0 = rf(req, requesterEmail)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.SelfHostedSignupConfirmResponse)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(model.SelfHostedConfirmPaymentMethodRequest, string) error); ok {
r1 = rf(req, requesterEmail)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ConfirmSelfHostedSignupLicenseApplication provides a mock function with given fields:
func (_m *CloudInterface) ConfirmSelfHostedSignupLicenseApplication() error {
ret := _m.Called()
var r0 error
if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf()
} else {
r0 = ret.Error(0)
}
return r0
}
// CreateCustomerPayment provides a mock function with given fields: userID
func (_m *CloudInterface) CreateCustomerPayment(userID string) (*model.StripeSetupIntent, error) {
ret := _m.Called(userID)
@@ -97,6 +134,29 @@ func (_m *CloudInterface) CreateCustomerPayment(userID string) (*model.StripeSet
return r0, r1
}
// CreateCustomerSelfHostedSignup provides a mock function with given fields: req, requesterEmail
func (_m *CloudInterface) CreateCustomerSelfHostedSignup(req model.SelfHostedCustomerForm, requesterEmail string) (*model.SelfHostedSignupCustomerResponse, error) {
ret := _m.Called(req, requesterEmail)
var r0 *model.SelfHostedSignupCustomerResponse
if rf, ok := ret.Get(0).(func(model.SelfHostedCustomerForm, string) *model.SelfHostedSignupCustomerResponse); ok {
r0 = rf(req, requesterEmail)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.SelfHostedSignupCustomerResponse)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(model.SelfHostedCustomerForm, string) error); ok {
r1 = rf(req, requesterEmail)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CreateOrUpdateSubscriptionHistoryEvent provides a mock function with given fields: userID, userCount
func (_m *CloudInterface) CreateOrUpdateSubscriptionHistoryEvent(userID string, userCount int) (*model.SubscriptionHistory, error) {
ret := _m.Called(userID, userCount)
@@ -279,6 +339,59 @@ func (_m *CloudInterface) GetLicenseRenewalStatus(userID string, token string) e
return r0
}
// GetSelfHostedInvoicePDF provides a mock function with given fields: invoiceID
func (_m *CloudInterface) GetSelfHostedInvoicePDF(invoiceID string) ([]byte, string, error) {
ret := _m.Called(invoiceID)
var r0 []byte
if rf, ok := ret.Get(0).(func(string) []byte); ok {
r0 = rf(invoiceID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]byte)
}
}
var r1 string
if rf, ok := ret.Get(1).(func(string) string); ok {
r1 = rf(invoiceID)
} else {
r1 = ret.Get(1).(string)
}
var r2 error
if rf, ok := ret.Get(2).(func(string) error); ok {
r2 = rf(invoiceID)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// GetSelfHostedInvoices provides a mock function with given fields:
func (_m *CloudInterface) GetSelfHostedInvoices() ([]*model.Invoice, error) {
ret := _m.Called()
var r0 []*model.Invoice
if rf, ok := ret.Get(0).(func() []*model.Invoice); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.Invoice)
}
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetSelfHostedProducts provides a mock function with given fields: userID
func (_m *CloudInterface) GetSelfHostedProducts(userID string) ([]*model.Product, error) {
ret := _m.Called(userID)
@@ -376,6 +489,20 @@ func (_m *CloudInterface) RequestCloudTrial(userID string, subscriptionID string
return r0, r1
}
// SelfHostedSignupAvailable provides a mock function with given fields:
func (_m *CloudInterface) SelfHostedSignupAvailable() error {
ret := _m.Called()
var r0 error
if rf, ok := ret.Get(0).(func() error); ok {
r0 = rf()
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateCloudCustomer provides a mock function with given fields: userID, customerInfo
func (_m *CloudInterface) UpdateCloudCustomer(userID string, customerInfo *model.CloudCustomerInfo) (*model.CloudCustomer, error) {
ret := _m.Called(userID, customerInfo)