# Welcome!

Welcome to TygaPay Documentation! Here you'll find all the documentation you need to get up and running with the TygaPay Platform.

## 1. API Integration

{% content-ref url="/pages/9qN0UTSKr8WdKpcdTpRb" %}
[API Integration Setup](/api/api-integration-setup)
{% endcontent-ref %}

## 2. Payment Gateway

{% content-ref url="/pages/k3FCN25TwMTLKccswjKW" %}
[Payment Gateway](/payment-gateway)
{% endcontent-ref %}

## 3. Plugins

{% content-ref url="/pages/xQ4uCkgF1Gfbi4B9ZCJH" %}
[WooCommerce](/plugins/woocommerce)
{% endcontent-ref %}

## 4. Refunds

{% content-ref url="/pages/MHgxQgfAEwIBrz4LKhSm" %}
[Refunds](/admin-portal/refunds)
{% endcontent-ref %}


# Payment Gateway

## Overview

Our TygaPay Payment Gateway makes it easy for any business to accept payments for their orders. We currently only support USDT or USDC via direct deposit OR the Tyga App. Users do have the ability to purchase USDT/USDC using their debit card direct in the app to then use on checkout via the Tyga App option.&#x20;

***

### Get Started

We've put together some helpful guides for you to get set up quickly and easily.

{% content-ref url="/pages/o7ch0w5dDF0to18561P2" %}
[How It Works](/payment-gateway/how-it-works)
{% endcontent-ref %}

{% content-ref url="/pages/4XsBQcxeevd3IbhvwNAu" %}
[Get Started](/payment-gateway/get-started)
{% endcontent-ref %}


# How It Works

We provide two distinct payment gateway order options: '**`payment`**' and '**`deposit`**'.

## :credit\_card: **Payment Orders (Fixed Amount):**

For payment orders, a specific, predetermined amount must be paid to complete the order.

{% hint style="info" %}
Use Case: Browse products on your website. Specify the exact amount and initiate the TygaPay order to be paid in full.
{% endhint %}

## :credit\_card: **Deposit Orders (Flexible Amount):**

In the case of deposit orders, there is no fixed amount requirement. Any payment made toward the order will be processed, and upon receipt, the order will be considered complete.

{% hint style="info" %}
Use Case: Accept donations of any amount for your organization or credit a user's account in your system upon successful payment.
{% endhint %}

## :map: Process Flow

1. :rocket: **CREATE:** Initiate Order Creation via API. See:[Orders](/api/apis/orders#create-order)
2. :computer: **PRESENT:** Present the Payment Gateway URL to the Customer.
3. :credit\_card: **PAY:** Customer proceeds with Payment for the Order.
4. :white\_check\_mark: **COMPLETE:** Automatically Redirect to the Specified **`returnUrl`**. See: [Orders](/api/apis/orders#order-redirect-url)
5. :loudspeaker: **NOTIFY:** Trigger Notification to the Specified **`notifyUrl`**. See: [Orders](/api/apis/orders#order-notify-url-webhook)

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FhyWrUlJ5fGUxncBwa8ju%2Fimage.png?alt=media&amp;token=f15f2adb-8ac1-451d-90f5-2acaf71952bb" alt=""><figcaption><p>Payment Gateway Process Flow</p></figcaption></figure>


# Get Started

To create your first Payment Gateway Order, you will need to follow the steps below.

### 1. Complete API Integration Setup

{% content-ref url="/pages/9qN0UTSKr8WdKpcdTpRb" %}
[API Integration Setup](/api/api-integration-setup)
{% endcontent-ref %}

### 2. Create a Payment Gateway Order

{% content-ref url="/pages/FTgLe1yg0bMp1MWFf0Pp" %}
[Orders](/api/apis/orders)
{% endcontent-ref %}


# API Integration Setup

{% hint style="info" %}
**Requirement:** Request an API Key and Secret Key from Tyga Support at <support@tygapay.com> to access the platform.
{% endhint %}

## 1. **Authenticate API Requests**

{% content-ref url="/pages/w80c55LaAC6SRC6dPGSc" %}
[Authentication](/api/api-integration-setup/authentication)
{% endcontent-ref %}

## 2. Making Subsequent API Requests

{% content-ref url="/pages/UTOlKqFWikhM8Ubrthpk" %}
[Requests](/api/api-integration-setup/requests)
{% endcontent-ref %}

## 3. Explore APIs

{% content-ref url="/pages/v3xsH89SW0d6q4aaKzAz" %}
[APIs](/api/apis)
{% endcontent-ref %}


# Authentication

Ensuring Secure and Authenticated API Requests Using HMAC SHA256.

## 1. Signing an API Request

To ensure the security and integrity of your API requests, you need to sign your requests using [<mark style="color:blue;">HMAC SHA256</mark>](https://en.wikipedia.org/wiki/HMAC).&#x20;

This process involves creating a specific string from your request, and then generating a signature using your secret key.

{% hint style="warning" %}
**Requirement:** Request an API Key and Secret Key from Tyga Support at <support@tygapay.com> to access APIs.
{% endhint %}

## 2. Step-by-Step Guide

This guide provides a clear process for signing an API request, from converting a JSON body to a query string (handling nested fields with a dot `.`), constructing the string to sign, and finally signing it using <mark style="color:blue;">HMAC SHA256</mark>.&#x20;

This ensures your API requests are secure and authenticated.

### 2.1 **Create the Query String from JSON**

Depending on your programming language, use the following methods to convert a JSON object to a query string. Note that nested fields are handled using a dot (`.`).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const qs = require('qs');

const jsonObj = {
    field1: "value2",
    nestedField: {
        nestedField1: "nestedValue1"
    }
};

const queryString = qs.stringify(jsonObj, { encode: false, delimiter: '&', allowDots: true });
console.log(queryString); // Output: field1=value2&nestedField.nestedField1=nestedValue1
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Web;
using System.Text.Json;

public class Program
{
    public static void Main()
    {
        var jsonObj = new Dictionary<string, object>
        {
            { "field1", "value2" },
            { "nestedField", new Dictionary<string, object> { { "nestedField1", "nestedValue1" } } }
        };

        var flatDict = FlattenObject(jsonObj);
        var query = HttpUtility.ParseQueryString(string.Empty);

        foreach (var kvp in flatDict)
        {
            query[kvp.Key] = kvp.Value.ToString();
        }

        string queryString = query.ToString().Replace("&amp;", "&");
        Console.WriteLine(queryString); // Output: field1=value2&nestedField.nestedField1=nestedValue1
    }

    public static Dictionary<string, object> FlattenObject(Dictionary<string, object> obj, string parentKey = "", string sep = ".")
    {
        var items = new Dictionary<string, object>();
        foreach (var kvp in obj)
        {
            var newKey = string.IsNullOrEmpty(parentKey) ? kvp.Key : $"{parentKey}{sep}{kvp.Key}";

            if (kvp.Value is Dictionary<string, object> nestedDict)
            {
                var nestedItems = FlattenObject(nestedDict, newKey, sep);
                foreach (var nestedKvp in nestedItems)
                {
                    items[nestedKvp.Key] = nestedKvp.Value;
                }
            }
            else
            {
                items[newKey] = kvp.Value;
            }
        }
        return items;
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
$jsonObj = [
    "field1" => "value2",
    "nestedField" => [
        "nestedField1" => "nestedValue1"
    ]
];

function flattenArray($arr, $parentKey = '', $sep = '.') {
    $items = [];
    foreach ($arr as $key => $value) {
        $newKey = $parentKey ? $parentKey . $sep . $key : $key;
        if (is_array($value)) {
            $items = array_merge($items, flattenArray($value, $newKey, $sep));
        } else {
            $items[$newKey] = $value;
        }
    }
    return $items;
}

$flatArr = flattenArray($jsonObj);
$queryString = urldecode(http_build_query($flatArr));
echo $queryString; // Output: field1=value2&nestedField.nestedField1=nestedValue1
```

{% endtab %}
{% endtabs %}

### 2.2 **Construct the String to Sign**

|                                                           |                                                      |
| --------------------------------------------------------- | ---------------------------------------------------- |
| FULL URL:                                                 | <https://api.com/users?test=xxx>                     |
| <mark style="color:green;">API PATH:</mark>               | /users?test=xxx                                      |
| <mark style="color:yellow;">QUERYSTRING FROM BODY:</mark> | field1=value2\&nestedField.nestedField1=nestedValue1 |

{% hint style="success" %}
Construct the string to sign by concatenating the <mark style="color:green;">API PATH</mark> and the <mark style="color:yellow;">QUERYSTRING FROM BODY</mark>:

stringToSign = "<mark style="color:green;">/users?test=xxx</mark><mark style="color:yellow;">field1=value2\&nestedField.nestedField1=nestedValue1</mark>"
{% endhint %}

### 2.3 **Sign the String using&#x20;**<mark style="color:blue;">**HMAC SHA256**</mark>

Use your programming language's libraries to sign the string using <mark style="color:blue;">HMAC SHA256</mark>.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const crypto = require('crypto');
const secretKey = 'your-secret-key';
const stringToSign = '/users?test=xxxfield1=value2&nestedField.nestedField1=nestedValue1';

const signature = crypto.createHmac('sha256', secretKey)
                        .update(stringToSign)
                        .digest('hex');
console.log(signature);
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Text;
using System.Security.Cryptography;

public class Program
{
    public static void Main()
    {
        string secretKey = "your-secret-key";
        string stringToSign = "/users?test=xxxfield1=value2&nestedField.nestedField1=nestedValue1";

        string signature = SignString(secretKey, stringToSign);
        Console.WriteLine(signature);
    }

    public static string SignString(string key, string data)
    {
        var encoding = new System.Text.ASCIIEncoding();
        byte[] keyByte = encoding.GetBytes(key);
        byte[] messageBytes = encoding.GetBytes(data);

        using (var hmacsha256 = new HMACSHA256(keyByte))
        {
            byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
            return BitConverter.ToString(hashmessage).Replace("-", "").ToLower();
        }
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
$secretKey = 'your-secret-key';
$stringToSign = '/users?test=xxxfield1=value2&nestedField.nestedField1=nestedValue1';

$signature = hash_hmac('sha256', $stringToSign, $secretKey);
echo $signature;
```

{% endtab %}
{% endtabs %}


# Requests

## Making Subsequent API Requests

When making API requests, it is essential to include specific headers to ensure both the identification of your tenant account and the security of your requests. Each request must include the following headers:

### 1.  API Key: 'x-api-key'

* API Keys are provided by TygaPay support. This key must be included in every API request to identify your tenant account.

### 2. API Hash: 'x-api-hash'

* To maintain the security and integrity of your API requests, you must sign your requests using <mark style="color:blue;">HMAC SHA256</mark>. This signature must be included in every API request. Below, we provide instructions on how to create an `x-api-hash`:

{% content-ref url="/pages/w80c55LaAC6SRC6dPGSc" %}
[Authentication](/api/api-integration-setup/authentication)
{% endcontent-ref %}

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" fullWidth="true" %}

```typescript
import axios, { AxiosInstance } from "axios";
import { URL } from "url";
import qs from "qs";
import crypto from "crypto";

class TygaPaySandbox {
  async runExamples() {
    // Store this in a secure place.
    const apiKey = "your-api-key";
    const apiSecret = "your-api-secret-key";

    const service = new TygaPayService(apiKey, apiSecret);

    // 1. GET EXAMPLE
    const user = await service.getUserByUserId("test");
    console.log(user);

    // 2. POST EXAMPLE
    const order = await service.createOrder({
      orderNumber: "order-example-1",
      type: "payment",
      email: "example@gmail.com",
      amount: 100,
      notifyUrl: "https://example.com/payment-webhook",
      returnUrl: "https://example.com/payment-completed",
    });
    console.log(order);
  }
}

/**
 * Refer to the API documentation here: https://tygapay.github.io/docs/
 */
export class TygaPayService {
  private readonly client: AxiosInstance;

  /**
   * Initializes a new instance of the TygaPayService.
   * @param apiKey The API key used for authenticating API requests.
   * @param apiSecret The secret key used for signing API requests.
   */
  constructor(apiKey: string, private apiSecret: string) {
    this.client = axios.create({
      headers: {
        "Content-Type": "application/json",
        "x-api-key": apiKey,
      },
    });
  }

  /**
   * POST EXAMPLE
   * Creates a new order in the TygaPay system.
   * @param request The order details.
   * @returns The API response.
   */
  public async createOrder(request: {
    orderNumber: string;
    type: "payment" | "deposit";
    email: string;
    amount: number;
    notifyUrl: string;
    returnUrl: string;
  }) {
    const url = "https://orders-v1-api-rdqehkur6a-ey.a.run.app/orders";
    return this.processApiRequest("POST", url, request);
  }

  /**
   * GET EXAMPLE
   * Retrieves a user by their user ID from TygaPay.
   * @param userId The user's unique identifier.
   * @returns The user's details.
   */
  public async getUserByUserId(userId: string) {
    const url = `https://users-v1-api-rdqehkur6a-ey.a.run.app/user?userId=${userId}`;
    return this.processApiRequest("GET", url);
  }

  /**
   * Processes an API request to TygaPay.
   * @param method The HTTP method (POST, GET, PUT, DELETE).
   * @param url The endpoint URL.
   * @param body The request payload, if any.
   * @returns The API response as a generic type T.
   */
  public async processApiRequest<T>(
    method: "POST" | "GET" | "PUT" | "DELETE",
    url: string,
    body?: any
  ): Promise<T> {
    try {
      const apiPath = this.extractApiPath(url);
      const signature = this.signApiRequest(body, apiPath);
      const response = await this.client.request({
        method,
        url,
        data: body,
        headers: {
          "x-api-hash": signature,
        },
      });
      return response.data as T;
    } catch (error) {
      console.error("TygaPay API request failed", error);
      throw error;
    }
  }

  /**
   * Extracts the API path from a URL.
   * @param url The full URL.
   * @returns The extracted path and query string.
   */
  private extractApiPath(url: string) {
    const parsedUrl = new URL(url);
    const apiPath = `${parsedUrl.pathname}${parsedUrl.search}`;
    console.log(`Parsed URL: ${apiPath}`);
    return apiPath;
  }

  /**
   * Signs an API request by generating a hash signature.
   * @param body The request payload.
   * @param apiPath The API path.
   * @returns The signature string.
   */
  private signApiRequest(body: any, apiPath: string) {
    const bodyQueryString = qs.stringify(body, {
      encode: false,
      delimiter: "&",
      allowDots: true,
    });
    console.log(bodyQueryString);

    const stringToSign = apiPath + bodyQueryString;
    const signature = crypto
      .createHmac("sha256", this.apiSecret)
      .update(stringToSign)
      .digest("hex");

    return signature;
  }
}

new TygaPaySandbox().runExamples();
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Text;
using Newtonsoft.Json;
using System.Net.Http.Headers;

/// <summary>
/// Refer to the API documentation here: https://tygapay.github.io/docs/
/// Demonstrates usage of the TygaPayService with example methods for both GET and POST requests.
/// </summary>
public class TygaPaySandbox
{
    /// <summary>
    /// Runs example GET and POST requests using the TygaPayService.
    /// </summary>
    public static async Task RunExamples()
    {
        string apiKey = "your-api-key";
        string apiSecret = "your-api-secret-key";

        var service = new TygaPayService(apiKey, apiSecret);

        // Example of a GET request to retrieve user information by userId.
        var user = await service.GetUserByUserId("test");
        Console.WriteLine(JsonConvert.SerializeObject(user));

        // Example of a POST request to create a new order.
        var order = await service.CreateOrder(new OrderRequest
        {
            OrderNumber = "order-example-1",
            Type = "payment",
            Email = "example@gmail.com",
            Amount = 100,
            NotifyUrl = "https://example.com/payment-webhook",
            ReturnUrl = "https://example.com/payment-completed"
        });
        Console.WriteLine(JsonConvert.SerializeObject(order));
    }
}

/// <summary>
/// Provides methods to interact with the TygaPay API.
/// </summary>
public class TygaPayService
{
    private readonly HttpClient client;
    private readonly string apiSecret;

    /// <summary>
    /// Constructor to initialize the TygaPayService with necessary API credentials.
    /// </summary>
    /// <param name="apiKey">API key for TygaPay authorization header.</param>
    /// <param name="apiSecret">Secret key used to sign the API requests.</param>
    public TygaPayService(string apiKey, string apiSecret)
    {
        this.apiSecret = apiSecret;
        client = new HttpClient();
        client.DefaultRequestHeaders.Add("x-api-key", apiKey);
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    }

    /// <summary>
    /// Creates an order with the TygaPay API.
    /// </summary>
    /// <param name="request">Details of the order to create.</param>
    /// <returns>The response from the API as a dynamic object.</returns>
    public async Task<object> CreateOrder(OrderRequest request)
    {
        string url = "https://orders-v1-api-rdqehkur6a-ey.a.run.app/orders";
        return await ProcessApiRequest("POST", url, request);
    }

    /// <summary>
    /// Retrieves user details from the TygaPay API using a user ID.
    /// </summary>
    /// <param name="userId">The ID of the user to retrieve.</param>
    /// <returns>The user details as a dynamic object.</returns>
    public async Task<object> GetUserByUserId(string userId)
    {
        string url = $"https://users-v1-api-rdqehkur6a-ey.a.run.app/user?userId={userId}";
        return await ProcessApiRequest("GET", url);
    }

    /// <summary>
    /// General method to process any API request to the TygaPay API.
    /// </summary>
    /// <param name="method">HTTP method (GET, POST, etc.)</param>
    /// <param name="url">Endpoint URL.</param>
    /// <param name="body">Body of the request, if applicable.</param>
    /// <returns>The API response as a dynamic object.</returns>
    private async Task<object> ProcessApiRequest(string method, string url, object body = null)
    {
        string jsonBody = body == null ? string.Empty : JsonConvert.SerializeObject(body);
        string apiPath = ExtractApiPath(url);
        string signature = SignApiRequest(jsonBody, apiPath);

        HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(method), url)
        {
            Content = new StringContent(jsonBody, Encoding.UTF8, "application/json"),
        };
        request.Headers.Add("x-api-hash", signature);

        HttpResponseMessage response = await client.SendAsync(request);
        string responseContent = await response.Content.ReadAsStringAsync();
        return JsonConvert.DeserializeObject(responseContent);
    }

    /// <summary>
    /// Extracts the API path from a URL to be used in signing the request.
    /// </summary>
    /// <param name="url">The full URL from which to extract the path and query.</param>
    /// <returns>The extracted path and query string.</returns>
    private string ExtractApiPath(string url)
    {
        Uri parsedUrl = new Uri(url);
        return $"{parsedUrl.AbsolutePath}{parsedUrl.Query}";
    }

    /// <summary>
    /// Signs the API request using HMAC SHA256 to generate a hash signature.
    /// </summary>
    /// <param name="body">The body of the request as a JSON string.</param>
    /// <param name="apiPath">The API path extracted from the URL.</param>
    /// <returns>A hexadecimal string of the hash signature.</returns>
    private string SignApiRequest(string body, string apiPath)
    {
        string stringToSign = apiPath + body;
        using var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(apiSecret));
        byte[] hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign));
        return BitConverter.ToString(hash).Replace("-", "").ToLower();
    }
}

