diff --git a/src/Application/Model/TeleCashConnectData.php b/src/Application/Model/TeleCashConnectData.php index 8ee36ab..787905e 100644 --- a/src/Application/Model/TeleCashConnectData.php +++ b/src/Application/Model/TeleCashConnectData.php @@ -20,9 +20,11 @@ use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\StandardException; use OxidSolutionCatalysts\TeleCash\Application\Model\Interface\TeleCashConnectDataInterface; +use OxidSolutionCatalysts\TeleCash\Core\Service\Logger; use OxidSolutionCatalysts\TeleCash\Core\Service\OxNewService; use OxidSolutionCatalysts\TeleCash\Core\Service\Price; use OxidSolutionCatalysts\TeleCash\IPG\TeleCashConnect; +use OxidSolutionCatalysts\TeleCash\Traits\Json; /** * Class TeleCashConnectData - Provider for TeleCashData @@ -31,6 +33,8 @@ */ class TeleCashConnectData implements TeleCashConnectDataInterface { + use Json; + protected ?User $user = null; protected ?Address $address = null; @@ -60,7 +64,8 @@ class TeleCashConnectData implements TeleCashConnectDataInterface */ public function __construct( private readonly TeleCashConnect $teleCashConnect, - private readonly OxNewService $oxNewService + private readonly OxNewService $oxNewService, + private readonly Logger $logger ) { } @@ -141,6 +146,11 @@ public function getTeleCashConnectData(): array $extHash = $this->teleCashConnect->calculateExtendedHashFromArray($allFields); $allFields['hashExtended'] = $extHash; + $this->logger->log( + 'debug', + 'Debug: getTeleCashConnectData: ' . $this->arrayToJson($allFields) + ); + return $allFields; } diff --git a/src/Core/Module.php b/src/Core/Module.php index 0fe3ec3..0018a96 100644 --- a/src/Core/Module.php +++ b/src/Core/Module.php @@ -83,7 +83,7 @@ final class Module ]; public const TELECASH_TXN_TYPE_SALE = 'sale'; - public const TELECASH_TXN_TYPE_POSTAUTH = 'postauth'; + public const TELECASH_TXN_TYPE_POSTAUTH = 'preauth'; public const TELECASH_TRANSACTION_TYPES = [ self::TELECASH_CAPTURE_TYPE_DIRECT => self::TELECASH_TXN_TYPE_SALE, diff --git a/src/Core/services.yaml b/src/Core/services.yaml index 62262b8..557b0df 100644 --- a/src/Core/services.yaml +++ b/src/Core/services.yaml @@ -6,6 +6,8 @@ services: OxidSolutionCatalysts\TeleCash\Core\Service\Logger: class: OxidSolutionCatalysts\TeleCash\Core\Service\Logger public: true + arguments: + Psr\Log\LoggerInterface: '@OxidSolutionCatalysts\TeleCash\Logger' OxidSolutionCatalysts\TeleCash\Core\Service\Context: class: OxidSolutionCatalysts\TeleCash\Core\Service\Context diff --git a/src/IPG/TeleCashConnect.php b/src/IPG/TeleCashConnect.php index bbe32f0..242f1c0 100644 --- a/src/IPG/TeleCashConnect.php +++ b/src/IPG/TeleCashConnect.php @@ -11,18 +11,24 @@ use DateTime; use InvalidArgumentException; +use OxidSolutionCatalysts\TeleCash\Core\Service\Logger; use OxidSolutionCatalysts\TeleCash\IPG\Model\BillingAddress; use OxidSolutionCatalysts\TeleCash\IPG\Model\CreditCardData; use OxidSolutionCatalysts\TeleCash\IPG\Model\CustomData; use OxidSolutionCatalysts\TeleCash\IPG\Model\DirectDebitData; use OxidSolutionCatalysts\TeleCash\IPG\Model\ShippingAddress; use OxidSolutionCatalysts\TeleCash\IPG\Model\TransactionResult; +use OxidSolutionCatalysts\TeleCash\Traits\Json; +use OxidSolutionCatalysts\TeleCash\Traits\ServiceContainer; /** * Base class for handling TeleCash Connect integration */ class TeleCashConnect { + use Json; + use ServiceContainer; + private string $hashMethod; private string $secretKey; private string $storeName; @@ -53,12 +59,20 @@ class TeleCashConnect */ private TeleCashCurrency $teleCashCurrency; - public function __construct(string $storeName, string $secretKey, string $hashMethod = 'HMACSHA256') - { + private ?Logger $logger; + + public function __construct( + string $storeName, + string $secretKey, + string $hashMethod = 'HMACSHA256' + ) { + $this->setContainer($this->getContainer()); + $this->hashMethod = $hashMethod; $this->secretKey = $secretKey; $this->storeName = $storeName; $this->teleCashCurrency = new TeleCashCurrency(); + $this->logger = $this->getServiceFromContainer(Logger::class); } /** @@ -324,6 +338,10 @@ public function isValidResponse(array $data = []): bool public function setResponseData(array $data): void { $this->responseData = $data; + $this->logger?->log( + 'debug', + 'Debug: setResponseData: ' . $this->arrayToJson($data) + ); } /** diff --git a/src/Traits/ModelGetter.php b/src/Traits/ModelGetter.php index fb15f7d..3e1a91e 100644 --- a/src/Traits/ModelGetter.php +++ b/src/Traits/ModelGetter.php @@ -14,6 +14,7 @@ use OxidEsales\Eshop\Core\Price; use OxidSolutionCatalysts\TeleCash\Application\Model\TeleCashOrder; use OxidSolutionCatalysts\TeleCash\Application\Model\TeleCashPayment; +use OxidSolutionCatalysts\TeleCash\Core\Service\Logger; use OxidSolutionCatalysts\TeleCash\Core\Service\OxNewService; use OxidSolutionCatalysts\TeleCash\Core\Service\TeleCashPaymentValidatorServiceInterface; use OxidSolutionCatalysts\TeleCash\Exception\TeleCashException; @@ -58,6 +59,7 @@ private function getTeleCashOrderModel(string $oxOrderId): TeleCashOrder return $this->getOxNewService()->oxNew(TeleCashOrder::class, [$oxOrderId]); } + /** * @throws TeleCashException */ @@ -114,11 +116,14 @@ private function getTeleCashConnect(): TeleCashConnect */ private function getTeleCashConnectData(): TeleCashConnectData { + $logger = $this->getServiceFromContainer(Logger::class); + return $this->getOxNewService()->oxNew( TeleCashConnectData::class, [ $this->getTeleCashConnect(), - $this->getOxNewService() + $this->getOxNewService(), + $logger ] ); } diff --git a/tests/Integration/Application/Model/TeleCashPaymentTest.php b/tests/Integration/Application/Model/TeleCashPaymentTest.php index c99b160..b0a8020 100644 --- a/tests/Integration/Application/Model/TeleCashPaymentTest.php +++ b/tests/Integration/Application/Model/TeleCashPaymentTest.php @@ -266,7 +266,7 @@ public function testGetTeleCashPaymentMethod(): void /** * Test getting the TeleCash transaction type based on capture type. - * This test verifies that the correct transaction type ('sale'/'postauth') + * This test verifies that the correct transaction type ('sale'/'preauth') * is returned for each capture type according to the TELECASH_TRANSACTION_TYPES mapping. */ public function testGetTeleCashTransactionType(): void @@ -287,7 +287,7 @@ public function testGetTeleCashTransactionType(): void Module::TELECASH_PAYMENT_IDENT_CC_VISA, Module::TELECASH_CAPTURE_TYPE_ONDELIVERY ); - $this->assertEquals('postauth', $teleCashPaymentReal->getTeleCashTransactionType()); + $this->assertEquals('preauth', $teleCashPaymentReal->getTeleCashTransactionType()); // Test manually capture type $teleCashPaymentReal->setTestValues( @@ -295,7 +295,7 @@ public function testGetTeleCashTransactionType(): void Module::TELECASH_PAYMENT_IDENT_CC_VISA, Module::TELECASH_CAPTURE_TYPE_MANUALLY ); - $this->assertEquals('postauth', $teleCashPaymentReal->getTeleCashTransactionType()); + $this->assertEquals('preauth', $teleCashPaymentReal->getTeleCashTransactionType()); } /** diff --git a/views/admin_twig/en/module_options.php b/views/admin_twig/en/module_options.php index 833f96c..bc6b2dd 100644 --- a/views/admin_twig/en/module_options.php +++ b/views/admin_twig/en/module_options.php @@ -18,7 +18,7 @@ # Module settings 'SHOP_MODULE_GROUP_' . ModuleSettingsServiceInterface::MODULE_CONFIG_API_VARGROUP => 'API', 'SHOP_MODULE_GROUP_' . ModuleSettingsServiceInterface::MODULE_CONFIG_API_FRONTEND_VARGROUP => 'API for OXID Frontend', - 'SHOP_MODULE_GROUP_' . ModuleSettingsServiceInterface::MODULE_CONFIG_API_BACKEND_VARGROUP => 'API für OXID Backend', + 'SHOP_MODULE_GROUP_' . ModuleSettingsServiceInterface::MODULE_CONFIG_API_BACKEND_VARGROUP => 'API for OXID Backend', 'SHOP_MODULE_GROUP_' . ModuleSettingsServiceInterface::MODULE_CONFIG_LANGUAGE => 'Languages', 'SHOP_MODULE_GROUP_' . ModuleSettingsServiceInterface::MODULE_CONFIG_DEBUG_VARGROUP => 'Debugging',