{"id":22319382,"url":"https://github.com/truelayer/truelayer-dotnet","last_synced_at":"2025-11-09T16:05:46.811Z","repository":{"id":39610206,"uuid":"360908752","full_name":"TrueLayer/truelayer-dotnet","owner":"TrueLayer","description":"The official TrueLayer .NET library provides convenient access to TrueLayer APIs from applications built with .NET.","archived":false,"fork":false,"pushed_at":"2024-04-09T15:48:50.000Z","size":3126,"stargazers_count":8,"open_issues_count":16,"forks_count":9,"subscribers_count":21,"default_branch":"main","last_synced_at":"2024-04-26T11:02:19.758Z","etag":null,"topics":["do-not-auto-tag","library","payments","sdk-dotnet"],"latest_commit_sha":null,"homepage":"https://docs.truelayer.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/TrueLayer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-23T14:20:34.000Z","updated_at":"2024-06-13T17:43:31.527Z","dependencies_parsed_at":"2024-06-13T17:43:28.545Z","dependency_job_id":"234bf513-4be2-4a04-9a59-3911d04ba480","html_url":"https://github.com/TrueLayer/truelayer-dotnet","commit_stats":{"total_commits":220,"total_committers":18,"mean_commits":"12.222222222222221","dds":0.6727272727272727,"last_synced_commit":"51325c6d63538e9b83023d171c284650773d1814"},"previous_names":["truelayer/truelayer-sdk-net"],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueLayer%2Ftruelayer-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueLayer%2Ftruelayer-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueLayer%2Ftruelayer-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueLayer%2Ftruelayer-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrueLayer","download_url":"https://codeload.github.com/TrueLayer/truelayer-dotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228017952,"owners_count":17856841,"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":["do-not-auto-tag","library","payments","sdk-dotnet"],"created_at":"2024-12-04T00:08:35.589Z","updated_at":"2025-11-09T16:05:46.806Z","avatar_url":"https://github.com/TrueLayer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrueLayer.NET\n\n[![NuGet](https://img.shields.io/nuget/v/TrueLayer.Client.svg)](https://www.nuget.org/packages/TrueLayer.Client)\n[![NuGet](https://img.shields.io/nuget/dt/TrueLayer.Client.svg)](https://www.nuget.org/packages/TrueLayer.Client)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://truelayer.mit-license.org/)\n\n![Build](https://github.com/TrueLayer/truelayer-dotnet/workflows/Build/badge.svg)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=TrueLayer_truelayer-dotnet\u0026metric=coverage\u0026token=98a2b0e3a6f70e0f4ad81d4a0aa23e04bcb19225)](https://sonarcloud.io/summary/overall?id=TrueLayer_truelayer-dotnet)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TrueLayer_truelayer-dotnet\u0026metric=alert_status\u0026token=98a2b0e3a6f70e0f4ad81d4a0aa23e04bcb19225)](https://sonarcloud.io/summary/overall?id=TrueLayer_truelayer-dotnet)\n\n\n\nThe official [TrueLayer](https://truelayer.com) .NET client provides convenient access to TrueLayer APIs from applications built with .NET.\n\nThe library currently supports .NET 9.0 and .NET 8.0.\n\n## Installation\n\nUsing the [.NET Core command-line interface (CLI) tools](https://docs.microsoft.com/en-us/dotnet/core/tools/):\n\n```sh\ndotnet add package TrueLayer.Client\n```\n\nUsing the [NuGet Command Line Interface (CLI)](https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference)\n\n```sh\nnuget install TrueLayer.Client\n```\n\nUsing the [Package Manager Console](https://docs.microsoft.com/en-us/nuget/tools/package-manager-console):\n\n```powershell\nInstall-Package TrueLayer.Client\n```\n\nFrom within Visual Studio:\n\n1. Open the Solution Explorer.\n2. Right-click on a project within your solution.\n3. Click on *Manage NuGet Packages...*\n4. Click on the *Browse* tab and search for \"TrueLayer.Client\".\n5. Click on the `TrueLayer.Client` package, select the appropriate version in the\n   right-tab and click *Install*.\n\n### Pre-release Packages\n\nPre-release packages can be downloaded from [GitHub Packages](https://github.com/truelayer?tab=packages\u0026repo_name=truelayer-dotnet).\n\n```\ndotnet add package TrueLayer.Client --prerelease --source https://nuget.pkg.github.com/TrueLayer/index.json\n```\n\n[More information](https://docs.github.com/en/packages/guides/configuring-dotnet-cli-for-use-with-github-packages) on using GitHub packages with .NET.\n\n## Documentation\n\nFor a comprehensive list of examples, check out the [API documentation](https://docs.truelayer.com).\n\n## Usage\n\n### Prerequisites\n\nFirst [sign up](https://console.truelayer.com/) for a developer account. Follow the instructions to set up a new application and obtain your Client ID and Secret. Once the application has been created you must add your application redirected URIs in order to test your integration end-to-end.\n\nNext, generate a signing key pair used to sign API requests.\n\nTo generate a private key, run:\n\n```sh\ndocker run --rm -v ${PWD}:/out -w /out -it alpine/openssl ecparam -genkey -name secp521r1 -noout -out ec512-private-key.pem\n```\n\nTo obtain the public key, run:\n\n```sh\ndocker run --rm -v ${PWD}:/out -w /out -it alpine/openssl ec -in ec512-private-key.pem -pubout -out ec512-public-key.pem\n```\n\nNavigate to the Payments settings section of the TrueLayer console and upload your public key. Obtain the Key Id.\n\n### Configure Settings\n\nAdd your Client ID, Secret and Signing Key ID to `appsettings.json` or any other supported [configuration provider](https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration).\n\n\n```json\n{\n  \"TrueLayer\": {\n    \"ClientId\": \"your id\",\n    \"ClientSecret\": \"your secret\",\n    \"UseSandbox\": true,\n    \"Payments\": {\n      \"SigningKey\": {\n        \"KeyId\": \"85eeb2da-702c-4f4b-bf9a-e98af5fd47c3\"\n      }\n    }\n  }\n}\n```\n\n### Initialize TrueLayer.NET\n\nRegister the TrueLayer client in `Startup.cs` or `Program.cs` (.NET 9.0/.NET 8.0):\n\n```c#\npublic IConfiguration Configuration { get; }\n\npublic void ConfigureServices(IServiceCollection services)\n{\n    services.AddTrueLayer(configuration, options =\u003e\n    {\n        if (options.Payments?.SigningKey != null)\n        {\n            // For demo purposes only. Private key should be stored securely\n            options.Payments.SigningKey.PrivateKey = File.ReadAllText(\"ec512-private-key.pem\");\n        }\n    },\n    // For best performance and reliability we advise to cache the auth token\n    authCachingStrategy: AuthCachingStrategy.InMemory)\n\n}\n```\n\n### Multiple TrueLayer Clients\n\nUse keyed version of TrueLayer client (.NET 9.0/.NET 8.0):\n\n```c#\n.AddKeyedTrueLayer(\"TrueLayerGbp\",\n    configuration,\n    options =\u003e\n    {\n        // For demo purposes only. Private key should be stored securely\n        var privateKey = File.ReadAllText(\"ec512-private-key.pem\");\n        if (options.Payments?.SigningKey != null)\n        {\n            options.Payments.SigningKey.PrivateKey = privateKey;\n        }\n    },\n    authTokenCachingStrategy: AuthTokenCachingStrategies.InMemory)\n.AddKeyedTrueLayer(\"TrueLayerEur\",\n    configuration,\n    options =\u003e\n    {\n        // For demo purposes only. Private key should be stored securely\n        var privateKey = File.ReadAllText(\"ec512-private-key.pem\");\n        if (options.Payments?.SigningKey != null)\n        {\n            options.Payments.SigningKey.PrivateKey = privateKey;\n        }\n    },\n    authTokenCachingStrategy: AuthTokenCachingStrategies.InMemory)\n```\n\nUse `[FromKeyedServices()]` attribute to retrieve keyed client\n\n```c#\npublic GbpController([FromKeyedServices(\"TrueLayerGbp\")]ITrueLayerClient trueLayerClient, ...\npublic EurController([FromKeyedServices(\"TrueLayerEur\")]ITrueLayerClient trueLayerClient, ...\n```\n\nOr `GetRequiredKeyedService`\n\n```c#\nvar GbpClient = ServiceProvider.GetRequiredKeyedService\u003cITrueLayerClient\u003e(\"TrueLayerGbp\");\nvar EurClient = ServiceProvider.GetRequiredKeyedService\u003cITrueLayerClient\u003e(\"TrueLayerEur\");\n```\n\n### Make a payment\n\nInject `ITrueLayerClient` into your classes:\n\n```c#\npublic class MyService\n{\n    private readonly ITrueLayerClient _client;\n\n    public MyService(ITrueLayerClient client)\n    {\n        _client = client;\n    }\n\n    public async Task\u003cActionResult\u003e MakePayment()\n    {\n        var paymentRequest = new CreatePaymentRequest(\n            amountInMinor: amount.ToMinorCurrencyUnit(2),\n            currency: Currencies.GBP,\n            paymentMethod: new CreatePaymentMethod.BankTransfer(\n                new CreateProviderSelection.UserSelected\n                {\n                    Filter = new ProviderFilter\n                    {\n                        ProviderIds = new[] { \"mock-payments-gb-redirect\" }\n                    }\n                },\n                new Beneficiary.ExternalAccount(\n                    \"TrueLayer\",\n                    \"truelayer-dotnet\",\n                    new AccountIdentifier.SortCodeAccountNumber(\"567890\", \"12345678\")\n                )\n            ),\n            user: new PaymentUserRequest(\"Jane Doe\", \"jane.doe@example.com\", \"0123456789\")\n        );\n\n        var apiResponse = await _client.Payments.CreatePayment(\n            paymentRequest,\n            idempotencyKey: Guid.NewGuid().ToString()\n        );\n\n        if (!apiResponse.IsSuccessful)\n        {\n            return HandleFailure(\n                apiResponse.StatusCode,\n                // Includes details of any errors\n                apiResponse.Problem\n            );\n        }\n\n        // Pass the ResourceToken to the TrueLayer Web or Mobile SDK\n\n        // or, redirect to the TrueLayer Hosted Payment Page\n        string hostedPaymentPageUrl = _client.Payments.CreateHostedPaymentPageLink(\n            apiResponse.Data!.Id,\n            apiResponse.Data!.ResourceToken,\n            new Uri(\"https://redirect.yourdomain.com\"));\n\n        return Redirect(hostedPaymentPageUrl);\n    }\n}\n```\n\nFor more examples see the [API documentation](https://docs.truelayer.com). Advanced customization options and documentation for contributors can be found in the [Wiki](https://github.com/TrueLayer/truelayer-sdk-net/wiki).\n\n### Retrieve provider details\n\nInject `ITrueLayerClient` into your classes:\n\n```c#\npublic class MyService\n{\n    private readonly ITrueLayerClient _client;\n\n    public MyService(ITrueLayerClient client)\n    {\n        _client = client;\n    }\n\n    public async Task\u003cActionResult\u003e GetProvider(string id)\n    {\n        var apiResponse = await _client.PaymentsProviders.GetPaymentsProvider(id);\n\n        if (!apiResponse.IsSuccessful)\n        {\n            return HandleFailure(\n                apiResponse.StatusCode,\n                // Includes details of any errors\n                apiResponse.Problem\n            );\n        }\n\n        return Ok(apiResponse.Data.Id);\n    }\n}\n```\n\nFor more examples see the [API documentation](https://docs.truelayer.com). Advanced customization options and documentation for contributors can be found in the [Wiki](https://github.com/TrueLayer/truelayer-sdk-net/wiki).\n\n### Make a payout\n\nInject `ITrueLayerClient` into your classes:\n\n```c#\npublic class MyService\n{\n    private readonly ITrueLayerClient _client;\n\n    public MyService(ITrueLayerClient client)\n    {\n        _client = client;\n    }\n\n    public async Task\u003cActionResult\u003e MakePayout()\n    {\n        var payoutRequest = new CreatePayoutRequest(\n            merchantAccountId: \"VALID_MERCHANT_ID\",\n            amountInMinor: amount.ToMinorCurrencyUnit(2),\n            currency: Currencies.GBP,\n            beneficiary: new Beneficiary.ExternalAccount(\n                \"TrueLayer\",\n                \"truelayer-dotnet\",\n                new SchemeIdentifier.Iban(\"VALID_IBAN\")\n            )\n        );\n\n        var apiResponse = await _client.Payouts.CreatePayout(\n            payoutRequest,\n            idempotencyKey: Guid.NewGuid().ToString()\n        );\n\n        if (!apiResponse.IsSuccessful)\n        {\n            return HandleFailure(\n                apiResponse.StatusCode,\n                // Includes details of any errors\n                apiResponse.Problem\n            );\n        }\n\n\n        return Accepted(apiResponse.Data.Id);\n    }\n}\n```\n\nFor more examples see the [API documentation](https://docs.truelayer.com). Advanced customization options and documentation for contributors can be found in the [Wiki](https://github.com/TrueLayer/truelayer-sdk-net/wiki).\n\n## Testing\n\nThis project includes two types of tests:\n\n**Unit Tests** - Run standalone without external dependencies:\n```shell\ndotnet test test/TrueLayer.Tests/\n```\n\n**Acceptance Tests** - End-to-end integration tests that require TrueLayer sandbox credentials:\n```shell\n# Set credentials via environment variables\nTrueLayer__ClientId=your_client_id TrueLayer__ClientSecret=your_client_secret dotnet test\n\n# Or run all tests (will fail without credentials)\ndotnet test\n```\n\nThe acceptance tests make real HTTP calls to TrueLayer's sandbox APIs to validate the entire SDK against live services. See `test/TrueLayer.AcceptanceTests/README.md` for credential setup instructions.\n\n## Building locally\n\nThis project uses [Cake](https://cakebuild.net/) to build, test and publish packages.\n\nRun `build.sh` (Mac/Linux) or `build.ps1` (Windows) To build and test the project.\n\nThis will output NuGet packages and coverage reports in the `artifacts` directory.\n\n## Contributing\n\nContributions are always welcome!\n\nPlease adhere to this project's [code of conduct](CODE_OF_CONDUCT.md).\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruelayer%2Ftruelayer-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruelayer%2Ftruelayer-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruelayer%2Ftruelayer-dotnet/lists"}