Skip to content

Commit

Permalink
Merge pull request #5 from franzholz/develop
Browse files Browse the repository at this point in the history
version 0.12.0 supports TYPO3 13
  • Loading branch information
franzholz authored Dec 12, 2024
2 parents 33ca87b + 2d47c46 commit 67d57c4
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 43 deletions.
20 changes: 9 additions & 11 deletions Classes/Api/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand Down Expand Up @@ -141,5 +141,3 @@ public function getCountry ()
}

}


6 changes: 3 additions & 3 deletions Classes/Api/PaymentPreviousApi.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down
134 changes: 109 additions & 25 deletions Classes/Api/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@

class Start implements \TYPO3\CMS\Core\SingletonInterface
{
private static $hasActionParameters = false;

static public function init (
$pLangObj,
$cObj, // DEPRECATED
Expand Down Expand Up @@ -364,13 +366,14 @@ static public function render (

if ($paramsValid) {
$lConf = $confScript;
$gatewayExtKey = $confScript['extName'];
$gatewayExtKey = $confScript['extName'] ?? '';
$ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey);
$paymentMethod = $confScript['paymentMethod'];
$paymentMethod = $confScript['paymentMethod'] ?? '';

if (
$ok &&
$errorMessage == ''
$errorMessage == '' &&
$paymentMethod != ''
) {
$gatewayProxyObject =
PaymentApi::getGatewayProxyObject(
Expand Down Expand Up @@ -1424,6 +1427,10 @@ static public function fFloat (
return round($float, $level);
}

static public function hasActionParameters(
) {
return static::$hasActionParameters;
}

static public function readActionParameters (
&$errorMessage,
Expand All @@ -1432,7 +1439,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 =
Expand All @@ -1445,6 +1452,9 @@ static public function readActionParameters (
) {
$result = $gatewayProxyObject->readActionParameters($cObj);
}
if ($result) {
static::$hasActionParameters = true;
}
}
return $result;
}
Expand All @@ -1455,8 +1465,8 @@ static public function addMainWindowJavascript (
)
{
$languageObj = GeneralUtility::makeInstance(Localization::class);
$addressFeatureClass = false;
$gatewayExtKey = $confScript['extName'];
$accountFeatureClass = false;
$gatewayExtKey = $confScript['extName'] ?? '';
$ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey);
$result = false;

Expand All @@ -1467,30 +1477,104 @@ static public function addMainWindowJavascript (
);

if (is_object($gatewayProxyObject)) {
$addressFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ADDRESS);
$accountFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ACCOUNT);
if (
$addressFeatureClass != '' &&
$accountFeatureClass != '' &&
$errorMessage == ''
) {
$parameters = [
&$errorMessage,
$confScript,
];
call_user_func_array(
$addressFeatureClass . '::addMainWindowJavascript',
$accountFeatureClass . '::addMainWindowJavascript',
$parameters
);
}
}
}
}

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,
Expand All @@ -1500,8 +1584,8 @@ static public function renderDataEntry (
array $extraData
) {
$languageObj = GeneralUtility::makeInstance(Localization::class);
$addressFeatureClass = false;
$gatewayExtKey = $confScript['extName'];
$accountFeatureClass = false;
$gatewayExtKey = $confScript['extName'] ?? '';
$ok = static::checkLoaded($errorMessage, $languageObj, $gatewayExtKey);
$result = false;

Expand All @@ -1515,7 +1599,7 @@ static public function renderDataEntry (
);

if (is_object($gatewayProxyObject)) {
$addressFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ADDRESS);
$accountFeatureClass = $gatewayProxyObject->getFeatureClass(Feature::ACCOUNT);
} else {
$paymentMethod = $confScript['paymentMethod'];
$message =
Expand All @@ -1527,7 +1611,7 @@ static public function renderDataEntry (
}

if (
$addressFeatureClass != ''
$accountFeatureClass != ''
) {
if (
$errorMessage == ''
Expand Down Expand Up @@ -1560,28 +1644,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
);
}
Expand All @@ -1595,7 +1680,7 @@ static public function renderDataEntry (
$languageObj->getLabel(
'error_feature_class'
),
$addressFeatureClass,
$accountFeatureClass,
$labelAdress
);
}
Expand All @@ -1607,7 +1692,6 @@ static public function renderDataEntry (
}
}
}

return $result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Constants/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class Feature
{
const ADDRESS = 1; // address from external login
const ACCOUNT = 1; // account from external login
}


2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.0',
'state' => 'stable',
'clearcacheonload' => 0,
'author' => 'Franz Holzinger',
Expand All @@ -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' => [
],
Expand Down

0 comments on commit 67d57c4

Please sign in to comment.