๐Ÿš€API Integration Setup

Requirement: Request an Auth Code from Tyga Support at support@tygapay.com to access the platform.

1. Create a Tenant Account

To begin using the TygaPay API, you need to set up a tenant by following these steps:

  1. Request an Auth Code from the TygaPay support team at support@tygapay.com.

  2. Use the Create Tenant API to create a tenant with the Auth Code.

  3. Upon successful creation of the tenant, you will receive a response object containing two essential values: apiSecret and apiKey.

Important: Ensure that you do not send the apiSecretover any HTTP call. It is meant to be kept confidential and is exclusively used for creating the sha256 HMAC x-api-hash.

2. How to make Subsequent API Requests

After setting up the tenant, you can make subsequent API requests.

These requests require two headers: x-api-key and x-api-hash.

The x-api-hash is a sha256 HMAC hash, which is derived using the API query combined with the request body.

# Install via NPM
npm install --save createHmac

# Example to Process API Requests
private readonly client: AxiosInstance;
apiSecret = "XXXXXXX"; // Get from a secure place.
apiKey = "XXXXXXX"; // Get from a secure place.

constructor() {
  this.client = axios.create();
}

private async processRequest<T>(method: "POST" | "GET" | "PUT" | "DELETE", url: string, body?: any) {
      const queryString = stringify({ ...body }, "&", "=", {
        encodeURIComponent: (str) => str,
      });

      const signature = createHmac("sha256",apiSecret).update(queryString).digest("hex");
  
      const response = await this.client.request({
        method,
        url,
        data: body,
        headers: {
          "Content-Type": "application/json",
          "x-api-key": apiKey,
          "x-api-hash": signature,
        },
      });

      return response.data as T;
  }

Ready to deep dive?

Explore our API reference to get an idea of everything possible with the API:

๐Ÿ“ฆpageAPIs

Last updated