Skip to content

mollie/mollie-api-csharp

Repository files navigation

Mollie

Developer-friendly & type-safe Csharp SDK specifically catered to leverage Mollie API.



Important

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 Installation

NuGet

To add the NuGet package to a .NET project:

dotnet add package Mollie

Locally

To add a reference to a local instance of the SDK in a .NET project:

dotnet add reference src/Mollie/Mollie.csproj

SDK Example Usage

Example

using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Requests;
using System.Collections.Generic;

var sdk = new Client(security: new Security() {
    ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
});

var res = await sdk.Payments.CreateAsync(
    include: CreatePaymentInclude.DetailsQrCode,
    requestBody: new CreatePaymentRequestBody() {
        Description = "Chess Board",
        Amount = new CreatePaymentAmountRequest() {
            Currency = "EUR",
            Value = "10.00",
        },
        RedirectUrl = "https://example.org/redirect",
        CancelUrl = "https://example.org/cancel",
        WebhookUrl = "https://example.org/webhooks",
        Lines = new List<CreatePaymentLineRequest>() {
            new CreatePaymentLineRequest() {
                Description = "LEGO 4440 Forest Police Station",
                Quantity = 1,
                QuantityUnit = "pcs",
                UnitPrice = new CreatePaymentUnitPriceRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                DiscountAmount = new CreatePaymentDiscountAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                TotalAmount = new CreatePaymentTotalAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                VatRate = "21.00",
                VatAmount = new CreatePaymentVatAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Sku = "9780241661628",
                Categories = new List<CreatePaymentCategoryRequest>() {
                    CreatePaymentCategoryRequest.Meal,
                    CreatePaymentCategoryRequest.Eco,
                },
                ImageUrl = "https://...",
                ProductUrl = "https://...",
                Recurring = new CreatePaymentRecurringRequest() {
                    Description = "Gym subscription",
                    Interval = CreatePaymentIntervalRequest.DotDotDotDays,
                    Amount = new CreatePaymentRecurringAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Times = 1,
                    StartDate = "2024-12-12",
                },
            },
        },
        BillingAddress = new CreatePaymentBillingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        ShippingAddress = new CreatePaymentShippingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        Locale = CreatePaymentLocaleRequest.EnUS,
        Method = CreatePaymentMethodRequest.Ideal,
        Issuer = "ideal_INGBNL2A",
        RestrictPaymentMethodsToCountry = "NL",
        CaptureMode = CreatePaymentCaptureModeRequest.Manual,
        CaptureDelay = "8 hours",
        ApplicationFee = new CreatePaymentApplicationFeeRequest() {
            Amount = new CreatePaymentApplicationFeeAmountRequest() {
                Currency = "EUR",
                Value = "10.00",
            },
            Description = "10",
        },
        Routing = new List<CreatePaymentRoutingRequest>() {
            new CreatePaymentRoutingRequest() {
                Amount = new CreatePaymentRoutingAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Destination = new CreatePaymentDestinationRequest() {
                    Type = CreatePaymentRoutingTypeRequest.Organization,
                    OrganizationId = "org_1234567",
                },
                ReleaseDate = "2024-12-12",
                Links = new CreatePaymentLinksRequest() {
                    Self = new CreatePaymentSelfRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                    Payment = new CreatePaymentPaymentRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                },
            },
        },
        MandateId = "mdt_5B8cwPMGnU",
        CustomerId = "cst_5B8cwPMGnU",
        ProfileId = "pfl_5B8cwPMGnU",
        DueDate = "2025-01-01",
        Testmode = false,
    }
);

// handle response

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

Name Type Scheme
ApiKey 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;
using System.Collections.Generic;

var sdk = new Client(security: new Security() {
    ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
});