/// <summary>
/// Represents the request body for creating an order.
/// </summary>
public class OrderRequest
{
    public string OrderNumber { get; set; }
    public string Type { get; set; }
    public string Email { get; set; }
    public double Amount { get; set; }
    public string NotifyUrl { get; set; }
    public string ReturnUrl { get; set; }
}

class Program
{
    static async Task Main(string[] args)
    {
        await TygaPaySandbox.RunExamples();
    }
}

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

/**
 * Refer to the API documentation here: https://tygapay.github.io/docs/
 * Service class to handle interactions with TygaPay API.
 */
class TygaPayService
{
    private $apiKey;
    private $apiSecret;

    /**
     * Constructor for initializing the TygaPayService with API credentials.
     * 
     * @param string $apiKey API key used for TygaPay API authentication.
     * @param string $apiSecret Secret key used for signing API requests.
     */
    public function __construct($apiKey, $apiSecret)
    {
        $this->apiKey = $apiKey;
        $this->apiSecret = $apiSecret;
    }

    /**
     * Creates an order with the TygaPay API.
     *
     * @param array $request Details of the order including type, email, amount, notifyUrl, and returnUrl.
     * @return array|false The response from the TygaPay API or false on failure.
     */
    public function createOrder($request)
    {
        $url = 'https://orders-v1-api-rdqehkur6a-ey.a.run.app/orders';
        return $this->processApiRequest('POST', $url, $request);
    }

