Skip to content

Commit

Permalink
Merge pull request #2 from franzholz/develop
Browse files Browse the repository at this point in the history
compatibility TYPO3 12 and TYPO3 13
  • Loading branch information
franzholz authored Oct 23, 2024
2 parents 31d87c2 + 94249cb commit 2ad61db
Show file tree
Hide file tree
Showing 19 changed files with 296 additions and 3,571 deletions.
6 changes: 6 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2024-03-28 Franz Holzinger <[email protected]>
* remove the old API

2023-11-18 Franz Holzinger <[email protected]>
* new feature: Enhance API method Start::render. Parameter $variantFields

2023-10-30 Franz Holzinger <[email protected]>
* new method getGatewayProxyObjectForExtension

Expand Down
118 changes: 111 additions & 7 deletions Classes/Api/PaymentApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

use JambageCom\Transactor\Constants\Field;


class PaymentApi
{
static public function getTransactorConf ($gatewayExtensionKey, $key = '')
static public function getTransactorConf ($gatewayExtensionKey, $key = '')
{
$transactorConf = [];
$result = '';
Expand All @@ -57,10 +59,11 @@ static public function getTransactorConf ($gatewayExtensionKey, $key = '')
)->get($gatewayExtensionKey);

if (
$key != '' &&
isset($transactorConf[$key])
$key != ''
) {
$result = $transactorConf[$key];
if (isset($transactorConf[$key])) {
$result = $transactorConf[$key];
}
} else {
$result = $transactorConf;
}
Expand Down Expand Up @@ -198,7 +201,7 @@ static public function getGatewayProxyObjectForExtension (
* and optionally the given extension reference string and or booking status.
* Use this function instead accessing the transaction records directly.
*
* @param string $extensionKey: Extension key of extension
* @param string $extensionKey: Extension key of extension
* which calls the transactor library
* @param int $gatewayid: (optional) Filter by gateway id
* @param string $reference: (optional) Filter by reference
Expand Down Expand Up @@ -427,8 +430,11 @@ static public function sendErrorEmail (

static public function getRequestId ($reference)
{
$position = strpos($reference, '#');
$requestId = substr($reference, $position + 1);
$requestId = 0;
if (!empty($reference)) {
$position = strpos($reference, '#');
$requestId = substr($reference, $position + 1);
}
return $requestId;
}

Expand Down Expand Up @@ -464,6 +470,104 @@ static public function getStoredReferenceUid ()
return static::getStoredData('referenceUid');
}

static public function storeInit (
$action,
$paymentMethod,
$callingExtensionKey,
$templateFilename = '',
$orderUid = 0,
$orderNumber = '0',
$currency = 'EUR',
$conf = [],
$basket = [],
$extraData = []
)
{
$data = [
'action' => $action,
'paymentMethod' => $paymentMethod,
'callingExtensionKey' => $callingExtensionKey,
'templateFilename' => $templateFilename,
'orderUid' => $orderUid,
'orderNumber' => $orderNumber,
'currency' => $currency,
'conf' => $conf,
'basket' => $basket,
'extraData' => $extraData
];

foreach ($data as $key => $value) {
static::storeData($key, $value);
}
}

static public function getStoredInit (
&$action,
&$paymentMethod,
&$callingExtensionKey,
&$templateFilename,
&$orderUid,
&$orderNumber,
&$currency,
&$conf,
&$basket,
&$extraData
) {
$data = [
'action' => &$action,
'paymentMethod' => &$paymentMethod,
'callingExtensionKey' => &$callingExtensionKey,
'templateFilename' => &$templateFilename,
'orderUid' => &$orderUid,
'orderNumber' => &$orderNumber,
'currency' => &$currency,
'conf' => &$conf,
'basket' => &$basket,
'extraData' => &$extraData
];


foreach ($data as $key => &$value) {
$value = static::getStoredData($key);
}
}

static public function convertToTransactorBasket (array $itemArray, array $variantFields)
{
$result = [];
// loop over all items in the basket indexed by sorting text
foreach ($itemArray as $sort => $actItemArray) {
foreach ($actItemArray as $k1 => $actItem) {
$row = $actItem['rec'];
if (!$row) { // avoid bug with missing row
continue;
}
$record = [];
$variants = [];
foreach ($variantFields as $field) {
if (
isset($row[$field]) &&
$row[$field] != ''
) {
$variants[] = $row[$field];
}
}

$record = $row;
$record[Field::VARIANT] = implode(' ', $variants);
$record[Field::QUANTITY] = $actItem['count'];
$record[Field::PRICE_TAX] = $row['pricetax'];
$record[Field::PRICE_NOTAX] = $row['pricenotax'];

$record[Field::TAX_PERCENTAGE] = $row['taxperc'];
$record[Field::NAME] = $row['title'];
$result[] = $record;
}
}

return $result;
}

/**
* @return FrontendUserAuthentication
*/
Expand Down
Loading

0 comments on commit 2ad61db

Please sign in to comment.