/home/kueuepay/public_html/vendor/dragonmantank/cron-expression/src/Cron/HoursField.php
<?php

declare(strict_types=1);

namespace Cron;

use DateTimeInterface;
use DateTimeZone;

/**
 * Hours field.  Allows: * , / -.
 */
class HoursField extends AbstractField
{
    /**
     * {@inheritdoc}
     */
    protected $rangeStart = 0;

    /**
     * {@inheritdoc}
     */
    protected $rangeEnd = 23;

    /**
     * @var array|null Transitions returned by DateTimeZone::getTransitions()
     */
    protected $transitions = [];

    /**
     * @var int|null Timestamp of the start of the transitions range
     */
    protected $transitionsStart = null;

    /**
     * @var int|null Timestamp of the end of the transitions range
     */
    protected $transitionsEnd = null;

    /**
     * {@inheritdoc}
     */
    public function isSatisfiedBy(DateTimeInterface $date, $value, bool $invert): bool
    {
        $checkValue = (int) $date->format('H');
        $retval = $this->isSatisfied($checkValue, $value);
        if ($retval) {
            return $retval;
        }

        // Are we on the edge of a transition
        $lastTransition = $this->getPastTransition($date);
        if (($lastTransition !== null) && ($lastTransition["ts"] > ((int) $date->format('U') - 3600))) {
            $dtLastOffset = clone $date;
            $this->timezoneSafeModify($dtLastOffset, "-1 hour");
            $lastOffset = $dtLastOffset->getOffset();

            $dtNextOffset = clone $date;
            $this->timezoneSafeModify($dtNextOffset, "+1 hour");
            $nextOffset = $dtNextOffset->getOffset();

            $offsetChange = $nextOffset - $lastOffset;
            if ($offsetChange >= 3600) {
                $checkValue -= 1;
                return $this->isSatisfied($checkValue, $value);
            }
            if ((! $invert) && ($offsetChange <= -3600)) {
                $checkValue += 1;
                return $this->isSatisfied($checkValue, $value);
            }
        }

        return $retval;
    }

    public function getPastTransition(DateTimeInterface $date): ?array
    {
        $currentTimestamp = (int) $date->format('U');
        if (
            ($this->transitions === null)
            || ($this->transitionsStart < ($currentTimestamp + 86400))
            || ($this->transitionsEnd > ($currentTimestamp - 86400))
        ) {
            // We start a day before current time so we can differentiate between the first transition entry
            // and a change that happens now
            $dtLimitStart = clone $date;
            $dtLimitStart = $dtLimitStart->modify("-12 months");
            $dtLimitEnd = clone $date;
            $dtLimitEnd = $dtLimitEnd->modify('+12 months');

            $this->transitions = $date->getTimezone()->getTransitions(
                $dtLimitStart->getTimestamp(),
                $dtLimitEnd->getTimestamp()
            );
            if (empty($this->transitions)) {
                return null;
            }
            $this->transitionsStart = $dtLimitStart->getTimestamp();
            $this->transitionsEnd = $dtLimitEnd->getTimestamp();
        }

        $nextTransition = null;
        foreach ($this->transitions as $transition) {
            if ($transition["ts"] > $currentTimestamp) {
                continue;
            }

            if (($nextTransition !== null) && ($transition["ts"] < $nextTransition["ts"])) {
                continue;
            }

            $nextTransition = $transition;
        }

        return ($nextTransition ?? null);
    }

