Developer Center


If your payment service provider supports refund, you can easily integrate it into the module.

There should be a function called "refundInvoice" inside your module class.

The parameter contains data from the 'invoices' table in the database.

Sample Usage

public function refundInvoice($invoice=[])
    $api_key        = $this->config["settings"]["example1"] ?? 'N/A';
    $secret_key     = $this->config["settings"]["example2"] ?? 'N/A';
    $amount         = $invoice["total"];
    $currency       = $this->currency($invoice["currency"]);

    // In callback or capture functions, the data transmitted as 'message' in the return value is retrieved.
    $method_msg         = Utility::jdecode($invoice["pmethod_msg"] ?? [],true);
    $transaction_id     = $method_msg["Merchant Transaction ID"] ?? false;

    $force_curr     = $this->config["settings"]["force_convert_to"] ?? 0;
    if($force_curr > 0)
        $amount         = Money::exChange($amount,$currency,$force_curr);
        $currency       = $this->currency($force_curr);

    // Here we are making an API call.
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "".$transaction_id);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'APIKEY: '.$api_key,
        'SECRET: '.$secret_key,
        'Content-Type: application/json',
    $result = curl_exec($curl);
        $result      = false;
        $this->error = curl_error($curl);
    $result             = json_decode($result,true);

    if($result && $result['status'] == 'OK') $result = true;
        $this->error = $result['message'] ?? 'something went wrong';
        $result = false;

    return $result;

The value to return from the function must be of the "boolean" data type.

Installment Options Callback

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel