{"id":13414084,"url":"https://github.com/stripe/stripe-go","last_synced_at":"2026-05-21T02:07:09.607Z","repository":{"id":37502448,"uuid":"20545279","full_name":"stripe/stripe-go","owner":"stripe","description":"Go library for the Stripe API.    ","archived":false,"fork":false,"pushed_at":"2025-05-14T20:05:08.000Z","size":32835,"stargazers_count":2296,"open_issues_count":10,"forks_count":475,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-05-14T21:22:31.836Z","etag":null,"topics":["stripe","stripe-sdk"],"latest_commit_sha":null,"homepage":"https://stripe.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stripe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-06-05T23:38:14.000Z","updated_at":"2025-05-14T17:28:58.000Z","dependencies_parsed_at":"2023-10-30T21:30:23.904Z","dependency_job_id":"1f2bbc16-8f2f-42c6-976c-a04035ccd6ae","html_url":"https://github.com/stripe/stripe-go","commit_stats":{"total_commits":2551,"total_committers":223,"mean_commits":"11.439461883408072","dds":0.7581340650725206,"last_synced_commit":"158552db5c41c88de62a38d3541bb11cdf40d3e4"},"previous_names":["stripe/stripe"],"tags_count":889,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stripe","download_url":"https://codeload.github.com/stripe/stripe-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235686,"owners_count":22036962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stripe","stripe-sdk"],"created_at":"2024-07-30T20:01:57.177Z","updated_at":"2026-04-02T13:50:45.653Z","avatar_url":"https://github.com/stripe.png","language":"Go","funding_links":[],"categories":["第三方API`第三方API 汇总`","Third-party APIs","Go","第三方api","API Clients \u0026 SDKs","第三方API","\u003cspan id=\"第三方api-third-party-apis\"\u003e第三方API Third-party APIs\u003c/span\u003e","Utility"],"sub_categories":["查询语","Utility/Miscellaneous","实用程序/Miscellaneous","HTTP Clients","Official SDKs","Fail injection","Advanced Console UIs","交流","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"# Go Stripe\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/stripe/stripe-go)](https://pkg.go.dev/github.com/stripe/stripe-go/v85)\n[![Build Status](https://github.com/stripe/stripe-go/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stripe/stripe-go/actions/workflows/ci.yml?query=branch%3Amaster)\n\n\u003e [!TIP]\n\u003e Want to chat live with Stripe engineers? Join us on our [Discord server](https://stripe.com/go/discord/go).\n\nThe official [Stripe][stripe] Go client library.\n\n## Requirements\n\nPer our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=go#stripe-sdk-language-version-support-policy), we support the 4 most recent Go versions at the time of release. Currently, that's **Go 1.22+**.\n\nRead more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=go#stripe-sdk-language-version-support-policy\n\n## Installation\n\nMake sure your project is using Go Modules (it will have a `go.mod` file in its\nroot if it already is):\n\n```sh\ngo mod init\n```\n\nThen, reference stripe-go in a Go program with `import`:\n\n```go\nimport (\n\t\"github.com/stripe/stripe-go/v85\"\n\t\"github.com/stripe/stripe-go/v85/customer\"\n)\n```\n\nRun any of the normal `go` commands (`build`/`install`/`test`). The Go\ntoolchain will resolve and fetch the stripe-go module automatically.\n\nAlternatively, you can also explicitly `go get` the package into a project:\n\n```bash\ngo get -u github.com/stripe/stripe-go/v85\n```\n\n## Documentation\n\nFor a comprehensive list of examples, check out the [API documentation][api-docs].\n\nFor details on all the functionality in this library, see the [Go documentation][goref].\n\nBelow are a few simple examples:\n\n### Customers\n\n```go\nsc := stripe.NewClient(apiKey)\nparams := \u0026stripe.CustomerCreateParams{\n\tDescription:      stripe.String(\"Stripe Developer\"),\n\tEmail:            stripe.String(\"gostripe@stripe.com\"),\n\tPreferredLocales: stripe.StringSlice([]string{\"en\", \"es\"}),\n}\n\nc, err := sc.V1Customers.Create(context.TODO(), params)\n```\n\n### PaymentIntents\n\n```go\nsc := stripe.NewClient(apiKey)\nparams := \u0026stripe.PaymentIntentListParams{\n\tCustomer: stripe.String(customer.ID),\n}\n\nfor pi, err := range sc.V1PaymentIntents.List(context.TODO(), params) {\n\t// handle err\n\t// do something\n}\n```\n\n### Events\n\n```go\nsc := stripe.NewClient(apiKey)\nfor e, err := range sc.V1Events.List(context.TODO(), nil) {\n\t// access event data via e.GetObjectValue(\"resource_name_based_on_type\", \"resource_property_name\")\n\t// alternatively you can access values via e.Data.Object[\"resource_name_based_on_type\"].(map[string]interface{})[\"resource_property_name\"]\n\n\t// access previous attributes via e.GetPreviousValue(\"resource_name_based_on_type\", \"resource_property_name\")\n\t// alternatively you can access values via e.Data.PreviousAttributes[\"resource_name_based_on_type\"].(map[string]interface{})[\"resource_property_name\"]\n}\n```\n\nAlternatively, you can use the `event.Data.Raw` property to unmarshal to the\nappropriate struct.\n\n### Authentication with Connect\n\nThere are two ways of authenticating requests when performing actions on behalf\nof a connected account, one that uses the `Stripe-Account` header containing an\naccount's ID, and one that uses the account's keys. Usually the former is the\nrecommended approach. [See the documentation for more information][connect].\n\nTo use the `Stripe-Account` approach, use `SetStripeAccount()` on a `ListParams`\nor `Params` class. For example:\n\n```go\n// For a list request\nlistParams := \u0026stripe.CustomerListParams{}\nlistParams.SetStripeAccount(\"acct_123\")\n```\n\nTo use a key, pass it into `stripe.NewClient`:\n\n```go\nimport (\n\t\"github.com/stripe/stripe-go/v85\"\n)\n\nsc := stripe.NewClient(\"access_token\")\n```\n\n### Google AppEngine\n\nIf you're running the client in a Google AppEngine environment, you'll need to\ncreate a per-request Stripe client since the `http.DefaultClient` is not\navailable. Here's a sample handler:\n\n```go\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"google.golang.org/appengine\"\n\t\"google.golang.org/appengine/urlfetch\"\n\n\t\"github.com/stripe/stripe-go/v85\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tctx := appengine.NewContext(r)\n\thttpClient := urlfetch.Client(ctx)\n\n\tbackends := stripe.NewBackends(httpClient)\n\tsc := stripe.NewClient(\"sk_test_123\", stripe.WithBackends(backends))\n\n\tparams := \u0026stripe.CustomerCreateParams{\n\t\tDescription: stripe.String(\"Stripe Developer\"),\n\t\tEmail:       stripe.String(\"gostripe@stripe.com\"),\n\t}\n\tcustomer, err := sc.V1Customers.Create(ctx, params)\n\tif err != nil {\n\t\tfmt.Fprintf(w, \"Could not create customer: %v\", err)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, \"Customer created: %v\", customer.ID)\n}\n```\n\n## Usage\n\nWhile some resources may contain more/less APIs, the following pattern is\napplied throughout the library for a given resource (like `Customer`).\n\n### With Stripe Client\n\nThe recommended pattern to access all Stripe resources is using `stripe.Client`. Below are some examples of how to use it to access the `Customer` resource.\n\n```go\nimport \"github.com/stripe/stripe-go/v85\"\n\n// Setup\nsc := stripe.NewClient(\"sk_key\")\n// To set backends, e.g. for testing, or to customize use this instead:\n// sc := stripe.NewClient(\"sk_key\", stripe.WithBackends(backends))\n\n// Create\nc, err := sc.V1Customers.Create(context.TODO(), \u0026stripe.CustomerCreateParams{})\n\n// Retrieve\nc, err := sc.V1Customers.Retrieve(context.TODO(), id, \u0026stripe.CustomerRetrieveParams{})\n\n// Update\nc, err := sc.V1Customers.Update(context.TODO(), id, \u0026stripe.CustomerUpdateParams{})\n\n// Delete\nc, err := sc.V1Customers.Delete(context.TODO(), id, \u0026stripe.CustomerDeleteParams{})\n\n// List\nfor c, err := range sc.Customers.List(context.TODO(), \u0026stripe.CustomerListParams{}) {\n\t// handle err\n\t// do something\n}\n```\n\n### `stripe.Client` vs legacy `client.API` pattern\n\nWe introduced `stripe.Client` in v82.1 of the Go SDK. The legacy client pattern used prior to that version (using `client.API`) is still available to use but is marked as deprecated. Review the [migration guide to use stripe.Client](https://github.com/stripe/stripe-go/wiki/Migration-guide-for-Stripe-Client) to help you move from the legacy pattern to `stripe.Client`.\n\n### Without a Client (Legacy)\n\nThe legacy pattern to access Stripe APIs is the \"resource pattern\" shown below. We plan to deprecate this pattern in a future release. Note also that Stripe's V2 APIs are not supported by this pattern.\n\n```go\nimport (\n\t\"github.com/stripe/stripe-go/v85\"\n\t\"github.com/stripe/stripe-go/v85/customer\"\n)\n\n// Setup\nstripe.Key = \"sk_key\"\n\n// Set backend (optional, useful for mocking)\n// stripe.SetBackend(\"api\", backend)\n\n// Create\nc, err := customer.New(\u0026stripe.CustomerParams{})\n\n// Get\nc, err := customer.Get(id, \u0026stripe.CustomerParams{})\n\n// Update\nc, err := customer.Update(id, \u0026stripe.CustomerParams{})\n\n// Delete\nc, err := customer.Del(id, \u0026stripe.CustomerParams{})\n\n// List\ni := customer.List(\u0026stripe.CustomerListParams{})\nfor i.Next() {\n\tc := i.Customer()\n\t// do something\n}\n\nif err := i.Err(); err != nil {\n\t// handle\n}\n```\n\n## Other usage patterns\n\n### Accessing the Last Response\n\nUse `LastResponse` on any `APIResource` to look at the API response that\ngenerated the current object:\n\n```go\ncoupon, err := sc.V1Coupons.Create(...)\nrequestID := coupon.LastResponse.RequestID\n```\n\nSee the definition of [`APIResponse`][apiresponse] for available fields.\n\nNote that where API resources are nested in other API resources, only\n`LastResponse` on the top-level resource is set.\n\n### Automatic Retries\n\nThe library automatically retries requests on intermittent failures like on a\nconnection error, timeout, or on certain API responses like a status `409\nConflict`. [Idempotency keys][idempotency-keys] are always added to requests to\nmake any such subsequent retries safe.\n\nBy default, it will perform up to two retries. That number can be configured\nwith `MaxNetworkRetries`:\n\n```go\nimport (\n\t\"github.com/stripe/stripe-go/v85\"\n)\n\nconfig := \u0026stripe.BackendConfig{\n    MaxNetworkRetries: stripe.Int64(0), // Zero retries\n}\n\nbackends := \u0026stripe.NewBackendWithConfig(config)\nsc := stripe.NewClient(\"sk_key\", stripe.WithBackends(backends))\ncoupon, err := sc.V1Coupons.Create(...)\n```\n\n### Configuring Logging\n\nBy default, the library logs error messages only (which are sent to `stderr`).\nConfigure default logging using the global `DefaultLeveledLogger` variable:\n\n```go\nstripe.DefaultLeveledLogger = \u0026stripe.LeveledLogger{\n    Level: stripe.LevelInfo,\n}\n```\n\nOr on a per-backend basis:\n\n```go\nconfig := \u0026stripe.BackendConfig{\n    LeveledLogger: \u0026stripe.LeveledLogger{\n        Level: stripe.LevelInfo,\n    },\n}\n```\n\nIt's possible to use non-Stripe leveled loggers as well. Stripe expects loggers\nto comply to the following interface:\n\n```go\ntype LeveledLoggerInterface interface {\n\tDebugf(format string, v ...interface{})\n\tErrorf(format string, v ...interface{})\n\tInfof(format string, v ...interface{})\n\tWarnf(format string, v ...interface{})\n}\n```\n\nSome loggers like [Logrus][logrus] and Zap's [SugaredLogger][zapsugaredlogger]\nsupport this interface out-of-the-box so it's possible to set\n`DefaultLeveledLogger` to a `*logrus.Logger` or `*zap.SugaredLogger` directly.\nFor others it may be necessary to write a thin shim layer to support them.\n\n### Expanding Objects\n\nAll [expandable objects][expandableobjects] in stripe-go take the form of a\nfull resource struct, but unless expansion is requested, only the `ID` field of\nthat struct is populated. Expansion is requested by calling `AddExpand` on\nparameter structs. For example:\n\n```go\n//\n// *Without* expansion\n//\nc, _ := sc.V1Charges.Retrieve(context.TODO(), \"ch_123\", nil)\n\nc.Customer.ID    // Only ID is populated\nc.Customer.Name  // All other fields are always empty\n\n//\n// With expansion\n//\np := \u0026stripe.ChargeCreateParams{}\np.AddExpand(\"customer\")\nc, _ = sc.V1Charges.Retrieve(context.TODO(), \"ch_123\", p)\n\nc.Customer.ID    // ID is still available\nc.Customer.Name  // Name is now also available (if it had a value)\n```\n\n### How to use undocumented parameters and properties\n\nstripe-go is a typed library and it supports all public properties or parameters.\n\nStripe sometimes launches private preview features which introduce new properties or parameters that are not immediately public. These will not have typed accessors in the stripe-go library but can still be used.\n\n#### Parameters\n\nTo pass undocumented parameters to Stripe using stripe-go you need to use the `AddExtra()` method, as shown below:\n\n```go\nparams := \u0026stripe.CustomerCreateParams{\n\tEmail: stripe.String(\"jenny.rosen@example.com\")\n}\nparams.AddExtra(\"secret_feature_enabled\", \"true\")\nparams.AddExtra(\"secret_parameter[primary]\",\"primary value\")\nparams.AddExtra(\"secret_parameter[secondary]\",\"secondary value\")\n\ncustomer, err := sc.V1Customer.Create(context.TODO(), params)\n```\n\n#### Properties\n\nYou can access undocumented properties returned by Stripe by querying the raw response JSON object. An example of this is shown below:\n\n```go\ncustomer, _ = sc.V1Charges.Retrieve(context.TODO(), \"cus_1234\", nil);\n\nvar rawData map[string]interface{}\n_ = json.Unmarshal(customer.LastResponse.RawJSON, \u0026rawData)\n\nsecretFeatureEnabled, _ := string(rawData[\"secret_feature_enabled\"].(bool))\n\nsecretParameter, ok := rawData[\"secret_parameter\"].(map[string]interface{})\nif ok {\n\tprimary := secretParameter[\"primary\"].(string)\n\tsecondary := secretParameter[\"secondary\"].(string)\n}\n```\n\nFor `List` and `Search` operations, you can access each resource's `RawJSON` as you iterate\n\n```go\nfor cust, err := range sc.V1Customers.List(context.TODO(), \u0026stripe.CustomerListParams{}) {\n    if err != nil {\n        return err\n    }\n    customerJSON := cust.LastResponse.RawJSON\n    log.Printf(\"Customer JSON: %s\", customerJSON) // {\"id\":\"cus_123\",...}\n}\n```\n\n#### Beta headers\n\nTo access a private preview feature, you will likely need to use a special beta header. If you are using a public preview or private preview SDK version (those with a version `v83.1.0-beta.1` or `v83.1.0-alpha.1`), you can use the `stripe.AddBetaVersion` function as described in [Public Preview SDKs](#public-preview-sdks). With a release version like `v83.1.0`, you can still set a beta header on a per-request basis in your request params as follows:\n\n```go\nparams := \u0026stripe.CustomerCreateParams{\n\t...\n\tParams: stripe.Params{\n\t\tHeaders: http.Header{\n\t\t\t\"Stripe-Version\": []string{\"2025-10-29.preview; beta_feature_1=v3; beta_feature_2=v1\"},\n\t\t},\n\t},\n}\n```\n\n### Webhook signing\n\nStripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it [here](https://stripe.com/docs/webhooks/signatures).\n\n#### Testing Webhook signing\n\nYou can use `stripe.GenerateTestSignedPayload` to mock webhook events that come from Stripe:\n\n```go\npayload := map[string]interface{}{\n\t\"id\":          \"evt_test_webhook\",\n\t\"object\":      \"event\",\n\t\"api_version\": stripe.APIVersion,\n}\ntestSecret := \"whsec_test_secret\"\n\npayloadBytes, err := json.Marshal(payload)\n\nsignedPayload := stripe.GenerateTestSignedPayload(\u0026webhook.UnsignedPayload{Payload: payloadBytes, Secret: testSecret})\nevent, err := stripe.ConstructEvent(signedPayload.Payload, signedPayload.Header, signedPayload.Secret)\n\nif event.ID == payload[\"id\"] {\n\t// Do something with the mocked signed event\n} else {\n\t// Handle invalid event payload\n}\n```\n\n### Writing a Plugin\n\nIf you're writing a plugin that uses the library, we'd appreciate it if you\nidentified using `stripe.SetAppInfo`:\n\n```go\nstripe.SetAppInfo(\u0026stripe.AppInfo{\n\tName:    \"MyAwesomePlugin\",\n\tURL:     \"https://myawesomeplugin.info\",\n\tVersion: \"1.2.34\",\n})\n```\n\nThis information is passed along when the library makes calls to the Stripe\nAPI. Note that while `Name` is always required, `URL` and `Version` are\noptional.\n\n### Telemetry\n\nBy default, the library sends telemetry to Stripe regarding request latency and feature usage. These\nnumbers help Stripe improve the overall latency of its API for all users, and\nimprove popular features.\n\nYou can disable this behavior if you prefer:\n\n```go\nconfig := \u0026stripe.BackendConfig{\n\tEnableTelemetry: stripe.Bool(false),\n}\n```\n\n### Mocking clients for unit tests\n\nTo mock a Stripe client for a unit tests using [GoMock](https://github.com/golang/mock):\n\n1. Generate a `Backend` type mock.\n\n```\nmockgen -destination=mocks/backend.go -package=mocks github.com/stripe/stripe-go/v85 Backend\n```\n\n2. Use the `Backend` mock to initialize and call methods on the client.\n\n```go\n\nimport (\n\t\"example/hello/mocks\"\n\t\"testing\"\n\n\t\"github.com/golang/mock/gomock\"\n\t\"github.com/stretchr/testify/assert\"\n\t\"github.com/stripe/stripe-go/v85\"\n)\n\nfunc UseMockedStripeClient(t *testing.T) {\n\t// Create a mock controller\n\tmockCtrl := gomock.NewController(t)\n\tdefer mockCtrl.Finish()\n\t// Create a mock stripe backend\n\tmockBackend := mocks.NewMockBackend(mockCtrl)\n\tbackends := \u0026stripe.Backends{API: mockBackend}\n\tclient := stripe.NewClient(\"sk_test\", stripe.WithBackends(backends))\n\n\t// Set up a mock call\n\tmockBackend.EXPECT().Call(\"GET\", \"/v1/accounts/acc_123\", gomock.Any(), gomock.Any(), gomock.Any()).\n\t\t// Return nil error\n\t\tReturn(nil).\n\t\tDo(func(method string, path string, key string, params stripe.ParamsContainer, v *stripe.Account) {\n\t\t\t// Set the return value for the method\n\t\t\t*v = stripe.Account{\n\t\t\t\tID: \"acc_123\",\n\t\t\t}\n\t\t}).Times(1)\n\n\t// Call the client method\n\tacc, _ := client.V1Accounts.GetByID(context.TODO(), \"acc_123\", nil)\n\n\t// Asset the result\n\tassert.Equal(t, \"acc_123\", acc.ID)\n}\n```\n\n### Public Preview SDKs\n\nStripe has features in the [public preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-beta.X` suffix like `82.2.0-beta.2`.\nWe would love for you to try these as we incrementally release new features and improve them based on your feedback.\n\nTo install, pick the latest version with the `beta` suffix by reviewing the [releases page](https://github.com/stripe/stripe-go/releases/) and use it in your `go.mod` file:\n\n```\nrequire (\n\t...\n\tgithub.com/stripe/stripe-go/v85 \u003creplace-with-the-version-of-your-choice\u003e\n\t...\n)\n```\n\n\u003e **Note**\n\u003e There can be breaking changes between two versions of the public preview SDKs without a bump in the major version.\n\nSome preview features require a name and version to be set in the `Stripe-Version` header like `feature_beta=v3`. If your preview feature has this requirement, use the `stripe.AddBetaVersion` function (available only in the public preview SDKs):\n\n```go\nstripe.AddBetaVersion(\"feature_beta\", \"v3\")\n```\n\n### Private Preview SDKs\n\nStripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-alpha.X` suffix like `82.2.0-alpha.2`. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-go?tab=readme-ov-file#public-preview-sdks) above and replacing the term `beta` with `alpha`.\n\n### Custom Request\n\n\u003e This feature is only available from version 80 of this SDK.\n\nIf you would like to send a request to an API that is:\n\n- undocumented (like a preview feature), or\n- you prefer to bypass the method definitions in the library and specify your request details directly\n\nYou can use the `rawrequest` package:\n\n```go\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/stripe/stripe-go/v85\"\n\t\"github.com/stripe/stripe-go/v85/form\"\n\t\"github.com/stripe/stripe-go/v85/rawrequest\"\n)\n\nfunc make_raw_request() error {\n\tstripe.Key = \"sk_test_123\"\n\n\tb, err := stripe.GetRawRequestBackend(stripe.APIBackend)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclient := rawrequest.Client{B: b, Key: apiKey}\n\n\tpayload := map[string]interface{}{\n\t\t\"event_name\": \"hotdogs_eaten\",\n\t\t\"payload\": map[string]string{\n\t\t\t\"value\":              \"123\",\n\t\t\t\"stripe_customer_id\": \"cus_Quq8itmW58RMet\",\n\t\t},\n\t}\n\n\t// for a v2 request, json encode the payload\n\tbody, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tv2_resp, err := client.RawRequest(http.MethodPost, \"/v2/billing/meter_events\", string(body), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar v2_response map[string]interface{}\n\terr = json.Unmarshal(v2_resp.RawJSON, \u0026v2_response)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"%#v\\n\", v2_response)\n\n\t// for a v1 request, form encode the payload\n\tformValues := \u0026form.Values{}\n\tform.AppendTo(formValues, payload)\n\tcontent := formValues.Encode()\n\n\tv1_resp, err := client.RawRequest(http.MethodPost, \"/v1/billing/meter_events\", content, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar v1_response map[string]interface{}\n\terr = json.Unmarshal(v1_resp.RawJSON, \u0026v1_response)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"%#v\\n\", v1_response)\n\n\treturn nil\n}\n\n```\n\nSee more examples in the [/example/v2 folder](example/v2).\n\n## Support\n\nNew features and bug fixes are released on the latest major version of the Stripe Go client library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.\n\n## Development\n\nPull requests from the community are welcome. If you submit one, please keep\nthe following guidelines in mind:\n\n1. Code must be `go fmt` compliant.\n2. All types, structs and funcs should be documented.\n3. Ensure that `just test` succeeds.\n\n[Other contribution guidelines for this project](CONTRIBUTING.md)\n\n## Test\n\nWe use [just](https://github.com/casey/just) for conveniently running development tasks. You can use them directly, or copy the commands out of the `justfile`. To our help docs, run `just`.\n\nThis package depends on [stripe-mock][stripe-mock], so make sure to fetch and run it from a\nbackground terminal ([stripe-mock's README][stripe-mock-usage] also contains\ninstructions for installing via Homebrew and other methods):\n\n    go get -u github.com/stripe/stripe-mock\n    stripe-mock\n\nRun all tests:\n\n```sh\njust test\n# or: go test ./...\n```\n\nRun tests for one package:\n\n```sh\njust test ./invoice\n# or: go test ./invoice\n```\n\nRun a single test:\n\n```sh\njust test ./invoice -run TestInvoiceGet\n# or: go test ./invoice -run TestInvoiceGet\n```\n\nFor any requests, bug or comments, please [open an issue][issues] or [submit a\npull request][pulls].\n\n[api-docs]: https://stripe.com/docs/api/?lang=go\n[api-changelog]: https://stripe.com/docs/upgrades\n[apiresponse]: https://godoc.org/github.com/stripe/stripe-go#APIResponse\n[connect]: https://stripe.com/docs/connect/authentication\n[depgomodsupport]: https://github.com/golang/dep/pull/1963\n[expandableobjects]: https://stripe.com/docs/api/expanding_objects\n[goref]: https://pkg.go.dev/github.com/stripe/stripe-go/v85\n[gomodrevert]: https://github.com/stripe/stripe-go/pull/774\n[gomodvsdep]: https://github.com/stripe/stripe-go/pull/712\n[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=go\n[issues]: https://github.com/stripe/stripe-go/issues/new\n[logrus]: https://github.com/sirupsen/logrus/\n[modules]: https://github.com/golang/go/wiki/Modules\n[package-management]: https://code.google.com/p/go-wiki/wiki/PackageManagementTools\n[pulls]: https://github.com/stripe/stripe-go/pulls\n[stripe]: https://stripe.com\n[stripe-mock]: https://github.com/stripe/stripe-mock\n[stripe-mock-usage]: https://github.com/stripe/stripe-mock#usage\n[zapsugaredlogger]: https://godoc.org/go.uber.org/zap#SugaredLogger\n\n\u003c!--\n# vim: set tw=79:\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe%2Fstripe-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstripe%2Fstripe-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe%2Fstripe-go/lists"}