Mollie 1.4.9
dotnet add package Mollie --version 1.4.9
NuGet\Install-Package Mollie -Version 1.4.9
<PackageReference Include="Mollie" Version="1.4.9" />
<PackageVersion Include="Mollie" Version="1.4.9" />
<PackageReference Include="Mollie" />
paket add Mollie --version 1.4.9
#r "nuget: Mollie, 1.4.9"
#:package Mollie@1.4.9
#addin nuget:?package=Mollie&version=1.4.9
#tool nuget:?package=Mollie&version=1.4.9
Mollie
Developer-friendly & type-safe Csharp SDK specifically catered to leverage Mollie API.
<div align="left"> <a href="https://www.speakeasy.com/?utm_source=mollie&utm_campaign=csharp"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a> <a href="https://opensource.org/licenses/MIT"> <img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" /> </a> </div>
<br /><br />
This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Summary
Table of Contents
SDK Example Usage
Example
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client();
var res = await sdk.Oauth.GenerateAsync(
security: new OauthGenerateTokensSecurity() {
Username = "",
Password = "",
},
idempotencyKey: "123e4567-e89b-12d3-a456-426",
requestBody: new OauthGenerateTokensRequestBody() {
GrantType = OauthGrantType.AuthorizationCode,
Code = "auth_...",
RefreshToken = "refresh_...",
RedirectUri = "https://example.com/redirect",
}
);
// handle response
Authentication
Per-Client Security Schemes
This SDK supports the following security schemes globally:
| Name | Type | Scheme |
|---|---|---|
ApiKey |
http | HTTP Bearer |
AdvancedAccessToken |
http | HTTP Bearer |
OAuth |
oauth2 | OAuth2 token |
You can set the security parameters through the security optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client(
security: new Security() {
ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
},
testmode: false
);
ListBalancesRequest req = new ListBalancesRequest() {
Currency = "EUR",
From = "bal_gVMhHKqSSRYJyPsuoPNFH",
Limit = 50,
IdempotencyKey = "123e4567-e89b-12d3-a456-426",
};
ListBalancesResponse? res = await sdk.Balances.ListAsync(req);
while(res != null)
{
// handle items
res = await res.Next!();
}
Per-Operation Security Schemes
Some operations in this SDK require the security scheme to be specified at the request level. For example:
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client();
var res = await sdk.Oauth.GenerateAsync(
security: new OauthGenerateTokensSecurity() {
Username = "",
Password = "",
},
idempotencyKey: "123e4567-e89b-12d3-a456-426",
requestBody: new OauthGenerateTokensRequestBody() {
GrantType = OauthGrantType.AuthorizationCode,
Code = "auth_...",
RefreshToken = "refresh_...",
RedirectUri = "https://example.com/redirect",
}
);
// handle response
Global Parameters
Certain parameters are configured globally. These parameters may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, These global values will be used as defaults on the operations that use them. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set profileId to `` at SDK initialization and then you do not have to pass the same value on calls to operations like List. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
Available Globals
The following global parameters are available.
| Name | Type | Description |
|---|---|---|
| profileId | string | The identifier referring to the profile you wish to<br/>retrieve the resources for.<br/><br/>Most API credentials are linked to a single profile. In these cases the profileId must not be sent. For<br/>organization-level credentials such as OAuth access tokens however, the profileId parameter is required. |
| testmode | bool | Most API credentials are specifically created for either live mode or test mode. In those cases the testmode query<br/>parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by<br/>setting the testmode query parameter to true.<br/><br/>Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa. |
| customUserAgent | string | Custom user agent string to be appended to the default Mollie SDK user agent. |
Example
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client(
testmode: false,
profileId: "<id>",
customUserAgent: "<value>",
security: new Security() {
AdvancedAccessToken = "<YOUR_BEARER_TOKEN_HERE>",
}
);
ListBalancesRequest req = new ListBalancesRequest() {
Currency = "EUR",
From = "bal_gVMhHKqSSRYJyPsuoPNFH",
Limit = 50,
IdempotencyKey = "123e4567-e89b-12d3-a456-426",
};
ListBalancesResponse? res = await sdk.Balances.ListAsync(req);
while(res != null)
{
// handle items
res = await res.Next!();
}
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a Next method that can be called to pull down the next group of results. If the
return value of Next is null, then there are no more pages to be fetched.
Here's an example of one such pagination call:
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client(
testmode: false,
security: new Security() {
AdvancedAccessToken = "<YOUR_BEARER_TOKEN_HERE>",
}
);
ListBalancesRequest req = new ListBalancesRequest() {
Currency = "EUR",
From = "bal_gVMhHKqSSRYJyPsuoPNFH",
Limit = 50,
IdempotencyKey = "123e4567-e89b-12d3-a456-426",
};
ListBalancesResponse? res = await sdk.Balances.ListAsync(req);
while(res != null)
{
// handle items
res = await res.Next!();
}
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply pass a RetryConfig to the call:
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client();
var res = await sdk.Oauth.GenerateAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
security: new OauthGenerateTokensSecurity() {
Username = "",
Password = "",
},
idempotencyKey: "123e4567-e89b-12d3-a456-426",
requestBody: new OauthGenerateTokensRequestBody() {
GrantType = OauthGrantType.AuthorizationCode,
Code = "auth_...",
RefreshToken = "refresh_...",
RedirectUri = "https://example.com/redirect",
}
);
// handle response
If you'd like to override the default retry strategy for all operations that support retries, you can use the RetryConfig optional parameter when intitializing the SDK:
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client(retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
));
var res = await sdk.Oauth.GenerateAsync(
security: new OauthGenerateTokensSecurity() {
Username = "",
Password = "",
},
idempotencyKey: "123e4567-e89b-12d3-a456-426",
requestBody: new OauthGenerateTokensRequestBody() {
GrantType = OauthGrantType.AuthorizationCode,
Code = "auth_...",
RefreshToken = "refresh_...",
RedirectUri = "https://example.com/redirect",
}
);
// handle response
Error Handling
BaseException is the base exception class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
Message |
string | Error message |
Request |
HttpRequestMessage | HTTP request object |
Response |
HttpResponseMessage | HTTP response object |
Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.
Example
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Errors;
using Mollie.Models.Requests;
var sdk = new Client();
try
{
var res = await sdk.Oauth.GenerateAsync(
security: new OauthGenerateTokensSecurity() {
Username = "",
Password = "",
},
idempotencyKey: "123e4567-e89b-12d3-a456-426",
requestBody: new OauthGenerateTokensRequestBody() {
GrantType = OauthGrantType.AuthorizationCode,
Code = "auth_...",
RefreshToken = "refresh_...",
RedirectUri = "https://example.com/redirect",
}
);
// handle response
}
catch (BaseException ex) // all SDK exceptions inherit from BaseException
{
// ex.ToString() provides a detailed error message
System.Console.WriteLine(ex);
// Base exception fields
HttpRequestMessage request = ex.Request;
HttpResponseMessage response = ex.Response;
var statusCode = (int)response.StatusCode;
var responseBody = ex.Body;
if (ex is ErrorResponse) // different exceptions may be thrown depending on the method
{
// Check error data fields
ErrorResponsePayload payload = ex.Payload;
long Status = payload.Status;
string Title = payload.Title;
// ...
}
// An underlying cause may be provided
if (ex.InnerException != null)
{
Exception cause = ex.InnerException;
}
}
catch (OperationCanceledException ex)
{
// CancellationToken was cancelled
}
catch (System.Net.Http.HttpRequestException ex)
{
// Check ex.InnerException for Network connectivity errors
}
Error Classes
Primary exceptions:
BaseException: The base class for HTTP error responses.ErrorResponse: An error response object.
Less common exceptions (2)
System.Net.Http.HttpRequestException: Network connectivity error. For more details about the underlying cause, inspect theex.InnerException.Inheriting from
BaseException:ResponseValidationError: Thrown when the response data could not be deserialized into the expected type.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:
using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
var sdk = new Client(serverUrl: "https://api.mollie.com");
var res = await sdk.Oauth.GenerateAsync(
security: new OauthGenerateTokensSecurity() {
Username = "",
Password = "",
},
idempotencyKey: "123e4567-e89b-12d3-a456-426",
requestBody: new OauthGenerateTokensRequestBody() {
GrantType = OauthGrantType.AuthorizationCode,
Code = "auth_...",
RefreshToken = "refresh_...",
RedirectUri = "https://example.com/redirect",
}
);
// handle response
Custom HTTP Client
The C# SDK makes API calls using an ISpeakeasyHttpClient that wraps the native
HttpClient. This
client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle
errors and response.
The ISpeakeasyHttpClient interface allows you to either use the default SpeakeasyHttpClient that comes with the SDK,
or provide your own custom implementation with customized configuration such as custom message handlers, timeouts,
connection pooling, and other HTTP client settings.
The following example shows how to create a custom HTTP client with request modification and error handling:
using Mollie;
using Mollie.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _defaultClient;
public CustomHttpClient()
{
_defaultClient = new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Add custom header and timeout
request.Headers.Add("x-custom-header", "custom value");
request.Headers.Add("x-request-timeout", "30");
try
{
var response = await _defaultClient.SendAsync(request, cancellationToken);
// Log successful response
Console.WriteLine($"Request successful: {response.StatusCode}");
return response;
}
catch (Exception error)
{
// Log error
Console.WriteLine($"Request failed: {error.Message}");
throw;
}
}
public void Dispose()
{
_httpClient?.Dispose();
_defaultClient?.Dispose();
}
}
// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new Client(client: customHttpClient);
You can also provide a completely custom HTTP client with your own configuration:
using Mollie.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
private readonly HttpClient _httpClient;
public AdvancedHttpClient()
{
var handler = new HttpClientHandler()
{
MaxConnectionsPerServer = 10,
// ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
};
_httpClient = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30)
};
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
}
public void Dispose()
{
_httpClient?.Dispose();
}
}
var sdk = Client.Builder()
.WithClient(new AdvancedHttpClient())
.Build();
For simple debugging, you can enable request/response logging by implementing a custom client:
public class LoggingHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _innerClient;
public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
{
_innerClient = innerClient ?? new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Log request
Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");
var response = await _innerClient.SendAsync(request, cancellationToken);
// Log response
Console.WriteLine($"Received {response.StatusCode} response");
return response;
}
public void Dispose() => _innerClient?.Dispose();
}
var sdk = new Client(client: new LoggingHttpClient());
The SDK also provides built-in hook support through the SDKConfiguration.Hooks system, which automatically handles
BeforeRequestAsync, AfterSuccessAsync, and AfterErrorAsync hooks for advanced request lifecycle management.
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
SDK Created by Speakeasy
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- newtonsoft.json (>= 13.0.3)
- nodatime (>= 3.1.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.4.9 | 0 | 9/7/2026 |
| 1.4.8 | 87 | 9/3/2026 |
| 1.4.7 | 70 | 9/2/2026 |
| 1.4.6 | 68 | 9/1/2026 |
| 1.4.5 | 100 | 8/31/2026 |
| 1.4.4 | 112 | 8/28/2026 |
| 1.4.3 | 106 | 8/27/2026 |
| 1.4.2 | 329 | 8/20/2026 |
| 1.4.1 | 118 | 8/19/2026 |
| 1.4.0 | 301 | 8/14/2026 |
| 1.3.27 | 588 | 8/7/2026 |
| 1.3.26 | 99 | 8/7/2026 |
| 1.3.25 | 95 | 8/6/2026 |
| 1.3.24 | 181 | 8/5/2026 |
| 1.3.23 | 108 | 8/5/2026 |
| 1.3.21 | 449 | 7/23/2026 |
| 1.3.20 | 123 | 7/22/2026 |
| 1.3.19 | 131 | 7/20/2026 |
| 1.3.18 | 150 | 7/17/2026 |
| 1.3.17 | 553 | 7/8/2026 |