Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
stripe: add Version and default to 2022-11-15 (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmizerany committed Jan 4, 2023
1 parent 6d2351d commit e4a653d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stripe/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ type Client struct {
// KeyPrefix is prepended to all idempotentcy keys. Use a new key prefix
// after deleting test data. It is not recommended for use with live mode.
KeyPrefix string

Version string // default is 2022-11-15
}

func FromEnv() (*Client, error) {
Expand All @@ -208,6 +210,13 @@ func (c *Client) Live() bool {
return IsLiveKey(c.APIKey)
}

func (c *Client) version() string {
if c.Version != "" {
return c.Version
}
return "2022-11-15"
}

func (c *Client) client() *http.Client {
if c.HTTPClient != nil {
return c.HTTPClient
Expand All @@ -234,6 +243,7 @@ func (c *Client) Do(ctx context.Context, method, path string, f Form, out any) e
}
req.SetBasicAuth(c.APIKey, "")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Stripe-Version", c.version())
if f.idempotencyKey != "" {
key := f.idempotencyKey
if c.KeyPrefix != "" {
Expand Down

0 comments on commit e4a653d

Please sign in to comment.