GoCardless 7.7.0

dotnet add package GoCardless --version 7.7.0
                    
NuGet\Install-Package GoCardless -Version 7.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GoCardless" Version="7.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoCardless" Version="7.7.0" />
                    
Directory.Packages.props
<PackageReference Include="GoCardless" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GoCardless --version 7.7.0
                    
#r "nuget: GoCardless, 7.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=GoCardless&version=7.7.0
                    
Install GoCardless as a Cake Addin
#tool nuget:?package=GoCardless&version=7.7.0
                    
Install GoCardless as a Cake Tool

.NET Client for the GoCardless API

For full details of the GoCardless API, see the API docs.

NuGet <GoCardless>

Installation

To install GoCardless, run the following command in the Package Manager Console

Install-Package GoCardless -Version 7.7.0

Usage

Note: This README will use "customers" in examples throughout, but every endpoint in the API is available in this library.

Initialising the client

The client is initialised with an access token and an environment.

var accessToken = "your_access_token";
var gocardless = GoCardlessClient.Create(accessToken, Environment.SANDBOX);

GET requests

Individual resources

You can retrieve individual resources by ID using that resource's GetAsync method:

var customerResponse = await gocardless.Customers.GetAsync("CU0123");
var customer = customerResponse.Customer;
Lists of resources

There are two ways to list resources. You can either make single requests for lists with ListAsync:

var customerRequest = new GoCardless.Services.CustomerListRequest()
{
    Limit = 100
};

var customerListResponse = await gocardless.Customers.ListAsync(customerRequest);

foreach (var customer in customerListResponse.Customers)
{
    Console.WriteLine(customer.GivenName);
}

Console.WriteLine("Next page cursor: " +  customerListResponse.Meta.Cursors.After);

or use the lazy pagination offered by All:

var customerRequest = new GoCardless.Services.CustomerListRequest()
{
    Limit = 100
};

var customerListResponse = gocardless.Customers.All(customerRequest);
foreach (var customer in customerListResponse)
{
    Console.WriteLine(customer.GivenName);
}

The lazy pagination approach is generally simpler - it automatically makes as many API requests as needed to return the whole list as an enumerable, and you don't need to take care of pagination manually.

POST/PUT requests

These work in a similar way to GET requests, and you can initialize a request object with all of the available parameters for each endpoint.

Creating a customer

var customerRequest = new GoCardless.Services.CustomerCreateRequest()
{
    Email = "user@example.com",
    GivenName = "Frank",
    FamilyName = "Osborne",
    AddressLine1 = "27 Acer Road",
    AddressLine2 = "Apt 2",
    City = "London",
    PostalCode = "E8 3GX",
    CountryCode = "GB",
    Metadata = new Dictionary<string, string>()
    {
      {"salesforce_id", "ABCD1234"}
    }
};

var customerResponse = await gocardless.Customers.CreateAsync(customerRequest);
var customer = customerResponse.Customer;

Updating a customer

var customerRequest = new GoCardless.Services.CustomerUpdateRequest()
{
    Metadata = new Dictionary<string, string>()
    {
        {"custom_reference", "NEWREFERENCE001"}
    }
};
var customerResponse = await gocardless.Customers.UpdateAsync("CU0123", customerRequest);

When creating a resource, the library will automatically include a randomly-generated idempotency key

  • this means that if a request appears to fail but is in fact successful (for example due to a timeout), you will not end up creating multiple duplicates of the resource.

You can provide your own key for any endpoints that support idempotency keys by setting it in the request object:

var customerRequest = new GoCardless.Services.CustomerCreateRequest()
{
    Email = "user@example.com",
    IdempotencyKey = "unique_customer_reference"
};

Setting custom headers

You shouldn't generally need to customise the headers sent by the library, but you may wish to in some cases (for example if you want to send an Accept-Language header when creating a mandate PDF).

To do this, you can provide RequestSettings like this:

var requestSettings = new GoCardless.Internals.RequestSettings
{
    Headers = new Dictionary<string, string>()
    {
        {"Accept-Language", "fr"}
    }
};

var mandatePdfRequest = new GoCardless.Services.MandatePdfsCreateRequest()
{
    Iban = "FR14BARC20000055779911"
};

var mandatePdfResponse = await gocardless.MandatePdfs.CreateAsync(mandatePdfRequest, requestSettings);

