From 5cd73c1f6d51e23ed551a4a09f6ef30d7b979b07 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 21 Nov 2024 16:48:32 +0100 Subject: [PATCH 1/6] fix #4 --- composer.json | 2 +- ext_emconf.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 5998cf5..957cb69 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^8.0", "typo3/cms-core": "^11.5 || ^12.4 || ^13.4", - "jambagecom/div2007": "^1.17" + "jambagecom/div2007": "^2.0.5 || ^2.2", }, "suggest": { "friendsoftypo3/typo3db-legacy": "^1" diff --git a/ext_emconf.php b/ext_emconf.php index 483d297..f23df00 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ 'title' => 'Payment Transactor API', 'description' => 'This is a basic API to develop extensions which connect to different payment transaction gateways.', 'category' => 'misc', - 'version' => '0.11.1', + 'version' => '0.12.1', 'state' => 'stable', 'clearcacheonload' => 0, 'author' => 'Franz Holzinger', @@ -18,7 +18,7 @@ 'depends' => [ 'php' => '8.0.0-8.4.99', 'typo3' => '11.5.0-13.4.99', - 'div2007' => '1.17.0-0.0.0', + 'div2007' => '2.0.5-2.2.99', ], 'conflicts' => [ ], From a031ce366585c3379b41efbd437b1c5697dacd41 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 21 Nov 2024 16:53:01 +0100 Subject: [PATCH 2/6] account data read function --- Classes/Api/Address.php | 20 +++--- Classes/Api/Start.php | 120 +++++++++++++++++++++++++++++----- Classes/Constants/Feature.php | 2 +- 3 files changed, 112 insertions(+), 30 deletions(-) diff --git a/Classes/Api/Address.php b/Classes/Api/Address.php index 89a7197..62580cd 100644 --- a/Classes/Api/Address.php +++ b/Classes/Api/Address.php @@ -38,15 +38,15 @@ class Address implements \TYPO3\CMS\Core\SingletonInterface { - protected $name; - protected $user_id; - protected $email; - protected $email_verified; - protected $street; - protected $zip; - protected $city; - protected $state; - protected $country; + protected $name = null; + protected $user_id = null; + protected $email = null; + protected $email_verified = null; + protected $street = null; + protected $zip = null; + protected $city = null; + protected $state = null; + protected $country = null; @@ -141,5 +141,3 @@ public function getCountry () } } - - diff --git a/Classes/Api/Start.php b/Classes/Api/Start.php index 8f0e779..24ae529 100644 --- a/Classes/Api/Start.php +++ b/Classes/Api/Start.php @@ -60,6 +60,8 @@ class Start implements \TYPO3\CMS\Core\SingletonInterface { + private static $hasActionParameters = false; + static public function init ( $pLangObj, $cObj, // DEPRECATED @@ -1424,6 +1426,10 @@ static public function fFloat ( return round($float, $level); } + static public function hasActionParameters( + ) { + return static::$hasActionParameters; + } static public function readActionParameters ( &$errorMessage, @@ -1445,6 +1451,9 @@ static public function readActionParameters ( ) { $result = $gatewayProxyObject->readActionParameters($cObj); } + if ($result) { + static::$hasActionParameters = true; + } } return $result; } @@ -1455,7 +1464,7 @@ static public function addMainWindowJavascript ( ) { $languageObj = GeneralUtility::makeInstance(Localization::class); - $addressFeatureClass = false; + $accountFeatureClass = false; $gatewayExtKey = $confScript['extName']; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); $result = false; @@ -1467,9 +1476,9 @@ static public function addMainWindowJavascript ( ); if (is_object($gatewayProxyObject)) { - $addressFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ADDRESS); + $accountFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ACCOUNT); if ( - $addressFeatureClass != '' && + $accountFeatureClass != '' && $errorMessage == '' ) { $parameters = [ @@ -1477,7 +1486,7 @@ static public function addMainWindowJavascript ( $confScript, ]; call_user_func_array( - $addressFeatureClass . '::addMainWindowJavascript', + $accountFeatureClass . '::addMainWindowJavascript', $parameters ); } @@ -1485,12 +1494,86 @@ static public function addMainWindowJavascript ( } } + static public function readAccountData ( + &$errorMessage, + &$addressModel, + array $confScript, + ) + { + $accountFeatureClass = false; + $languageObj = GeneralUtility::makeInstance(Localization::class); + $gatewayExtKey = $confScript['extName']; + $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); + $result = false; + + if ( + !empty($confScript['login']) && + $ok + ) { + $gatewayProxyObject = + PaymentApi::getGatewayProxyObject( + $confScript + ); + + if (is_object($gatewayProxyObject)) { + $accountFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ACCOUNT); + } else { + $paymentMethod = $confScript['paymentMethod']; + $message = + $languageObj->getLabel( + 'error_gateway_missing' + ); + $messageArray = explode('|', $message); + $errorMessage = $messageArray[0] . $paymentMethod . $messageArray[1]; + } + + if ( + $accountFeatureClass != '' + ) { + if ( + $errorMessage == '' + ) { + + } + + if (class_exists($accountFeatureClass)) { + if ( + method_exists($accountFeatureClass, 'init') && + method_exists($accountFeatureClass, 'fetch') + ) { + $account = + GeneralUtility::makeInstance( + $accountFeatureClass + ); + $account->init( + $gatewayProxyObject->getGatewayObj(), + $confScript + ); + + // read the login box from the Payment Gateway + $result = $account->fetch($errorMessage, $addressModel); + } else { + $errorMessage = + sprintf( + $languageObj->getLabel( + 'error_feature_class_interface' + ), + $accountFeatureClass, + $labelAdress + ); + } + } + } + } + return $result; + } + /** * Render data entry forms for the user billing and shipping address */ - static public function renderDataEntry ( + static public function renderLoginBox ( &$errorMessage, - &$addressModel, + &$accountModel, array $confScript, $extensionKey, array $basket, @@ -1500,7 +1583,7 @@ static public function renderDataEntry ( array $extraData ) { $languageObj = GeneralUtility::makeInstance(Localization::class); - $addressFeatureClass = false; + $accountFeatureClass = false; $gatewayExtKey = $confScript['extName']; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); $result = false; @@ -1515,7 +1598,7 @@ static public function renderDataEntry ( ); if (is_object($gatewayProxyObject)) { - $addressFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ADDRESS); + $accountFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ACCOUNT); } else { $paymentMethod = $confScript['paymentMethod']; $message = @@ -1527,7 +1610,7 @@ static public function renderDataEntry ( } if ( - $addressFeatureClass != '' + $accountFeatureClass != '' ) { if ( $errorMessage == '' @@ -1560,28 +1643,29 @@ static public function renderDataEntry ( $extraData ); - if (class_exists($addressFeatureClass)) { + if (class_exists($accountFeatureClass)) { if ( - method_exists($addressFeatureClass, 'init') && - method_exists($addressFeatureClass, 'fetch') + method_exists($accountFeatureClass, 'init') && + method_exists($accountFeatureClass, 'render') ) { - $address = + $account = GeneralUtility::makeInstance( - $addressFeatureClass + $accountFeatureClass ); - $address->init( + $account->init( $gatewayProxyObject->getGatewayObj(), $confScript ); - $result = $address->fetch($errorMessage, $addressModel); + // read the login box from the Payment Gateway + $result = $account->render($errorMessage, $accountModel); } else { $errorMessage = sprintf( $languageObj->getLabel( 'error_feature_class_interface' ), - $addressFeatureClass, + $accountFeatureClass, $labelAdress ); } @@ -1595,7 +1679,7 @@ static public function renderDataEntry ( $languageObj->getLabel( 'error_feature_class' ), - $addressFeatureClass, + $accountFeatureClass, $labelAdress ); } diff --git a/Classes/Constants/Feature.php b/Classes/Constants/Feature.php index 6ffe666..fb2a45e 100644 --- a/Classes/Constants/Feature.php +++ b/Classes/Constants/Feature.php @@ -20,7 +20,7 @@ */ class Feature { - const ADDRESS = 1; // address from external login + const ACCOUNT = 1; // account from external login } From 776ac1819d30fe9bc8f20c2c857baede471434cd Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 21 Nov 2024 16:54:18 +0100 Subject: [PATCH 3/6] next version 0.12.0 --- ext_emconf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext_emconf.php b/ext_emconf.php index f23df00..fb28148 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ 'title' => 'Payment Transactor API', 'description' => 'This is a basic API to develop extensions which connect to different payment transaction gateways.', 'category' => 'misc', - 'version' => '0.12.1', + 'version' => '0.12.0', 'state' => 'stable', 'clearcacheonload' => 0, 'author' => 'Franz Holzinger', From 6199c59b29ca805aa0d96c6a5a21004561a927e6 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 21 Nov 2024 16:56:22 +0100 Subject: [PATCH 4/6] - --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 957cb69..5af1cc5 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^8.0", "typo3/cms-core": "^11.5 || ^12.4 || ^13.4", - "jambagecom/div2007": "^2.0.5 || ^2.2", + "jambagecom/div2007": "^2.0.5 || ^2.2" }, "suggest": { "friendsoftypo3/typo3db-legacy": "^1" From 8b6232e7f54b00574ece8d199fafc39088bcfe57 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Fri, 22 Nov 2024 16:37:42 +0100 Subject: [PATCH 5/6] undefined extName --- Classes/Api/PaymentPreviousApi.php | 6 +++--- Classes/Api/Start.php | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) mode change 100755 => 100644 Classes/Api/PaymentPreviousApi.php diff --git a/Classes/Api/PaymentPreviousApi.php b/Classes/Api/PaymentPreviousApi.php old mode 100755 new mode 100644 index 8458261..2014562 --- a/Classes/Api/PaymentPreviousApi.php +++ b/Classes/Api/PaymentPreviousApi.php @@ -45,14 +45,14 @@ class PaymentPreviousApi { */ static public function getGatewayProxyObject ( $confScript - ) + ) { $result = false; if ( is_array($confScript) && - $confScript['extName'] != '' && - $confScript['paymentMethod'] != '' + isset($confScript['extName']) && + isset($confScript['paymentMethod']) ) { $gatewayExtKey = $confScript['extName']; diff --git a/Classes/Api/Start.php b/Classes/Api/Start.php index 24ae529..c75dcc3 100644 --- a/Classes/Api/Start.php +++ b/Classes/Api/Start.php @@ -366,7 +366,7 @@ static public function render ( if ($paramsValid) { $lConf = $confScript; - $gatewayExtKey = $confScript['extName']; + $gatewayExtKey = $confScript['extName'] ?? ''; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); $paymentMethod = $confScript['paymentMethod']; @@ -1438,7 +1438,7 @@ static public function readActionParameters ( ) { $result = false; $languageObj = GeneralUtility::makeInstance(Localization::class); - $gatewayExtKey = $confScript['extName']; + $gatewayExtKey = $confScript['extName'] ?? ''; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); if ($ok) { $gatewayProxyObject = @@ -1465,7 +1465,7 @@ static public function addMainWindowJavascript ( { $languageObj = GeneralUtility::makeInstance(Localization::class); $accountFeatureClass = false; - $gatewayExtKey = $confScript['extName']; + $gatewayExtKey = $confScript['extName'] ?? ''; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); $result = false; @@ -1502,7 +1502,7 @@ static public function readAccountData ( { $accountFeatureClass = false; $languageObj = GeneralUtility::makeInstance(Localization::class); - $gatewayExtKey = $confScript['extName']; + $gatewayExtKey = $confScript['extName'] ?? ''; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); $result = false; @@ -1584,7 +1584,7 @@ static public function renderLoginBox ( ) { $languageObj = GeneralUtility::makeInstance(Localization::class); $accountFeatureClass = false; - $gatewayExtKey = $confScript['extName']; + $gatewayExtKey = $confScript['extName'] ?? ''; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); $result = false; @@ -1691,7 +1691,6 @@ static public function renderLoginBox ( } } } - return $result; } } From 2d47c4686cc8488b04c9cd9dcc5044fb459e64d1 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 12 Dec 2024 12:15:09 +0100 Subject: [PATCH 6/6] - --- Classes/Api/Start.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Classes/Api/Start.php b/Classes/Api/Start.php index c75dcc3..78a9d86 100644 --- a/Classes/Api/Start.php +++ b/Classes/Api/Start.php @@ -368,11 +368,12 @@ static public function render ( $lConf = $confScript; $gatewayExtKey = $confScript['extName'] ?? ''; $ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey); - $paymentMethod = $confScript['paymentMethod']; + $paymentMethod = $confScript['paymentMethod'] ?? ''; if ( $ok && - $errorMessage == '' + $errorMessage == '' && + $paymentMethod != '' ) { $gatewayProxyObject = PaymentApi::getGatewayProxyObject(