Skip to content

Basis-Theory/basistheory-dotnet

Repository files navigation

Basis Theory .NET SDK

NuGet Verify

The Basis Theory .NET SDK for .NET Standard 2.0 and .NET Standard 2.1, supporting .Net 5.0 +, .NET Core 2.1 +, and .NET Framework 4.6.2 +.

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package BasisTheory.net

Using the NuGet Command Line Interface (CLI):

nuget install BasisTheory.net

Using the Package Manager Console:

Install-Package BasisTheory.net

Documentation

For a complete list of endpoints and examples, please refer to our API docs

Usage

Per-request configuration

All of the service methods accept an optional RequestOptions object. This is used if you want to set a correlation ID or if you want to set a per-request BT-API-KEY

var requestOptions = new RequestOptions();
requestOptions.ApiKey = "API KEY";
requestOptions.CorrelationId = Guid.NewGuid().ToString();

Using a custom HttpClient

Each client can be configured to use a custom HttpClient:

var httpClient = new HttpClient();
var client = new TokenClient(apiKey, httpClient: httpClient);

Setting a custom API Url

Each client can set a custom API Url, such as calling a deployed instance of the Token Proxy.

var client = new TokenClient(apiKey, apiBaseUrl: "https://token-proxy.somedomain.com");

AspNetCore Setup

See complete documentation in the BasisTheory.net.AspNetCore project

Development

The provided scripts with the SDK will check for all dependencies, start docker, build the solution, and run all tests.

Dependencies

Build the SDK and run Tests

Run the following command from the root of the project:

make verify