    /**
     * {@inheritdoc}
     *
     * @param string|null                  $parts
     */
    public function increment(DateTimeInterface &$date, $invert = false, $parts = null): FieldInterface
    {
        $originalTimestamp = (int) $date->format('U');

        // Change timezone to UTC temporarily. This will
        // allow us to go back or forwards and hour even
        // if DST will be changed between the hours.
        if (null === $parts || '*' === $parts) {
            if ($invert) {
                $date = $date->sub(new \DateInterval('PT1H'));
            } else {
                $date = $date->add(new \DateInterval('PT1H'));
            }

            $date = $this->setTimeHour($date, $invert, $originalTimestamp);
            return $this;
        }

        $parts = false !== strpos($parts, ',') ? explode(',', $parts) : [$parts];
        $hours = [];
        foreach ($parts as $part) {
            $hours = array_merge($hours, $this->getRangeForExpression($part, 23));
        }

        $current_hour = (int) $date->format('H');
        $position = $invert ? \count($hours) - 1 : 0;
        $countHours = \count($hours);
        if ($countHours > 1) {
            for ($i = 0; $i < $countHours - 1; ++$i) {
                if ((!$invert && $current_hour >= $hours[$i] && $current_hour < $hours[$i + 1]) ||
                    ($invert && $current_hour > $hours[$i] && $current_hour <= $hours[$i + 1])) {
                    $position = $invert ? $i : $i + 1;

                    break;
                }
            }
        }

        $target = (int) $hours[$position];
        $originalHour = (int)$date->format('H');

        $originalDay = (int)$date->format('d');
        $previousOffset = $date->getOffset();

        if (! $invert) {
            if ($originalHour >= $target) {
                $distance = 24 - $originalHour;
                $date = $this->timezoneSafeModify($date, "+{$distance} hours");

                $actualDay = (int)$date->format('d');
                $actualHour = (int)$date->format('H');
                if (($actualDay !== ($originalDay + 1)) && ($actualHour !== 0)) {
                    $offsetChange = ($previousOffset - $date->getOffset());
                    $date = $this->timezoneSafeModify($date, "+{$offsetChange} seconds");
                }

                $originalHour = (int)$date->format('H');
            }

            $distance = $target - $originalHour;
            $date = $this->timezoneSafeModify($date, "+{$distance} hours");
        } else {
            if ($originalHour <= $target) {
                $distance = ($originalHour + 1);
                $date = $this->timezoneSafeModify($date, "-" . $distance . " hours");

                $actualDay = (int)$date->format('d');
                $actualHour = (int)$date->format('H');
                if (($actualDay !== ($originalDay - 1)) && ($actualHour !== 23)) {
                    $offsetChange = ($previousOffset - $date->getOffset());
                    $date = $this->timezoneSafeModify($date, "+{$offsetChange} seconds");
                }

                $originalHour = (int)$date->format('H');
            }

            $distance = $originalHour - $target;
            $date = $this->timezoneSafeModify($date, "-{$distance} hours");
        }

        $date = $this->setTimeHour($date, $invert, $originalTimestamp);

        $actualHour = (int)$date->format('H');
        if ($invert && ($actualHour === ($target - 1) || (($actualHour === 23) && ($target === 0)))) {
            $date = $this->timezoneSafeModify($date, "+1 hour");
        }

        return $this;
    }
}
Access Token

Get Access Token

Get access token to initiates payment transaction.

Endpoint: POST generate-token
Parameter Type Comments
client_id string Enter merchant API client/primary key
secret_id string Enter merchant API secret key
env string Enter merchant API environment
merchant_id string Enter merchant API merchant id
Just request to that endpoint with all parameter listed below:
                    
                        Request Example (guzzle)
                        

<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $base_url. 'v1/generate-token', [
'headers' => [
  'accept' => 'application/json',
  'content-type' => 'application/json',
 ],
'form_params' => [
  'client_id' => '$client_id',
  'secret_id' => 'secret_id',
  'env' => 'env',
  'merchant_id' => 'merchant_id',
 ],
]);
echo $response->getBody();
                    
                        
**Response: SUCCESS (200 OK)**
{
 "message": {
 "success": [
  "Successfully token is generated"
 ]
},
"data": {
 "token":"eyJpdiI6InpkczhjTjhQdVhUL2lKQ0pSUUx6aUE9P
SIsInZhbHVlIjoiVGVBTVBDTXltbjNZcEIvdEJveGpTSno3TU5NRUtn
VkhCZ1pHTFNCUnZGQ2UxMnYxN202cEE1YVRDTEFsc0ZERExoTjdtL0dTL2x
oU3QzeUJJOExiMUx5T0w1L0llUXhTUkU1cWVLWEdEbEplb0dKNXcwbTNRM0
VxdkUwYzZuNFdtNkhMQ0pRZysyNWkvdzBxSlBoSVBSOGFTekNnR2RXNHVtc
G9lMGZOTmNCcm1hR3c5Sk9KTnB4Y3ltZDl6cm90MThrR21Ca3B1azc3bXRi
Q0J6SW96UVo1elNkU1ZqeE05bTcwWGp1MEUxWlJFdnNWTmpSbnVpeW92b2U
4dXZkUGgyb1VmK0luaGdyaFlsVTZlcVpVRnZlTG1DeFF6Ykk2T2h6Z3Jzbn
IyNHpNdHowSE5JdDR0Y0pZT20zUm1XYW8iLCJtYWMiOiJlY2M4NGE1OGUzYz
kzYzk0YzljNmVmNjE0YWI0ZDIwOGI3NDQ2YWEyY2ZhNzc0NzE4ZmY1ZmYyMz
IyZmQzNDY1IiwidGFnIjoiIn0=",
},
"type": "success"
}
                    
                        
**Response: ERROR (400 FAILED)**
{
 "message": {
 "error": [
  "Invalid credentials."
 ]
},
"data": null,
"type": "error"
}