Plugin Directory

Changeset 3382275


Ignore:
Timestamp:
10/22/2025 03:54:30 AM (5 months ago)
Author:
bruceanetwork
Message:

1.3.4 - 2025-10-16

  • Added PHP 7.4 support.
  • Refactored add_settings_error to use WordPress Settings API; removed direct $wp_settings_errors manipulation.
  • JS block registration now handles missing/undefined server data in index.js.
  • Synced package.json version with PHP plugin version.
  • Improved logging handling (?WC_Logger).
  • Improved save_data() to handle missing/incomplete session data gracefully.
  • Code quality improvements.
Location:
ngenius/trunk
Files:
2 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • ngenius/trunk/composer.json

    r3368573 r3382275  
    88  "config": {
    99    "platform": {
    10       "php": "8.0.30"
     10      "php": "7.4"
    1111    }
    1212  }
  • ngenius/trunk/composer.lock

    r3368573 r3382275  
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "39c224ceee6be1a1ad2a09fa811edefb",
     7    "content-hash": "6138cddb765de9f8f570ce3ab1d44ced",
    88    "packages": [
    99        {
     
    397397                "guzzlehttp/guzzle": "^7.9",
    398398                "megastruktur/phone-country-codes": "0.4",
    399                 "php": "^8.0"
     399                "php": "^7.4"
    400400            },
    401401            "type": "library",
     
    704704    "platform-dev": [],
    705705    "platform-overrides": {
    706         "php": "8.0.30"
     706        "php": "7.4"
    707707    },
    708708    "plugin-api-version": "2.2.0"
  • ngenius/trunk/gateway/class-network-international-ngenius-abstract.php

    r3368573 r3382275  
    2020require_once dirname(__FILE__) . '/config/class-network-international-ngenius-gateway-config.php';
    2121require_once dirname(__FILE__) . '/request/class-network-international-ngenius-gateway-request-token.php';
    22 require_once dirname(__FILE__) . '/http/class-network-international-ngenius-gateway-http-transfer.php';
    2322require_once dirname(__FILE__) . '/http/class-network-international-ngenius-gateway-http-abstract.php';
    2423
     
    3837     * Logger instance
    3938     *
    40      * @var bool|WC_Logger
    41      */
    42     public static bool|WC_Logger $log = false;
     39     * @var null|WC_Logger
     40     */
     41    public $log = null;
    4342
    4443    /**
     
    122121
    123122        self::$logEnabled = $this->debug;
     123        // Initialize logger if debug is enabled
     124        if ($this->debug && empty($this->log)) {
     125            $this->log = wc_get_logger();
     126        }
    124127    }
    125128
     
    219222
    220223
    221     public function validateRefund($token, $config, $order, $orderItem, $amount): bool|array
     224    /**
     225     * Validates a refund request.
     226     *
     227     * @param string $token
     228     * @param object $config
     229     * @param object $order
     230     * @param object $orderItem
     231     * @param float $amount
     232     * @return bool|array
     233     */
     234    public function validateRefund($token, $config, $order, $orderItem, $amount)
    222235    {
    223236        if ($token) {
  • ngenius/trunk/gateway/class-network-international-ngenius-gateway-payment.php

    r3368573 r3382275  
    274274        include_once dirname(__FILE__) . '/config/class-network-international-ngenius-gateway-config.php';
    275275        include_once dirname(__FILE__) . '/request/class-network-international-ngenius-gateway-request-token.php';
    276         include_once dirname(__FILE__) . '/http/class-network-international-ngenius-gateway-http-transfer.php';
    277276        include_once dirname(__FILE__) . '/http/class-network-international-ngenius-gateway-http-fetch.php';
    278277
     
    354353     * Fetch Order details.
    355354     *
    356      * @param string $where
    357      *
     355     * @param string $order_ref
    358356     * @return object|null
    359357     */
    360     public function fetch_order_by_reference(string $order_ref): ?object
     358    public function fetch_order_by_reference(string $order_ref)
    361359    {
    362360        global $wpdb;
     
    417415    /**
    418416     * Cron Job function
    419      */
    420     public function order_update(): bool|string
     417     *
     418     * @return bool|string
     419     */
     420    public function order_update()
    421421    {
    422422        wc_get_logger()->debug("N-GENIUS: Cron started");
  • ngenius/trunk/gateway/class-network-international-ngenius-gateway.php

    r3368573 r3382275  
    3636     * Logger instance
    3737     *
    38      * @var bool|WC_Logger
    39      */
    40     public static bool|WC_Logger $log = false;
     38     * @var null|WC_Logger
     39     */
     40    public $log = null;
    4141
    4242    /**
     
    6666    {
    6767        parent::__construct();
    68 
     68        $this->log = wc_get_logger();
    6969        // Initialize form fields and settings
    7070        $this->init_form_fields();
    7171        $this->init_settings();
    72 
    7372        // Load settings
    7473        $this->title = $this->get_option('title', __('N-Genius by Network', 'ngenius'));
     
    9392     *                        emergency|alert|critical|error|warning|notice|info|debug.
    9493     */
    95     public static function log(string $message, string $level = 'debug')
    96     {
    97         if (self::$logEnabled) {
    98             if (empty(self::$log)) {
    99                 self::$log = wc_get_logger();
    100             }
    101             self::$log->log($level, $message, array('source' => 'ngenius'));
     94    public function log(string $message, string $level = 'debug')
     95    {
     96        if ('yes' === $this->get_option('debug', 'no')) {
     97            $this->log($level, $message, array('source' => 'ngenius'));
    10298        }
    10399    }
     
    158154                }
    159155
    160                 self::log('Cleared cron event on plugin update: ' . $cron_hook, 'info');
     156                $this->log('Cleared cron event on plugin update: ' . $cron_hook, 'info');
    161157            }
    162158        }
     
    178174        }
    179175
    180         self::log('Cleared cron event on plugin deactivation: ' . $cron_hook, 'info');
     176        $this->log('Cleared cron event on plugin deactivation: ' . $cron_hook, 'info');
    181177    }
    182178
     
    250246        // Check if the order object is valid
    251247        if (!$order instanceof WC_Order) {
    252             self::log("Invalid order object for post ID: {$post->ID}", 'error');
     248            $this->log("Invalid order object for post ID: {$post->ID}", 'error');
    253249
    254250            return;
     
    522518        $cache_key = 'ngenius_order_' . $order_id;
    523519
     520        // Check if wp_session exists and has ngenius data
     521        $ngenius_session_data = [];
     522        if (isset($wp_session) && is_array($wp_session) && isset($wp_session['ngenius'])) {
     523            $ngenius_session_data = $wp_session['ngenius'];
     524        } else {
     525            self::log('Missing or incomplete wp_session data for order: ' . $order_id, 'warning');
     526        }
     527
    524528        // Prepare the data to be saved
    525529        $data = array_merge(
    526             $wp_session['ngenius'],
     530            $ngenius_session_data,
    527531            array(
    528532                'order_id' => $order_id,
     
    583587        if ('yes' === $this->get_option('enabled', 'no')) {
    584588            if (empty($this->get_option('outletRef'))) {
    585                 $this->add_settings_error(
     589                $this->add_ngenius_settings_error(
    586590                    'ngenius_error',
    587591                    esc_attr('settings_updated'),
     
    591595            }
    592596            if (empty($this->get_option('apiKey'))) {
    593                 $this->add_settings_error(
     597                $this->add_ngenius_settings_error(
    594598                    'ngenius_error',
    595599                    esc_attr('settings_updated'),
     
    601605        }
    602606        if ('yes' !== $this->get_option('debug', 'no')) {
    603             if (empty(self::$log)) {
    604                 self::$log = wc_get_logger();
    605             }
    606             self::$log->clear('ngenius');
     607            $this->log->clear('ngenius');
    607608        }
    608609
     
    610611    }
    611612
    612     public function add_settings_error($setting, $code, $message, $type = 'error')
    613     {
    614         global $wp_settings_errors;
    615 
    616         $wp_settings_errors[] = array(
    617             'setting' => $setting,
    618             'code'    => $code,
    619             'message' => $message,
    620             'type'    => $type,
    621         );
     613    /**
     614     * Add settings error using WordPress native functionality
     615     *
     616     * @param string $setting Setting name
     617     * @param string $code Error code
     618     * @param string $message Error message
     619     * @param string $type Error type (error, warning, info, success)
     620     */
     621    public function add_ngenius_settings_error($setting, $code, $message, $type = 'error')
     622    {
     623        // Ensure we're in admin context and the function is available
     624        if (is_admin() && !function_exists('add_settings_error')) {
     625            require_once ABSPATH . 'wp-admin/includes/template.php';
     626        }
     627
     628        // Check if function exists before calling it
     629        if (function_exists('add_settings_error')) {
     630            add_settings_error($setting, $code, $message, $type);
     631        } else {
     632            // Fallback to WooCommerce admin notices
     633            WC_Admin_Notices::add_custom_notice($setting, $message);
     634        }
    622635    }
    623636
     
    669682     *
    670683     * @param int $order_id
    671      *
    672      * @return object
    673      */
    674     public function fetch_order(int $order_id): ?object
     684     * @return object|null
     685     */
     686    public function fetch_order(int $order_id)
    675687    {
    676688        global $wpdb;
  • ngenius/trunk/gateway/http/class-network-international-ngenius-gateway-http-abstract.php

    r3368573 r3382275  
    3737     *
    3838     * @param NgeniusHTTPTransfer $transferObject
    39      *
    4039     * @return WP_Error|array|stdClass|null
    4140     */
    42     public function place_request(NgeniusHttpTransfer $transferObject): WP_Error|array|null|stdClass
     41    public function place_request(NgeniusHttpTransfer $transferObject)
    4342    {
    4443        $this->orderStatus = NgeniusOrderStatuses::orderStatuses('N-Genius', 'ng');
     
    6160    abstract protected function pre_process(array $data);
    6261
    63 
    64     protected function post_process(stdClass $response): array|stdClass|null
     62    /**
     63     * Post-processes the response from the gateway.
     64     *
     65     * @param stdClass $response
     66     * @return array|stdClass|null
     67     */
     68    protected function post_process(stdClass $response)
    6569    {
    6670        if (isset($response->_links->payment->href)) {
  • ngenius/trunk/gateway/http/class-network-international-ngenius-gateway-http-capture.php

    r3368573 r3382275  
    3333    }
    3434
    35     public function get_captured_amount($lastTransaction): float|null
     35    /**
     36     * Gets the captured amount from the last transaction.
     37     *
     38     * @param object $lastTransaction
     39     * @return float|null
     40     */
     41    public function get_captured_amount($lastTransaction)
    3642    {
    3743        if (isset($lastTransaction->state)
     
    4450    }
    4551
    46     public function get_transaction_id($lastTransaction): bool|null|string
     52    /**
     53     * Gets the transaction ID from the last transaction.
     54     *
     55     * @param object $lastTransaction
     56     * @return bool|string|null
     57     */
     58    public function get_transaction_id($lastTransaction)
    4759    {
    4860        if (isset($lastTransaction->_links->self->href)) {
     
    8193     * Processing of API response
    8294     *
    83      * @param array $response_enc
    84      *
     95     * @param stdClass $response
    8596     * @return array|null
    8697     */
    87     protected function post_process(stdClass $response): ?array
     98    protected function post_process(stdClass $response)
    8899    {
    89100        if (isset($response->errors)) {
  • ngenius/trunk/gateway/request/class-network-international-ngenius-gateway-request-token.php

    r3368573 r3382275  
    4242     * @return WP_Error|string|null
    4343     */
    44     public function get_access_token(): WP_Error|string|null
     44    public function get_access_token()
    4545    {
    4646        require_once(dirname(__DIR__) . '/http/class-network-international-ngenius-gateway-http-fetch.php');
  • ngenius/trunk/ngenius.php

    r3368573 r3382275  
    66 * Author: Network International
    77 * Author URI: https://www.network.ae/en
    8  * Version: 1.3.3
     8 * Version: 1.3.4
    99 * Requires at least: 6.0
    10  * Requires PHP: 8.0
     10 * Requires PHP: 7.4
    1111 * Tested up to: 6.8.2
    1212 * WC tested up to: 10.1.2
     
    3737});
    3838
    39 if (version_compare(phpversion(), '8.0', '<')) {
    40     die("N-Genius Online by Network requires PHP 8.0 or higher.");
     39if (version_compare(phpversion(), '7.4', '<')) {
     40    die("N-Genius Online by Network requires PHP 7.4 or higher.");
    4141}
    4242
     
    4747use Ngenius\NgeniusCommon\NgeniusOrderStatuses;
    4848
    49 define('NETWORK_INTERNATIONAL_NGENIUS_VERSION', '1.3.3'); // WRCS: DEFINED_VERSION.
     49define('NETWORK_INTERNATIONAL_NGENIUS_VERSION', '1.3.4'); // WRCS: DEFINED_VERSION.
    5050define(
    5151    'NETWORK_INTERNATIONAL_NGENIUS_URL',
  • ngenius/trunk/readme.txt

    r3368579 r3382275  
    55Tested up to: 6.8
    66Requires PHP: 8.0
    7 Stable tag: 1.3.3
     7Stable tag: 1.3.4
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2323
    2424== Changelog ==
     25= 1.3.4 - 2025-10-16 =
     26 * Added PHP 7.4 support.
     27 * Refactored add_settings_error to use WordPress Settings API; removed direct $wp_settings_errors manipulation.
     28 * JS block registration now handles missing/undefined server data in index.js.
     29 * Synced package.json version with PHP plugin version.
     30 * Improved logging handling (?WC_Logger).
     31 * Improved save_data() to handle missing/incomplete session data gracefully.
     32 * Code quality improvements.
     33
    2534= 1.3.3 - 2025-09-26 =
    2635 * Composer Version Issue: This is a fix for an issue identified in automated testing, as it corrects a problem with the Composer version to ensure compatibility.
  • ngenius/trunk/resources/js/index.asset.php

    r3343864 r3382275  
    1 <?php return array('dependencies' => array('wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '27fa44a8445b716e340127efffb7706f');
     1<?php return array('dependencies' => array('wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'b3e19186c28ef18bf40073aee071ee35');
  • ngenius/trunk/resources/js/index.js

    r3346214 r3382275  
    1 !function(){"use strict";var e=window.wp.element,t=window.wp.htmlEntities,n=window.wp.i18n,i=window.wc.wcBlocksRegistry,a=window.wc.wcSettings;const l=()=>{const e=(0,a.getSetting)("ngenius_data",null);if(!e)throw new Error("N-Genius initialization data is not available");return e};var o;const r=()=>(0,t.decodeEntities)(l()?.description||"");(0,i.registerPaymentMethod)({name:"ngenius",label:(0,e.createElement)((()=>(0,e.createElement)("img",{src:l()?.logo_url,alt:l()?.title})),null),ariaLabel:(0,n.__)("N-Genius payment method","woocommerce-gateway-ngenius"),canMakePayment:()=>!0,content:(0,e.createElement)(r,null),edit:(0,e.createElement)(r,null),supports:{features:null!==(o=l()?.supports)&&void 0!==o?o:[]}})}();
     1!function(){"use strict";var e=window.wp.element,n=window.wp.htmlEntities,t=window.wp.i18n,i=window.wc.wcBlocksRegistry;const o="N-Genius Online";var l=window.wc.wcSettings;const r=()=>{const e=(0,l.getSetting)("ngenius_data",null);if(!e)throw new Error("N-Genius initialization data is not available");return e};var a;const s=()=>{const e=r?.()||{};return(0,n.decodeEntities)(e.description||"N-Genius Online by Network")};(0,i.registerPaymentMethod)({name:"ngenius",label:(0,e.createElement)((()=>{const n=r?.()||{};return n.logo_url?(0,e.createElement)("img",{src:n.logo_url||"/resources/network_logo.png",alt:n.title||o}):(0,e.createElement)("span",null,n.title||o)}),null),ariaLabel:(0,t.__)("N-Genius payment method","woocommerce-gateway-ngenius"),canMakePayment:()=>!0,content:(0,e.createElement)(s,null),edit:(0,e.createElement)(s,null),supports:{features:null!==(a=r?.()?.supports)&&void 0!==a?a:[]}})}();
  • ngenius/trunk/vendor/autoload.php

    r3343865 r3382275  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit0461033e2cc219eb4e54cb8e1cd34bca::getLoader();
     7return ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3::getLoader();
  • ngenius/trunk/vendor/composer/autoload_psr4.php

    r3343865 r3382275  
    88return array(
    99    'megastruktur\\' => array($vendorDir . '/megastruktur/phone-country-codes/src'),
    10     'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
     10    'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
    1111    'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
    1212    'Ngenius\\NgeniusCommon\\' => array($vendorDir . '/ngenius/ngenius-common/src'),
  • ngenius/trunk/vendor/composer/autoload_real.php

    r3343865 r3382275  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit0461033e2cc219eb4e54cb8e1cd34bca
     5class ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         require __DIR__ . '/platform_check.php';
    26 
    27         spl_autoload_register(array('ComposerAutoloaderInit0461033e2cc219eb4e54cb8e1cd34bca', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3', 'loadClassLoader'), true, true);
    2826        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit0461033e2cc219eb4e54cb8e1cd34bca', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3', 'loadClassLoader'));
    3028
    3129        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3331            require __DIR__ . '/autoload_static.php';
    3432
    35             call_user_func(\Composer\Autoload\ComposerStaticInit0461033e2cc219eb4e54cb8e1cd34bca::getInitializer($loader));
     33            call_user_func(\Composer\Autoload\ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::getInitializer($loader));
    3634        } else {
    3735            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5452
    5553        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInit0461033e2cc219eb4e54cb8e1cd34bca::$files;
     54            $includeFiles = Composer\Autoload\ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$files;
    5755        } else {
    5856            $includeFiles = require __DIR__ . '/autoload_files.php';
    5957        }
    6058        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequire0461033e2cc219eb4e54cb8e1cd34bca($fileIdentifier, $file);
     59            composerRequire6126a3b43013470be8aa9265ce57e5b3($fileIdentifier, $file);
    6260        }
    6361
     
    7169 * @return void
    7270 */
    73 function composerRequire0461033e2cc219eb4e54cb8e1cd34bca($fileIdentifier, $file)
     71function composerRequire6126a3b43013470be8aa9265ce57e5b3($fileIdentifier, $file)
    7472{
    7573    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • ngenius/trunk/vendor/composer/autoload_static.php

    r3343865 r3382275  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit0461033e2cc219eb4e54cb8e1cd34bca
     7class ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3
    88{
    99    public static $files = array (
     
    4242        'Psr\\Http\\Message\\' =>
    4343        array (
    44             0 => __DIR__ . '/..' . '/psr/http-factory/src',
    45             1 => __DIR__ . '/..' . '/psr/http-message/src',
     44            0 => __DIR__ . '/..' . '/psr/http-message/src',
     45            1 => __DIR__ . '/..' . '/psr/http-factory/src',
    4646        ),
    4747        'Psr\\Http\\Client\\' =>
     
    7474    {
    7575        return \Closure::bind(function () use ($loader) {
    76             $loader->prefixLengthsPsr4 = ComposerStaticInit0461033e2cc219eb4e54cb8e1cd34bca::$prefixLengthsPsr4;
    77             $loader->prefixDirsPsr4 = ComposerStaticInit0461033e2cc219eb4e54cb8e1cd34bca::$prefixDirsPsr4;
    78             $loader->classMap = ComposerStaticInit0461033e2cc219eb4e54cb8e1cd34bca::$classMap;
     76            $loader->prefixLengthsPsr4 = ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$prefixLengthsPsr4;
     77            $loader->prefixDirsPsr4 = ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$prefixDirsPsr4;
     78            $loader->classMap = ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$classMap;
    7979
    8080        }, null, ClassLoader::class);
  • ngenius/trunk/vendor/composer/installed.php

    r3368573 r3382275  
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => '62bd134240a63d737814f1f749170fbe9359ac47',
     8        'reference' => '7f95c54ab7d323441b48e5404208936c4edabc84',
    99        'name' => 'ngenius/woocommerce',
    1010        'dev' => true,
     
    6262            'install_path' => __DIR__ . '/../../',
    6363            'aliases' => array(),
    64             'reference' => '62bd134240a63d737814f1f749170fbe9359ac47',
     64            'reference' => '7f95c54ab7d323441b48e5404208936c4edabc84',
    6565            'dev_requirement' => false,
    6666        ),
  • ngenius/trunk/vendor/ngenius/ngenius-common/composer.json

    r3343865 r3382275  
    33  "description": "N-Genius common class for modules.",
    44  "type": "library",
    5   "license": "GPL-3.0",
     5  "license": "GPL-3.0-or-later",
    66  "homepage": "https://github.com/Ngenius/ngenius-common",
    77  "authors": [
     
    1212  ],
    1313  "require": {
    14     "php": "^8.0",
     14    "php": ">=7.4",
    1515    "megastruktur/phone-country-codes": "0.4",
    16     "guzzlehttp/guzzle": "^7.9"
     16    "guzzlehttp/guzzle": "^7.9",
     17    "ext-intl": "*"
    1718  },
    1819  "autoload": {
  • ngenius/trunk/vendor/ngenius/ngenius-common/src/Formatter/ValueFormatter.php

    r3343865 r3382275  
    1515     * @return float|int
    1616     */
    17     public static function formatOrderStatusAmount($currencyCode, $amount): float|int
     17    public static function formatOrderStatusAmount($currencyCode, $amount)
    1818    {
    1919        if (in_array($currencyCode, ['UGX', 'XOF'])) {
     
    3636     * @return void
    3737     */
    38     public static function formatCurrencyAmount($currencyCode, &$amount): void
     38    public static function formatCurrencyAmount($currencyCode, &$amount)
    3939    {
    4040        if (in_array($currencyCode, ['UGX', 'XOF'])) {
     
    5353     * @return void
    5454     */
    55     public static function formatCurrencyDecimals($currencyCode, &$amount): void
     55    public static function formatCurrencyDecimals($currencyCode, &$amount)
    5656    {
    5757        $amount = number_format($amount, self::getCurrencyDecimals($currencyCode));
     
    6666     * @return int
    6767     */
    68     public static function floatToIntRepresentation($currencyCode, $floatNumber): int
     68    public static function floatToIntRepresentation($currencyCode, $floatNumber)
    6969    {
    7070        $floatNumber = number_format($floatNumber, self::getCurrencyDecimals($currencyCode));
     
    8585     * @return float|int
    8686     */
    87     public static function intToFloatRepresentation(string $currencyCode, int $integer): float|int
     87    public static function intToFloatRepresentation($currencyCode, $integer)
    8888    {
    8989        $decimalPlaces = self::getCurrencyDecimals($currencyCode);
     
    105105     * @return int
    106106     */
    107     public static function getCurrencyDecimals($currency): int
     107    public static function getCurrencyDecimals($currency)
    108108    {
    109109        $currencyFormatter = new NumberFormatter('en_EN', NumberFormatter::CURRENCY);
  • ngenius/trunk/vendor/ngenius/ngenius-common/src/NgeniusHTTPCommon.php

    r3343865 r3382275  
    1313     * @return string|bool
    1414     */
    15     public static function placeRequest(NgeniusHTTPTransfer $ngeniusHTTPTransfer): string|bool
     15    public static function placeRequest(NgeniusHTTPTransfer $ngeniusHTTPTransfer)
    1616    {
    1717        $client       = new Client();
     
    2121        $data         = $ngeniusHTTPTransfer->getData();
    2222
    23         $httpVersion = match ($ngeniusHTTPTransfer->getHttpVersion()) {
    24             "CURL_HTTP_VERSION_1_0" => '1.0',
    25             "CURL_HTTP_VERSION_2_0", "CURL_HTTP_VERSION_2TLS", "CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE" => '2.0',
    26             default => '1.1',
    27         };
     23        $httpVersionRaw = $ngeniusHTTPTransfer->getHttpVersion();
     24        $httpVersion = '1.1';
     25        switch ($httpVersionRaw) {
     26            case "CURL_HTTP_VERSION_1_0":
     27                $httpVersion = '1.0';
     28                break;
     29            case "CURL_HTTP_VERSION_2_0":
     30            case "CURL_HTTP_VERSION_2TLS":
     31            case "CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE":
     32                $httpVersion = '2.0';
     33                break;
     34            default:
     35                $httpVersion = '1.1';
     36                break;
     37        }
    2838
    2939        // Convert the headers array to an associative array for Guzzle
  • ngenius/trunk/vendor/ngenius/ngenius-common/src/NgeniusHTTPTransfer.php

    r3343865 r3382275  
    55class NgeniusHTTPTransfer
    66{
    7     private string $url;
    8     private string $httpVersion;
    9     private array $headers;
    10     private string $method;
    11     private array $data;
     7    private $url;
     8    private $httpVersion;
     9    private $headers;
     10    private $method;
     11    private $data;
    1212
    1313    /**
     
    1919     */
    2020    public function __construct(
    21         string $url,
    22         string $httpVersion = "",
    23         string $method = "",
    24         array $data = [],
    25         array $headers = []
     21        $url,
     22        $httpVersion = "",
     23        $method = "",
     24        $data = [],
     25        $headers = []
    2626    ) {
    2727        $this->url         = $url;
     
    7777     * @return string
    7878     */
    79     public function getUrl(): string
     79    public function getUrl()
    8080    {
    8181        return $this->url;
     
    8585     * @param string $url
    8686     */
    87     public function setUrl(string $url): void
     87    public function setUrl($url)
    8888    {
    8989        $this->url = $url;
     
    9393     * @return array
    9494     */
    95     public function getHeaders(): array
     95    public function getHeaders()
    9696    {
    9797        return $this->headers;
     
    101101     * @param array $headers
    102102     */
    103     public function setHeaders(array $headers): void
     103    public function setHeaders($headers)
    104104    {
    105105        $this->headers = $headers;
     
    109109     * @return string
    110110     */
    111     public function getMethod(): string
     111    public function getMethod()
    112112    {
    113113        return $this->method;
     
    117117     * @param string $method
    118118     */
    119     public function setMethod(string $method): void
     119    public function setMethod($method)
    120120    {
    121121        $this->method = $method;
     
    125125     * @return array
    126126     */
    127     public function getData(): array
     127    public function getData()
    128128    {
    129129        return $this->data ?? [];
     
    133133     * @param array $data
    134134     */
    135     public function setData(array $data): void
     135    public function setData($data)
    136136    {
    137137        $this->data = $data;
     
    141141     * @return string
    142142     */
    143     public function getHttpVersion(): string
     143    public function getHttpVersion()
    144144    {
    145145        return $this->httpVersion ?? "";
     
    149149     * @param string $httpVersion
    150150     */
    151     public function setHttpVersion(string $httpVersion): void
     151    public function setHttpVersion($httpVersion)
    152152    {
    153153        $this->httpVersion = $httpVersion;
    154154    }
    155155
    156     public function build(array $requestData): void
     156    public function build($requestData)
    157157    {
    158158        $this->url    = $requestData["uri"];
  • ngenius/trunk/vendor/ngenius/ngenius-common/src/Processor/ApiProcessor.php

    r3343865 r3382275  
    55class ApiProcessor
    66{
    7     private array $response;
     7    private $response;
    88
    99    public const NGENIUS_CAPTURE_LITERAL  = 'cnp:capture';
     
    1212    public const NGENIUS_STATES_SUCCESS   = ['AUTHORISED', self::NGENIUS_PURCHASED, 'CAPTURED'];
    1313
    14     public function __construct(array $response)
     14    public function __construct($response)
    1515    {
    1616        $this->response = $response;
     
    2222     * @return string|array
    2323     */
    24     public function getLastTransaction(): string|array
     24    public function getLastTransaction()
    2525    {
    2626        $lastTransaction = '';
     
    4242     * @return string
    4343     */
    44     public function getPaymentId(): string
     44    public function getPaymentId()
    4545    {
    4646        $paymentId = '';
     
    5858     * @return string
    5959     */
    60     public function getTransactionId(): string
     60    public function getTransactionId()
    6161    {
    6262        $lastTransaction = $this->getLastTransaction();
     
    7878     * @return int|string
    7979     */
    80     public function getCapturedAmount(): int|string
     80    public function getCapturedAmount()
    8181    {
    8282        $captureAmount = 0;
     
    104104     * @return string|null
    105105     */
    106     public function getState(): ?string
     106    public function getState()
    107107    {
    108108        return $this->response['_embedded']['payment'][0]['state'];
     
    113113     * @return array
    114114     */
    115     public function getResponse(): array
     115    public function getResponse()
    116116    {
    117117        return $this->response;
     
    121121     * @param array $response
    122122     */
    123     public function setResponse(array $response): void
     123    public function setResponse($response)
    124124    {
    125125        $this->response = $response;
     
    145145     * @return array|null
    146146     */
    147     public function getPaymentResult(): ?array
     147    public function getPaymentResult()
    148148    {
    149149        return $this->response['_embedded']['payment'][0];
     
    155155     * @return bool
    156156     */
    157     public function isPaymentConfirmed(): bool
     157    public function isPaymentConfirmed()
    158158    {
    159159        return in_array($this->getState(), self::NGENIUS_STATES_SUCCESS);
     
    165165     * @return bool
    166166     */
    167     public function isPaymentAbandoned(): bool
     167    public function isPaymentAbandoned()
    168168    {
    169169        return in_array($this->getState(), self::NGENIUS_STATES_ABANDONED);
  • ngenius/trunk/vendor/ngenius/ngenius-common/src/Processor/TransactionProcessor.php

    r3343865 r3382275  
    55class TransactionProcessor
    66{
    7     private array $response;
     7    private $response;
    88    private const EMBEDDED_LITERAL    = '_embedded';
    99    private const CAPTURE_LITERAL     = 'cnp:capture';
     
    1111    private const NGENIUS_CUP_RESULTS = 'cnp:china_union_pay_results';
    1212
    13     public function __construct(array $response)
     13    public function __construct($response)
    1414    {
    1515        $this->response = $response;
     
    1919     * @return array
    2020     */
    21     public function getResponse(): array
     21    public function getResponse()
    2222    {
    2323        return $this->response;
     
    2929     * @return void
    3030     */
    31     public function setResponse(array $response): void
     31    public function setResponse($response)
    3232    {
    3333        $this->response = $response;
     
    3939     * @return float
    4040     */
    41     public function getTotalRefunded(): float
     41    public function getTotalRefunded()
    4242    {
    4343        $refunded_amt = 0.00;
     
    6161     * @return float
    6262     */
    63     public function getTotalCaptured(): float
     63    public function getTotalCaptured()
    6464    {
    6565        $captured_amt = 0.00;
     
    8080     * @return array
    8181     */
    82     public function getLastRefundTransaction(): array
     82    public function getLastRefundTransaction()
    8383    {
    8484        return end($this->response[self::EMBEDDED_LITERAL][self::REFUND_LITERAL]);
     
    9090     * @return array
    9191     */
    92     public function getLastCaptureTransaction(): array
     92    public function getLastCaptureTransaction()
    9393    {
    9494        return end($this->response[self::EMBEDDED_LITERAL][self::CAPTURE_LITERAL]);
     
    102102     * @return float
    103103     */
    104     public function getTransactionAmount(array $transaction): float
     104    public function getTransactionAmount($transaction)
    105105    {
    106106        $amount = 0.00;
     
    123123     * @return string
    124124     */
    125     public function getTransactionID($transaction): string
     125    public function getTransactionID($transaction)
    126126    {
    127127        $transactionId = '';
Note: See TracChangeset for help on using the changeset viewer.