1. Client Options Configuration
First, define your merchant API credentials obtained from the OneKhusa Portal.IsSandbox is set to true, so you can omit this if you are using sandbox environment. Likewise, with ApiVersion is defaulted to v1, for any new version change it to something like v2, v3 etc.
2. Initializing the Client
Option 1: Using Dependency Injection
This is recommended for web apps and web APIs and in yourProgram.cs, register the service as below. This automatically manages connection pooling and logging.
Usage: Sample Code
This code shows how to inject OneKhusaClient into your services, controllers etc. as follows:Option 2: Manual Instantiation
This is recommended for console apps. Use this code below to create a client. Do not create newOneKhusaClient instance on every API request, create it once, reuse it for subsequent API calls.
var client = new OneKhusaClient(options);