{"id":20290643,"url":"https://github.com/gocardless/gocardless-dotnet","last_synced_at":"2025-04-11T11:02:19.635Z","repository":{"id":14383667,"uuid":"69486425","full_name":"gocardless/gocardless-dotnet","owner":"gocardless","description":"GoCardless .NET Client","archived":false,"fork":false,"pushed_at":"2025-04-04T10:04:37.000Z","size":1382,"stargazers_count":28,"open_issues_count":10,"forks_count":15,"subscribers_count":67,"default_branch":"master","last_synced_at":"2025-04-06T10:03:22.954Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developer.gocardless.com/api-reference/?lang=dotnet","language":"C#","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/gocardless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-28T17:18:04.000Z","updated_at":"2025-04-03T12:46:14.000Z","dependencies_parsed_at":"2024-04-29T10:29:41.107Z","dependency_job_id":"57e40448-8cf8-4959-ada3-dac8fefdf9a8","html_url":"https://github.com/gocardless/gocardless-dotnet","commit_stats":{"total_commits":383,"total_committers":9,"mean_commits":42.55555555555556,"dds":0.2689295039164491,"last_synced_commit":"24c5657e6ffffe16de473a48608f0d288c8fdea6"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fgocardless-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gocardless","download_url":"https://codeload.github.com/gocardless/gocardless-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248381716,"owners_count":21094525,"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":[],"created_at":"2024-11-14T15:08:35.394Z","updated_at":"2025-04-11T11:02:19.627Z","avatar_url":"https://github.com/gocardless.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# .NET Client for the GoCardless API\n\nFor full details of the GoCardless API, see the [API docs](https://developer.gocardless.com/).\n\n[![NuGet](https://img.shields.io/nuget/v/GoCardless.svg)](https://www.nuget.org/packages/GoCardless/)\n[![\u003cGoCardless\u003e](https://github.com/gocardless/gocardless-dotnet/actions/workflows/build_and_publish.yml/badge.svg)](https://github.com/gocardless/gocardless-dotnet/actions)\n\n- [\"Getting started\" guide](https://developer.gocardless.com/getting-started/api/introduction/)\n- [API Reference](https://developer.gocardless.com/api-reference)\n- [NuGet Package](https://www.nuget.org/packages/GoCardless/)\n\n## Installation\n\nTo install `GoCardless`, run the following command in the [Package Manager Console](https://docs.microsoft.com/en-us/nuget/tools/package-manager-console)\n\n`Install-Package GoCardless -Version 7.7.0`\n\n\n## Usage\n\n\u003e Note: This README will use \"customers\" in examples throughout, but every endpoint in the API is available in this library.\n\n### Initialising the client\n\nThe client is initialised with an access token and an environment.\n\n```cs\nvar accessToken = \"your_access_token\";\nvar gocardless = GoCardlessClient.Create(accessToken, Environment.SANDBOX);\n```\n\n### GET requests\n\n#### Individual resources\n\nYou can retrieve individual resources by ID using that resource's `GetAsync` method:\n\n```cs\nvar customerResponse = await gocardless.Customers.GetAsync(\"CU0123\");\nvar customer = customerResponse.Customer;\n```\n\n#### Lists of resources\n\nThere are two ways to list resources. You can either make single requests for lists with `ListAsync`:\n\n```cs\nvar customerRequest = new GoCardless.Services.CustomerListRequest()\n{\n    Limit = 100\n};\n\nvar customerListResponse = await gocardless.Customers.ListAsync(customerRequest);\n\nforeach (var customer in customerListResponse.Customers)\n{\n    Console.WriteLine(customer.GivenName);\n}\n\nConsole.WriteLine(\"Next page cursor: \" +  customerListResponse.Meta.Cursors.After);\n```\n\nor use the lazy pagination offered by `All`:\n\n```cs\nvar customerRequest = new GoCardless.Services.CustomerListRequest()\n{\n    Limit = 100\n};\n\nvar customerListResponse = gocardless.Customers.All(customerRequest);\nforeach (var customer in customerListResponse)\n{\n    Console.WriteLine(customer.GivenName);\n}\n```\n\nThe lazy pagination approach is generally simpler - it automatically makes as many API requests as needed to return\nthe whole list as an enumerable, and you don't need to take care of pagination manually.\n\n### POST/PUT requests\n\nThese work in a similar way to GET requests, and you can initialize a request object with all of the available\nparameters for each endpoint.\n\n*Creating a customer*\n\n```cs\nvar customerRequest = new GoCardless.Services.CustomerCreateRequest()\n{\n    Email = \"user@example.com\",\n    GivenName = \"Frank\",\n    FamilyName = \"Osborne\",\n    AddressLine1 = \"27 Acer Road\",\n    AddressLine2 = \"Apt 2\",\n    City = \"London\",\n    PostalCode = \"E8 3GX\",\n    CountryCode = \"GB\",\n    Metadata = new Dictionary\u003cstring, string\u003e()\n    {\n      {\"salesforce_id\", \"ABCD1234\"}\n    }\n};\n\nvar customerResponse = await gocardless.Customers.CreateAsync(customerRequest);\nvar customer = customerResponse.Customer;\n```\n\n*Updating a customer*\n\n```cs\nvar customerRequest = new GoCardless.Services.CustomerUpdateRequest()\n{\n    Metadata = new Dictionary\u003cstring, string\u003e()\n    {\n        {\"custom_reference\", \"NEWREFERENCE001\"}\n    }\n};\nvar customerResponse = await gocardless.Customers.UpdateAsync(\"CU0123\", customerRequest);\n```\n\nWhen creating a resource, the library will automatically include a randomly-generated\n[idempotency key](https://developer.gocardless.com/api-reference/#making-requests-idempotency-keys)\n- this means that if a request appears to fail but is in fact successful (for example due\nto a timeout), you will not end up creating multiple duplicates of the resource.\n\nYou can provide your own key for any endpoints that support idempotency keys by setting it in\nthe request object:\n\n```cs\nvar customerRequest = new GoCardless.Services.CustomerCreateRequest()\n{\n    Email = \"user@example.com\",\n    IdempotencyKey = \"unique_customer_reference\"\n};\n```\n\n### Setting custom headers\n\nYou shouldn't generally need to customise the headers sent by the library, but you may\nwish to in some cases (for example if you want to send an `Accept-Language` header when\n[creating a mandate PDF](https://developer.gocardless.com/api-reference/#mandate-pdfs-create-a-mandate-pdf)).\n\nTo do this, you can provide `RequestSettings` like this:\n\n```cs\nvar requestSettings = new GoCardless.Internals.RequestSettings\n{\n    Headers = new Dictionary\u003cstring, string\u003e()\n    {\n        {\"Accept-Language\", \"fr\"}\n    }\n};\n\nvar mandatePdfRequest = new GoCardless.Services.MandatePdfsCreateRequest()\n{\n    Iban = \"FR14BARC20000055779911\"\n};\n\nvar mandatePdfResponse = await gocardless.MandatePdfs.CreateAsync(mandatePdfRequest, requestSettings);\n```\n\nCustom headers you specify will override any headers generated by the library itself (for\nexample, an `Authorization` header with your configured access token or an\n`Idempotency-Key` header with a randomly-generated value or one you've configured\nmanually). Custom headers always take precedence.\n\n### Accessing raw response data\n\nYou can retrieve the `System.Net.Http.HttpResponseMessage` from any resource or resource list response:\n\n```cs\nvar customerRequest = new GoCardless.Services.CustomerUpdateRequest()\n{\n    Metadata = new Dictionary\u003cstring, string\u003e()\n    {\n        {\"custom_reference\", \"NEWREFERENCE001\"}\n    }\n};\nvar customerResponse = await gocardless.Customers.UpdateAsync(\"CU0123\", customerRequest);\n\nHttpResponseMessage responseMessage = customerResponse.ResponseMessage;\n```\n\n### Errors\n\nIf the API returns an error response, the client will raise a corresponding Exception.\nThe exceptions are all subclasses of `GoCardless.Exceptions.ApiException`:\n\n- `InternalException`\n- `InvalidApiUsageException`\n- `InvalidStateException`\n- `ValidationFailedException`\n\nThese errors are fully documented in the [API documentation](https://developer.gocardless.com/api-reference/#overview-errors).\n\nThe exceptions have the following properties to facilitate access to information in the API response:\n\n- `string Type`\n- `string DocumentationUrl`\n- `string RequestId`\n- `int Code`\n- `IReadOnlyList\u003cGoCardless.Errors.Error\u003e Errors`\n\n`GoCardless.Errors.Error` provides more specific error messages and reasons from the response.\n\nWhen the API returns an `invalid_state` error due to an `idempotent_creation_conflict` the library will, where possible,\nautomatically retrieve the existing record which was created using the same idempotency key.\n\nIf a timeout occurs, and the request being made is idempotent, the library will automatically retry the request up to 2 more times.\n\n### Support and feedback\n\n- [Developer documentation](https://developer.gocardless.com/)\n- [Developer support](https://support.gocardless.com/hc/en-us/categories/115000140449)\n- api@gocardless.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocardless%2Fgocardless-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgocardless%2Fgocardless-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocardless%2Fgocardless-dotnet/lists"}