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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6fd174a95f
Коммит
a8fa3f29e9
@@ -8558,6 +8558,72 @@ func (c *Client4) GetNewTeamMembersSince(teamID string, timeRange string, page i
|
||||
return newTeamMembersList, BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) SelfHostedSignupAvailable() (*Response, error) {
|
||||
r, err := c.DoAPIGet(c.hostedCustomerRoute()+"/signup_available", "")
|
||||
|
||||
if err != nil {
|
||||
return BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
return BuildResponse(r), nil
|
||||
}
|
||||
|
||||
func (c *Client4) SelfHostedSignupCustomer(form *SelfHostedCustomerForm) (*Response, *SelfHostedSignupCustomerResponse, error) {
|
||||
payloadBytes, err := json.Marshal(form)
|
||||
if err != nil {
|
||||
return nil, nil, NewAppError("SelfHostedSignupCustomer", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
r, err := c.DoAPIPost(c.hostedCustomerRoute()+"/customer", string(payloadBytes))
|
||||
|
||||
if err != nil {
|
||||
return BuildResponse(r), nil, err
|
||||
}
|
||||
data, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return BuildResponse(r), nil, err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
response := SelfHostedSignupCustomerResponse{}
|
||||
err = json.Unmarshal(data, &response)
|
||||
if err != nil {
|
||||
return BuildResponse(r), nil, err
|
||||
}
|
||||
|
||||
return BuildResponse(r), &response, nil
|
||||
}
|
||||
|
||||
func (c *Client4) SelfHostedSignupConfirm(form *SelfHostedConfirmPaymentMethodRequest) (*Response, *SelfHostedSignupConfirmClientResponse, error) {
|
||||
payloadBytes, err := json.Marshal(form)
|
||||
if err != nil {
|
||||
return nil, nil, NewAppError("SelfHostedSignupConfirm", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
r, err := c.DoAPIPost(c.hostedCustomerRoute()+"/confirm", string(payloadBytes))
|
||||
|
||||
if err != nil {
|
||||
return BuildResponse(r), nil, err
|
||||
}
|
||||
|
||||
data, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return BuildResponse(r), nil, err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
response := SelfHostedSignupConfirmClientResponse{}
|
||||
err = json.Unmarshal(data, &response)
|
||||
if err != nil {
|
||||
return BuildResponse(r), nil, err
|
||||
}
|
||||
|
||||
defer closeBody(r)
|
||||
|
||||
return BuildResponse(r), &response, nil
|
||||
}
|
||||
|
||||
func (c *Client4) GetPostInfo(postId string) (*PostInfo, *Response, error) {
|
||||
r, err := c.DoAPIGet(c.postRoute(postId)+"/info", "")
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user