<?php

if (!defined('IN_SITE')) {
    die('The Request Not Found');
}
$hash_4bb8d2 = '18c2d09000a8bb37d2958a746eaddc7cb0faafd567922223cac62da72f62b8b2';
if (!function_exists('verify_license_integrity_4bb8d2')) {
    function verify_license_integrity_4bb8d2($expectedHash)
    {
        static $verified = false;
        if ($verified) {
            return;
        }
        $licenseFile = __DIR__ . '/../models/is_license.php';
        if (!is_file($licenseFile) || hash_file('sha256', $licenseFile) !== $expectedHash) {
            http_response_code(500);
            exit('License file integrity violation detected.');
        }
        $verified = true;
    }
}
verify_license_integrity_4bb8d2($hash_4bb8d2);
unset($hash_4bb8d2);

class toyyibpay {
	private $userSecretKey;

	function __construct(string $userSecretKey) {
		if(empty($userSecretKey)) {
			throw new Exception('User Secret Key is not specified');
		} else {
			$this->userSecretKey = $userSecretKey;
		}
	}
	public function getBillTransactions(array $some_data) {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/getBillTransactions');  
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
        $result = curl_exec($curl);
        $info = curl_getinfo($curl);  
        curl_close($curl);
        return $result;
	}

    public function createBill(array $some_data) {
        $some_data['userSecretKey'] = $this->userSecretKey;
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_URL, 'https://toyyibpay.com/index.php/api/createBill');  
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $some_data);
        $result = curl_exec($curl);
        $info = curl_getinfo($curl);  
        curl_close($curl);
        return $result;
	}
 
	function __destruct() {
	 
	}
	
}