    /**
     * Retrieves a user by their user ID from the TygaPay API.
     *
     * @param string $userId The user's unique identifier.
     * @return array|false The user details from the API or false on failure.
     */
    public function getUserByUserId($userId)
    {
        $url = "https://users-v1-api-rdqehkur6a-ey.a.run.app/user?userId={$userId}";
        return $this->processApiRequest('GET', $url);
    }

    /**
     * Processes an API request to the TygaPay API.
     *
     * @param string $method HTTP method (GET, POST, etc.).
     * @param string $url Full URL to the API endpoint.
     * @param array|null $body Body of the request if applicable.
     * @return array|false The decoded JSON response from the API or false on failure.
     */
    private function processApiRequest($method, $url, $body = null)
    {
        $apiPath = $this->extractApiPath($url);
        echo "API PATH:\n";
        print_r($apiPath);
        $signature = $this->signApiRequest($body, $apiPath);

        $options = [
            'http' => [
                'header' => "x-api-key: {$this->apiKey}\r\n" .
                            "Content-Type: application/json\r\n" .
                            "x-api-hash: {$signature}\r\n",
                'method' => $method,
                'ignore_errors' => true,
            ]
        ];

        if ($body !== null) {
            $options['http']['content'] = json_encode($body);
        }

        $context = stream_context_create($options);
        $response = file_get_contents($url, false, $context);

        if ($response === FALSE) {
            throw new Exception("Error Processing Request");
        }

        return json_decode($response, true);
    }

    /**
     * Extracts the API path from a full URL, used for signing requests.
     *
     * @param string $url The full URL.
     * @return string Extracted path and query part of the URL.
     */
    private function extractApiPath($url)
    {
        $parsedUrl = parse_url($url);
        return $parsedUrl['path'] . (isset($parsedUrl['query']) ? '?' . $parsedUrl['query'] : '');
    }

    /**
     * Signs an API request using HMAC SHA256.
     *
     * @param array|null $body The body of the request, if applicable.
     * @param string $apiPath The API path to be included in the signature.
     * @return string The generated hash signature.
     */
    private function signApiRequest($body, $apiPath)
    {
      $bodyQueryString = $body ? $this->buildQueryString($body) : '';
      echo "\nBodyQueryString:\n";
      print_r($bodyQueryString);

      // Concatenate the API path and query string
      $stringToSign = $apiPath . $bodyQueryString;
      echo "\nStringToSign:\n";
      print_r($stringToSign);

      // Generate HMAC signature
      $hash = hash_hmac('sha256', $stringToSign, $this->apiSecret);
      echo "\nHash:\n";
      print_r($hash);
      return $hash;
    }

  private function buildQueryString($params, $prefix = '')
  {
      $query = [];
      foreach ($params as $key => $value) {
          if (is_array($value)) {
              $newPrefix = $prefix === '' ? $key : $prefix . '.' . $key;
              $query[] = $this->buildQueryString($value, $newPrefix);
          } else {
              $newKey = $prefix === '' ? $key : $prefix . '.' . $key;
              $query[] = $newKey . '=' . $value;
          }
      }
      return $query ? implode('&', $query) : '';
  }
}

/**
 * A sandbox class to demonstrate the use of the TygaPayService.
 */
class TygaPaySandbox
{
    /**
     * Runs examples of creating an order and retrieving a user by ID.
     */
    public static function runExamples()
    {
        $apiKey = 'your-api-key';
        $apiSecret = 'your-api-secret-key';
        $service = new TygaPayService($apiKey, $apiSecret);
    
        // $user = $service->getUserByUserId('test');
        // echo "User Info:\n";
        // print_r($user);
    
        $order = $service->createOrder([
            'orderNumber' => 'order-example-1-2',
            'type' => 'payment',
            'email' => 'example@gmail.com',
            'amount' => 100,
            'notifyUrl' => 'https://example.com/payment-webhook',
            'returnUrl' => 'https://example.com/payment-completed'
        ]);
        echo "Order Info:\n";
        print_r($order);
    }
}

