Changeset 3382275
- Timestamp:
- 10/22/2025 03:54:30 AM (5 months ago)
- Location:
- ngenius/trunk
- Files:
-
- 2 deleted
- 23 edited
-
changelog.txt (deleted)
-
composer.json (modified) (1 diff)
-
composer.lock (modified) (3 diffs)
-
gateway/class-network-international-ngenius-abstract.php (modified) (4 diffs)
-
gateway/class-network-international-ngenius-gateway-payment.php (modified) (3 diffs)
-
gateway/class-network-international-ngenius-gateway.php (modified) (12 diffs)
-
gateway/http/class-network-international-ngenius-gateway-http-abstract.php (modified) (2 diffs)
-
gateway/http/class-network-international-ngenius-gateway-http-capture.php (modified) (3 diffs)
-
gateway/http/class-network-international-ngenius-gateway-http-transfer.php (deleted)
-
gateway/request/class-network-international-ngenius-gateway-request-token.php (modified) (1 diff)
-
ngenius.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
resources/js/index.asset.php (modified) (1 diff)
-
resources/js/index.js (modified) (1 diff)
-
vendor/autoload.php (modified) (1 diff)
-
vendor/composer/autoload_psr4.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (5 diffs)
-
vendor/composer/autoload_static.php (modified) (3 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
-
vendor/ngenius/ngenius-common/composer.json (modified) (2 diffs)
-
vendor/ngenius/ngenius-common/src/Formatter/ValueFormatter.php (modified) (6 diffs)
-
vendor/ngenius/ngenius-common/src/NgeniusHTTPCommon.php (modified) (2 diffs)
-
vendor/ngenius/ngenius-common/src/NgeniusHTTPTransfer.php (modified) (12 diffs)
-
vendor/ngenius/ngenius-common/src/Processor/ApiProcessor.php (modified) (12 diffs)
-
vendor/ngenius/ngenius-common/src/Processor/TransactionProcessor.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ngenius/trunk/composer.json
r3368573 r3382275 8 8 "config": { 9 9 "platform": { 10 "php": " 8.0.30"10 "php": "7.4" 11 11 } 12 12 } -
ngenius/trunk/composer.lock
r3368573 r3382275 5 5 "This file is @generated automatically" 6 6 ], 7 "content-hash": " 39c224ceee6be1a1ad2a09fa811edefb",7 "content-hash": "6138cddb765de9f8f570ce3ab1d44ced", 8 8 "packages": [ 9 9 { … … 397 397 "guzzlehttp/guzzle": "^7.9", 398 398 "megastruktur/phone-country-codes": "0.4", 399 "php": "^ 8.0"399 "php": "^7.4" 400 400 }, 401 401 "type": "library", … … 704 704 "platform-dev": [], 705 705 "platform-overrides": { 706 "php": " 8.0.30"706 "php": "7.4" 707 707 }, 708 708 "plugin-api-version": "2.2.0" -
ngenius/trunk/gateway/class-network-international-ngenius-abstract.php
r3368573 r3382275 20 20 require_once dirname(__FILE__) . '/config/class-network-international-ngenius-gateway-config.php'; 21 21 require_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';23 22 require_once dirname(__FILE__) . '/http/class-network-international-ngenius-gateway-http-abstract.php'; 24 23 … … 38 37 * Logger instance 39 38 * 40 * @var bool|WC_Logger41 */ 42 public static bool|WC_Logger $log = false;39 * @var null|WC_Logger 40 */ 41 public $log = null; 43 42 44 43 /** … … 122 121 123 122 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 } 124 127 } 125 128 … … 219 222 220 223 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) 222 235 { 223 236 if ($token) { -
ngenius/trunk/gateway/class-network-international-ngenius-gateway-payment.php
r3368573 r3382275 274 274 include_once dirname(__FILE__) . '/config/class-network-international-ngenius-gateway-config.php'; 275 275 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';277 276 include_once dirname(__FILE__) . '/http/class-network-international-ngenius-gateway-http-fetch.php'; 278 277 … … 354 353 * Fetch Order details. 355 354 * 356 * @param string $where 357 * 355 * @param string $order_ref 358 356 * @return object|null 359 357 */ 360 public function fetch_order_by_reference(string $order_ref) : ?object358 public function fetch_order_by_reference(string $order_ref) 361 359 { 362 360 global $wpdb; … … 417 415 /** 418 416 * Cron Job function 419 */ 420 public function order_update(): bool|string 417 * 418 * @return bool|string 419 */ 420 public function order_update() 421 421 { 422 422 wc_get_logger()->debug("N-GENIUS: Cron started"); -
ngenius/trunk/gateway/class-network-international-ngenius-gateway.php
r3368573 r3382275 36 36 * Logger instance 37 37 * 38 * @var bool|WC_Logger39 */ 40 public static bool|WC_Logger $log = false;38 * @var null|WC_Logger 39 */ 40 public $log = null; 41 41 42 42 /** … … 66 66 { 67 67 parent::__construct(); 68 68 $this->log = wc_get_logger(); 69 69 // Initialize form fields and settings 70 70 $this->init_form_fields(); 71 71 $this->init_settings(); 72 73 72 // Load settings 74 73 $this->title = $this->get_option('title', __('N-Genius by Network', 'ngenius')); … … 93 92 * emergency|alert|critical|error|warning|notice|info|debug. 94 93 */ 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')); 102 98 } 103 99 } … … 158 154 } 159 155 160 self::log('Cleared cron event on plugin update: ' . $cron_hook, 'info');156 $this->log('Cleared cron event on plugin update: ' . $cron_hook, 'info'); 161 157 } 162 158 } … … 178 174 } 179 175 180 self::log('Cleared cron event on plugin deactivation: ' . $cron_hook, 'info');176 $this->log('Cleared cron event on plugin deactivation: ' . $cron_hook, 'info'); 181 177 } 182 178 … … 250 246 // Check if the order object is valid 251 247 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'); 253 249 254 250 return; … … 522 518 $cache_key = 'ngenius_order_' . $order_id; 523 519 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 524 528 // Prepare the data to be saved 525 529 $data = array_merge( 526 $ wp_session['ngenius'],530 $ngenius_session_data, 527 531 array( 528 532 'order_id' => $order_id, … … 583 587 if ('yes' === $this->get_option('enabled', 'no')) { 584 588 if (empty($this->get_option('outletRef'))) { 585 $this->add_ settings_error(589 $this->add_ngenius_settings_error( 586 590 'ngenius_error', 587 591 esc_attr('settings_updated'), … … 591 595 } 592 596 if (empty($this->get_option('apiKey'))) { 593 $this->add_ settings_error(597 $this->add_ngenius_settings_error( 594 598 'ngenius_error', 595 599 esc_attr('settings_updated'), … … 601 605 } 602 606 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'); 607 608 } 608 609 … … 610 611 } 611 612 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 } 622 635 } 623 636 … … 669 682 * 670 683 * @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) 675 687 { 676 688 global $wpdb; -
ngenius/trunk/gateway/http/class-network-international-ngenius-gateway-http-abstract.php
r3368573 r3382275 37 37 * 38 38 * @param NgeniusHTTPTransfer $transferObject 39 *40 39 * @return WP_Error|array|stdClass|null 41 40 */ 42 public function place_request(NgeniusHttpTransfer $transferObject) : WP_Error|array|null|stdClass41 public function place_request(NgeniusHttpTransfer $transferObject) 43 42 { 44 43 $this->orderStatus = NgeniusOrderStatuses::orderStatuses('N-Genius', 'ng'); … … 61 60 abstract protected function pre_process(array $data); 62 61 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) 65 69 { 66 70 if (isset($response->_links->payment->href)) { -
ngenius/trunk/gateway/http/class-network-international-ngenius-gateway-http-capture.php
r3368573 r3382275 33 33 } 34 34 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) 36 42 { 37 43 if (isset($lastTransaction->state) … … 44 50 } 45 51 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) 47 59 { 48 60 if (isset($lastTransaction->_links->self->href)) { … … 81 93 * Processing of API response 82 94 * 83 * @param array $response_enc 84 * 95 * @param stdClass $response 85 96 * @return array|null 86 97 */ 87 protected function post_process(stdClass $response) : ?array98 protected function post_process(stdClass $response) 88 99 { 89 100 if (isset($response->errors)) { -
ngenius/trunk/gateway/request/class-network-international-ngenius-gateway-request-token.php
r3368573 r3382275 42 42 * @return WP_Error|string|null 43 43 */ 44 public function get_access_token() : WP_Error|string|null44 public function get_access_token() 45 45 { 46 46 require_once(dirname(__DIR__) . '/http/class-network-international-ngenius-gateway-http-fetch.php'); -
ngenius/trunk/ngenius.php
r3368573 r3382275 6 6 * Author: Network International 7 7 * Author URI: https://www.network.ae/en 8 * Version: 1.3. 38 * Version: 1.3.4 9 9 * Requires at least: 6.0 10 * Requires PHP: 8.010 * Requires PHP: 7.4 11 11 * Tested up to: 6.8.2 12 12 * WC tested up to: 10.1.2 … … 37 37 }); 38 38 39 if (version_compare(phpversion(), ' 8.0', '<')) {40 die("N-Genius Online by Network requires PHP 8.0or higher.");39 if (version_compare(phpversion(), '7.4', '<')) { 40 die("N-Genius Online by Network requires PHP 7.4 or higher."); 41 41 } 42 42 … … 47 47 use Ngenius\NgeniusCommon\NgeniusOrderStatuses; 48 48 49 define('NETWORK_INTERNATIONAL_NGENIUS_VERSION', '1.3. 3'); // WRCS: DEFINED_VERSION.49 define('NETWORK_INTERNATIONAL_NGENIUS_VERSION', '1.3.4'); // WRCS: DEFINED_VERSION. 50 50 define( 51 51 'NETWORK_INTERNATIONAL_NGENIUS_URL', -
ngenius/trunk/readme.txt
r3368579 r3382275 5 5 Tested up to: 6.8 6 6 Requires PHP: 8.0 7 Stable tag: 1.3. 37 Stable tag: 1.3.4 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 23 23 24 24 == 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 25 34 = 1.3.3 - 2025-09-26 = 26 35 * 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 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 0461033e2cc219eb4e54cb8e1cd34bca::getLoader();7 return ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3::getLoader(); -
ngenius/trunk/vendor/composer/autoload_psr4.php
r3343865 r3382275 8 8 return array( 9 9 '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'), 11 11 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), 12 12 'Ngenius\\NgeniusCommon\\' => array($vendorDir . '/ngenius/ngenius-common/src'), -
ngenius/trunk/vendor/composer/autoload_real.php
r3343865 r3382275 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 0461033e2cc219eb4e54cb8e1cd34bca5 class ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 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); 28 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 0461033e2cc219eb4e54cb8e1cd34bca', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit6126a3b43013470be8aa9265ce57e5b3', 'loadClassLoader')); 30 28 31 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 33 31 require __DIR__ . '/autoload_static.php'; 34 32 35 call_user_func(\Composer\Autoload\ComposerStaticInit 0461033e2cc219eb4e54cb8e1cd34bca::getInitializer($loader));33 call_user_func(\Composer\Autoload\ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::getInitializer($loader)); 36 34 } else { 37 35 $map = require __DIR__ . '/autoload_namespaces.php'; … … 54 52 55 53 if ($useStaticLoader) { 56 $includeFiles = Composer\Autoload\ComposerStaticInit 0461033e2cc219eb4e54cb8e1cd34bca::$files;54 $includeFiles = Composer\Autoload\ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$files; 57 55 } else { 58 56 $includeFiles = require __DIR__ . '/autoload_files.php'; 59 57 } 60 58 foreach ($includeFiles as $fileIdentifier => $file) { 61 composerRequire 0461033e2cc219eb4e54cb8e1cd34bca($fileIdentifier, $file);59 composerRequire6126a3b43013470be8aa9265ce57e5b3($fileIdentifier, $file); 62 60 } 63 61 … … 71 69 * @return void 72 70 */ 73 function composerRequire 0461033e2cc219eb4e54cb8e1cd34bca($fileIdentifier, $file)71 function composerRequire6126a3b43013470be8aa9265ce57e5b3($fileIdentifier, $file) 74 72 { 75 73 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
ngenius/trunk/vendor/composer/autoload_static.php
r3343865 r3382275 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 0461033e2cc219eb4e54cb8e1cd34bca7 class ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3 8 8 { 9 9 public static $files = array ( … … 42 42 'Psr\\Http\\Message\\' => 43 43 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', 46 46 ), 47 47 'Psr\\Http\\Client\\' => … … 74 74 { 75 75 return \Closure::bind(function () use ($loader) { 76 $loader->prefixLengthsPsr4 = ComposerStaticInit 0461033e2cc219eb4e54cb8e1cd34bca::$prefixLengthsPsr4;77 $loader->prefixDirsPsr4 = ComposerStaticInit 0461033e2cc219eb4e54cb8e1cd34bca::$prefixDirsPsr4;78 $loader->classMap = ComposerStaticInit 0461033e2cc219eb4e54cb8e1cd34bca::$classMap;76 $loader->prefixLengthsPsr4 = ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$prefixLengthsPsr4; 77 $loader->prefixDirsPsr4 = ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$prefixDirsPsr4; 78 $loader->classMap = ComposerStaticInit6126a3b43013470be8aa9265ce57e5b3::$classMap; 79 79 80 80 }, null, ClassLoader::class); -
ngenius/trunk/vendor/composer/installed.php
r3368573 r3382275 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' 62bd134240a63d737814f1f749170fbe9359ac47',8 'reference' => '7f95c54ab7d323441b48e5404208936c4edabc84', 9 9 'name' => 'ngenius/woocommerce', 10 10 'dev' => true, … … 62 62 'install_path' => __DIR__ . '/../../', 63 63 'aliases' => array(), 64 'reference' => ' 62bd134240a63d737814f1f749170fbe9359ac47',64 'reference' => '7f95c54ab7d323441b48e5404208936c4edabc84', 65 65 'dev_requirement' => false, 66 66 ), -
ngenius/trunk/vendor/ngenius/ngenius-common/composer.json
r3343865 r3382275 3 3 "description": "N-Genius common class for modules.", 4 4 "type": "library", 5 "license": "GPL-3.0 ",5 "license": "GPL-3.0-or-later", 6 6 "homepage": "https://github.com/Ngenius/ngenius-common", 7 7 "authors": [ … … 12 12 ], 13 13 "require": { 14 "php": " ^8.0",14 "php": ">=7.4", 15 15 "megastruktur/phone-country-codes": "0.4", 16 "guzzlehttp/guzzle": "^7.9" 16 "guzzlehttp/guzzle": "^7.9", 17 "ext-intl": "*" 17 18 }, 18 19 "autoload": { -
ngenius/trunk/vendor/ngenius/ngenius-common/src/Formatter/ValueFormatter.php
r3343865 r3382275 15 15 * @return float|int 16 16 */ 17 public static function formatOrderStatusAmount($currencyCode, $amount) : float|int17 public static function formatOrderStatusAmount($currencyCode, $amount) 18 18 { 19 19 if (in_array($currencyCode, ['UGX', 'XOF'])) { … … 36 36 * @return void 37 37 */ 38 public static function formatCurrencyAmount($currencyCode, &$amount) : void38 public static function formatCurrencyAmount($currencyCode, &$amount) 39 39 { 40 40 if (in_array($currencyCode, ['UGX', 'XOF'])) { … … 53 53 * @return void 54 54 */ 55 public static function formatCurrencyDecimals($currencyCode, &$amount) : void55 public static function formatCurrencyDecimals($currencyCode, &$amount) 56 56 { 57 57 $amount = number_format($amount, self::getCurrencyDecimals($currencyCode)); … … 66 66 * @return int 67 67 */ 68 public static function floatToIntRepresentation($currencyCode, $floatNumber) : int68 public static function floatToIntRepresentation($currencyCode, $floatNumber) 69 69 { 70 70 $floatNumber = number_format($floatNumber, self::getCurrencyDecimals($currencyCode)); … … 85 85 * @return float|int 86 86 */ 87 public static function intToFloatRepresentation( string $currencyCode, int $integer): float|int87 public static function intToFloatRepresentation($currencyCode, $integer) 88 88 { 89 89 $decimalPlaces = self::getCurrencyDecimals($currencyCode); … … 105 105 * @return int 106 106 */ 107 public static function getCurrencyDecimals($currency) : int107 public static function getCurrencyDecimals($currency) 108 108 { 109 109 $currencyFormatter = new NumberFormatter('en_EN', NumberFormatter::CURRENCY); -
ngenius/trunk/vendor/ngenius/ngenius-common/src/NgeniusHTTPCommon.php
r3343865 r3382275 13 13 * @return string|bool 14 14 */ 15 public static function placeRequest(NgeniusHTTPTransfer $ngeniusHTTPTransfer) : string|bool15 public static function placeRequest(NgeniusHTTPTransfer $ngeniusHTTPTransfer) 16 16 { 17 17 $client = new Client(); … … 21 21 $data = $ngeniusHTTPTransfer->getData(); 22 22 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 } 28 38 29 39 // Convert the headers array to an associative array for Guzzle -
ngenius/trunk/vendor/ngenius/ngenius-common/src/NgeniusHTTPTransfer.php
r3343865 r3382275 5 5 class NgeniusHTTPTransfer 6 6 { 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; 12 12 13 13 /** … … 19 19 */ 20 20 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 = [] 26 26 ) { 27 27 $this->url = $url; … … 77 77 * @return string 78 78 */ 79 public function getUrl() : string79 public function getUrl() 80 80 { 81 81 return $this->url; … … 85 85 * @param string $url 86 86 */ 87 public function setUrl( string $url): void87 public function setUrl($url) 88 88 { 89 89 $this->url = $url; … … 93 93 * @return array 94 94 */ 95 public function getHeaders() : array95 public function getHeaders() 96 96 { 97 97 return $this->headers; … … 101 101 * @param array $headers 102 102 */ 103 public function setHeaders( array $headers): void103 public function setHeaders($headers) 104 104 { 105 105 $this->headers = $headers; … … 109 109 * @return string 110 110 */ 111 public function getMethod() : string111 public function getMethod() 112 112 { 113 113 return $this->method; … … 117 117 * @param string $method 118 118 */ 119 public function setMethod( string $method): void119 public function setMethod($method) 120 120 { 121 121 $this->method = $method; … … 125 125 * @return array 126 126 */ 127 public function getData() : array127 public function getData() 128 128 { 129 129 return $this->data ?? []; … … 133 133 * @param array $data 134 134 */ 135 public function setData( array $data): void135 public function setData($data) 136 136 { 137 137 $this->data = $data; … … 141 141 * @return string 142 142 */ 143 public function getHttpVersion() : string143 public function getHttpVersion() 144 144 { 145 145 return $this->httpVersion ?? ""; … … 149 149 * @param string $httpVersion 150 150 */ 151 public function setHttpVersion( string $httpVersion): void151 public function setHttpVersion($httpVersion) 152 152 { 153 153 $this->httpVersion = $httpVersion; 154 154 } 155 155 156 public function build( array $requestData): void156 public function build($requestData) 157 157 { 158 158 $this->url = $requestData["uri"]; -
ngenius/trunk/vendor/ngenius/ngenius-common/src/Processor/ApiProcessor.php
r3343865 r3382275 5 5 class ApiProcessor 6 6 { 7 private array$response;7 private $response; 8 8 9 9 public const NGENIUS_CAPTURE_LITERAL = 'cnp:capture'; … … 12 12 public const NGENIUS_STATES_SUCCESS = ['AUTHORISED', self::NGENIUS_PURCHASED, 'CAPTURED']; 13 13 14 public function __construct( array$response)14 public function __construct($response) 15 15 { 16 16 $this->response = $response; … … 22 22 * @return string|array 23 23 */ 24 public function getLastTransaction() : string|array24 public function getLastTransaction() 25 25 { 26 26 $lastTransaction = ''; … … 42 42 * @return string 43 43 */ 44 public function getPaymentId() : string44 public function getPaymentId() 45 45 { 46 46 $paymentId = ''; … … 58 58 * @return string 59 59 */ 60 public function getTransactionId() : string60 public function getTransactionId() 61 61 { 62 62 $lastTransaction = $this->getLastTransaction(); … … 78 78 * @return int|string 79 79 */ 80 public function getCapturedAmount() : int|string80 public function getCapturedAmount() 81 81 { 82 82 $captureAmount = 0; … … 104 104 * @return string|null 105 105 */ 106 public function getState() : ?string106 public function getState() 107 107 { 108 108 return $this->response['_embedded']['payment'][0]['state']; … … 113 113 * @return array 114 114 */ 115 public function getResponse() : array115 public function getResponse() 116 116 { 117 117 return $this->response; … … 121 121 * @param array $response 122 122 */ 123 public function setResponse( array $response): void123 public function setResponse($response) 124 124 { 125 125 $this->response = $response; … … 145 145 * @return array|null 146 146 */ 147 public function getPaymentResult() : ?array147 public function getPaymentResult() 148 148 { 149 149 return $this->response['_embedded']['payment'][0]; … … 155 155 * @return bool 156 156 */ 157 public function isPaymentConfirmed() : bool157 public function isPaymentConfirmed() 158 158 { 159 159 return in_array($this->getState(), self::NGENIUS_STATES_SUCCESS); … … 165 165 * @return bool 166 166 */ 167 public function isPaymentAbandoned() : bool167 public function isPaymentAbandoned() 168 168 { 169 169 return in_array($this->getState(), self::NGENIUS_STATES_ABANDONED); -
ngenius/trunk/vendor/ngenius/ngenius-common/src/Processor/TransactionProcessor.php
r3343865 r3382275 5 5 class TransactionProcessor 6 6 { 7 private array$response;7 private $response; 8 8 private const EMBEDDED_LITERAL = '_embedded'; 9 9 private const CAPTURE_LITERAL = 'cnp:capture'; … … 11 11 private const NGENIUS_CUP_RESULTS = 'cnp:china_union_pay_results'; 12 12 13 public function __construct( array$response)13 public function __construct($response) 14 14 { 15 15 $this->response = $response; … … 19 19 * @return array 20 20 */ 21 public function getResponse() : array21 public function getResponse() 22 22 { 23 23 return $this->response; … … 29 29 * @return void 30 30 */ 31 public function setResponse( array $response): void31 public function setResponse($response) 32 32 { 33 33 $this->response = $response; … … 39 39 * @return float 40 40 */ 41 public function getTotalRefunded() : float41 public function getTotalRefunded() 42 42 { 43 43 $refunded_amt = 0.00; … … 61 61 * @return float 62 62 */ 63 public function getTotalCaptured() : float63 public function getTotalCaptured() 64 64 { 65 65 $captured_amt = 0.00; … … 80 80 * @return array 81 81 */ 82 public function getLastRefundTransaction() : array82 public function getLastRefundTransaction() 83 83 { 84 84 return end($this->response[self::EMBEDDED_LITERAL][self::REFUND_LITERAL]); … … 90 90 * @return array 91 91 */ 92 public function getLastCaptureTransaction() : array92 public function getLastCaptureTransaction() 93 93 { 94 94 return end($this->response[self::EMBEDDED_LITERAL][self::CAPTURE_LITERAL]); … … 102 102 * @return float 103 103 */ 104 public function getTransactionAmount( array $transaction): float104 public function getTransactionAmount($transaction) 105 105 { 106 106 $amount = 0.00; … … 123 123 * @return string 124 124 */ 125 public function getTransactionID($transaction) : string125 public function getTransactionID($transaction) 126 126 { 127 127 $transactionId = '';
Note: See TracChangeset
for help on using the changeset viewer.