{"id":28254957,"url":"https://github.com/chargebee/chargebee-go","last_synced_at":"2026-02-23T11:34:37.490Z","repository":{"id":33851962,"uuid":"136480914","full_name":"chargebee/chargebee-go","owner":"chargebee","description":"Go library for the Chargebee API.","archived":false,"fork":false,"pushed_at":"2026-02-16T08:52:59.000Z","size":1796,"stargazers_count":25,"open_issues_count":13,"forks_count":25,"subscribers_count":31,"default_branch":"master","last_synced_at":"2026-02-16T16:29:30.736Z","etag":null,"topics":["chargebee","go"],"latest_commit_sha":null,"homepage":" https://apidocs.chargebee.com/docs/api?lang=go","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/chargebee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-06-07T13:23:38.000Z","updated_at":"2026-02-13T11:56:35.000Z","dependencies_parsed_at":"2023-10-13T00:02:44.677Z","dependency_job_id":"b26357d8-5c7b-4460-821a-fb720101a0eb","html_url":"https://github.com/chargebee/chargebee-go","commit_stats":{"total_commits":75,"total_committers":17,"mean_commits":4.411764705882353,"dds":0.76,"last_synced_commit":"9ed3cf982e743719a1ff4744715c0064a8060922"},"previous_names":[],"tags_count":106,"template":false,"template_full_name":null,"purl":"pkg:github/chargebee/chargebee-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chargebee","download_url":"https://codeload.github.com/chargebee/chargebee-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chargebee%2Fchargebee-go/sbom","scorecard":{"id":274114,"data":{"date":"2025-08-11","repo":{"name":"github.com/chargebee/chargebee-go","commit":"3124f5997646b871754bbafb0dc17be992484c21"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":1,"reason":"Found 3/28 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":4,"reason":"3 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":4,"reason":"SAST tool is not run on all commits -- score normalized to 4","details":["Warn: 2 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T14:03:01.160Z","repository_id":33851962,"created_at":"2025-08-17T14:03:01.160Z","updated_at":"2025-08-17T14:03:01.160Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29741632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["chargebee","go"],"created_at":"2025-05-19T20:16:34.211Z","updated_at":"2026-02-23T11:34:37.444Z","avatar_url":"https://github.com/chargebee.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chargebee Go Client Library\n\n\u003e [!NOTE]\n\u003e [![Join Discord](https://img.shields.io/badge/Discord-Early%20Access-blue?logo=discord\u0026logoColor=white)](https://discord.gg/S3SXDzXHAg)\n\u003e\n\u003e We are trialing a Discord server for developers building with Chargebee. Limited spots are open on a first-come basis. Join [here](https://discord.gg/gpsNqnhDm2) if interested.\n\n\nThis is the official Go library for integrating with Chargebee\n- 📘 For a complete reference of available APIs, check out our [API Documentation](https://apidocs.chargebee.com/docs/api/?lang=go).  \n- 🧪 To explore and test API capabilities interactively, head over to our [API Explorer](https://api-explorer.chargebee.com).\n\n**Go version**: v3 and v2 of the library require Go v1.3 or higher.\n\n## Library versions\n***\n\nThe versioning scheme of this library is inspired by [SemVer](https://semver.org/) and the format is `v{MAJOR}.{MINOR}.{PATCH}`. For example, `v3.0.0` and `v2.5.1` are valid library versions.\n\nThe following table provides some details for each major version:\n\n| Library major version | Status   | Compatible API versions                                                                             | **Branch**        |\n|----------------------------|----------|-----------------------------------------------------------------------------------------------------|---------------|\n| v3                         | Active   | [v2](https://apidocs.chargebee.com/docs/api/v2?lang=go) and [v1](https://apidocs.chargebee.com/docs/api/v1?lang=go) | `master`      |\n| v2                         | Inactive | [v2](https://apidocs.chargebee.com/docs/api/v2?lang=go) and [v1](https://apidocs.chargebee.com/docs/api/v1?lang=go) | `chargebee-v2`|\n\n\nA couple of terms used in the above table are explained below:\n- **Status**: The current development status for the library version. An **Active** major version is currently being maintained and continues to get backward-compatible changes.\n- **Branch**: The branch in this repository containing the source code for the latest release of the library version. Every version of the library has been [tagged](https://github.com/chargebee/chargebee-go/tags). You can check out the source code for any version using its tag.\n\n🔴 **Attention**: The support for v2 will eventually be discontinued on **December 31st 2023** and will no longer receive any further updates. We strongly recommend [upgrading to v3](https://github.com/chargebee/chargebee-go/wiki/Migration-guide-for-v3) as soon as possible.\n\n**Note:** See the [changelog](CHANGELOG.md) for a history of changes.\n\n## Install the library\n***\n\nInstall the latest version of the library with the following commands:\n\n### Install v3\n``` shell\ngo get github.com/chargebee/chargebee-go/v3\n```\n\n### Install v2\n``` shell\ngo get github.com/chargebee/chargebee-go\n```\n\n\n## Use the library\n***\n\nSome examples for using the library are listed below.\n\n### Create a customer and subscription\n\n```go\nimport (\n  \"fmt\"\n  \"github.com/chargebee/chargebee-go/v3\"\n  subscriptionAction \"github.com/chargebee/chargebee-go/v3/actions/subscription\"\n  \"github.com/chargebee/chargebee-go/v3/models/subscription\"\n)\n\nfunc main() {\n  chargebee.Configure(\"{site_api_key}\", \"{site}\")\n  res, err := subscriptionAction.Create(\u0026subscription.CreateRequestParams{\n    PlanId:         \"cbdemo_grow\",\n    BillingCycles:  chargebee.Int32(3),\n    AutoCollection: enum.AutoCollectionOff,\n    Customer: \u0026subscription.CreateCustomerParams{\n      Email:          \"john@user.com\",\n      FirstName:      \"John\",\n      LastName:       \"Doe\",\n      Locale:         \"fr-CA\",\n      Phone:          \"+1-949-999-9999\",\n      AutoCollection: enum.AutoCollectionOff,\n    }}).Request()\n  if err != nil {\n    panic(err)\n  }else{\n     Subscription := res.Subscription\n     Customer := res.Customer\n     Invoice := res.Invoice\n  }\n}\n```\n\n### Create a subscription with addons, metadata, and coupons\n\n```go\nimport (\n  \"fmt\"\n  \"github.com/chargebee/chargebee-go/v3\"\n  subscriptionAction \"github.com/chargebee/chargebee-go/v3/actions/subscription\"\n  \"github.com/chargebee/chargebee-go/v3/models/subscription\"\n)\n\nfunc main() {\n  chargebee.Configure(\"{site_api_key}\", \"{site}\")\n  res, err := subscriptionAction.Create(\u0026subscription.CreateRequestParams{\n    PlanId:         \"cbdemo_grow\",\n    BillingCycles:  chargebee.Int32(3),\n    AutoCollection: enum.AutoCollectionOff,\n    Customer: \u0026subscription.CreateCustomerParams{\n      Email:          \"john@user.com\",\n      FirstName:      \"John\",\n      LastName:       \"Doe\",\n      Locale:         \"fr-CA\",\n      Phone:          \"+1-949-999-9999\",\n      AutoCollection: enum.AutoCollectionOff,\n    },\n    BillingAddress: \u0026subscription.CreateBillingAddressParams{\n      FirstName: \"John\",\n      LastName:  \"Doe\",\n      Line1:     \"PO Box 9999\",\n      City:      \"Walnut\",\n      State:     \"California\",\n      Zip:       \"91789\",\n      Country:   \"US\",\n    },\n    MetaData: map[string]interface{}{\n      \"features\": map[string]interface{}{\n        \"usage-limit\":        \"5GB\",\n        \"speed-within-quota\": \"2MBbps\",\n        \"post-usage-quota\":   \"512kbps\",\n      },\n    },\n    Addons: []*subscription.CreateAddonParams{\n      {\n        Id: \"cbdemo_conciergesupport\",\n      },\n      {\n        Id:       \"cbdemo_additionaluser\",\n        Quantity: chargebee.Int32(2),\n      },\n    },\n    CouponIds: []string{\"cbdemo_earlybird\"},\n  }).Request()\n  if err != nil {\n    panic(err)\n  }else{\n  Subscription := res.Subscription\n  Customer := res.Customer\n  Card := res.Card\n  Invoice := res.Invoice\n  UnbilledCharges := res.UnbilledCharges\n  }\n}\n```\n\n### Create a subscription with custom headers, custom fields and custom context\n\n```go\nimport (\n  \"fmt\"\n  \"github.com/chargebee/chargebee-go/v3\"\n  subscriptionAction \"github.com/chargebee/chargebee-go/v3/actions/subscription\"\n  \"github.com/chargebee/chargebee-go/v3/models/subscription\"\n)\n\nfunc main() {\n  chargebee.Configure(\"{site_api_key}\", \"{site}\")\n  res, err := subscriptionAction.Create(\u0026subscription.CreateRequestParams{\n    PlanId: \"cbdemo_grow\",\n  }).Headers(\"chargebee-request-origin-ip\", \"192.168.1.2\").Contexts(ctx).AddParams(\"cf_gender\",\"Female\").Request() // Customer level custom field. \n  if err != nil {\n    panic(err)\n  }else{\n  Subscription := res.Subscription\n  Customer := res.Customer\n  Card := res.Card\n  Invoice := res.Invoice\n  UnbilledCharges := res.UnbilledCharges\n  }\n}\n```\n\n### Retrieve a filtered list of subscriptions\n\n```go\nimport (\n  \"fmt\"\n  \"github.com/chargebee/chargebee-go/v3\"\n  subscriptionAction \"github.com/chargebee/chargebee-go/v3/actions/subscription\"\n  \"github.com/chargebee/chargebee-go/v3/filter\"\n  \"github.com/chargebee/chargebee-go/v3/models/subscription\"\n)\n\nfunc main() {\n  chargebee.Configure(\"{site_api_key}\", \"{site}\")\n  res, err := subscriptionAction.List(\u0026subscription.ListRequestParams{\n    Limit: chargebee.Int32(5),\n    Id: \u0026filter.StringFilter{\n      In: []string{\"cbdemo_john-sub\", \"cbdemo_ricky-sub\"},\n    },\n    PlanId: \u0026filter.StringFilter{\n      IsNot: \"basic\",\n    },\n    Status: \u0026filter.EnumFilter{\n      Is: subscriptionEnum.StatusActive,\n    },\n    SortBy: \u0026filter.SortFilter{\n      Asc: \"created_at\",\n    },\n  }).ListRequest()\n  if err != nil {\n    panic(err)\n  }else{\n  for i := range res.List {\n    Subscription := res.List[i].Subscription\n    Customer := res.List[i].Customer\n    Card := res.List[i].Card\n  }\n  }\n}\n```\n\n### Create an idempotent request\n\n[Idempotency keys](https://apidocs.chargebee.com/docs/api/idempotency?prod_cat_ver=2) are passed along with request headers to allow a safe retry of POST requests. \n\n```go\nimport (\n\t\"fmt\"\n\t\"github.com/chargebee/chargebee-go/v3\"\n\tcustomerAction \"github.com/chargebee/chargebee-go/v3/actions/customer\"\n\t\"github.com/chargebee/chargebee-go/v3/models/customer\"\n)\n\nfunc main() {\n    chargebee.Configure(\"{site_api_key}\", \"{site}\")\n\tres, err := customerAction.Create(\u0026customer.CreateRequestParams{\n\t\tFirstName: \"John\",\n\t\tLastName:  \"Doe\",\n\t\tEmail:     \"john@test.com\",\n\t})\n\t.SetIdempotencyKey(\"ghggh\") // Replace \u003c\u003cUUID\u003e\u003e with a unique string\n\t.Request()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t} else {\n\t\tCustomer := res.Customer\n\t\tfmt.Println(Customer)\n\t}\n  headerValue := res.GetResponseHeaders() // Retrieves response headers\n\tfmt.Println(headerValue)\n  idempotencyReplayedValue := res.IsIdempotencyReplayed()// Retrieves idempotency replayed header value \n  fmt.Println(idempotencyReplayedValue)\n}\n```\n`IsIdempotencyReplayed()` method can be accessed to differentiate between original and replayed requests.\n\n### Handle webhooks\n\nUse the `webhook` package to parse and route webhook payloads from Chargebee.\n\nHigh-level: route events with callbacks using `WebhookHandler`:\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/chargebee/chargebee-go/v3/webhook\"\n)\n\nfunc main() {\n\thandler := \u0026webhook.WebhookHandler{\n\t\t// Optional: protect endpoint (e.g., Basic Auth)\n\t\tRequestValidator: webhook.BasicAuthValidator(func(user, pass string) bool {\n\t\t\treturn user == \"admin\" \u0026\u0026 pass == \"secret\"\n\t\t}),\n\t\tOnError: webhook.BasicAuthErrorHandler, // Optional: standard auth error responses\n\n\t\t// Register only the events you care about\n\t\tOnSubscriptionCreated: func(e webhook.SubscriptionCreatedEvent) error {\n\t\t\tlog.Printf(\"Subscription created event %s\", e.Id)\n\t\t\treturn nil\n\t\t},\n\t\tOnPaymentSucceeded: func(e webhook.PaymentSucceededEvent) error {\n\t\t\tlog.Printf(\"Payment succeeded for customer: %v\", e.Content.Customer)\n\t\t\treturn nil\n\t\t},\n\t}\n\n\thttp.Handle(\"/chargebee/webhooks\", handler.HTTPHandler())\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\nLow-level: parse just the event type and unmarshal yourself:\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\n\t\"github.com/chargebee/chargebee-go/v3/enum\"\n\t\"github.com/chargebee/chargebee-go/v3/webhook\"\n)\n\nfunc cbWebhook(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\tbody, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tevtType, err := webhook.ParseEventType(body) // validates api_version too\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tswitch evtType {\n\tcase enum.EventTypeSubscriptionCreated:\n\t\tvar e webhook.SubscriptionCreatedEvent\n\t\tif err := json.Unmarshal(body, \u0026e); err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\t// handle e\n\tdefault:\n\t\t// ignore or log\n\t}\n\tw.WriteHeader(http.StatusOK)\n}\n```\n\n#### Unhandled events\n\nBy default, if an incoming webhook’s event type is unknown or you have not registered a corresponding handler on `WebhookHandler`, the SDK treats it as an error. When using `HTTPHandler()`, this results in a 500 response unless you provide a custom `OnError` handler.\n\nIf you prefer to acknowledge unknown/unregistered events (return 200) and just log them, set `OnUnhandledEvent` to a function that returns `nil`:\n\n```go\nimport (\n\t\"log\"\n\t\"github.com/chargebee/chargebee-go/v3/enum\"\n\t\"github.com/chargebee/chargebee-go/v3/webhook\"\n)\n\nhandler := \u0026webhook.WebhookHandler{\n\tOnUnhandledEvent: func(t enum.EventType, body []byte) error {\n\t\tlog.Printf(\"Ignoring unhandled event: %s\", t)\n\t\treturn nil // swallow as OK\n\t},\n}\n```\n\n## Use the test suite\n***\nUse [Testify's `require`](https://github.com/stretchr/testify/#require-package) package to run the test suite\n\n```shell\ngo get github.com/stretchr/testify/require\n```\n\n## Handle errors\n***\n\n```go\n_,err := //Go Library call \n\nif err != nil {\n  if goErr,ok := err.(*chargebee.Error); ok {\n\n    //Identify the type of Error \n    switch goErr.Type {\n      \n    case chargebee.PaymentError:\n      // First check for card parameters entered by the user.\n        // We recommend you to validate the input at the client side itself to catch simple mistakes.\n        if goErr.Param == \"card[number]\" {\n          // Ask your user to recheck the card number. A better way is to use \n          // Stripe's https://github.com/stripe/jquery.payment for validating it in the client side itself.  \n          //}else if(goErr.Param == \u0026lt;other card params\u0026gt;){ \n            //Similarly check for other card parameters entered by the user.\n            //....\n        } else {\n            // Verfication or processing failures.\n            // Provide a standard message to your user to recheck his card details or provide a different card.\n            // Like  'Sorry,there was a problem when processing your card, please check the details and try again'. \n        }\n\n      case chargebee.InvalidRequestError:\n        // For coupons you could decide to provide specific messages by using \n        // the 'api_error_code' attribute in the ex.\n        if goErr.Param == \"coupon\" {\n          if goErr.APIErrorCode == \"resource_not_found\" {\n            // Inform user to recheck his coupon code.\n          } else if goErr.APIErrorCode == \"resource_limit_exhausted\" {\n            // Inform user that the coupon code has expired.\n          } else if goErr.APIErrorCode == \"invalid_request\" {\n            // Inform user that the coupon code is not applicable for his plan(/addons).\n          } else {\n            // Inform user to recheck his coupon code.\n          }\n        } else {\n          // Since you would have validated all other parameters on your side itself, \n          // this could probably be a bug in your code. Provide a generic message to your users.\n        }\n\n    case chargebee.OperationFailedError:\n      // Indicates that the request parameters were right but the request couldn't be completed.\n        // The reasons might be \"api_request_limit_exceeded\" or could be due to an issue in ChargeBee side.\n        // These should occur very rarely and mostly be of temporary nature. \n        // You could ask your user to retry after some time.\n      default :\n        // These are unhandled exceptions (Could be due to a bug in your code or very rarely in client library).\n          // The errors from ChargeBee such as authentication failures will come here.\n            // You could ask users contact your support.     \n    }\n  }\n}\n```\n\n ### Retry Handling\n\nChargebee's SDK includes built-in retry logic to handle temporary network issues and server-side errors. This feature is **disabled by default** but can be **enabled when needed**.\n\n#### Key features include:\n\n- **Automatic retries for specific HTTP status codes**: Retries are automatically triggered for status codes `500`, `502`, `503`, and `504`.\n- **Exponential backoff**: Retry delays increase exponentially to prevent overwhelming the server.\n- **Rate limit management**: If a `429 Too Many Requests` response is received with a `Retry-After` header, the SDK waits for the specified duration before retrying.\n  \u003e *Note: Exponential backoff and max retries do not apply in this case.*\n- **Customizable retry behavior**: Retry logic can be configured using the `retryConfig` parameter in the environment configuration.\n\n#### Example: Customizing Retry Logic\n\nYou can enable and configure the retry logic by passing a `retryConfig` object when initializing the Chargebee environment:\n\n```go\nimport (\n\"fmt\"\n\"github.com/chargebee/chargebee-go/v3\"\ncustomerAction \"github.com/chargebee/chargebee-go/v3/actions/customer\"\n\"github.com/chargebee/chargebee-go/v3/models/customer\"\n)\n\nfunc main() {\n    chargebee.Configure(\"{site_api_key}\", \"{site}\")\n    retryConfig := \u0026chargebee.RetryConfig{\n        Enabled:       true,\n        MaxRetries:    3,\n\t\tDelayMs:   500,\n        RetryOn: map[int]struct{}{500: {}, 503: {}},\n    }\n    chargebee.WithRetryConfig(retryConfig)\n}\n\n// ... your Chargebee API operations below ...\n\n```\n\n#### Example: Rate Limit retry logic\n\nYou can enable and configure the retry logic for rate-limit by passing a `retryConfig` object when initializing the Chargebee environment:\n\n```go\nimport (\n\"fmt\"\n\"github.com/chargebee/chargebee-go/v3\"\ncustomerAction \"github.com/chargebee/chargebee-go/v3/actions/customer\"\n\"github.com/chargebee/chargebee-go/v3/models/customer\"\n)\n\nfunc main() {\n    chargebee.Configure(\"{site_api_key}\", \"{site}\")\n    retryConfig := \u0026chargebee.RetryConfig{\n        Enabled:       true,\n        MaxRetries:    3,\n        DelayMs:   500,\n        RetryOn: map[int]struct{}{429: {}},\n    }\n    chargebee.WithRetryConfig(retryConfig)\n}\n\n// ... your Chargebee API operations below ...\n\n```\n\n## Contribution\n***\nYou may contribute patches to any of the **Active** versions of this library. To do so, raise a PR against the [respective branch](#library-versions).\n\nIf you find something amiss, you are welcome to create an [issue](https://github.com/chargebee/chargebee-go/issues).\n\n## API documentation\n***\n\nThe API documentation for the Go library can be found in our [API reference](https://apidocs.chargebee.com/docs/api?lang=go).\n\n## License\n***\n\nSee the [LICENSE](LICENSE).\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchargebee%2Fchargebee-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchargebee%2Fchargebee-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchargebee%2Fchargebee-go/lists"}