// Running the examples
TygaPaySandbox::runExamples();
?>
```

{% endtab %}
{% endtabs %}


# APIs

Dive into the specifics of each API by checking out our complete documentation.

{% hint style="info" %}
**Good to know:** All the APIs are kept  up to date via Swagger Docs: <https://tygapay.github.io/docs/>
{% endhint %}

## :bank: Tenant APIs

All the APIs associated with `Tenants`.

{% content-ref url="/pages/B7RKiGw9WNJfrIcfu85K" %}
[Tenants](/api/apis/tenants)
{% endcontent-ref %}

## :smile: Users

All the APIs associated with `Users`.

{% content-ref url="/pages/rbg1C3ykL79vzCArvrAk" %}
[Users](/api/apis/users)
{% endcontent-ref %}

## :left\_right\_arrow: Transactions

All the APIs associated with `Transactions`.

{% content-ref url="/pages/cTT4ud0CZgDolY9UrPI4" %}
[Transactions](/api/apis/transactions)
{% endcontent-ref %}

## :receipt: Orders

All the APIs associated with `Orders`.

{% content-ref url="/pages/FTgLe1yg0bMp1MWFf0Pp" %}
[Orders](/api/apis/orders)
{% endcontent-ref %}


# Swagger Docs

Access TygaPay Swagger Docs here: <https://tygapay.github.io/docs/>


# Tenants

API's for managing Tenants.

{% hint style="success" %}
Production URL: <https://tenants-v1-api-rdqehkur6a-ey.a.run.app>
{% endhint %}

## Create Tenant

{% hint style="info" %}
**Requirement:** Request an Auth Code from Tyga Support at <support@tygapay.com> to create a Tenant Account.
{% endhint %}

## Get Tenant Wallets

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/tenant/wallets" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Get Tenant Deposit Addresses

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/tenant/deposit-addresses" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}


# Users

API's to manage Users.

{% hint style="info" %}
Production URL: [https://users-v1-api-rdqehkur6a-ey.a.run.app](https://users-v1-api-rdqehkur6a-ey.a.run.app/)
{% endhint %}

## Create User

{% hint style="info" %}
Supported Date formats includes:\
"2015-03-25" (The International Standard)\
"03/25/2015"\
"Mar 25 2015" or "25 Mar 2015"\
1726726779171 (Epoch milliseconds)
{% endhint %}

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/user" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Get User

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/user" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Get User Balances

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/user/balances" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Get User Crypto Deposit Addresses

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/user/deposit-addresses" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}


# Transactions

API's to manage Transactions.

{% hint style="info" %}
Production URL: [https://transactions-v1-api-rdqehkur6a-ey.a.run.app](https://transactions-v1-api-rdqehkur6a-ey.a.run.app/)
{% endhint %}

## Create Payout Request

Payouts can be created for users which will be deducted from the Tenant <mark style="color:yellow;">Distribution Wallet</mark>.

{% hint style="info" %}
Good to know:

* Payouts can be processed automatically or manually via the TygaPay dashboard. Contact <support@tygapay.com> to configure your preferred payout process.
* Tenant Distribution Wallets can be funded via bank transfers or crypto deposits. Contact <support@tygapay.com> for more information.
  {% endhint %}

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/transactions/payout" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Create Staking Payout Request

Staking allows users to earn rewards by holding and locking their cryptocurrencies over a period.

{% hint style="info" %}
Good to know:

* Rewards are calculated based on the asset configuration.
* For more details about staking terms and conditions, please contact <support@tygapay.com>.
  {% endhint %}

{% openapi src="/files/jvzZKBHS5SUmBpqj3MQg" path="/transactions/staking/payout" method="post" %}
[definition.latest.json](https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2Fnu6vNPt3wKDfs4NABu4X%2Fdefinition.latest.json?alt=media\&token=b1c8df22-da43-4a33-be25-149ad5add318)
{% endopenapi %}

## Revoke Staking Payout

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/transactions/staking/payout/revoke" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Payout Completed Notify Url

<mark style="color:green;">`POST`</mark> `https://your-notify-url`

#### Request Body

<table data-full-width="true"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>transactionId<mark style="color:red;">*</mark></td><td>string</td><td>Unique Transaction Id.</td></tr><tr><td>thirdPartyId<mark style="color:red;">*</mark></td><td>string</td><td>Unique Id of the third party involved in the transaction.</td></tr><tr><td>amount<mark style="color:red;">*</mark></td><td>number</td><td>The transaction payout amount.</td></tr><tr><td>status<mark style="color:red;">*</mark></td><td>string</td><td><code>success</code>: Payout has been processed successfully.<br><code>cancelled</code>: Payout has been cancelled.</td></tr></tbody></table>

## Get User Transactions

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/transactions/users" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Search Transactions

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/transactions" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Refund Pending Confirmation Transactions

In some instances, customers may make a duplicate payment or send a payment to a crypto wallet address that is no longer associated with an order. In such cases, the payment will remain unlinked to an order and be placed in a 'pending\_confirmation' status until it can be confirmed or refunded.

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/transactions/refund" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}


# Orders

API's to manage Orders.

{% hint style="success" %}
Production URL: <https://orders-v1-api-rdqehkur6a-ey.a.run.app>
{% endhint %}

## Create Order

{% hint style="info" %}
Please Note: If you want to pre-populate user data for the **Stripe Onramp** payment feature - Please ensure to add the `customerInformation` object data.
{% endhint %}

{% openapi src="/files/rPuT9KOddCSPtVoRBzsx" path="/orders" method="post" %}
[definition.new.json](https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2F8VicTOvYhEdmoV6a6WSY%2Fdefinition.new.json?alt=media\&token=60ac049a-c07a-4a3e-9dfe-6a603166fe84)
{% endopenapi %}

## Order Notify Url (Webhook)

{% hint style="warning" %}
WARNING: Ensure that your system accepts payments ONLY when the status of the notifyUrl request is "**success**".
{% endhint %}

## Order Completed Notify Url

<mark style="color:green;">`POST`</mark> `https://your-notify-url`

#### Request Body

<table><thead><tr><th>Name</th><th width="459">Type</th><th>Description</th></tr></thead><tbody><tr><td>orderId<mark style="color:red;">*</mark></td><td>string</td><td>TygaPay Order Id.</td></tr><tr><td>orderNumber<mark style="color:red;">*</mark></td><td>string</td><td>Unique Order Number .</td></tr><tr><td>status<mark style="color:red;">*</mark></td><td>string</td><td><p>Status of the order upon completion:</p><p><code>success</code>: Payment has been successfully processed.</p><p><code>expired</code>: The order has expired.</p><p><code>cancelled</code>: The order has been cancelled.</p></td></tr><tr><td>date<mark style="color:red;">*</mark></td><td>string</td><td><p>Order complettion date. i.e </p><p>2024-01-07T19:05:30.175Z</p></td></tr><tr><td>amount</td><td>number</td><td>The paid amount. Amount will only be present if the status is equal to <code>success</code>.</td></tr><tr><td>currency</td><td>string</td><td>i.e USDT, KRU etc<br>Currency will only be present if the status is equal to <code>success</code>.</td></tr><tr><td>txId</td><td>String</td><td>The payment TygaPay txId. TxID will only be present if the status is equal to <code>success</code>.</td></tr></tbody></table>

