{"id":27151407,"url":"https://github.com/checkout/checkout-sdk-net","last_synced_at":"2025-04-08T14:40:22.427Z","repository":{"id":37784996,"uuid":"131138842","full_name":"checkout/checkout-sdk-net","owner":"checkout","description":"Checkout SDK for Microsoft .NET","archived":false,"fork":false,"pushed_at":"2025-04-02T15:12:53.000Z","size":1645,"stargazers_count":22,"open_issues_count":3,"forks_count":26,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-02T16:22:25.934Z","etag":null,"topics":["payment-gateway","sdk","sdk-dotnet"],"latest_commit_sha":null,"homepage":"https://checkout.com","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/checkout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2018-04-26T10:22:30.000Z","updated_at":"2025-04-02T15:03:36.000Z","dependencies_parsed_at":"2023-09-23T01:38:11.858Z","dependency_job_id":"6d664558-274e-40c0-bce6-25cad0aa7e12","html_url":"https://github.com/checkout/checkout-sdk-net","commit_stats":{"total_commits":271,"total_committers":20,"mean_commits":13.55,"dds":0.7453874538745388,"last_synced_commit":"e1c4fd4e8759975f7d3e1a0828223c00f163e470"},"previous_names":[],"tags_count":89,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-sdk-net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/checkout","download_url":"https://codeload.github.com/checkout/checkout-sdk-net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247863674,"owners_count":21008945,"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":["payment-gateway","sdk","sdk-dotnet"],"created_at":"2025-04-08T14:40:21.859Z","updated_at":"2025-04-08T14:40:22.418Z","avatar_url":"https://github.com/checkout.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Checkout.com .NET SDK\n\n[![build-status](https://github.com/checkout/checkout-sdk-net/workflows/build-master/badge.svg)](https://github.com/checkout/checkout-sdk-net/actions/workflows/build-master.yml)\n![CodeQL](https://github.com/checkout/checkout-sdk-net/workflows/CodeQL/badge.svg)\n\n[![build-status](https://github.com/checkout/checkout-sdk-net/workflows/build-release/badge.svg)](https://github.com/checkout/checkout-sdk-net/actions/workflows/build-release.yml)\n[![GitHub release](https://img.shields.io/github/release/checkout/checkout-sdk-net.svg)](https://GitHub.com/checkout/checkout-sdk-net/releases/)\n[![NuGet](https://img.shields.io/nuget/v/CheckoutSDK.svg)](https://www.nuget.org/packages/CheckoutSDK)\n\n[![GitHub license](https://img.shields.io/github/license/checkout/checkout-sdk-net.svg)](https://github.com/checkout/checkout-sdk-net/blob/master/LICENSE.md)\n\n## Getting started\n\n\u003e **Version 4.0.0 is here!**\n\u003e  \u003cbr/\u003e\u003cbr/\u003e\n\u003e We improved the initialization of SDK making it easier to understand the available options. \u003cbr/\u003e\n\u003e Now `NAS` accounts are the default instance for the SDK and `ABC` structure was moved to a `previous` prefixes. \u003cbr/\u003e\n\u003e If you have been using this SDK before, you may find the following important changes:\n\u003e * Marketplace module was moved to Accounts module, same for classes and references.\n\u003e * In most cases, IDE can help you determine from where to import, but if you’re still having issues don't hesitate to open a [ticket](https://github.com/checkout/checkout-sdk-net/issues/new/choose).\n\n### :rocket: Please check in [GitHub releases](https://github.com/checkout/checkout-sdk-net/releases) for all the versions available.\n\n### :book: Checkout our official documentation.\n\n* [Official Docs (Default)](https://docs.checkout.com/)\n* [Official Docs (Previous)](https://docs.checkout.com/previous)\n\n### :books: Check out our official API documentation guide, where you can also find more usage examples.\n\n* [API Reference (Default)](https://api-reference.checkout.com/)\n* [API Reference (Previous)](https://api-reference.checkout.com/previous)\n\n## How to use the SDK\n\nThis SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply using specific API features. \u003c/br\u003e\nPlease find in the table below the types of keys that can be used within this SDK.\n\n| Account System | Public Key (example)                    | Secret Key (example)                    |\n|----------------|-----------------------------------------| --------------------------------------- |\n| Default        | pk_pkhpdtvabcf7hdgpwnbhw7r2uic          | sk_m73dzypy7cf3gf5d2xr4k7sxo4e          |\n| Previous       | pk_g650ff27-7c42-4ce1-ae90-5691a188ee7b | sk_gk3517a8-3z01-45fq-b4bd-4282384b0a64 |\n\nNote: sandbox keys have a `sbox_` or `test_` identifier, for Default and Previous accounts respectively.\n\n**PLEASE NEVER SHARE OR PUBLISH YOUR CHECKOUT CREDENTIALS.**\n\nIf you don't have your own API keys, you can sign up for a test account [here](https://www.checkout.com/get-test-account).\n\n\n### Default\n\nDefault keys client instantiation can be done as follows:\n\n```c#\nICheckoutApi api = CheckoutSdk.Builder().StaticKeys()\n    .PublicKey(\"public_key\") // optional, only required for operations related with tokens\n    .SecretKey(\"secret_key\")\n    .Environment(Environment.Sandbox)\n    .EnvironmentSubdomain(\"subdomain\") // optional, Merchant-specific DNS name\n    .LogProvider(logFactory) // optional\n    .HttpClientFactory(httpClientFactory) // optional\n    .Build();\n    \n```\n\n### Default OAuth\n\nThe SDK supports client credentials OAuth, when initialized as follows:\n\n```c#\nICheckoutApi api = CheckoutSdk.Builder().OAuth()\n    .ClientCredentials(\"client_id\", \"client_secret\")\n    .AuthorizationUri(new Uri(\"https://access.sandbox.checkout.com/connect/token\")) // custom authorization URI, optional\n    .Scopes(OAuthScope.Files, OAuthScope.Flow) // array of scopes, optional\n    .Environment(Environment.Sandbox)\n    .EnvironmentSubdomain(\"subdomain\") // optional, Merchant-specific DNS name\n    .LogProvider(logFactory) // optional\n    .HttpClientFactory(httpClientFactory) // optional\n    .Build();\n```\n\n### Previous\n\nIf your pair of keys matches the previous system type, this is how the SDK should be used:\n\n```c#\nCheckout.Previous.ICheckoutApi api = CheckoutSdk.Builder()\n    .Previous()\n    .StaticKeys()\n    .PublicKey(\"public_key\") // optional, only required for operations related with tokens\n    .SecretKey(\"secret_key\")\n    .Environment(Environment.Sandbox)\n    .EnvironmentSubdomain(\"subdomain\") // optional, Merchant-specific DNS name\n    .LogProvider(logFactory) // optional\n    .HttpClientFactory(httpClientFactory) // optional\n    .Build();\n```\n\nThen just get any client, and start making requests:\n\n```c#\nvar paymentResponse = await api.PaymentsClient().RequestPayment(new PaymentRequest());\n```\n\n### .NET Core Applications\n\nThe [CheckoutSDK.Extensions.Microsoft](https://www.nuget.org/packages/CheckoutSDK.Extensions.Microsoft) package makes it easier to add the Checkout SDK to your .NET Core applications.\n\nInitialize the Configuration of your `appsettings.json` file:\n\n```json\n{\n  \"Checkout\": {\n    \"SecretKey\": \"secret_key\",\n    \"PublicKey\": \"public_key\",\n    \"Environment\": \"Sandbox\",\n    \"PlatformType\": \"Default\" \n  }\n}\n```\nYou can chose PlatformType `Default` or `Previous` depending of the type of keys and account system access.\n\nFor OAuth, the configuration file should include the following properties:\n\n```json\n{\n  \"Checkout\": {\n    \"ClientId\": \"client_id\",\n    \"ClientSecret\": \"client_secret\",\n    \"AuthorizationUri\": \"https://access.sandbox.checkout.com/connect/token\",\n    \"Scopes\": [\"vault\", \"fx\"],\n    \"Environment\": \"Sandbox\",\n    \"PlatformType\": \"DefaultOAuth\"\n  }\n}\n```\nUse `Environment` enum value to choose the desired environment for the SDK, and `PlatformType` value to choose between the different Account Settings. Then add the configuration:\n\n```c#\npublic class Startup \n{\n    public IConfigurationRoot Configuration { get; set; }\n\n    public Startup(IWebHostEnvironment env)\n    {\n        var builder = new ConfigurationBuilder()\n            .SetBasePath(env.ContentRootPath)\n            .AddJsonFile(\"appsettings.json\", optional: true, reloadOnChange: true);\n\n        Configuration = builder.Build();\n    }\n}\n```\nRegister the `CheckoutSdk`:\n\n```c#\npublic void ConfigureServices(IServiceCollection services)\n{\n    // LogFactory and HttpClientFactory are optional\n    CheckoutServiceCollection.AddCheckoutSdk(services, configuration, logFactory, httpClientFactory);\n}\n```\nThen take a dependency on `ICheckoutApi` in your class constructor:\n\n```c#\npublic class CheckoutController : ControllerBase\n{\n    private readonly ICheckoutApi _api;\n\n    public CheckoutController(ICheckoutApi api)\n    {\n        _api = api;\n    }\n}\n```\nPlease note again that there are 2 different `ICheckoutApi` interfaces, depending on the way the SDK is built.\n\n## Custom HttpClient\n\nSometimes you need a custom thread pool, or any custom http property, so you can provide your own httpClient configuration as follows.\n\n```c#\n// Create a custom class from IHttpClientFactory\nprivate class CustomClientFactory : IHttpClientFactory\n{\n    public HttpClient CreateClient()\n    {\n        var handler = new HttpClientHandler();\n        handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;\n        var httpClient = new HttpClient(handler);\n        httpClient.Timeout = TimeSpan.FromSeconds(2);\n        return httpClient;\n    }\n}\n\nICheckoutApi api = CheckoutSdk.Builder().StaticKeys()\n    .SecretKey(\"secret_key\")\n    .Environment(Environment.Sandbox)\n    .EnvironmentSubdomain(\"subdomain\") // optional, Merchant-specific DNS name\n    .HttpClientFactory(new CustomClientFactory()) // optional\n    .Build();\n```\n\n## Logging\n\nThe SDK supports custom LogProvider that extends from Microsoft.Extensions.Logging `ILoggerFactory`, you need to provide your configuration as follows.\n\n```c#\nvar logFactory = new NLogLoggerFactory();\n_log = logFactory.CreateLogger(typeof(SandboxTestFixture));\n\nICheckoutApi api = CheckoutSdk.Builder().StaticKeys()\n    .SecretKey(\"secret_key\")\n    .Environment(Environment.Sandbox)\n    .EnvironmentSubdomain(\"subdomain\") // optional, Merchant-specific DNS name\n    .LogProvider(logFactory)\n    .Build();\n```\n\n## Exception handling\n\nAll the API responses that do not fall in the 2** status codes will cause a `CheckoutApiException`. The exception encapsulates\nthe `requestId`, `httpStatusCode` and a map of `errorDetails`, if available.\n\n## Building from source\n\nOnce you check out the code from GitHub, the project can be built using the netcore CLI tools:\n\n```\ndotnet build\n\n# run tests\ndotnet test\n```\n\nThe execution of integration tests require the following environment variables set in your system:\n\n* For Default account systems (NAS): `CHECKOUT_DEFAULT_PUBLIC_KEY` \u0026 `CHECKOUT_DEFAULT_SECRET_KEY`\n* For Default account systems (OAuth): `CHECKOUT_DEFAULT_OAUTH_CLIENT_ID` \u0026 `CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET`\n* For Previous account systems (ABC): `CHECKOUT_PREVIOUS_PUBLIC_KEY` \u0026 `CHECKOUT_PREVIOUS_SECRET_KEY`\n\n## Telemetry\nRequest telemetry is enabled by default in the .NET SDK. Request latency is included in the telemetry data. Recording the request latency allows Checkout.com to continuously monitor and improve the merchant experience.\n\nRequest telemetry can be disabled by opting out during CheckoutSdk builder step:\n```\nICheckoutApi api = CheckoutSdk.Builder().StaticKeys()\n    .SecretKey(\"secret_key\")\n    .RecordTelemetry(false)\n    .Environment(Environment.Sandbox)\n    .Build();\n```\n\nOr when using `CheckoutSDK.Extensions.Microsoft`:\n```\n{\n  \"Checkout\": {\n    ...\n    \"RecordTelemetry\": false,\n    ...\n  }\n}\n```\n\n## Code of Conduct\n\nPlease refer to [Code of Conduct](CODE_OF_CONDUCT.md)\n\n## Licensing\n\n[MIT](LICENSE.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckout%2Fcheckout-sdk-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheckout%2Fcheckout-sdk-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckout%2Fcheckout-sdk-net/lists"}