var res = await sdk.Payments.CreateAsync(
    include: CreatePaymentInclude.DetailsQrCode,
    requestBody: new CreatePaymentRequestBody() {
        Description = "Chess Board",
        Amount = new CreatePaymentAmountRequest() {
            Currency = "EUR",
            Value = "10.00",
        },
        RedirectUrl = "https://example.org/redirect",
        CancelUrl = "https://example.org/cancel",
        WebhookUrl = "https://example.org/webhooks",
        Lines = new List<CreatePaymentLineRequest>() {
            new CreatePaymentLineRequest() {
                Description = "LEGO 4440 Forest Police Station",
                Quantity = 1,
                QuantityUnit = "pcs",
                UnitPrice = new CreatePaymentUnitPriceRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                DiscountAmount = new CreatePaymentDiscountAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                TotalAmount = new CreatePaymentTotalAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                VatRate = "21.00",
                VatAmount = new CreatePaymentVatAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Sku = "9780241661628",
                Categories = new List<CreatePaymentCategoryRequest>() {
                    CreatePaymentCategoryRequest.Meal,
                    CreatePaymentCategoryRequest.Eco,
                },
                ImageUrl = "https://...",
                ProductUrl = "https://...",
                Recurring = new CreatePaymentRecurringRequest() {
                    Description = "Gym subscription",
                    Interval = CreatePaymentIntervalRequest.DotDotDotDays,
                    Amount = new CreatePaymentRecurringAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Times = 1,
                    StartDate = "2024-12-12",
                },
            },
        },
        BillingAddress = new CreatePaymentBillingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        ShippingAddress = new CreatePaymentShippingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        Locale = CreatePaymentLocaleRequest.EnUS,
        Method = CreatePaymentMethodRequest.Ideal,
        Issuer = "ideal_INGBNL2A",
        RestrictPaymentMethodsToCountry = "NL",
        CaptureMode = CreatePaymentCaptureModeRequest.Manual,
        CaptureDelay = "8 hours",
        ApplicationFee = new CreatePaymentApplicationFeeRequest() {
            Amount = new CreatePaymentApplicationFeeAmountRequest() {
                Currency = "EUR",
                Value = "10.00",
            },
            Description = "10",
        },
        Routing = new List<CreatePaymentRoutingRequest>() {
            new CreatePaymentRoutingRequest() {
                Amount = new CreatePaymentRoutingAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Destination = new CreatePaymentDestinationRequest() {
                    Type = CreatePaymentRoutingTypeRequest.Organization,
                    OrganizationId = "org_1234567",
                },
                ReleaseDate = "2024-12-12",
                Links = new CreatePaymentLinksRequest() {
                    Self = new CreatePaymentSelfRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                    Payment = new CreatePaymentPaymentRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                },
            },
        },
        MandateId = "mdt_5B8cwPMGnU",
        CustomerId = "cst_5B8cwPMGnU",
        ProfileId = "pfl_5B8cwPMGnU",
        DueDate = "2025-01-01",
        Testmode = false,
    }
);

// handle response

Available Resources and Operations

Available methods
  • List - List capabilities
  • List - List payment chargebacks
  • Get - Get payment chargeback
  • All - List all chargebacks
  • List - List clients
  • Get - Get client
  • Create - Create a delayed route
  • List - List payment routes
  • List - List invoices
  • Get - Get invoice
  • List - List payment methods
  • All - List all payment methods
  • Get - Get payment method
  • Get - Get onboarding status
  • Submit - Submit onboarding data
  • List - List permissions
  • Get - Get permission
  • Create - Create payment refund
  • List - List payment refunds
  • Get - Get payment refund
  • Cancel - Cancel payment refund
  • All - List all refunds
  • Create - Create sales invoice
  • List - List sales invoices
  • Get - Get sales invoice
  • Update - Update sales invoice
  • Delete - Delete sales invoice
  • Create - Create subscription
  • List - List customer subscriptions
  • Get - Get subscription
  • Update - Update subscription
  • Cancel - Cancel subscription
  • All - List all subscriptions
  • ListPayments - List subscription payments
  • List - List terminals
  • Get - Get terminal
  • Get - Get a Webhook Event
  • Create - Create a webhook
  • List - List all webhooks
  • Update - Update a webhook
  • Get - Get a webhook
  • Delete - Delete a webhook
  • Test - Test a webhook

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;
using System.Collections.Generic;