## Order Redirect Url

When an order receives a final outcome, the Payment Gateway will redirect to the specified redirect URL. The redirect URL will have the following parameters appended: \
`?orderId=[ORDER_ID]&orderNumber=[ORDER_NUMBER]&status=[STATUS]`

i.e <https://your-redirect-url?orderId=004Qs494RxpEMFYUyXBz\\&orderNumber=323421\\&status=success>

| Fields        | Description                                                                                                                                                                                                                     |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ORDER\_ID     | The TygaPay Order Id                                                                                                                                                                                                            |
| ORDER\_NUMBER | The orderNumber supplied in the creation of the order.                                                                                                                                                                          |
| STATUS        | <p>Status of the order upon completion:</p><p><code>success</code>: Payment has been successfully processed.</p><p><code>expired</code>: The order has expired.</p><p><code>cancelled</code>: The order has been cancelled.</p> |

{% hint style="info" %}
Note: TygaPay will accommodate the specific format required for your redirect URL.
{% endhint %}

## Get Order

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/orders" method="get" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Cancel Order

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/orders/:orderId/cancel" method="put" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Refund Order to TygaPay Account

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/orders/:orderId/refund" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Refund Order to Crypto Address

{% hint style="info" %}

* To process a refund to a cryptocurrency address, an OTP (One-Time Password) is necessary. Please reach out to <support@tygapay.com> to set up the Tenant Admin account that will receive these OTPs.
  {% endhint %}

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/orders/:orderId/refund/crypto/otp" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

{% openapi src="<https://tygapay.github.io/docs/definition.json>" path="/orders/:orderId/refund/crypto" method="post" %}
<https://tygapay.github.io/docs/definition.json>
{% endopenapi %}

## Refund NotifyUrl Request (Webhook)

<mark style="color:green;">`POST`</mark> `https://your-refund-notify-url`

#### Request Body

<table><thead><tr><th>Name</th><th width="459">Type</th><th>Description</th></tr></thead><tbody><tr><td>type<mark style="color:red;">*</mark></td><td>string</td><td><code>order_refund</code> | <code>order_refund_crypto</code></td></tr><tr><td>orderId<mark style="color:red;">*</mark></td><td>string</td><td>TygaPay Order Id.</td></tr><tr><td>orderNumber<mark style="color:red;">*</mark></td><td>string</td><td>Unique Order Number .</td></tr><tr><td>status<mark style="color:red;">*</mark></td><td>string</td><td><p>Status of the order refund upon completion:</p><p><code>refunded</code>: Order has been refunded successfully.</p></td></tr><tr><td>date<mark style="color:red;">*</mark></td><td>string</td><td><p>Order complettion date. i.e </p><p>2024-01-07T19:05:30.175Z</p></td></tr><tr><td>amount<mark style="color:red;">*</mark></td><td>number</td><td>The refunded amount. </td></tr><tr><td>currency<mark style="color:red;">*</mark></td><td>string</td><td>The refunded currency. i.e USDT</td></tr><tr><td>txId<mark style="color:red;">*</mark></td><td>string</td><td>The payment TygaPay txId. </td></tr><tr><td>thirdPartyId</td><td>string</td><td>The specified <code>thirdPartyId</code> is used to initiate the refund request.</td></tr><tr><td>address</td><td>string</td><td>The address to which the refunded amount was sent. This address is provided when the type is <code>order_refund_crypto</code>.</td></tr><tr><td>token</td><td>string</td><td>The token, such as USDT, that has been transferred to the blockchain address.</td></tr><tr><td>network</td><td>string</td><td>The network used to transmit the token.</td></tr><tr><td>txHash</td><td>string</td><td>The blockchain transaction ID, which can be used to verify the legitimacy of the transfer.</td></tr></tbody></table>


# WooCommerce

## Overview

Our WooCommerce Plugin makes it easy for any developer to integrate with the TygaPay Payment Gateway.

***

### Get Started

We've put together some helpful guides for you to get setup quickly and easily.

{% content-ref url="/spaces/pCZIBuMMKukshUmEKQzb/pages/gEoek82DG23UkebWQR5f" %}
[API Credentials](/plugins/woocommerce/api-credentials)
{% endcontent-ref %}

{% content-ref url="/spaces/pCZIBuMMKukshUmEKQzb/pages/JH16kxLxKvNxwIzOj3QI" %}
[Integration](/plugins/woocommerce/integration)
{% endcontent-ref %}


# How It Works

Check out a video of the TygaPay WooCommerce plugin in action.

{% embed url="<https://firebasestorage.googleapis.com/v0/b/tygapay-ba6b4.appspot.com/o/woocommerce_plugin%2FPayMe%2FTygaPay%20WooCommerce%20PayMe.mp4?alt=media&token=a9ff5962-ec79-4a00-b9fa-17c6834e6039>" %}


# API Credentials

