/home/kueuepay/www/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/TableReader.php
<?php

namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;

use PhpOffice\PhpSpreadsheet\Worksheet\Table;
use PhpOffice\PhpSpreadsheet\Worksheet\Table\TableStyle;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use SimpleXMLElement;

class TableReader
{
    /**
     * @var Worksheet
     */
    private $worksheet;

    /**
     * @var SimpleXMLElement
     */
    private $tableXml;

    public function __construct(Worksheet $workSheet, SimpleXMLElement $tableXml)
    {
        $this->worksheet = $workSheet;
        $this->tableXml = $tableXml;
    }

    /**
     * Loads Table into the Worksheet.
     */
    public function load(): void
    {
        // Remove all "$" in the table range
        $tableRange = (string) preg_replace('/\$/', '', $this->tableXml['ref'] ?? '');
        if (strpos($tableRange, ':') !== false) {
            $this->readTable($tableRange, $this->tableXml);
        }
    }

    /**
     * Read Table from xml.
     */
    private function readTable(string $tableRange, SimpleXMLElement $tableXml): void
    {
        $table = new Table($tableRange);
        $table->setName((string) $tableXml['displayName']);
        $table->setShowHeaderRow((string) $tableXml['headerRowCount'] !== '0');
        $table->setShowTotalsRow((string) $tableXml['totalsRowCount'] === '1');

        $this->readTableAutoFilter($table, $tableXml->autoFilter);
        $this->readTableColumns($table, $tableXml->tableColumns);
        $this->readTableStyle($table, $tableXml->tableStyleInfo);

        (new AutoFilter($table, $tableXml))->load();
        $this->worksheet->addTable($table);
    }

    /**
     * Reads TableAutoFilter from xml.
     */
    private function readTableAutoFilter(Table $table, SimpleXMLElement $autoFilterXml): void
    {
        if ($autoFilterXml->filterColumn === null) {
            $table->setAllowFilter(false);

            return;
        }

        foreach ($autoFilterXml->filterColumn as $filterColumn) {
            $column = $table->getColumnByOffset((int) $filterColumn['colId']);
            $column->setShowFilterButton((string) $filterColumn['hiddenButton'] !== '1');
        }
    }

    /**
     * Reads TableColumns from xml.
     */
    private function readTableColumns(Table $table, SimpleXMLElement $tableColumnsXml): void
    {
        $offset = 0;
        foreach ($tableColumnsXml->tableColumn as $tableColumn) {
            $column = $table->getColumnByOffset($offset++);

            if ($table->getShowTotalsRow()) {
                if ($tableColumn['totalsRowLabel']) {
                    $column->setTotalsRowLabel((string) $tableColumn['totalsRowLabel']);
                }

                if ($tableColumn['totalsRowFunction']) {
                    $column->setTotalsRowFunction((string) $tableColumn['totalsRowFunction']);
                }
            }

            if ($tableColumn->calculatedColumnFormula) {
                $column->setColumnFormula((string) $tableColumn->calculatedColumnFormula);
            }
        }
    }

    /**
     * Reads TableStyle from xml.
     */
    private function readTableStyle(Table $table, SimpleXMLElement $tableStyleInfoXml): void
    {
        $tableStyle = new TableStyle();
        $tableStyle->setTheme((string) $tableStyleInfoXml['name']);
        $tableStyle->setShowRowStripes((string) $tableStyleInfoXml['showRowStripes'] === '1');
        $tableStyle->setShowColumnStripes((string) $tableStyleInfoXml['showColumnStripes'] === '1');
        $tableStyle->setShowFirstColumn((string) $tableStyleInfoXml['showFirstColumn'] === '1');
        $tableStyle->setShowLastColumn((string) $tableStyleInfoXml['showLastColumn'] === '1');
        $table->setStyle($tableStyle);
    }
}
Initiate Payment

Initiate Payment

Initiates a new payment transaction.

Endpoint: POST create-order
Parameter Type Details
amount decimal Your Amount , Must be rounded at 2 precision.
currency string Currency Code, Must be in Upper Case (Alpha-3 code)
success_url string Enter your return or success URL
cancel_url string (optional) Enter your cancel or failed URL
                    
                        Request Example (guzzle)
                        

<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $base_url.'create-order', [
'headers' => [
  'Authorization' => 'Bearer '. $authorizationToken,
  'accept' => 'application/json',
  'content-type' => 'application/json',
 ],
'form_params' => [
  'amount' => '$amount',
  'currency' => 'currency',
  'success_url' => 'success_url',
  'cancel_url' => 'cancel_url',
 ],
]);
echo $response->getBody();
                    
                        
**Response: SUCCESS (200 OK)**
{
 "message": {
 "success": [
  "Order created successfully."
 ]
},
"data": {
 "redirect_url":"https://example.com/login/OISADFDFSDFSF",
 "order_details":{
 "amount" : "10",
 "fixed_charge" : 2,
 "percent_charge" : 1,
 "total_charge" : 3,
 "total_payable" : 13,
 "currency" : "USD",
 "expiry_time": "2024-04-25T06:48:35.984285Z",
 "success_url": "http://127.0.0.1/nfcpay/user/transaction/success",
 "cancel_url": "http://127.0.0.1/nfcpay/user/transaction/cancel"
}
},
"type": "success"
}
                    
                        
**Response: ERROR (400 FAILED)**
{
 "message": {
 "error": [
  "Invalid token."
 ]
},
"data": null,
"type": "error"
}