var sdk = new Client(security: new Security() {
    ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
});

var res = await sdk.Payments.CreateAsync(
    retryConfig: new RetryConfig(
        strategy: RetryConfig.RetryStrategy.BACKOFF,
        backoff: new BackoffStrategy(
            initialIntervalMs: 1L,
            maxIntervalMs: 50L,
            maxElapsedTimeMs: 100L,
            exponent: 1.1
        ),
        retryConnectionErrors: false
    ),
    include: CreatePaymentInclude.DetailsQrCode,
    requestBody: new CreatePaymentRequestBody() {
        Description = "Chess Board",
        Amount = new CreatePaymentAmountRequest() {
            Currency = "EUR",
            Value = "10.00",
        },
        RedirectUrl = "https://example.org/redirect",
        CancelUrl = "https://example.org/cancel",
        WebhookUrl = "https://example.org/webhooks",
        Lines = new List<CreatePaymentLineRequest>() {
            new CreatePaymentLineRequest() {
                Description = "LEGO 4440 Forest Police Station",
                Quantity = 1,
                QuantityUnit = "pcs",
                UnitPrice = new CreatePaymentUnitPriceRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                DiscountAmount = new CreatePaymentDiscountAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                TotalAmount = new CreatePaymentTotalAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                VatRate = "21.00",
                VatAmount = new CreatePaymentVatAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Sku = "9780241661628",
                Categories = new List<CreatePaymentCategoryRequest>() {
                    CreatePaymentCategoryRequest.Meal,
                    CreatePaymentCategoryRequest.Eco,
                },
                ImageUrl = "https://...",
                ProductUrl = "https://...",
                Recurring = new CreatePaymentRecurringRequest() {
                    Description = "Gym subscription",
                    Interval = CreatePaymentIntervalRequest.DotDotDotDays,
                    Amount = new CreatePaymentRecurringAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Times = 1,
                    StartDate = "2024-12-12",
                },
            },
        },
        BillingAddress = new CreatePaymentBillingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        ShippingAddress = new CreatePaymentShippingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        Locale = CreatePaymentLocaleRequest.EnUS,
        Method = CreatePaymentMethodRequest.Ideal,
        Issuer = "ideal_INGBNL2A",
        RestrictPaymentMethodsToCountry = "NL",
        CaptureMode = CreatePaymentCaptureModeRequest.Manual,
        CaptureDelay = "8 hours",
        ApplicationFee = new CreatePaymentApplicationFeeRequest() {
            Amount = new CreatePaymentApplicationFeeAmountRequest() {
                Currency = "EUR",
                Value = "10.00",
            },
            Description = "10",
        },
        Routing = new List<CreatePaymentRoutingRequest>() {
            new CreatePaymentRoutingRequest() {
                Amount = new CreatePaymentRoutingAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Destination = new CreatePaymentDestinationRequest() {
                    Type = CreatePaymentRoutingTypeRequest.Organization,
                    OrganizationId = "org_1234567",
                },
                ReleaseDate = "2024-12-12",
                Links = new CreatePaymentLinksRequest() {
                    Self = new CreatePaymentSelfRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                    Payment = new CreatePaymentPaymentRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                },
            },
        },
        MandateId = "mdt_5B8cwPMGnU",
        CustomerId = "cst_5B8cwPMGnU",
        ProfileId = "pfl_5B8cwPMGnU",
        DueDate = "2025-01-01",
        Testmode = false,
    }
);

// 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;
using System.Collections.Generic;

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
    ),
    security: new Security() {
        ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
    }
);