{% hint style="info" %}
Contact us [here](https://tygapay.com/business.html#contactUs) and we will gladly set you up.
{% endhint %}


# Integration

{% hint style="warning" %}
Before you continue make sure that you have your TygaPay Api credentials.
{% endhint %}

### 1. Install the TygaPay plugin for WooCommerce

* Download the latest plugin zip file below:

  :paperclip:  [Plugin v1.0.5](https://firebasestorage.googleapis.com/v0/b/tygapay-ba6b4.appspot.com/o/woocommerce_plugin%2FPayMe%2Ftygapay-woocommerce-payme-v1.0.5.zip?alt=media\&token=cfc044b7-48cf-4b25-94e3-55dbe4ae1b9d)
* Within your Wordpress admin section navigate to "**Plugins**".
* Click "**Add new**".
* Then click "**Upload Plugin**".
* Now click "**Choose file**" and upload the plugin zip file you downloaded.
* Make sure you click "**Activate**" after the installation has been completed.

<figure><img src="https://tygapay.com/images/woocommerce_add_new.jpg" alt=""><figcaption><p>Upload the plugin</p></figcaption></figure>

### 2. Confirm that the TygaPay plugin has been enabled

* Within your Wordpress admin section navigate to "**WooCommerce**".
* Click "**Settings**".
* Then click the "**Payments**" tab at the top.
* Ensure that the payment method for **TygaPay Gateway** is enabled.

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FiaEK6w9Utvg3lEeRBJ0T%2FSCR-20240213-jtet.png?alt=media&amp;token=559a551d-2d53-46f1-888c-f8d17dd83dbf" alt=""><figcaption><p>Enable the plugin</p></figcaption></figure>

### 3. Lastly enter your TygaPay Api credentials

* Following on from step 2 click "**Manage**" next to TygaPay Gateway.
* Enter the "**Live Api Key**" provided by the TygaPay team.
* And the "**Live Secret**" provided by the TygaPay team.
* Click "**Save changes**" and you are ready to go.

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FT9Y6YB2Ih7FLg2uPSlkK%2Fimage.png?alt=media&amp;token=0d86bfeb-c5bc-44a8-9791-87a5ab5238ef" alt=""><figcaption><p>Enter your credentials</p></figcaption></figure>

### 4. Success

On the checkout page users will now have the option to pay using the TygaPay payment option.

Check out the plugin in action below:

{% content-ref url="/spaces/pCZIBuMMKukshUmEKQzb/pages/I2NESDwew43vEW6VREtD" %}
[How It Works](/plugins/woocommerce/how-it-works)
{% endcontent-ref %}


# Refunds

{% hint style="info" %}
**Refund Policy:**\
All refund requests must be associated with a valid email address linked to a registered TygaPay account. **Refunds cannot be processed if the user does not have an account with TygaPay.** Once a refund is approved, the associated TygaPay wallet will be credited accordingly.
{% endhint %}

## 1. **Paid Order Refunds**

To issue a Paid Order Refund, the organization must have sufficient funds in its <mark style="color:blue;">Distribution Wallet</mark>. If the organization's <mark style="color:blue;">Distribution Wallet</mark> lacks the necessary funds, the refund request will fail.

{% hint style="success" %}
Checklist:

1. The order must have a <mark style="color:green;">"Paid"</mark> status.
2. The email linked to the order must have a <mark style="color:yellow;">TygaPay Account</mark> to receive the refund.
3. The Tenant's <mark style="color:blue;">Distribution Wallet</mark> must contain sufficient funds.
   {% endhint %}

{% content-ref url="/pages/60zsY2frnQDfhyHTaOTA" %}
[Paid Order Refunds](/admin-portal/refunds/paid-order-refunds)
{% endcontent-ref %}

## 2. **Partial Paid Order Refunds**

TygaPay maintains a designated float for partial refunds. If a partial refund is requested for an order, funds will be transferred from the partial refund float to the user's TygaPay wallet.

{% hint style="success" %}
Checklist:

1. The order must have a <mark style="color:green;">"Partial Paid"</mark> status.
2. The email linked to the order must have a <mark style="color:yellow;">TygaPay Account</mark> to receive the refund.
   {% endhint %}

{% content-ref url="/pages/3anjuvoF44Jy3TuQJ2Gl" %}
[Partial Paid Order Refunds](/admin-portal/refunds/partial-paid-order-refunds)
{% endcontent-ref %}

## 2. **Overpaid Order Refunds**

TygaPay maintains a designated float for overpaid funds. If a user overpays for an order, the surplus amount will be refunded to the user's linked TygaPay wallet.

{% hint style="success" %}
Checklist:

1. The order must have a <mark style="color:green;">"Paid"</mark> status.
2. The email linked to the order must have a <mark style="color:yellow;">TygaPay Account</mark> to receive the refund.
   {% endhint %}

{% content-ref url="/pages/J7ZoEMSU4eqBwRz7Ar6n" %}
[Overpaid Order Refunds](/admin-portal/refunds/overpaid-order-refunds)
{% endcontent-ref %}


# Paid Order Refunds

Follow the instructions to perform a Paid Order Refund.

{% hint style="warning" %}

1. Paid Order Refund permissions must be granted at the tenant level. To enable refunds, please contact TygaPay support.&#x20;
2. Only tenant admin users are authorized to process refunds.
   {% endhint %}

### 1. Find the Order <a href="#id-1.-search-order" id="id-1.-search-order"></a>

{% hint style="info" %}
You can find all orders at <https://tygapay-admin.web.app/orders/all>.
{% endhint %}

**Search Filters**

To enhance your search and narrow down results, utilize the following filters:

<table data-header-hidden data-full-width="false"><thead><tr><th>Filter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Order Number</strong></td><td>Locate orders based on their unique order number.</td></tr><tr><td><strong>Order ID</strong></td><td>Use the specific identifier for each order.</td></tr><tr><td><strong>Email</strong></td><td>Search for orders associated with a specific email address.</td></tr><tr><td><strong>Status</strong></td><td>Filter orders by their current status.</td></tr><tr><td><strong>Deposit Address</strong></td><td>Find orders using the cryptocurrency deposit address.</td></tr><tr><td><strong>Created Date</strong></td><td>Search for orders by the date they were created.</td></tr><tr><td><strong>Completed Date</strong></td><td>Locate orders based on the date they were completed.</td></tr><tr><td><strong>TxHash</strong></td><td>Use the transaction hash to find specific transactions.</td></tr></tbody></table>

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FPxBpTjMpxC6ym7CRL13P%2Fimage.png?alt=media&amp;token=f0b9504e-1d44-4a4b-aed4-6bf0d8d02dbb" alt=""><figcaption><p>Example of Filtering for Orders with "Paid" Status</p></figcaption></figure>

### 2. Action Full Refund

The refund button will be available based on the specified order status and the paid amount.

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2Fo38szXWxGWbRQPoFNPsu%2Fimage.png?alt=media&amp;token=adadcade-a4d3-4359-9f92-a56cac6ab1d2" alt=""><figcaption><p>Example of Clicking the Refund Action Button. <br>(Refund Button Highlighted)</p></figcaption></figure>

### 3. Authorize Full Refund

A refund can only be authorized by a tenant admin user. The current tenant admin user will receive an OTP via email to approve the refund.

{% hint style="success" %}
Checklist:

1. The order must have a <mark style="color:green;">"Paid"</mark> status.
2. The email linked to the order must have a <mark style="color:yellow;">TygaPay Account</mark> to receive the refund.
3. The Tenant's <mark style="color:blue;">Distribution Wallet</mark> must contain sufficient funds.
   {% endhint %}

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2F0QQyK0yHRLKZT3S8t6Ox%2Fimage.png?alt=media&amp;token=74ab46bf-d0ef-40b7-ae76-7b9f00814189" alt=""><figcaption><p>Example of Authorizing a Refund.</p></figcaption></figure>

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FOK0ADGa104tbJ66QzbCl%2Fimage.png?alt=media&amp;token=4881d133-eaab-41bd-a0f0-90fb875ec6b0" alt=""><figcaption><p>Example of the Order Refunded.</p></figcaption></figure>


# Partial Paid Order Refunds

Follow the instructions to perform a Partial Paid Order Refund.

{% hint style="warning" %}

1. Partial Paid Order Refund permissions must be granted at the tenant level. To enable refunds, please contact TygaPay support.&#x20;
2. Only tenant admin users are authorized to process refunds.
   {% endhint %}

### 1. Find the Order <a href="#id-1.-search-order" id="id-1.-search-order"></a>

{% hint style="info" %}
You can find all orders at <https://tygapay-admin.web.app/orders/all>.
{% endhint %}

**Search Filters**

To enhance your search and narrow down results, utilize the following filters:

<table data-header-hidden data-full-width="false"><thead><tr><th>Filter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Order Number</strong></td><td>Locate orders based on their unique order number.</td></tr><tr><td><strong>Order ID</strong></td><td>Use the specific identifier for each order.</td></tr><tr><td><strong>Email</strong></td><td>Search for orders associated with a specific email address.</td></tr><tr><td><strong>Status</strong></td><td>Filter orders by their current status.</td></tr><tr><td><strong>Deposit Address</strong></td><td>Find orders using the cryptocurrency deposit address.</td></tr><tr><td><strong>Created Date</strong></td><td>Search for orders by the date they were created.</td></tr><tr><td><strong>Completed Date</strong></td><td>Locate orders based on the date they were completed.</td></tr><tr><td><strong>TxHash</strong></td><td>Use the transaction hash to find specific transactions.</td></tr></tbody></table>

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2F82iuBbkXEvndSCZ7wN5q%2Fimage.png?alt=media&amp;token=e34e6bfb-f60a-4361-9920-7d0c16fcde00" alt=""><figcaption><p>Example of Filtering for Orders with "Partial Paid" Status</p></figcaption></figure>

### 2. Action Partial Refund

The refund button will be available based on the specified order status and the paid amount.

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FCzKM6x4FgeaWlqQ9XsNE%2Fimage.png?alt=media&amp;token=86be6370-003b-459f-a2b3-bd16f1ea2d51" alt=""><figcaption><p>Example of Clicking the Refund Action Button. <br>(Refund Button Highlighted)</p></figcaption></figure>

### 3. Authorize Partial Refund

A refund can only be authorized by a tenant admin user. The current tenant admin user will receive an OTP via email to approve the refund.

{% hint style="success" %}
Checklist:

1. The order must have a <mark style="color:green;">"Partial Paid"</mark> status.
2. The email linked to the order must have a <mark style="color:yellow;">TygaPay Account</mark> to receive the refund.
   {% endhint %}

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2F00k6fMkS6eKdNhYH5db4%2Fimage.png?alt=media&amp;token=61bd9f85-032a-4231-856c-ddb43923a4ac" alt=""><figcaption><p>Example of Authorizing a Refund.</p></figcaption></figure>

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FOK0ADGa104tbJ66QzbCl%2Fimage.png?alt=media&amp;token=4881d133-eaab-41bd-a0f0-90fb875ec6b0" alt=""><figcaption><p>Example of the Order Refunded.</p></figcaption></figure>


# Overpaid Order Refunds

Follow the instructions to perform a Overpaid Order Refund.

{% hint style="warning" %}

1. Overpaid Order Refund permissions must be granted at the tenant level. To enable refunds, please contact TygaPay support.&#x20;
2. Only tenant admin users are authorized to process refunds.
   {% endhint %}

### 1. Find the Order <a href="#id-1.-search-order" id="id-1.-search-order"></a>

{% hint style="info" %}
You can find all orders at <https://tygapay-admin.web.app/orders/all>.
{% endhint %}

**Search Filters**

To enhance your search and narrow down results, utilize the following filters:

| **Order Number**    | Locate orders based on their unique order number.           |
| ------------------- | ----------------------------------------------------------- |
| **Order ID**        | Use the specific identifier for each order.                 |
| **Email**           | Search for orders associated with a specific email address. |
| **Status**          | Filter orders by their current status.                      |
| **Deposit Address** | Find orders using the cryptocurrency deposit address.       |
| **Created Date**    | Search for orders by the date they were created.            |
| **Completed Date**  | Locate orders based on the date they were completed.        |
| **TxHash**          | Use the transaction hash to find specific transactions.     |

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FaT88yd7Vqfacd9fELHXH%2Fimage.png?alt=media&amp;token=6422948c-d9af-40c8-9245-d80303f53600" alt=""><figcaption><p>Example of Filtering for Orders with "Paid" Status</p></figcaption></figure>

### 2. Action Overpaid Refund

The refund button will be available based on the specified order status and the paid amount.

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FiYaSr9HjyU0bZgfXdUVL%2Fimage.png?alt=media&amp;token=14ea7587-ed9e-4053-923a-a881108ffa7a" alt=""><figcaption><p>Example of Clicking the Refund Action Button. <br>(Refund Button Highlighted)</p></figcaption></figure>

### 3. Authorize Overpaid Refund

A refund can only be authorized by a tenant admin user. The current tenant admin user will receive an OTP via email to approve the refund.

{% hint style="success" %}
Checklist:

1. The order must have a <mark style="color:green;">"Paid"</mark> status.
2. The email linked to the order must have a <mark style="color:yellow;">TygaPay Account</mark> to receive the refund.
   {% endhint %}

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FEkMK9bCuT0o065eXeaKU%2Fimage.png?alt=media&amp;token=8a71c6f6-0c37-440f-9505-ca20a64a758a" alt=""><figcaption><p>Example of Authorizing a Refund.</p></figcaption></figure>

<figure><img src="https://820186084-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpCZIBuMMKukshUmEKQzb%2Fuploads%2FkjbKLHXhd8VDxPiOIv6m%2Fimage.png?alt=media&amp;token=d8f913cb-a10f-423b-9036-ba5738a8b410" alt=""><figcaption><p>Example of Overpaid Refunded</p></figcaption></figure>

{% hint style="info" %}
The overpaid amount will be refunded to the email associated with the order, and it will be deducted from the total.
{% endhint %}