Custom headers you specify will override any headers generated by the library itself (for example, an Authorization header with your configured access token or an Idempotency-Key header with a randomly-generated value or one you've configured manually). Custom headers always take precedence.

Accessing raw response data

You can retrieve the System.Net.Http.HttpResponseMessage from any resource or resource list response:

var customerRequest = new GoCardless.Services.CustomerUpdateRequest()
{
    Metadata = new Dictionary<string, string>()
    {
        {"custom_reference", "NEWREFERENCE001"}
    }
};
var customerResponse = await gocardless.Customers.UpdateAsync("CU0123", customerRequest);

HttpResponseMessage responseMessage = customerResponse.ResponseMessage;

Errors

If the API returns an error response, the client will raise a corresponding Exception. The exceptions are all subclasses of GoCardless.Exceptions.ApiException:

  • InternalException
  • InvalidApiUsageException
  • InvalidStateException
  • ValidationFailedException

These errors are fully documented in the API documentation.

The exceptions have the following properties to facilitate access to information in the API response:

  • string Type
  • string DocumentationUrl
  • string RequestId
  • int Code
  • IReadOnlyList<GoCardless.Errors.Error> Errors

GoCardless.Errors.Error provides more specific error messages and reasons from the response.

When the API returns an invalid_state error due to an idempotent_creation_conflict the library will, where possible, automatically retrieve the existing record which was created using the same idempotency key.

If a timeout occurs, and the request being made is idempotent, the library will automatically retry the request up to 2 more times.

Support and feedback

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on GoCardless:

Package Downloads
N3O.Umbraco.Payments.GoCardless

TODO

Kartris

Kartris is a free, open source cart system optimized for performance and capable of handling 1,000,000+ SKUs out of the box

N3O.Umbraco.Payments.GoCardless.Core

Support for GoCardless payments.

ActingOffice.Addons.GoCardless

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.7.0 508 7 days ago
7.4.0 6,225 2 months ago
7.3.0 2,349 2 months ago
7.2.0 9,322 4 months ago
7.1.0 4,827 5 months ago
7.0.0 15,593 7 months ago
6.7.0 14,869 8 months ago
6.6.0 6,860 8 months ago
6.5.0 22,038 9 months ago
6.4.0 118 9 months ago
6.3.0 9,930 5/28/2024
6.2.0 2,067 5/23/2024
6.1.0 137 5/22/2024
6.0.2 7,089 5/3/2024
6.0.1 15,078 4/25/2024
6.0.0 140 4/25/2024
5.21.2 424 4/25/2024
5.21.1 11,058 3/20/2024
5.21.0 96,414 1/18/2024
5.20.0 5,208 1/10/2024
5.19.0 4,387 12/11/2023
5.18.0 25,746 10/26/2023
5.17.1 20,436 8/7/2023
5.17.0 18,058 5/15/2023
5.16.0 328 5/11/2023
5.15.0 27,418 4/11/2023
5.14.0 7,997 3/20/2023
5.13.0 23,736 3/16/2023
5.12.1 7,563 2/13/2023
5.12.0 18,804 2/7/2023
5.11.0 42,559 12/22/2022
5.10.0 1,284 12/19/2022
5.9.0 1,640 12/13/2022
5.8.0 330 12/12/2022
5.7.0 79,297 7/22/2022
5.6.0 3,465 7/13/2022
5.5.0 2,058 7/8/2022
5.4.0 5,450 6/29/2022
5.3.0 63,239 4/22/2022
5.2.0 185,485 11/30/2021
5.1.0 3,142 11/22/2021
5.0.2 378 11/22/2021
5.0.1 7,603 10/21/2021
5.0.0 45,712 8/18/2021
4.10.0 2,414 8/12/2021
4.9.0 79,115 5/20/2021
4.8.0 8,469 4/13/2021
4.7.0 10,200 3/2/2021
4.6.0 11,281 1/11/2021
4.5.0 15,397 11/4/2020
4.4.0 23,986 8/18/2020
4.3.0 35,506 7/14/2020
4.2.0 9,424 6/18/2020
4.1.0 1,631 6/1/2020
4.0.0 1,413 5/18/2020
3.7.0 6,952 4/28/2020
3.6.0 6,261 4/20/2020
3.5.2 1,460 4/8/2020
3.5.1 685 4/7/2020
3.5.0 5,132 3/12/2020
3.4.1 51,290 2/26/2020
3.3.1 2,879 2/24/2020
3.3.0 2,168 2/10/2020
3.2.0 846 2/6/2020
3.1.1 9,362 1/29/2020
3.1.0 632 1/28/2020
3.0.1 16,229 12/17/2019
3.0.0 69,173 11/29/2019
2.18.0 11,141 10/25/2019
2.17.0 2,368 10/16/2019
2.16.0 13,670 9/6/2019
2.15.0 8,226 7/26/2019
2.13.0 69,157 1/17/2019
2.12.1 17,191 12/10/2018
2.12.0 10,411 10/10/2018
2.11.1 9,394 8/24/2018
2.11.0 3,084 7/13/2018
2.10.1 8,776 7/5/2018
2.10.0 10,894 6/8/2018
2.9.0 5,981 5/22/2018
2.8.0 2,671 5/17/2018
2.7.0 2,268 4/26/2018
2.6.0 1,877 4/11/2018
2.5.0 1,862 3/16/2018
2.4.0 10,681 12/5/2017
2.3.0 2,259 11/14/2017
2.2.0 5,884 10/25/2017
2.1.1 5,532 9/18/2017
2.1.0 1,380 9/18/2017
2.0.6 13,241 9/1/2017
2.0.5 1,471 8/23/2017
2.0.4 5,530 8/18/2017
2.0.3 3,700 7/21/2017
2.0.2 2,544 7/6/2017