var res = await sdk.Payments.CreateAsync(
    include: CreatePaymentInclude.DetailsQrCode,
    requestBody: new CreatePaymentRequestBody() {
        Description = "Chess Board",
        Amount = new CreatePaymentAmountRequest() {
            Currency = "EUR",
            Value = "10.00",
        },
        RedirectUrl = "https://example.org/redirect",
        CancelUrl = "https://example.org/cancel",
        WebhookUrl = "https://example.org/webhooks",
        Lines = new List<CreatePaymentLineRequest>() {
            new CreatePaymentLineRequest() {
                Description = "LEGO 4440 Forest Police Station",
                Quantity = 1,
                QuantityUnit = "pcs",
                UnitPrice = new CreatePaymentUnitPriceRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                DiscountAmount = new CreatePaymentDiscountAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                TotalAmount = new CreatePaymentTotalAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                VatRate = "21.00",
                VatAmount = new CreatePaymentVatAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Sku = "9780241661628",
                Categories = new List<CreatePaymentCategoryRequest>() {
                    CreatePaymentCategoryRequest.Meal,
                    CreatePaymentCategoryRequest.Eco,
                },
                ImageUrl = "https://...",
                ProductUrl = "https://...",
                Recurring = new CreatePaymentRecurringRequest() {
                    Description = "Gym subscription",
                    Interval = CreatePaymentIntervalRequest.DotDotDotDays,
                    Amount = new CreatePaymentRecurringAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Times = 1,
                    StartDate = "2024-12-12",
                },
            },
        },
        BillingAddress = new CreatePaymentBillingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        ShippingAddress = new CreatePaymentShippingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        Locale = CreatePaymentLocaleRequest.EnUS,
        Method = CreatePaymentMethodRequest.Ideal,
        Issuer = "ideal_INGBNL2A",
        RestrictPaymentMethodsToCountry = "NL",
        CaptureMode = CreatePaymentCaptureModeRequest.Manual,
        CaptureDelay = "8 hours",
        ApplicationFee = new CreatePaymentApplicationFeeRequest() {
            Amount = new CreatePaymentApplicationFeeAmountRequest() {
                Currency = "EUR",
                Value = "10.00",
            },
            Description = "10",
        },
        Routing = new List<CreatePaymentRoutingRequest>() {
            new CreatePaymentRoutingRequest() {
                Amount = new CreatePaymentRoutingAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Destination = new CreatePaymentDestinationRequest() {
                    Type = CreatePaymentRoutingTypeRequest.Organization,
                    OrganizationId = "org_1234567",
                },
                ReleaseDate = "2024-12-12",
                Links = new CreatePaymentLinksRequest() {
                    Self = new CreatePaymentSelfRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                    Payment = new CreatePaymentPaymentRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                },
            },
        },
        MandateId = "mdt_5B8cwPMGnU",
        CustomerId = "cst_5B8cwPMGnU",
        ProfileId = "pfl_5B8cwPMGnU",
        DueDate = "2025-01-01",
        Testmode = false,
    }
);

// handle response

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default, an API error will raise a Mollie.Models.Errors.APIException exception, which has the following properties:

Property Type Description
Message string The error message
Request HttpRequestMessage The HTTP request
Response HttpResponseMessage The HTTP response

When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the CreateAsync method throws the following exceptions:

Error Type Status Code Content Type
Mollie.Models.Errors.CreatePaymentUnprocessableEntityHalJSONException 422 application/hal+json
Mollie.Models.Errors.CreatePaymentServiceUnavailableHalJSONException 503 application/hal+json
Mollie.Models.Errors.APIException 4XX, 5XX */*

Example

using Mollie;
using Mollie.Models.Components;
using Mollie.Models.Errors;
using Mollie.Models.Requests;
using System.Collections.Generic;

var sdk = new Client(security: new Security() {
    ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
});

try
{
    var res = await sdk.Payments.CreateAsync(
        include: CreatePaymentInclude.DetailsQrCode,
        requestBody: new CreatePaymentRequestBody() {
            Description = "Chess Board",
            Amount = new CreatePaymentAmountRequest() {
                Currency = "EUR",
                Value = "10.00",
            },
            RedirectUrl = "https://example.org/redirect",
            CancelUrl = "https://example.org/cancel",
            WebhookUrl = "https://example.org/webhooks",
            Lines = new List<CreatePaymentLineRequest>() {
                new CreatePaymentLineRequest() {
                    Description = "LEGO 4440 Forest Police Station",
                    Quantity = 1,
                    QuantityUnit = "pcs",
                    UnitPrice = new CreatePaymentUnitPriceRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    DiscountAmount = new CreatePaymentDiscountAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    TotalAmount = new CreatePaymentTotalAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    VatRate = "21.00",
                    VatAmount = new CreatePaymentVatAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Sku = "9780241661628",
                    Categories = new List<CreatePaymentCategoryRequest>() {
                        CreatePaymentCategoryRequest.Meal,
                        CreatePaymentCategoryRequest.Eco,
                    },
                    ImageUrl = "https://...",
                    ProductUrl = "https://...",
                    Recurring = new CreatePaymentRecurringRequest() {
                        Description = "Gym subscription",
                        Interval = CreatePaymentIntervalRequest.DotDotDotDays,
                        Amount = new CreatePaymentRecurringAmountRequest() {
                            Currency = "EUR",
                            Value = "10.00",
                        },
                        Times = 1,
                        StartDate = "2024-12-12",
                    },
                },
            },
            BillingAddress = new CreatePaymentBillingAddressRequest() {
                Title = "Mr.",
                GivenName = "Piet",
                FamilyName = "Mondriaan",
                OrganizationName = "Mollie B.V.",
                StreetAndNumber = "Keizersgracht 126",
                StreetAdditional = "Apt. 1",
                PostalCode = "1234AB",
                Email = "piet@example.org",
                Phone = "31208202070",
                City = "Amsterdam",
                Region = "Noord-Holland",
                Country = "NL",
            },
            ShippingAddress = new CreatePaymentShippingAddressRequest() {
                Title = "Mr.",
                GivenName = "Piet",
                FamilyName = "Mondriaan",
                OrganizationName = "Mollie B.V.",
                StreetAndNumber = "Keizersgracht 126",
                StreetAdditional = "Apt. 1",
                PostalCode = "1234AB",
                Email = "piet@example.org",
                Phone = "31208202070",
                City = "Amsterdam",
                Region = "Noord-Holland",
                Country = "NL",
            },
            Locale = CreatePaymentLocaleRequest.EnUS,
            Method = CreatePaymentMethodRequest.Ideal,
            Issuer = "ideal_INGBNL2A",
            RestrictPaymentMethodsToCountry = "NL",
            CaptureMode = CreatePaymentCaptureModeRequest.Manual,
            CaptureDelay = "8 hours",
            ApplicationFee = new CreatePaymentApplicationFeeRequest() {
                Amount = new CreatePaymentApplicationFeeAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Description = "10",
            },
            Routing = new List<CreatePaymentRoutingRequest>() {
                new CreatePaymentRoutingRequest() {
                    Amount = new CreatePaymentRoutingAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Destination = new CreatePaymentDestinationRequest() {
                        Type = CreatePaymentRoutingTypeRequest.Organization,
                        OrganizationId = "org_1234567",
                    },
                    ReleaseDate = "2024-12-12",
                    Links = new CreatePaymentLinksRequest() {
                        Self = new CreatePaymentSelfRequest() {
                            Href = "https://...",
                            Type = "application/hal+json",
                        },
                        Payment = new CreatePaymentPaymentRequest() {
                            Href = "https://...",
                            Type = "application/hal+json",
                        },
                    },
                },
            },
            MandateId = "mdt_5B8cwPMGnU",
            CustomerId = "cst_5B8cwPMGnU",
            ProfileId = "pfl_5B8cwPMGnU",
            DueDate = "2025-01-01",
            Testmode = false,
        }
    );

    // handle response
}
catch (Exception ex)
{
    if (ex is CreatePaymentUnprocessableEntityHalJSONException)
    {
        // Handle exception data
        throw;
    }
    else if (ex is CreatePaymentServiceUnavailableHalJSONException)
    {
        // Handle exception data
        throw;
    }
    else if (ex is Mollie.Models.Errors.APIException)
    {
        // Handle default exception
        throw;
    }
}

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;
using System.Collections.Generic;

var sdk = new Client(
    serverUrl: "https://api.mollie.com/v2",
    security: new Security() {
        ApiKey = "<YOUR_BEARER_TOKEN_HERE>",
    }
);

var res = await sdk.Payments.CreateAsync(
    include: CreatePaymentInclude.DetailsQrCode,
    requestBody: new CreatePaymentRequestBody() {
        Description = "Chess Board",
        Amount = new CreatePaymentAmountRequest() {
            Currency = "EUR",
            Value = "10.00",
        },
        RedirectUrl = "https://example.org/redirect",
        CancelUrl = "https://example.org/cancel",
        WebhookUrl = "https://example.org/webhooks",
        Lines = new List<CreatePaymentLineRequest>() {
            new CreatePaymentLineRequest() {
                Description = "LEGO 4440 Forest Police Station",
                Quantity = 1,
                QuantityUnit = "pcs",
                UnitPrice = new CreatePaymentUnitPriceRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                DiscountAmount = new CreatePaymentDiscountAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                TotalAmount = new CreatePaymentTotalAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                VatRate = "21.00",
                VatAmount = new CreatePaymentVatAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Sku = "9780241661628",
                Categories = new List<CreatePaymentCategoryRequest>() {
                    CreatePaymentCategoryRequest.Meal,
                    CreatePaymentCategoryRequest.Eco,
                },
                ImageUrl = "https://...",
                ProductUrl = "https://...",
                Recurring = new CreatePaymentRecurringRequest() {
                    Description = "Gym subscription",
                    Interval = CreatePaymentIntervalRequest.DotDotDotDays,
                    Amount = new CreatePaymentRecurringAmountRequest() {
                        Currency = "EUR",
                        Value = "10.00",
                    },
                    Times = 1,
                    StartDate = "2024-12-12",
                },
            },
        },
        BillingAddress = new CreatePaymentBillingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        ShippingAddress = new CreatePaymentShippingAddressRequest() {
            Title = "Mr.",
            GivenName = "Piet",
            FamilyName = "Mondriaan",
            OrganizationName = "Mollie B.V.",
            StreetAndNumber = "Keizersgracht 126",
            StreetAdditional = "Apt. 1",
            PostalCode = "1234AB",
            Email = "piet@example.org",
            Phone = "31208202070",
            City = "Amsterdam",
            Region = "Noord-Holland",
            Country = "NL",
        },
        Locale = CreatePaymentLocaleRequest.EnUS,
        Method = CreatePaymentMethodRequest.Ideal,
        Issuer = "ideal_INGBNL2A",
        RestrictPaymentMethodsToCountry = "NL",
        CaptureMode = CreatePaymentCaptureModeRequest.Manual,
        CaptureDelay = "8 hours",
        ApplicationFee = new CreatePaymentApplicationFeeRequest() {
            Amount = new CreatePaymentApplicationFeeAmountRequest() {
                Currency = "EUR",
                Value = "10.00",
            },
            Description = "10",
        },
        Routing = new List<CreatePaymentRoutingRequest>() {
            new CreatePaymentRoutingRequest() {
                Amount = new CreatePaymentRoutingAmountRequest() {
                    Currency = "EUR",
                    Value = "10.00",
                },
                Destination = new CreatePaymentDestinationRequest() {
                    Type = CreatePaymentRoutingTypeRequest.Organization,
                    OrganizationId = "org_1234567",
                },
                ReleaseDate = "2024-12-12",
                Links = new CreatePaymentLinksRequest() {
                    Self = new CreatePaymentSelfRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                    Payment = new CreatePaymentPaymentRequest() {
                        Href = "https://...",
                        Type = "application/hal+json",
                    },
                },
            },
        },
        MandateId = "mdt_5B8cwPMGnU",
        CustomerId = "cst_5B8cwPMGnU",
        ProfileId = "pfl_5B8cwPMGnU",
        DueDate = "2025-01-01",
        Testmode = false,
    }
);

// handle response

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

About

Mollie's SDK for C# (alpha version)

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages