diff --git a/CHANGELOG.md b/CHANGELOG.md index 9acb45c8..1a68c459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.2.0] - unreleased - 2024-??-?? ### NEW -- new Paymentmethod Unzer installment (Paylater) -- If customers - for whatever reason - interrupt the order in the checkout, the order is still saved using a temporary order and Unzer's webhook +- New Paymentmethod Unzer installment (Paylater) +- If a customer interrupt the order in the checkout for any reason, the order is still saved using a temporary order and Unzer's webhook [oxid6] ### FIXED +- refactor of the correct use of the appropriate credentials depending on the payment method used - [0007553](https://bugs.oxid-esales.com/view.php?id=7553) revert this task because, it is possible to have different billing and delivery addresses for invoice purchases (Paylater) - [0007586](https://bugs.oxid-esales.com/view.php?id=7586) - Fix: Unable to finish the checkout process using the Apple Pay as the payment method - [0007638](https://bugs.oxid-esales.com/view.php?id=7638) - Fix: Sometimes duplicate order-positions in Backend, and dublicate ordermails ... diff --git a/Tests/Codeception/_data/dump.sql b/Tests/Codeception/_data/dump.sql index dcb4f5b8..2e866630 100644 --- a/Tests/Codeception/_data/dump.sql +++ b/Tests/Codeception/_data/dump.sql @@ -36,4 +36,15 @@ REPLACE INTO `oxuser` SET OXCOUNTRYID = 'a7c40f631fc920687.20179984', OXBIRTHDATE = '1980-11-22', OXCREATE = '2021-02-05 14:42:42', - OXREGISTER = '2021-02-05 14:42:42'; \ No newline at end of file + OXREGISTER = '2021-02-05 14:42:42'; + + +REPLACE INTO `oxcounters` SET + OXIDENT = 'oxOrder', + OXCOUNT = 747, + OXTIMESTAMP = '2024-05-13 12:04:58'; + +REPLACE INTO `oxcounters` SET + OXIDENT = 'oxUnzerOrder', + OXCOUNT = 420, + OXTIMESTAMP = '2024-05-13 12:04:58'; diff --git a/Tests/PhpStan/phpstan.neon b/Tests/PhpStan/phpstan.neon index 42e0bdd8..14688a94 100644 --- a/Tests/PhpStan/phpstan.neon +++ b/Tests/PhpStan/phpstan.neon @@ -1,9 +1,10 @@ parameters: - checkMissingIterableValueType: false treatPhpDocTypesAsCertain: false bootstrapFiles: - phpstan-bootstrap.php level: max scanFiles: - ../../vendor/oxid-esales/oxideshop-ce/source/oxfunctions.php - - ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php \ No newline at end of file + - ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php + ignoreErrors: + - identifier: missingType.iterableValue diff --git a/Tests/Unit/PaymentExtensions/UnzerPaymentTest.php b/Tests/Unit/PaymentExtensions/UnzerPaymentTest.php index eae5fe68..a648876c 100644 --- a/Tests/Unit/PaymentExtensions/UnzerPaymentTest.php +++ b/Tests/Unit/PaymentExtensions/UnzerPaymentTest.php @@ -41,7 +41,7 @@ public function testDefaultExecute(): void $unzerServiceMock->method('prepareOrderRedirectUrl')->willReturn('someRedirectUrl'); $unzerServiceMock->method('getUnzerCustomer')->with($userModel)->willReturn($customer = new Customer()); $unzerServiceMock->method('getShopMetadata')->willReturn($metadata = new Metadata()); - $unzerServiceMock->method('generateUnzerOrderId')->willReturn(1234567890); + $unzerServiceMock->method('generateUnzerOrderId')->willReturn('1234567890'); $unzerServiceMock->method('getUnzerBasket')->willReturn($unzerBasket); $chargeResult = $this->createPartialMock(Charge::class, []); @@ -78,7 +78,7 @@ public function testDefaultExecute(): void 'EUR', 'someRedirectUrl', $customer, - 1234567890, + '1234567890', $metadata, $unzerBasket ) diff --git a/Tests/Unit/Service/ModuleSettingsTest.php b/Tests/Unit/Service/ModuleSettingsTest.php index dd6d4004..2d8b9690 100644 --- a/Tests/Unit/Service/ModuleSettingsTest.php +++ b/Tests/Unit/Service/ModuleSettingsTest.php @@ -86,7 +86,7 @@ public function getSettingsDataProvider(): array ['sandbox-UnzerPublicKey', Module::MODULE_ID, 'sandboxPublicKey'], ['production-UnzerPublicKey', Module::MODULE_ID, 'productionPublicKey'], ], - 'settingMethod' => 'getShopPublicKey', + 'settingMethod' => 'getStandardPublicKey', 'settingValue' => 'sandboxPublicKey' ], [ @@ -95,7 +95,7 @@ public function getSettingsDataProvider(): array ['sandbox-UnzerPublicKey', Module::MODULE_ID, 'sandboxPublicKey'], ['production-UnzerPublicKey', Module::MODULE_ID, 'productionPublicKey'], ], - 'settingMethod' => 'getShopPublicKey', + 'settingMethod' => 'getStandardPublicKey', 'settingValue' => 'productionPublicKey' ], [ @@ -104,7 +104,7 @@ public function getSettingsDataProvider(): array ['sandbox-UnzerPrivateKey', Module::MODULE_ID, 'sandboxPrivateKey'], ['production-UnzerPrivateKey', Module::MODULE_ID, 'productionPrivateKey'], ], - 'settingMethod' => 'getShopPrivateKey', + 'settingMethod' => 'getStandardPrivateKey', 'settingValue' => 'sandboxPrivateKey' ], [ @@ -113,7 +113,7 @@ public function getSettingsDataProvider(): array ['sandbox-UnzerPrivateKey', Module::MODULE_ID, 'sandboxPrivateKey'], ['production-UnzerPrivateKey', Module::MODULE_ID, 'productionPrivateKey'], ], - 'settingMethod' => 'getShopPrivateKey', + 'settingMethod' => 'getStandardPrivateKey', 'settingValue' => 'productionPrivateKey' ], [ diff --git a/Tests/Unit/Service/UnzerTest.php b/Tests/Unit/Service/UnzerTest.php index 4e68ca55..2cacc6ab 100644 --- a/Tests/Unit/Service/UnzerTest.php +++ b/Tests/Unit/Service/UnzerTest.php @@ -121,7 +121,7 @@ public function testIfImmediatePostAuthCollectFalse(): void $paymentService = $this->getPaymentServiceMock($sut); $paymentService->method('getUnzerOrderId') - ->willReturn(666); + ->willReturn('666'); $sql = "INSERT INTO oxorder SET OXID=9999, OXPAYMENTTYPE='oscunzer_paypal', OXUNZERORDERNR=666"; DatabaseProvider::getDb()->execute($sql); diff --git a/metadata.php b/metadata.php index a9cd9d9b..79ff03c3 100644 --- a/metadata.php +++ b/metadata.php @@ -52,7 +52,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.2.0-rc.6', + 'version' => '1.2.0-rc.7', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', @@ -272,152 +272,164 @@ 'type' => 'str', 'value' => '' ], - // unzer invoice keypairs + + // live Paylater Invoice B2C EUR [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPublicKeyB2CEUR', + 'name' => 'production-UnzerPayLaterInvoiceB2CEURPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPrivateKeyB2CEUR', + 'name' => 'production-UnzerPayLaterInvoiceB2CEURPublicKey', 'type' => 'str', 'value' => '' ], + // live Paylater Invoice B2B EUR [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPublicKeyB2BEUR', + 'name' => 'production-UnzerPayLaterInvoiceB2BEURPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPrivateKeyB2BEUR', + 'name' => 'production-UnzerPayLaterInvoiceB2BEURPublicKey', 'type' => 'str', 'value' => '' ], + // live Paylater Invoice B2C CHF [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPublicKeyB2CCHF', + 'name' => 'production-UnzerPayLaterInvoiceB2CCHFPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPrivateKeyB2CCHF', + 'name' => 'production-UnzerPayLaterInvoiceB2CCHFPublicKey', 'type' => 'str', 'value' => '' ], + // live Paylater Invoice B2B CHF [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPublicKeyB2BCHF', + 'name' => 'production-UnzerPayLaterInvoiceB2BCHFPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerinvoice', - 'name' => 'sandbox-UnzerPrivateKeyB2BCHF', + 'name' => 'production-UnzerPayLaterInvoiceB2BCHFPublicKey', 'type' => 'str', 'value' => '' ], + // live Paylater Installment B2C EUR [ - 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPublicKeyB2CEUR', + 'group' => 'unzerpaylater', + 'name' => 'production-UnzerPayLaterInstallmentB2CEURPrivateKey', 'type' => 'str', 'value' => '' ], [ - 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPrivateKeyB2CEUR', + 'group' => 'unzerpaylater', + 'name' => 'production-UnzerPayLaterInstallmentB2CEURPublicKey', 'type' => 'str', 'value' => '' ], + // live Paylater Installment B2C CHF [ - 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPublicKeyB2BEUR', + 'group' => 'unzerpaylater', + 'name' => 'production-UnzerPayLaterInstallmentB2CCHFPrivateKey', 'type' => 'str', 'value' => '' ], [ - 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPrivateKeyB2BEUR', + 'group' => 'unzerpaylater', + 'name' => 'production-UnzerPayLaterInstallmentB2CCHFPublicKey', 'type' => 'str', 'value' => '' ], - + // sandbox Paylater Invoice B2C EUR [ 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPublicKeyB2CCHF', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2CEURPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPrivateKeyB2CCHF', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2CEURPublicKey', 'type' => 'str', 'value' => '' ], + // sandbox Paylater Invoice B2B EUR [ 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPublicKeyB2BCHF', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2BEURPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerinvoice', - 'name' => 'production-UnzerPrivateKeyB2BCHF', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2BEURPublicKey', 'type' => 'str', 'value' => '' ], + // sandbox Paylater Invoice B2C CHF [ - 'group' => 'unzerpaylater', - 'name' => 'sandbox-UnzerPaylaterPublicKeyB2CEUR', + 'group' => 'unzerinvoice', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2CCHFPrivateKey', 'type' => 'str', 'value' => '' ], [ - 'group' => 'unzerpaylater', - 'name' => 'sandbox-UnzerPaylaterPrivateKeyB2CEUR', + 'group' => 'unzerinvoice', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2CCHFPublicKey', 'type' => 'str', 'value' => '' ], + // sandbox Paylater Invoice B2B CHF [ - 'group' => 'unzerpaylater', - 'name' => 'sandbox-UnzerPaylaterPublicKeyB2CCHF', + 'group' => 'unzerinvoice', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2BCHFPrivateKey', 'type' => 'str', 'value' => '' ], [ - 'group' => 'unzerpaylater', - 'name' => 'sandbox-UnzerPaylaterPrivateKeyB2CCHF', + 'group' => 'unzerinvoice', + 'name' => 'sandbox-UnzerPayLaterInvoiceB2BCHFPublicKey', 'type' => 'str', 'value' => '' ], + // sandbox Paylater Installment B2C EUR [ 'group' => 'unzerpaylater', - 'name' => 'production-UnzerPaylaterPublicKeyB2CEUR', + 'name' => 'sandbox-UnzerPayLaterInstallmentB2CEURPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerpaylater', - 'name' => 'production-UnzerPaylaterPrivateKeyB2CEUR', + 'name' => 'sandbox-UnzerPayLaterInstallmentB2CEURPublicKey', 'type' => 'str', 'value' => '' ], + // sandbox Paylater Installment B2C CHF [ 'group' => 'unzerpaylater', - 'name' => 'production-UnzerPaylaterPublicKeyB2CCHF', + 'name' => 'sandbox-UnzerPayLaterInstallmentB2CCHFPrivateKey', 'type' => 'str', 'value' => '' ], [ 'group' => 'unzerpaylater', - 'name' => 'production-UnzerPaylaterPrivateKeyB2CCHF', + 'name' => 'sandbox-UnzerPayLaterInstallmentB2CCHFPublicKey', 'type' => 'str', 'value' => '' ], + [ 'group' => 'unzerother', 'name' => 'UnzerjQuery', diff --git a/src/Controller/AccountSavedPaymentController.php b/src/Controller/AccountSavedPaymentController.php index d4562137..39a51fe2 100644 --- a/src/Controller/AccountSavedPaymentController.php +++ b/src/Controller/AccountSavedPaymentController.php @@ -9,6 +9,9 @@ use OxidEsales\Eshop\Application\Controller\AccountController; use OxidEsales\Eshop\Core\DatabaseProvider; +use OxidSolutionCatalysts\Unzer\Exception\UnzerException; +use OxidSolutionCatalysts\Unzer\Service\DebugHandler; +use OxidSolutionCatalysts\Unzer\Service\Transaction; use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; use OxidEsales\Eshop\Core\Registry; @@ -33,56 +36,53 @@ public function render() protected function setPaymentListsToView(): void { - $UnzerSdk = $this->getServiceFromContainer(UnzerSDKLoader::class); - $unzerSDK = $UnzerSdk->getUnzerSDK(); - - $ids = $this->getTransactionIds(); + $transactionService = $this->getServiceFromContainer(Transaction::class); + $ids = $transactionService->getTrancactionIds($this->getUser()); $paymentTypes = false; - foreach ($ids as $typeId) { - if (empty($typeId['PAYMENTTYPEID'])) { + foreach ($ids as $typeData) { + $paymentTypeId = $typeData['PAYMENTTYPEID']; + $paymentId = $typeData['OXPAYMENTTYPE']; + $currency = $typeData['CURRENCY']; + $customerType = $typeData['CUSTOMERTYPE']; + $transactionOxId = $typeData['OXID']; + + if (empty($paymentTypeId)) { continue; } + try { - $paymentType = $unzerSDK->fetchPaymentType($typeId['PAYMENTTYPEID']); - } catch (UnzerApiException $exception) { - if ($exception->getCode() !== 'API.500.100.001') { - throw $exception; + $unzerSDK = $this->getServiceFromContainer(UnzerSDKLoader::class)->getUnzerSDK( + $paymentId, + $currency, + $customerType + ); + $paymentType = $unzerSDK->fetchPaymentType($paymentTypeId); + if (strpos($paymentTypeId, 'crd') && method_exists($paymentType, 'getBrand')) { + $paymentTypes[$paymentType->getBrand()][$transactionOxId] = $paymentType->expose(); } - - $paymentTypes['invalid_payment_method'][$typeId['OXID']] = $paymentType->expose(); - } - - if (strpos($typeId['PAYMENTTYPEID'], 'crd') && method_exists($paymentType, 'getBrand')) { - $paymentTypes[$paymentType->getBrand()][$typeId['OXID']] = $paymentType->expose(); - } - if (strpos($typeId['PAYMENTTYPEID'], 'ppl')) { - $paymentTypes['paypal'][$typeId['OXID']] = $paymentType->expose(); - } - if (strpos($typeId['PAYMENTTYPEID'], 'sdd')) { - $paymentTypes['sepa'][$typeId['OXID']] = $paymentType->expose(); + if (strpos($paymentTypeId, 'ppl')) { + $paymentTypes['paypal'][$transactionOxId] = $paymentType->expose(); + } + if (strpos($paymentTypeId, 'sdd')) { + $paymentTypes['sepa'][$transactionOxId] = $paymentType->expose(); + } + } catch (UnzerApiException | UnzerException $e) { + if ($e->getCode() !== 'API.500.100.001') { + $logEntry = sprintf( + 'Unknown error code while creating the PaymentList: "%s"', + $e->getCode() + ); + $logger = $this->getServiceFromContainer(DebugHandler::class); + $logger->log($logEntry); + continue; + } + $paymentTypes['invalid_payment_method_with_id'][$transactionOxId] = $paymentTypeId; } } $this->_aViewData['unzerPaymentType'] = $paymentTypes; } - /** - * @SuppressWarnings(PHPMD.StaticAccess) - */ - protected function getTransactionIds(): array - { - $result = []; - if ($this->getUser()) { - $oDB = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); - $result = $oDB->getAll( - "SELECT OXID, PAYMENTTYPEID from oscunzertransaction - where OXUSERID = :oxuserid AND PAYMENTTYPEID IS NOT NULL GROUP BY PAYMENTTYPEID ", - [':oxuserid' => $this->getUser()->getId()] - ); - } - return $result; - } - /** * @SuppressWarnings(PHPMD.StaticAccess) */ diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 07d397c4..9bfd955b 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -49,8 +49,8 @@ class AdminOrderController extends AdminDetailsController /** @var Payment $oPayment */ protected $oPayment = null; - /** @var string $sPaymentId */ - protected $sPaymentId; + /** @var string $sTypeId */ + protected string $sTypeId; /** * Executes parent method parent::render() @@ -80,12 +80,14 @@ public function render() $this->_aViewData['paymentTitle'] = $this->oPayment->getFieldData('OXDESC'); $this->_aViewData['oOrder'] = $oOrder; + /** @var string $sPaymentId */ + $sPaymentId = $oOrder->getFieldData('oxpaymenttype'); $transactionService = $this->getServiceFromContainer(TransactionService::class); - $this->sPaymentId = $transactionService->getPaymentIdByOrderId($this->getEditObjectId()); - $this->_aViewData['sPaymentId'] = $this->sPaymentId; - if ($this->sPaymentId) { - $this->getUnzerViewData($this->sPaymentId); + $this->sTypeId = $transactionService::getPaymentIdByOrderId($this->getEditObjectId()); + $this->_aViewData['sTypeId'] = $this->sTypeId; + if ($this->sTypeId) { + $this->getUnzerViewData($sPaymentId, $this->sTypeId); } } else { $translator = $this->getServiceFromContainer(Translator::class); @@ -95,27 +97,28 @@ public function render() return "oscunzer_order.tpl"; } - public function getUnzerSDK(string $customerType = '', string $currency = ''): Unzer + public function getUnzerSDK(string $paymentId = '', string $currency = '', string $customerType = ''): Unzer { return $this->getServiceFromContainer(UnzerSDKLoader::class) - ->getUnzerSDK($customerType, $currency); + ->getUnzerSDK($paymentId, $currency, $customerType); } /** - * @param string $sPaymentId + * @param string $sPaymentId - OXID Payment ID + * @param string $sTypeId - Unzer Type ID * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - protected function getUnzerViewData(string $sPaymentId): void + protected function getUnzerViewData(string $sPaymentId, string $sTypeId): void { try { $transactionInfo = $this->getCustomerTypeAndCurrencyFromTransaction(); // initialize proper SDK object - $sdk = $this->getUnzerSDK($transactionInfo['customertype'], $transactionInfo['currency']); + $sdk = $this->getUnzerSDK($sPaymentId, $transactionInfo['currency'], $transactionInfo['customertype']); /** @var \UnzerSDK\Resources\Payment $unzerPayment */ - $unzerPayment = $sdk->fetchPayment($sPaymentId); + $unzerPayment = $sdk->fetchPayment($sTypeId); $fCancelled = 0.0; $fCharged = 0.0; @@ -369,7 +372,7 @@ public function doUnzerCancel() return; } $paymentService = $this->getServiceFromContainer(\OxidSolutionCatalysts\Unzer\Service\Payment::class); - /** @var Order $oOrder */ + /** @var \OxidSolutionCatalysts\Unzer\Model\Order $oOrder */ $oOrder = $this->getEditObject(); $oStatus = $paymentService->doUnzerCancel($oOrder, $unzerid, $chargeid, $amount, (string)$reason); if ($oStatus instanceof UnzerApiException) { diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index 63200319..7ad63859 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -70,8 +70,7 @@ public function updatePaymentTransStatus(): void $url = parse_url($aJson['retrieveUrl']); /** @var Transaction $transaction */ $transaction = $this->getServiceFromContainer(Transaction::class); - $aPath = explode("/", $url['path']); - $typeid = end($aPath); + /** @var Request $request */ $request = Registry::getRequest(); /** @var string $context */ @@ -95,10 +94,6 @@ public function updatePaymentTransStatus(): void $resource = $unzer->fetchResourceFromEvent($jsonRequest); $paymentId = $resource->getId(); - if (!$transaction->isValidTransactionTypeId($typeid)) { - // Registry::getUtils()->showMessageAndExit("Invalid type id"); - } - if (is_string($paymentId)) { /** @var \OxidSolutionCatalysts\Unzer\Model\Order $order */ $order = oxNew(Order::class); diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 97e8c681..6202f24a 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -18,9 +18,11 @@ use OxidSolutionCatalysts\Unzer\Exception\Redirect; use OxidSolutionCatalysts\Unzer\Exception\RedirectWithMessage; use OxidSolutionCatalysts\Unzer\Model\Payment; +use OxidSolutionCatalysts\Unzer\Service\DebugHandler; use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; use OxidSolutionCatalysts\Unzer\Service\ResponseHandler; +use OxidSolutionCatalysts\Unzer\Service\Transaction; use OxidSolutionCatalysts\Unzer\Service\Translator; use OxidSolutionCatalysts\Unzer\Service\Unzer; use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; @@ -28,6 +30,7 @@ use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions as CoreUnzerDefinitions; use UnzerSDK\Exceptions\UnzerApiException; +use OxidSolutionCatalysts\Unzer\Exception\UnzerException; /** * TODO: Decrease count of dependencies to 13 @@ -133,13 +136,13 @@ public function unzerExecuteAfterRedirect(): void $unzerService = $this->getServiceFromContainer(Unzer::class); if (stripos($nextStep, 'thankyou') !== false) { $oDB->commitTransaction(); - $unzerPaymentId = Registry::getSession()->getVariable('paymentid'); + $unzerPaymentId = $this->getUnzerPaymentIdFromSession(); $paymentService = $this->getServiceFromContainer(PaymentService::class); - if ($unzerService->ifImmediatePostAuthCollect($paymentService)) { + if (!empty($unzerPaymentId) && $unzerService->ifImmediatePostAuthCollect($paymentService)) { $paymentService->doUnzerCollect( $oOrder, $unzerPaymentId, - $oBasket->getDiscountedProductsBruttoPrice() + (float)$oOrder->getTotalOrderSum() ); } @@ -357,54 +360,50 @@ public function getExecuteFnc() } protected function getSavedPayment(): void { - $UnzerSdk = $this->getServiceFromContainer(UnzerSDKLoader::class); - $unzerSDK = $UnzerSdk->getUnzerSDK(); - - $ids = $this->getTrancactionIds(); + $transactionService = $this->getServiceFromContainer(Transaction::class); + $ids = $transactionService->getTrancactionIds($this->getUser()); $paymentTypes = false; if ($ids) { - foreach ($ids as $typeId) { - if (!empty($typeId['PAYMENTTYPEID'])) { + foreach ($ids as $typeData) { + $paymentTypeId = $typeData['PAYMENTTYPEID'] ?: ''; + $paymentId = $typeData['OXPAYMENTTYPE'] ?: ''; + $currency = $typeData['CURRENCY'] ?: ''; + $customerType = $typeData['CUSTOMERTYPE'] ?: ''; + if (!empty($paymentTypeId)) { try { - $paymentType = $unzerSDK->fetchPaymentType($typeId['PAYMENTTYPEID']); - } catch (UnzerApiException $e) { + $UnzerSdk = $this->getServiceFromContainer(UnzerSDKLoader::class); + $unzerSDK = $UnzerSdk->getUnzerSDK( + $paymentId, + $currency, + $customerType + ); + $paymentType = $unzerSDK->fetchPaymentType($paymentTypeId); + } catch (UnzerException | UnzerApiException $e) { + $userId = $this->getUser() ? $this->getUser()->getId() : 'unknown'; + $logEntry = sprintf( + 'The incorrect data used to initialize the SDK ' . + 'comes from the transactions of the user: "%s"', + $userId + ); + $logger = $this->getServiceFromContainer(DebugHandler::class); + $logger->log($logEntry); continue; } - - if (strpos($typeId['PAYMENTTYPEID'], 'crd')) { - $paymentTypes['card'][$typeId['PAYMENTTYPEID']] = $paymentType->expose(); + if (strpos($paymentTypeId, 'crd')) { + $paymentTypes['card'][$paymentTypeId] = $paymentType->expose(); } - if (strpos($typeId['PAYMENTTYPEID'], 'ppl')) { - $paymentTypes['paypal'][$typeId['PAYMENTTYPEID']] = $paymentType->expose(); + if (strpos($paymentTypeId, 'ppl')) { + $paymentTypes['paypal'][$paymentTypeId] = $paymentType->expose(); } - if (strpos($typeId['PAYMENTTYPEID'], 'sdd')) { - $paymentTypes['sepa'][$typeId['PAYMENTTYPEID']] = $paymentType->expose(); + if (strpos($paymentTypeId, 'sdd')) { + $paymentTypes['sepa'][$paymentTypeId] = $paymentType->expose(); } } } } - $this->_aViewData['unzerPaymentType'] = $paymentTypes; } - /** - * @SuppressWarnings(PHPMD.StaticAccess) - */ - protected function getTrancactionIds(): array - { - $result = []; - if ($this->getUser() && $this->getUser()->getId() !== null) { - $oDB = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); - $result = $oDB->getAll( - "SELECT PAYMENTTYPEID from oscunzertransaction - where OXUSERID = :oxuserid AND PAYMENTTYPEID IS NOT NULL - GROUP BY PAYMENTTYPEID ", - [':oxuserid' => $this->getUser()->getId()] - ); - } - return $result; - } - protected function getBasketHash(): string { /** @var ?Basket $oBasket */ @@ -421,4 +420,14 @@ protected function getBasketHash(): string serialize($basketContents) ); } + + private function getUnzerPaymentIdFromSession(): string + { + $paymentId = Registry::getSession()->getVariable('UnzerPaymentId'); + if (is_string($paymentId)) { + return $paymentId; + } + + return ''; + } } diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index f4334f57..dc63b4cf 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -9,6 +9,7 @@ use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Session; +use OxidSolutionCatalysts\Unzer\Model\TmpOrder; use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; use OxidSolutionCatalysts\Unzer\Service\UserRepository; use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions as UnzerDefinitionsService; @@ -17,6 +18,7 @@ use OxidEsales\Eshop\Core\Registry; use UnzerSDK\Constants\PaymentState; use UnzerSDK\Exceptions\UnzerApiException; +use UnzerSDK\Unzer; class PaymentController extends PaymentController_parent { @@ -118,34 +120,69 @@ protected function checkForUnzerPaymentErrors(): void * @param $session Session * @return void */ - protected function checkForDuplicateOrderAttempt(Session $session) + private function checkForDuplicateOrderAttempt(Session $session): void { - $unzerSDK = $this->getServiceFromContainer(UnzerSDKLoader::class); - $unzerSDK = $unzerSDK->getUnzerSDK(); - $oxOrderIdOfTmpOrder = $session->getVariable('oxOrderIdOfTmpOrder'); - $paymentId = is_string($session->getVariable('paymentid')) ? $session->getVariable('paymentid') : ''; - if ($oxOrderIdOfTmpOrder) { - if ($paymentId) { - try { - $unzerPayment = $unzerSDK->fetchPayment($paymentId); - $unzerOrderId = $unzerPayment->getOrderId(); - $sessionUnzerOrderId = $session->getVariable('UnzerOrderId'); - if ( - (int) $unzerOrderId === $sessionUnzerOrderId && - ($unzerPayment->getState() === PaymentState::STATE_COMPLETED || - $unzerPayment->getState() === PaymentState::STATE_PENDING) - ) { - $session->deleteVariable('paymentid'); - $session->deleteVariable('UnzerOrderId'); - } - } catch (UnzerApiException $e) { - Registry::getLogger()->warning( - 'Payment not found with key: ' . $paymentId . ' and message: ' . $e->getMessage() - ); + $oxOrderIdOfTmpOrder = is_string($session->getVariable('oxOrderIdOfTmpOrder')) ? + $session->getVariable('oxOrderIdOfTmpOrder') : + ''; + + $unzerPaymentId = is_string($session->getVariable('UnzerPaymentId')) ? + $session->getVariable('UnzerPaymentId') : + ''; + + $unzerSDK = $this->getUnzerSDKFromTmpOrder($oxOrderIdOfTmpOrder); + + if ($unzerSDK && $unzerPaymentId) { + try { + $unzerPayment = $unzerSDK->fetchPayment($unzerPaymentId); + $unzerOrderId = $unzerPayment->getOrderId(); + $sessionUnzerOrderId = $session->getVariable('UnzerOrderId'); + if ( + (int) $unzerOrderId === $sessionUnzerOrderId && + ($unzerPayment->getState() === PaymentState::STATE_COMPLETED || + $unzerPayment->getState() === PaymentState::STATE_PENDING) + ) { + $session->deleteVariable('UnzerPaymentId'); + $session->deleteVariable('UnzerOrderId'); } + } catch (UnzerApiException $e) { + Registry::getLogger()->warning( + 'Payment not found with key: ' . $unzerPaymentId . ' and message: ' . $e->getMessage() + ); } + $session->deleteVariable('sess_challenge'); $session->deleteVariable('oxOrderIdOfTmpOrder'); } } + + /** + * @param $oxOrderIdOfTmpOrder string + * @return Unzer|null + */ + private function getUnzerSDKFromTmpOrder(string $oxOrderIdOfTmpOrder): ?Unzer + { + $result = null; + /** @var Order $tmpOrder */ + $tmpOrder = oxNew(TmpOrder::class)->getTmpOrderByOxOrderId($oxOrderIdOfTmpOrder); + if ($tmpOrder) { + $unzerSDK = $this->getServiceFromContainer(UnzerSDKLoader::class); + + /** @var string $paymentId */ + $paymentId = $tmpOrder->getFieldData('oxpaymenttype'); + /** @var string $currency */ + $currency = $tmpOrder->getFieldData('oxcurrency'); + $customerType = !empty($tmpOrder->getFieldData('oxdelcompany')) + || !empty($tmpOrder->getFieldData('oxbillcompany')) ? + 'B2B' : + 'B2C'; + + $result = $unzerSDK->getUnzerSDK( + $paymentId, + $currency, + $customerType + ); + } + return $result; + } } diff --git a/src/Core/ViewConfig.php b/src/Core/ViewConfig.php index 964c3f79..8a3fcac5 100644 --- a/src/Core/ViewConfig.php +++ b/src/Core/ViewConfig.php @@ -71,16 +71,16 @@ public function getUnzerPubKey(): string Registry::getSession()->getBasket()->getPaymentId() === UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID ) { - return $this->moduleSettings->getShopPublicKeyInvoice(); + return $this->moduleSettings->getInvoicePublicKey(); } if ( Registry::getSession()->getBasket()->getPaymentId() === UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID ) { - return $this->moduleSettings->getShopPublicKeyInstallment(); + return $this->moduleSettings->getInstallmentPublicKey(); } - return $this->moduleSettings->getShopPublicKey(); + return $this->moduleSettings->getStandardPublicKey(); } /** @@ -94,39 +94,27 @@ public function getUnzerPrivKey(): string Registry::getSession()->getBasket()->getPaymentId() === UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID ) { - return $this->moduleSettings->getShopPrivateKeyInvoice(); + return $this->moduleSettings->getInvoicePrivateKey(); } if ( Registry::getSession()->getBasket()->getPaymentId() === UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID ) { - return $this->moduleSettings->getShopPrivateKeyInstallment(); + return $this->moduleSettings->getInstallmentPrivateKey(); } - return $this->moduleSettings->getShopPrivateKey(); + return $this->moduleSettings->getStandardPrivateKey(); } public function getUnzerB2BPubKey(): string { - $key = $this->moduleSettings->getShopPublicKeyInvoice('B2B'); - return $key; - } - - public function getUnzerB2BPrivKey(): string - { - $key = $this->moduleSettings->getShopPrivateKeyInvoice('B2B'); + $key = $this->moduleSettings->getInvoicePublicKey('B2B'); return $key; } public function getUnzerB2CPubKey(): string { - $key = $this->moduleSettings->getShopPublicKeyInvoice('B2C'); - return $key; - } - - public function getUnzerB2CPrivKey(): string - { - $key = $this->moduleSettings->getShopPrivateKeyInvoice('B2C'); + $key = $this->moduleSettings->getInvoicePublicKey(); return $key; } diff --git a/src/Model/Order.php b/src/Model/Order.php index a523af9d..7280e6c0 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -115,7 +115,7 @@ public function finalizeUnzerOrderAfterRedirect( } $this->initWriteTransactionToDB( - $paymentService->getSessionUnzerPayment(null,true) + $paymentService->getSessionUnzerPayment(true) ); // cleanUp Tmp Order @@ -193,7 +193,7 @@ public function createTmpOrder( $tmpOrder = oxNew(TmpOrder::class); $tmpOrder->saveTmpOrder($this); - Registry::getSession()->setVariable('oxOrderIdOfTmpOrder', $this->getId()); + Registry::getSession()->setVariable('oxOrderIdOfTmpOrder', $orderId); return $iRet; } diff --git a/src/Model/TmpOrder.php b/src/Model/TmpOrder.php index e1723fd4..1f5373bd 100644 --- a/src/Model/TmpOrder.php +++ b/src/Model/TmpOrder.php @@ -124,4 +124,35 @@ public function getTmpOrderByUnzerId(string $unzerOrderNr): array $result = is_a($blocksData, Result::class) ? $blocksData->fetchAssociative() : false; return is_array($result) ? $result : []; } + + public function getTmpOrderByOxOrderId(string $oxSessionOrderId): ?CoreOrderModel + { + $queryBuilderFactory = $this->getServiceFromContainer(QueryBuilderFactoryInterface::class); + /** @var QueryBuilder $queryBuilder */ + $queryBuilder = $queryBuilderFactory->create(); + $queryBuilder + ->select('*') + ->from('oscunzertmporder') + ->where('oxorderid = :oxorderid') + ->andWhere('status = "NOT_FINISHED"') + ->orderBy('timestamp', 'ASC') + ->setParameters( + ['oxorderid' => $oxSessionOrderId] + ); + /** @var Result $blocksData */ + $blocksData = $queryBuilder->execute(); + $result = is_a($blocksData, Result::class) ? $blocksData->fetchAssociative() : false; + + if (is_array($result) && isset($result['TMPORDER']) && is_string($result['TMPORDER'])) { + $tmpOrder = $result['TMPORDER']; + $result = unserialize(base64_decode($tmpOrder)); + if (is_array($result) && isset($result['order']) && is_object($result['order'])) { + /** @var \OxidSolutionCatalysts\Unzer\Model\Order $order */ + $order = $result['order']; + return $order; + } + } + + return null; + } } diff --git a/src/PaymentExtensions/UnzerPayment.php b/src/PaymentExtensions/UnzerPayment.php index eca0e1ca..db3ef3db 100644 --- a/src/PaymentExtensions/UnzerPayment.php +++ b/src/PaymentExtensions/UnzerPayment.php @@ -12,6 +12,7 @@ use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Request; +use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\DebugHandler; use OxidSolutionCatalysts\Unzer\Service\Transaction as TransactionService; use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; @@ -27,7 +28,6 @@ use UnzerSDK\Resources\TransactionTypes\AbstractTransactionType; use UnzerSDK\Resources\TransactionTypes\Authorization; use UnzerSDK\Unzer; -use JsonException; /** * TODO: Decrease count of dependencies to 13 @@ -204,14 +204,19 @@ protected function doTransactions( $auth->setRiskData($uzrRiskData); try { $loader = $this->getServiceFromContainer(UnzerSDKLoader::class); - $UnzerSdk = $loader->getUnzerSDK('B2C', $currency->name, true); + $UnzerSdk = $loader->getUnzerSDK( + UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID, + $currency->name + ); $transaction = $UnzerSdk->performAuthorization($auth, $paymentType, $customer, null, $uzrBasket); } catch (UnzerApiException $e) { throw new UnzerApiException($e->getMerchantMessage(), $e->getClientMessage()); } } else { + $priceObj = $basketModel->getPrice(); + $price = $priceObj ? $priceObj->getPrice() : 0; $transaction = $paymentType->{$paymentProcedure}( - $basketModel->getPrice()->getPrice(), + $price, $basketModel->getBasketCurrency()->name, $this->unzerService->prepareOrderRedirectUrl($this->redirectUrlNeedPending()), $customer, diff --git a/src/Service/ApiClient.php b/src/Service/ApiClient.php index 257de0ab..f3a406f1 100644 --- a/src/Service/ApiClient.php +++ b/src/Service/ApiClient.php @@ -42,7 +42,7 @@ public function __construct( $this->headers = [ 'Accept' => '*/*', - 'Authorization' => 'Basic ' . base64_encode($this->moduleSettings->getShopPrivateKey() . ':') + 'Authorization' => 'Basic ' . base64_encode($this->moduleSettings->getStandardPrivateKey() . ':') ]; } diff --git a/src/Service/ModuleSettings.php b/src/Service/ModuleSettings.php index 0440ba31..eabe7bcb 100644 --- a/src/Service/ModuleSettings.php +++ b/src/Service/ModuleSettings.php @@ -104,21 +104,6 @@ public function setSystemMode(string $systemMode): void $this->saveSetting('UnzerSystemMode', $systemMode); } - /** - * @return string - */ - public function getShopPublicKey(): string - { - /** @var string $unzerPublicKey */ - $unzerPublicKey = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKey'); - return $unzerPublicKey; - } - public function getShopPublicKeyPaylater(): string - { - /** @var string $unzerPublicKey */ - $unzerPublicKey = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKey'); - return $unzerPublicKey; - } /** * @return float */ @@ -129,16 +114,21 @@ public function getInstallmentRate(): float return $unzerOption; } - /** - * @return string - */ - public function getShopPrivateKey(): string + public function getStandardPrivateKey(): string { /** @var string $unzerPrivateKey */ $unzerPrivateKey = $this->getSettingValue($this->getSystemMode() . '-UnzerPrivateKey'); return $unzerPrivateKey; } + + public function getStandardPublicKey(): string + { + /** @var string $unzerPublicKey */ + $unzerPublicKey = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKey'); + return $unzerPublicKey; + } + /** * @return bool */ @@ -329,7 +319,7 @@ public function getApplePayMerchantCertKeyFilePath(): string /** * @return string - * @throws FileException + * @throws FileException|Exception */ public function getFilesPath(): string { @@ -419,26 +409,26 @@ public function getWebhookConfiguration(): array public function getPrivateKeysWithContext(): array { $privateKeys = []; - if ('' !== $this->getShopPrivateKey()) { - $privateKeys['shop'] = $this->getShopPrivateKey(); + if ('' !== $this->getStandardPrivateKey()) { + $privateKeys['shop'] = $this->getStandardPrivateKey(); } - if ('' !== $this->getShopPrivateKeyB2CInvoiceEUR()) { - $privateKeys['b2ceur'] = $this->getShopPrivateKeyB2CInvoiceEUR(); + if ('' !== $this->getInvoiceB2CEURPrivateKey()) { + $privateKeys['b2ceur'] = $this->getInvoiceB2CEURPrivateKey(); } - if ('' !== $this->getShopPrivateKeyB2CInvoiceCHF()) { - $privateKeys['b2cchf'] = $this->getShopPrivateKeyB2CInvoiceCHF(); + if ('' !== $this->getInvoiceB2CCHFPrivateKey()) { + $privateKeys['b2cchf'] = $this->getInvoiceB2CCHFPrivateKey(); } - if ('' !== $this->getShopPrivateKeyB2BInvoiceEUR()) { - $privateKeys['b2beur'] = $this->getShopPrivateKeyB2BInvoiceEUR(); + if ('' !== $this->getInvoiceB2BEURPrivateKey()) { + $privateKeys['b2beur'] = $this->getInvoiceB2BEURPrivateKey(); } - if ('' !== $this->getShopPrivateKeyB2BInvoiceCHF()) { - $privateKeys['b2bchf'] = $this->getShopPrivateKeyB2BInvoiceCHF(); + if ('' !== $this->getInvoiceB2BCHFPrivateKey()) { + $privateKeys['b2bchf'] = $this->getInvoiceB2BCHFPrivateKey(); } - if ('' !== $this->getShopPrivateKeyB2CInstallmentEUR()) { - $privateKeys['b2ceurinstallment'] = $this->getShopPrivateKeyB2CInstallmentEUR(); + if ('' !== $this->getInstallmentB2CEURPrivateKey()) { + $privateKeys['b2ceurinstallment'] = $this->getInstallmentB2CEURPrivateKey(); } - if ('' !== $this->getShopPrivateKeyB2CInstallmentCHF()) { - $privateKeys['b2cchfinstallment'] = $this->getShopPrivateKeyB2CInstallmentCHF(); + if ('' !== $this->getInstallmentB2CCHFPrivateKey()) { + $privateKeys['b2cchfinstallment'] = $this->getInstallmentB2CCHFPrivateKey(); } return $privateKeys; @@ -481,8 +471,8 @@ private function isActiveSetting($active): bool public function isStandardEligibility(): bool { return ( - $this->getShopPrivateKey() && - $this->getShopPublicKey() && + $this->getStandardPrivateKey() && + $this->getStandardPublicKey() && $this->hasWebhookConfiguration('shop') ); } @@ -518,13 +508,13 @@ public function isB2CInstallmentEligibility(): bool { return ( $this->isBasketCurrencyCHF() && - !empty($this->getShopPublicKeyB2CinstallmentCHF()) && - !empty($this->getShopPrivateKeyB2CInstallmentCHF()) + !empty($this->getInstallmentB2CCHFPublicKey()) && + !empty($this->getInstallmentB2CCHFPrivateKey()) ) || ( $this->isBasketCurrencyEUR() && - !empty($this->getShopPublicKeyB2CInstallmentEUR()) && - !empty($this->getShopPrivateKeyB2CInstallmentEUR()) + !empty($this->getInstallmentB2CEURPublicKey()) && + !empty($this->getInstallmentB2CEURPrivateKey()) ); } /** @@ -534,13 +524,13 @@ public function isB2CInvoiceEligibility(): bool { return ( $this->isBasketCurrencyCHF() && - !empty($this->getShopPublicKeyB2CInvoiceCHF()) && - !empty($this->getShopPrivateKeyB2CInvoiceCHF()) + !empty($this->getInvoiceB2CCHFPublicKey()) && + !empty($this->getInvoiceB2CCHFPrivateKey()) ) || ( $this->isBasketCurrencyEUR() && - !empty($this->getShopPublicKeyB2CInvoiceEUR()) && - !empty($this->getShopPrivateKeyB2CInvoiceEUR()) + !empty($this->getInvoiceB2CEURPublicKey()) && + !empty($this->getInvoiceB2CEURPrivateKey()) ); } @@ -551,219 +541,183 @@ public function isB2BInvoiceEligibility(): bool { return ( $this->isBasketCurrencyCHF() && - !empty($this->getShopPublicKeyB2BInvoiceCHF()) && - !empty($this->getShopPrivateKeyB2BInvoiceCHF()) + !empty($this->getInvoiceB2BCHFPublicKey()) && + !empty($this->getInvoiceB2BCHFPrivateKey()) ) || ( $this->isBasketCurrencyEUR() && - !empty($this->getShopPublicKeyB2BInvoiceEUR()) && - !empty($this->getShopPrivateKeyB2BInvoiceEUR()) + !empty($this->getInvoiceB2BEURPublicKey()) && + !empty($this->getInvoiceB2BEURPrivateKey()) ); } - /** - * @return string - */ - private function getShopPublicKeyB2CInvoiceEUR(): string + private function getInvoiceB2CEURPrivateKey(): string { - /** @var string $unzerPubKeyB2CEUR */ - $unzerPubKeyB2CEUR = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKeyB2CEUR'); - return $unzerPubKeyB2CEUR; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2CEURPrivateKey'); + return $key; } - /** - * @return string - */ - private function getShopPublicKeyB2CInstallmentEUR(): string + + private function getInvoiceB2CEURPublicKey(): string { - /** @var string $unzerPubKeyB2CEUR */ - $unzerPubKeyB2CEUR = $this->getSettingValue($this->getSystemMode() . '-UnzerPaylaterPublicKeyB2CEUR'); - return $unzerPubKeyB2CEUR; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2CEURPublicKey'); + return $key; } - /** - * @return string - */ - private function getShopPrivateKeyB2CInvoiceEUR(): string + + private function getInvoiceB2BEURPrivateKey(): string { - /** @var string $unzerPrivKeyB2CEUR */ - $unzerPrivKeyB2CEUR = $this->getSettingValue($this->getSystemMode() . '-UnzerPrivateKeyB2CEUR'); - return $unzerPrivKeyB2CEUR; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2BEURPrivateKey'); + return $key; } - private function getShopPrivateKeyB2CInstallmentEUR(): string + + private function getInvoiceB2BEURPublicKey(): string { - /** @var string $unzerPrivKeyB2CEUR */ - $unzerPrivKeyB2CEUR = $this->getSettingValue($this->getSystemMode() . '-UnzerPaylaterPrivateKeyB2CEUR'); - return $unzerPrivKeyB2CEUR; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2BEURPublicKey'); + return $key; } - /** - * @return string - */ - private function getShopPublicKeyB2BInvoiceEUR(): string + + private function getInvoiceB2CCHFPrivateKey(): string { - /** @var string $unzerPubKeyB2BEUR */ - $unzerPubKeyB2BEUR = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKeyB2BEUR'); - return $unzerPubKeyB2BEUR; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2CCHFPrivateKey'); + return $key; } - /** - * @return string - */ - private function getShopPrivateKeyB2BInvoiceEUR(): string + private function getInvoiceB2CCHFPublicKey(): string { - /** @var string $unzerPrivKeyB2BEUR */ - $unzerPrivKeyB2BEUR = $this->getSettingValue($this->getSystemMode() . '-UnzerPrivateKeyB2BEUR'); - return $unzerPrivKeyB2BEUR; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2CCHFPublicKey'); + return $key; } - /** - * @return string - */ - private function getShopPublicKeyB2CInvoiceCHF(): string + private function getInvoiceB2BCHFPrivateKey(): string { - /** @var string $unzerPubKeyB2CCHF */ - $unzerPubKeyB2CCHF = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKeyB2CCHF'); - return $unzerPubKeyB2CCHF; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2BCHFPrivateKey'); + return $key; } - private function getShopPublicKeyB2CInstallmentCHF(): string + + private function getInvoiceB2BCHFPublicKey(): string { - /** @var string $unzerPubKeyB2CCHF */ - $unzerPubKeyB2CCHF = $this->getSettingValue($this->getSystemMode() . '-UnzerPaylaterPublicKeyB2CCHF'); - return $unzerPubKeyB2CCHF; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInvoiceB2BCHFPublicKey'); + return $key; } - private function getShopPrivateKeyB2CInstallmentCHF(): string + + private function getInstallmentB2CEURPrivateKey(): string { - /** @var string $unzerPrivKeyB2CCHF */ - $unzerPrivKeyB2CCHF = $this->getSettingValue($this->getSystemMode() . '-UnzerPaylaterPrivateKeyB2CCHF'); - return $unzerPrivKeyB2CCHF; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInstallmentB2CEURPrivateKey'); + return $key; } - /** - * @return string - */ - private function getShopPrivateKeyB2CInvoiceCHF(): string + + private function getInstallmentB2CEURPublicKey(): string { - /** @var string $unzerPrivKeyB2CCHF */ - $unzerPrivKeyB2CCHF = $this->getSettingValue($this->getSystemMode() . '-UnzerPrivateKeyB2CCHF'); - return $unzerPrivKeyB2CCHF; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInstallmentB2CEURPublicKey'); + return $key; } - /** - * @return string - */ - private function getShopPublicKeyB2BInvoiceCHF(): string + private function getInstallmentB2CCHFPrivateKey(): string { - /** @var string $unzerPubKeyB2BCHF */ - $unzerPubKeyB2BCHF = $this->getSettingValue($this->getSystemMode() . '-UnzerPublicKeyB2BCHF'); - return $unzerPubKeyB2BCHF; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInstallmentB2CCHFPrivateKey'); + return $key; } - /** - * @return string - */ - private function getShopPrivateKeyB2BInvoiceCHF(): string + private function getInstallmentB2CCHFPublicKey(): string { - /** @var string $unzerPrivKeyB2BCHF */ - $unzerPrivKeyB2BCHF = $this->getSettingValue($this->getSystemMode() . '-UnzerPrivateKeyB2BCHF'); - return $unzerPrivKeyB2BCHF; + /** @var string $key */ + $key = $this->getSettingValue($this->getSystemMode() . '-UnzerPayLaterInstallmentB2CCHFPublicKey'); + return $key; } /** * @param string $customerType * @return string */ - public function getShopPublicKeyInvoice(string $customerType = 'B2C'): string + public function getInvoicePublicKey(string $customerType = 'B2C'): string { - $result = $this->getShopPublicKey(); + $result = ''; - if ($this->isB2CInvoiceEligibility() && $customerType === 'B2C') { + if ($customerType === 'B2C' && $this->isB2CInvoiceEligibility()) { if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPublicKeyB2CInvoiceCHF(); + $result = $this->getInvoiceB2CCHFPublicKey(); } if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPublicKeyB2CInvoiceEUR(); + $result = $this->getInvoiceB2CEURPublicKey(); } } - if ($this->isB2BInvoiceEligibility() && $customerType === 'B2B') { + if ($customerType === 'B2B' && $this->isB2BInvoiceEligibility()) { if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPublicKeyB2BInvoiceCHF(); + $result = $this->getInvoiceB2BCHFPublicKey(); } if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPublicKeyB2BInvoiceEUR(); + $result = $this->getInvoiceB2BEURPublicKey(); } } return $result; } - public function getShopPublicKeyInstallment(string $customerType = 'B2C'): string + /** + * @param string $customerType + * @return string + */ + public function getInvoicePrivateKey(string $customerType = 'B2C'): string { - $result = $this->getShopPublicKeyPaylater(); + $result = ''; - if ($this->isB2CInstallmentEligibility() && $customerType === 'B2C') { + if ($customerType === 'B2C' && $this->isB2CInvoiceEligibility()) { if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPublicKeyB2CInstallmentCHF(); + $result = $this->getInvoiceB2CCHFPrivateKey(); } if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPublicKeyB2CInstallmentEUR(); + $result = $this->getInvoiceB2CEURPrivateKey(); } } - if ($this->isB2BInvoiceEligibility() && $customerType === 'B2B') { + + if ($customerType === 'B2B' && $this->isB2BInvoiceEligibility()) { if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPublicKeyB2BInvoiceCHF(); + $result = $this->getInvoiceB2BCHFPrivateKey(); } if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPublicKeyB2BInvoiceEUR(); + $result = $this->getInvoiceB2BEURPrivateKey(); } } return $result; } - public function getShopPrivateKeyInstallment(string $customerType = 'B2C'): string - { - $result = $this->getShopPrivateKey(); - if ($this->isB2CInvoiceEligibility() && $customerType === 'B2C') { - if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPrivateKeyB2CInstallmentCHF(); - } - if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPrivateKeyB2CInvoiceEUR(); - } - } + public function getInstallmentPublicKey(): string + { + $result = ''; - if ($this->isB2BInvoiceEligibility() && $customerType === 'B2B') { + if ($this->isB2CInstallmentEligibility()) { if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPrivateKeyB2BInvoiceCHF(); + $result = $this->getInstallmentB2CCHFPublicKey(); } if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPrivateKeyB2BInvoiceEUR(); + $result = $this->getInstallmentB2CEURPublicKey(); } } return $result; } - /** - * @param string $customerType - * @return string - */ - public function getShopPrivateKeyInvoice(string $customerType = 'B2C'): string + public function getInstallmentPrivateKey(): string { - $result = $this->getShopPrivateKey(); - - if ($this->isB2CInvoiceEligibility() && $customerType === 'B2C') { - if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPrivateKeyB2CInvoiceCHF(); - } - if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPrivateKeyB2CInvoiceEUR(); - } - } + $result = ''; - if ($this->isB2BInvoiceEligibility() && $customerType === 'B2B') { + if ($this->isB2CInstallmentEligibility()) { if ($this->isBasketCurrencyCHF()) { - $result = $this->getShopPrivateKeyB2BInvoiceCHF(); + $result = $this->getInstallmentB2CCHFPrivateKey(); } if ($this->isBasketCurrencyEUR()) { - $result = $this->getShopPrivateKeyB2BInvoiceEUR(); + $result = $this->getInstallmentB2CEURPrivateKey(); } } @@ -775,58 +729,34 @@ public function getShopPrivateKeyInvoice(string $customerType = 'B2C'): string * @param string $currency * @return string */ - public function getShopPublicKeyInvoiceByCustomerTypeAndCurrency(string $customerType, string $currency): string - { - $key = ''; - if ($customerType == 'B2C' && $currency == 'EUR') { - $key = $this->getShopPublicKeyB2CInvoiceEUR(); - } elseif ($customerType == 'B2C' && $currency == 'CHF') { - $key = $this->getShopPublicKeyB2CInvoiceCHF(); - } elseif ($customerType == 'B2B' && $currency == 'EUR') { - $key = $this->getShopPublicKeyB2BInvoiceEUR(); - } elseif ($customerType == 'B2B' && $currency == 'CHF') { - $key = $this->getShopPublicKeyB2BInvoiceCHF(); - } - return $key; - } - - /** - * @param string $customerType - * @param string $currency - * @return string - */ - public function getShopPrivateKeyInvoiceByCustomerTypeAndCurrency(string $customerType, string $currency): string - { + public function getInvoicePrivateKeyByCustomerTypeAndCurrency( + string $customerType, + string $currency + ): string { $key = ''; - if ($customerType == 'B2C' && $currency == 'EUR') { - $key = $this->getShopPrivateKeyB2CInvoiceEUR(); - } elseif ($customerType == 'B2C' && $currency == 'CHF') { - $key = $this->getShopPrivateKeyB2CInvoiceCHF(); - } elseif ($customerType == 'B2B' && $currency == 'EUR') { - $key = $this->getShopPrivateKeyB2BInvoiceEUR(); - } elseif ($customerType == 'B2B' && $currency == 'CHF') { - $key = $this->getShopPrivateKeyB2BInvoiceCHF(); + if ($customerType === 'B2C' && $currency === 'EUR') { + $key = $this->getInvoiceB2CEURPrivateKey(); + } elseif ($customerType === 'B2C' && $currency === 'CHF') { + $key = $this->getInvoiceB2CCHFPrivateKey(); + } elseif ($customerType === 'B2B' && $currency === 'EUR') { + $key = $this->getInvoiceB2BEURPrivateKey(); + } elseif ($customerType === 'B2B' && $currency === 'CHF') { + $key = $this->getInvoiceB2BCHFPrivateKey(); } return $key; } /** - * @param string $customerType * @param string $currency * @return string */ - public function getShopPrivateKeyInstallmentByCustomerTypeAndCurrency( - string $customerType, + public function getInstallmentPrivateKeyByCurrency( string $currency ): string { $key = ''; - if ($customerType == 'B2C' && $currency == 'EUR') { - $key = $this->getShopPrivateKeyB2CInstallmentEUR(); - } elseif ($customerType == 'B2C' && $currency == 'CHF') { - $key = $this->getShopPrivateKeyB2CInstallmentCHF(); - } elseif ($customerType == 'B2B' && $currency == 'EUR') { - $key = $this->getShopPrivateKeyB2BInvoiceEUR(); - } elseif ($customerType == 'B2B' && $currency == 'CHF') { - $key = $this->getShopPrivateKeyB2BInvoiceCHF(); + if ($currency === 'EUR') { + $key = $this->getInstallmentB2CEURPrivateKey(); + } elseif ($currency === 'CHF') { + $key = $this->getInstallmentB2CCHFPrivateKey(); } return $key; } @@ -855,7 +785,7 @@ private function getBasketCurrency(): string } /** - * @param $context + * @param string $context * @return bool */ private function hasWebhookConfiguration(string $context): bool diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 5c6c8145..31a882cc 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -8,15 +8,17 @@ namespace OxidSolutionCatalysts\Unzer\Service; use Exception; -use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Payment as PaymentModel; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Session; use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Exception\Redirect; use OxidSolutionCatalysts\Unzer\Exception\RedirectWithMessage; +use OxidSolutionCatalysts\Unzer\Model\TmpOrder; +use OxidSolutionCatalysts\Unzer\Model\Order; use OxidSolutionCatalysts\Unzer\PaymentExtensions\UnzerPayment as AbstractUnzerPayment; use OxidSolutionCatalysts\Unzer\Service\Transaction as TransactionService; +use stdClass; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\Payment as UnzerPayment; use UnzerSDK\Resources\AbstractUnzerResource; @@ -223,21 +225,25 @@ public function getUnzerOrderId(): string } /** - * @param string $customerType + * @param string $paymentId * @param string $currency + * @param string $customerType * @return \UnzerSDK\Unzer */ - protected function getUnzerSDK(string $customerType = '', string $currency = ''): \UnzerSDK\Unzer - { - return $this->unzerSDKLoader->getUnzerSDK($customerType, $currency); + protected function getUnzerSDK( + string $paymentId = '', + string $currency = '', + string $customerType = '' + ): \UnzerSDK\Unzer { + return $this->unzerSDKLoader->getUnzerSDK($paymentId, $currency, $customerType); } /** - * @param null $paymentExtension * @param bool $noCache * @return UnzerPayment|null + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function getSessionUnzerPayment($paymentExtension = null, $noCache = false): ?UnzerPayment + public function getSessionUnzerPayment(bool $noCache = false): ?UnzerPayment { $result = null; if ($noCache === false) { @@ -246,29 +252,28 @@ public function getSessionUnzerPayment($paymentExtension = null, $noCache = fals } } - $paymentId = $this->session->getVariable('paymentid'); - if (is_string($paymentId)) { + $uzrPaymentId = $this->session->getVariable('UnzerPaymentId'); + + if (is_string($uzrPaymentId)) { /** @var string $sessionOrderId */ $sessionOrderId = $this->session->getVariable('sess_challenge'); /** @var Order $order */ $order = oxNew(Order::class); $order->load($sessionOrderId); - $customerType = 'B2C'; - /** @var string $currency */ - $currency = $order->getFieldData('oxcurrency') ?? ''; - - if ($paymentExtension !== null && $currency !== null) { - if ($order->getFieldData('oxpaymenttype') === UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID) { - if (Registry::getRequest()->getRequestParameter('unzer_customer_type') !== 'B2C') { - $customerType = 'B2B'; - } - } - } + + $paymentType = $this->getPaymentType($sessionOrderId, $order); + $currency = $this->getOrderCurrency($sessionOrderId, $order, $paymentType); + $customerType = $this->getCustomerType($currency, $paymentType); + try { - $result = $this->unzerSDKLoader->getUnzerSDK($customerType, $currency)->fetchPayment($paymentId); + $result = $this->unzerSDKLoader->getUnzerSDK( + $paymentType, + $currency, + $customerType + )->fetchPayment($uzrPaymentId); } catch (UnzerApiException $e) { Registry::getLogger()->warning( - 'Payment not found with key: ' . $paymentId + 'Payment not found with key: ' . $uzrPaymentId ); } $this->sessionUnzerPayment = $result; @@ -277,6 +282,64 @@ public function getSessionUnzerPayment($paymentExtension = null, $noCache = fals return $result; } + private function getCustomerType(?string $currency, string $paymentType): string + { + $customerType = 'B2C'; + + if ($currency !== null) { + if ($this->isPaylaterInvoice($paymentType)) { + $customerInRequest = Registry::getRequest()->getRequestParameter('unzer_customer_type');# + if ($customerInRequest !== 'B2C') { + $customerType = 'B2B'; + } + } + } + return $customerType; + } + + private function isPaylaterInvoice(string $paymentType): bool + { + return in_array($paymentType, [ + UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID, + UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID, + UnzerDefinitions::INSTALLMENT_UNZER_PAYMENT_ID, + ], true); + } + + private function getOrderCurrency(string $sessionOrderId, Order $order, string $paymentType): string + { + /** @var string $currency */ + $currency = $order->getFieldData('oxcurrency') ?? ''; + + if ($this->isPaylaterInvoice($paymentType)) { + $tmpOrder = oxNew(TmpOrder::class)->getTmpOrderByOxOrderId($sessionOrderId); + if ($tmpOrder !== null) { + /** @var stdClass{name: string} $orderCurrency */ + $orderCurencyStdCls = $tmpOrder->getOrderCurrency(); + $currency = $orderCurencyStdCls->name; + } + } + return $currency; + } + + private function getPaymentType(string $sessionOrderId, Order $order): string + { + $paymentType = $order->getFieldData('oxpaymenttype'); + + if (empty($paymentType)) { + $tmpOrder = oxNew(TmpOrder::class)->getTmpOrderByOxOrderId($sessionOrderId); + if ($tmpOrder !== null) { + $paymentType = $tmpOrder->getFieldData('oxpaymenttype'); + } + } + + if (is_string($paymentType)) { + return $paymentType; + } + + return ''; + } + /** * @param Order $oOrder * @param string $unzerid @@ -409,13 +472,17 @@ public function sendShipmentNotification($oOrder, $sPaymentId = null) return false; } - $sPaymentId = $sPaymentId ?? $this->transactionService->getPaymentIdByOrderId($oOrder->getId()); + $sPaymentId = $sPaymentId ?? $this->transactionService::getPaymentIdByOrderId($oOrder->getId()); $transactionDetails = $this->transactionService->getCustomerTypeAndCurrencyByOrderId($oOrder->getId()); $blSuccess = false; if ($sPaymentId) { - $sdk = $this->getUnzerSDK($transactionDetails['customertype'], $transactionDetails['currency']); + $sdk = $this->getUnzerSDK( + $sPaymentId, + $transactionDetails['currency'], + $transactionDetails['customertype'] + ); /** @var string $sInvoiceNr */ $sInvoiceNr = $oOrder->getUnzerInvoiceNr(); diff --git a/src/Service/PaymentExtensionLoader.php b/src/Service/PaymentExtensionLoader.php index ef2b650a..b1ead6c1 100644 --- a/src/Service/PaymentExtensionLoader.php +++ b/src/Service/PaymentExtensionLoader.php @@ -81,6 +81,10 @@ public function __construct( } /** + * Please only use this method if you want to have static information about the payment method and do not + * need functions of the SDK. The SDK must always be loaded with the correct credentials. This is only + * guaranteed if method getPaymentExtensionByCustomerTypeAndCurrency is used, as only this loads the SDK + * with the correct credentials at all times * @param PaymentModel $payment * @return AbstractUnzerPayment */ @@ -95,6 +99,9 @@ public function getPaymentExtension(PaymentModel $payment): AbstractUnzerPayment } /** + * Please only use this method if you need the SDK. This is the only way to load the SDK with the correct + * credentials. The getPaymentExtension method is only used to obtain static information about the payment + * method. * @param PaymentModel $payment * @param string $customerType * @param string $currency @@ -105,17 +112,13 @@ public function getPaymentExtensionByCustomerTypeAndCurrency( string $customerType, string $currency ): AbstractUnzerPayment { - if ($payment->getId() === UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID) { - return oxNew( - self::UNZERCLASSNAMEMAPPING[$payment->getId()], - $this->unzerSdkLoader->getUnzerSDK($customerType, $currency, true), - $this->unzerService, - $this->logger - ); - } return oxNew( self::UNZERCLASSNAMEMAPPING[$payment->getId()], - $this->unzerSdkLoader->getUnzerSDK($customerType, $currency), + $this->unzerSdkLoader->getUnzerSDK( + $payment->getId(), + $currency, + $customerType + ), $this->unzerService, $this->logger ); diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index 2decf033..f5dad795 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -8,6 +8,7 @@ namespace OxidSolutionCatalysts\Unzer\Service; use Doctrine\DBAL\Driver\Result; +use OxidEsales\Eshop\Application\Model\User; use OxidSolutionCatalysts\Unzer\Model\Order; use PDO; use Doctrine\DBAL\Query\QueryBuilder; @@ -482,4 +483,36 @@ public function isValidTransactionTypeId($typeid): bool } return false; } + + /** + * @SuppressWarnings(PHPMD.StaticAccess) + */ + public function getTrancactionIds(?User $user = null): array + { + $result = []; + + // check user Model + if (!$user) { + return $result; + } + + // check user Id + $userId = $user->getId() ?: null; + if (!$userId) { + return $result; + } + + $oDB = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); + if ($oDB) { + $result = $oDB->getAll( + "SELECT ot.OXID, ot.PAYMENTTYPEID, ot.CURRENCY, ot.CUSTOMERTYPE, o.OXPAYMENTTYPE + from oscunzertransaction as ot + left join oxorder as o ON (ot.oxorderid = o.OXID) + where ot.OXUSERID = :oxuserid AND ot.PAYMENTTYPEID IS NOT NULL + GROUP BY ot.PAYMENTTYPEID ", + [':oxuserid' => $userId] + ); + } + return $result; + } } diff --git a/src/Service/Unzer.php b/src/Service/Unzer.php index da56650f..c2b2811a 100644 --- a/src/Service/Unzer.php +++ b/src/Service/Unzer.php @@ -543,7 +543,7 @@ public function setSessionVars(AbstractTransactionType $charge): void $this->session->setVariable('ShortId', $charge->getShortId()); } - $this->session->setVariable('paymentid', $charge->getPaymentId()); + $this->session->setVariable('UnzerPaymentId', $charge->getPaymentId()); if ($charge instanceof Authorization) { $this->session->setVariable('UzrPdfLink', $charge->getPDFLink()); diff --git a/src/Service/UnzerSDKLoader.php b/src/Service/UnzerSDKLoader.php index b9f9bf03..d472629d 100644 --- a/src/Service/UnzerSDKLoader.php +++ b/src/Service/UnzerSDKLoader.php @@ -7,7 +7,9 @@ namespace OxidSolutionCatalysts\Unzer\Service; -use OxidEsales\Eshop\Core\Session; +use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; +use OxidSolutionCatalysts\Unzer\Exception\UnzerException; +use RuntimeException; use OxidEsales\Eshop\Core\DatabaseProvider; use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions; use UnzerSDK\Unzer; @@ -22,12 +24,8 @@ class UnzerSDKLoader /** * @var DebugHandler */ - private $debugHandler; + private DebugHandler $debugHandler; - /** - * @var Session - */ - private $session; /** * @param ModuleSettings $moduleSettings @@ -37,72 +35,51 @@ class UnzerSDKLoader */ public function __construct( ModuleSettings $moduleSettings, - DebugHandler $debugHandler, - Session $session + DebugHandler $debugHandler ) { $this->moduleSettings = $moduleSettings; $this->debugHandler = $debugHandler; - $this->session = $session; - $ignore = $this->session->isAdmin(); } /** - * @param string $customerType + * @param string $paymentId * @param string $currency - * @param bool $type - * @return Unzer - * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) - */ - public function getUnzerSDK(string $customerType = '', string $currency = '', bool $type = false): Unzer - { - if ($customerType != '' && $currency != '') { - return $this->getUnzerSDKbyCustomerTypeAndCurrency($customerType, $currency, $type); - } - $key = $this->moduleSettings->getShopPrivateKey(); - $sdk = oxNew(Unzer::class, $key); - if ($this->moduleSettings->isDebugMode()) { - $sdk->setDebugMode(true)->setDebugHandler($this->debugHandler); - } - return $sdk; - } - - /** - * Will return a Unzer SDK object using a specific key, depending on $customerType and $currency. - * Relevant for PaylaterInvoice. If $customerType or $currency is empty, the regular key is used. * @param string $customerType - * @param string $currency - * @param bool $type * @return Unzer * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) * @SuppressWarnings(PHPMD.ElseExpression) + * @throws UnzerException */ - public function getUnzerSDKbyCustomerTypeAndCurrency( - string $customerType, - string $currency, - bool $type = false - ): Unzer { - if ($customerType == '' || $currency == '') { - return $this->getUnzerSDK(); - } - if ($type === false) { - $key = $this->moduleSettings->getShopPrivateKeyInvoiceByCustomerTypeAndCurrency( + public function getUnzerSDK(string $paymentId = '', string $currency = '', string $customerType = ''): Unzer + { + if (UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID === $paymentId) { + $key = $this->moduleSettings->getInvoicePrivateKeyByCustomerTypeAndCurrency( $customerType, $currency ); - $sdk = oxNew(Unzer::class, $key); - } else { - $key = $this->moduleSettings->getShopPrivateKeyInstallmentByCustomerTypeAndCurrency( - $customerType, + } elseif (UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID === $paymentId) { + $key = $this->moduleSettings->getInstallmentPrivateKeyByCurrency( $currency ); - $sdk = oxNew(Unzer::class, $key); + } else { + $key = $this->moduleSettings->getStandardPrivateKey(); } - if ($this->moduleSettings->isDebugMode()) { - $sdk->setDebugMode(true)->setDebugHandler($this->debugHandler); + try { + $sdk = $this->getUnzerSDKbyKey($key); + } catch (UnzerException $e) { + $logEntry = sprintf( + 'Try to get the SDK with the Key "%s" defined by paymentId "%s", currency "%s", customerType "%s"', + $key, + $paymentId, + $currency, + $customerType + ); + $this->debugHandler->log($logEntry); + throw new UnzerException($logEntry); } + return $sdk; } @@ -110,12 +87,18 @@ public function getUnzerSDKbyCustomerTypeAndCurrency( * Creates an UnzerSDK object based upon a specific private key. * @param string $key * @return Unzer + * @throws UnzerException */ public function getUnzerSDKbyKey(string $key): Unzer { - $sdk = oxNew(Unzer::class, $key); - if ($this->moduleSettings->isDebugMode()) { - $sdk->setDebugMode(true)->setDebugHandler($this->debugHandler); + try { + $sdk = oxNew(Unzer::class, $key); + if ($this->moduleSettings->isDebugMode()) { + $sdk->setDebugMode(true)->setDebugHandler($this->debugHandler); + } + } catch (RuntimeException $e) { + $this->debugHandler->log($e->getMessage()); + throw new UnzerException($e->getMessage()); } return $sdk; } @@ -125,6 +108,7 @@ public function getUnzerSDKbyKey(string $key): Unzer * @param string $sPaymentId * @return Unzer * + * @throws UnzerException|DatabaseConnectionException * @SuppressWarnings(PHPMD.StaticAccess) */ public function getUnzerSDKbyPaymentType(string $sPaymentId): Unzer @@ -138,19 +122,18 @@ public function getUnzerSDKbyPaymentType(string $sPaymentId): Unzer $customerType = ''; $currency = ''; + $paymentId = ''; if ($row) { $currency = $row['CURRENCY']; - $paymentType = $row['OXPAYMENTTYPE']; - if ($paymentType == UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID) { + $paymentId = $row['OXPAYMENTTYPE']; + if ($paymentId === UnzerDefinitions::INVOICE_UNZER_PAYMENT_ID) { $customerType = 'B2C'; if (!empty($row['OXDELCOMPANY']) || !empty($row['OXBILLCOMPANY'])) { $customerType = 'B2B'; } } - if ($paymentType === UnzerDefinitions::INSTALLMENT_UNZER_PAYLATER_PAYMENT_ID) { - $customerType = 'B2C'; - } } - return $this->getUnzerSDK($customerType, $currency); + + return $this->getUnzerSDK($paymentId, $currency, $customerType); } } diff --git a/src/Service/UnzerWebhooks.php b/src/Service/UnzerWebhooks.php index 78309390..a7823210 100644 --- a/src/Service/UnzerWebhooks.php +++ b/src/Service/UnzerWebhooks.php @@ -164,7 +164,7 @@ public function getWebhookURL(array $extraParams): string protected function cleanOldWebhook(): void { // v1.0.0 - the original URL and payment method - $shopKey = $this->moduleSettings->getShopPrivateKey(); + $shopKey = $this->moduleSettings->getStandardPrivateKey(); $orgEvent = WebhookEvents::PAYMENT; $orgUrl = $this->getWebhookURL([]); $unzerWebhooks = $this->getUnzerWebhooksByKey($shopKey); diff --git a/views/admin/de/module_options.php b/views/admin/de/module_options.php index fd74060c..610b4e1f 100644 --- a/views/admin/de/module_options.php +++ b/views/admin/de/module_options.php @@ -79,28 +79,40 @@ 'HELP_SHOP_MODULE_applepay_networks' => 'Vom Händler unterstützte Kreditkarten. Wählen Sie mindestens eine Kreditkarte aus, die Sie dem Kunden anbieten wollen. Wenn Sie keine Kreditkarte auswählen, so werden standardmäßig alle Kreditkarten angezeigt.', 'SHOP_MODULE_applepay_label' => 'Firma', 'HELP_SHOP_MODULE_applepay_label' => 'Wenn kein Wert eingetragen ist, wird stattdessen der in den Grundeinstellungen hinterlegte Firmenname verwendet', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2CEUR' => 'Sandbox öffentlicher Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2CEUR' => 'Sandbox privater Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2BEUR' => 'Sandbox öffentlicher Schlüssel für B2B-Käufe in EUR', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2BEUR' => 'Sandbox privater Schlüssel für B2B-Käufe in EUR', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2CCHF' => 'Sandbox öffentlicher Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2CCHF' => 'Sandbox privater Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2BCHF' => 'Sandbox öffentlicher Schlüssel für B2B-Käufe in CHF', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2BCHF' => 'Sandbox privater Schlüssel für B2B-Käufe in CHF', - 'SHOP_MODULE_production-UnzerPublicKeyB2CEUR' => 'Live öffentlicher Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_production-UnzerPrivateKeyB2CEUR' => 'Live privater Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_production-UnzerPublicKeyB2BEUR' => 'Live öffentlicher Schlüssel für B2B-Käufe in EUR', - 'SHOP_MODULE_production-UnzerPrivateKeyB2BEUR' => 'Live privater Schlüssel für B2B-Käufe in EUR', - 'SHOP_MODULE_production-UnzerPublicKeyB2CCHF' => 'Live öffentlicher Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_production-UnzerPrivateKeyB2CCHF' => 'Live privater Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_production-UnzerPublicKeyB2BCHF' => 'Live öffentlicher Schlüssel für B2B-Käufe in CHF', - 'SHOP_MODULE_production-UnzerPrivateKeyB2BCHF' => 'Live privater Schlüssel für B2B-Käufe in CHF', - 'SHOP_MODULE_sandbox-UnzerPaylaterPublicKeyB2CEUR' => 'Sandbox öffentlicher Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_sandbox-UnzerPaylaterPrivateKeyB2CEUR' => 'Sandbox privater Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_sandbox-UnzerPaylaterPublicKeyB2CCHF' => 'Sandbox öffentlicher Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_sandbox-UnzerPaylaterPrivateKeyB2CCHF' => 'Sandbox privater Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_production-UnzerPaylaterPublicKeyB2CEUR' => 'Live öffentlicher Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_production-UnzerPaylaterPrivateKeyB2CEUR' => 'Live privater Schlüssel für B2C-Käufe in EUR', - 'SHOP_MODULE_production-UnzerPaylaterPublicKeyB2CCHF' => 'Live öffentlicher Schlüssel für B2C-Käufe in CHF', - 'SHOP_MODULE_production-UnzerPaylaterPrivateKeyB2CCHF' => 'Live privater Schlüssel für B2C-Käufe in CHF', + // live Paylater Invoice B2C EUR + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CEURPrivateKey' => 'Live privater Schlüssel für Rechnung B2C-Käufe in EUR', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CEURPublicKey' => 'Live öffentlicher Schlüssel für Rechnung B2C-Käufe in EUR', + // live Paylater Invoice B2B EUR + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BEURPrivateKey' => 'Live privater Schlüssel für Rechnung B2B-Käufe in EUR', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BEURPublicKey' => 'Live öffentlicher Schlüssel für Rechnung B2B-Käufe in EUR', + // live Paylater Invoice B2C CHF + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CCHFPrivateKey' => 'Live privater Schlüssel für Rechnung B2C-Käufe in CHF', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CCHFPublicKey' => 'Live öffentlicher Schlüssel für Rechnung B2C-Käufe in CHF', + // live Paylater Invoice B2B CHF + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BCHFPrivateKey' => 'Live privater Schlüssel für Rechnung B2B-Käufe in CHF', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BCHFPublicKey' => 'Live öffentlicher Schlüssel für Rechnung B2B-Käufe in CHF', + // live Paylater Installment B2C EUR + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CEURPrivateKey' => 'Live privater Schlüssel für Ratenkauf B2C-Käufe in EUR', + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CEURPublicKey' => 'Live öffentlicher Schlüssel für Ratenkauf B2C-Käufe in EUR', + // live Paylater Installment B2C CHF + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CCHFPrivateKey' => 'Live privater Schlüssel für Ratenkauf B2C-Käufe in CHF', + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CCHFPublicKey' => 'Live öffentlicher Schlüssel für Ratenkauf B2C-Käufe in CHF', + // sandbox Paylater Invoice B2C EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CEURPrivateKey' => 'Sandbox privater Schlüssel für Rechnung B2C-Käufe in EUR', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CEURPublicKey' => 'Sandbox öffentlicher Schlüssel für Rechnung B2C-Käufe in EUR', + // sandbox Paylater Invoice B2B EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BEURPrivateKey' => 'Sandbox privater Schlüssel für Rechnung B2B-Käufe in EUR', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BEURPublicKey' => 'Sandbox öffentlicher Schlüssel Rechnung für B2B-Käufe in EUR', + // sandbox Paylater Invoice B2C CHF + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CCHFPrivateKey' => 'Sandbox privater Schlüssel für Rechnung B2C-Käufe in CHF', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CCHFPublicKey' => 'Sandbox öffentlicher Schlüssel für Rechnung B2C-Käufe in CHF', + // sandbox Paylater Invoice B2B CHF + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BCHFPrivateKey' => 'Sandbox privater Schlüssel für Rechnung B2B-Käufe in CHF', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BCHFPublicKey' => 'Sandbox öffentlicher Schlüssel für Rechnung B2B-Käufe in CHF', + // sandbox Paylater Installment B2C EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CEURPrivateKey' => 'Sandbox privater Schlüssel für Ratenkauf B2C-Käufe in EUR', + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CEURPublicKey' => 'Sandbox öffentlicher Schlüssel für Ratenkauf B2C-Käufe in EUR', + // sandbox Paylater Installment B2C EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CCHFPrivateKey' => 'Sandbox privater Schlüssel für Ratenkauf B2C-Käufe in CHF', + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CCHFPublicKey' => 'Sandbox öffentlicher Schlüssel für Ratenkauf B2C-Käufe in CHF', ]; diff --git a/views/admin/en/module_options.php b/views/admin/en/module_options.php index 5bad087f..49abdae7 100644 --- a/views/admin/en/module_options.php +++ b/views/admin/en/module_options.php @@ -79,28 +79,40 @@ 'HELP_SHOP_MODULE_applepay_networks' => 'Credit cards supported by the merchant. Select at least one credit card that you want to offer the customer. If you do not select a credit card, all credit cards are displayed by default.', 'SHOP_MODULE_applepay_label' => 'Company', 'HELP_SHOP_MODULE_applepay_label' => 'If no value is entered, the company name stored in the basic settings is used instead', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2CEUR' => 'Sandbox Public-Key for B2C-purchases in EUR', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2CEUR' => 'Sandbox Private-Key for B2C-purchases in EUR', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2BEUR' => 'Sandbox Public-Key for B2B-purchases in EUR', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2BEUR' => 'Sandbox Private-Key for B2B-purchases in EUR', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2CCHF' => 'Sandbox Public-Key for B2C-purchases in CHF', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2CCHF' => 'Sandbox Private-Key for B2C-purchases in CHF', - 'SHOP_MODULE_sandbox-UnzerPublicKeyB2BCHF' => 'Sandbox Public-Key for B2B-purchases in CHF', - 'SHOP_MODULE_sandbox-UnzerPrivateKeyB2BCHF' => 'Sandbox Private-Key for B2B-purchases in CHF', - 'SHOP_MODULE_production-UnzerPublicKeyB2CEUR' => 'Live Public-Key for B2C-purchases in EUR', - 'SHOP_MODULE_production-UnzerPrivateKeyB2CEUR' => 'Live Private-Key for B2C-purchases in EUR', - 'SHOP_MODULE_production-UnzerPublicKeyB2BEUR' => 'Live Public-Key for B2B-purchases in EUR', - 'SHOP_MODULE_production-UnzerPrivateKeyB2BEUR' => 'Live Private-Key for B2B-purchases in EUR', - 'SHOP_MODULE_production-UnzerPublicKeyB2CCHF' => 'Live Public-Key for B2C-purchases in CHF', - 'SHOP_MODULE_production-UnzerPrivateKeyB2CCHF' => 'Live Private-Key for B2C-purchases in CHF', - 'SHOP_MODULE_production-UnzerPublicKeyB2BCHF' => 'Live Public-Key for B2B-purchases in CHF', - 'SHOP_MODULE_production-UnzerPrivateKeyB2BCHF' => 'Live Private-Key for B2B-purchases in CHF', - 'SHOP_MODULE_sandbox-UnzerPaylaterPublicKeyB2CEUR' => 'Sandbox Public-Key for B2B-purchases in EUR', - 'SHOP_MODULE_sandbox-UnzerPaylaterPrivateKeyB2CEUR' => 'Sandbox Private-Key for B2B-purchases in EUR', - 'SHOP_MODULE_sandbox-UnzerPaylaterPublicKeyB2CCHF' => 'Sandbox Public-Key for B2B-purchases in CHF', - 'SHOP_MODULE_sandbox-UnzerPaylaterPrivateKeyB2CCHF' => 'Sandbox Private-Key for B2B-purchases in CHF', - 'SHOP_MODULE_production-UnzerPaylaterPublicKeyB2CEUR' => 'Live Public-Key for B2B-purchases in EUR', - 'SHOP_MODULE_production-UnzerPaylaterPrivateKeyB2CEUR' => 'Live Private-Key for B2B-purchases in EUR', - 'SHOP_MODULE_production-UnzerPaylaterPublicKeyB2CCHF' => 'Live Public-Key for B2B-purchases in CHF', - 'SHOP_MODULE_production-UnzerPaylaterPrivateKeyB2CCHF' => 'Live Private-Key for B2B-purchases in CHF', + // live Paylater Invoice B2C EUR + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CEURPrivateKey' => 'Live Private-Key for Invoice B2C-purchases in EUR', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CEURPublicKey' => 'Live Public-Key for Invoice B2C-purchases in EUR', + // live Paylater Invoice B2B EUR + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BEURPrivateKey' => 'Live Private-Key for Invoice B2B-purchases in EUR', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BEURPublicKey' => 'Live Public-Key for Invoice B2B-purchases in EUR', + // live Paylater Invoice B2C CHF + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CCHFPrivateKey' => 'Live Private-Key for Invoice B2C-purchases in CHF', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2CCHFPublicKey' => 'Live Public-Key for Invoice B2C-purchases in CHF', + // live Paylater Invoice B2B CHF + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BCHFPrivateKey' => 'Live Private-Key for Invoice B2B-purchases in CHF', + 'SHOP_MODULE_production-UnzerPayLaterInvoiceB2BCHFPublicKey' => 'Live Public-Key for Invoice B2B-purchases in CHF', + // live Paylater Installment B2C EUR + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CEURPrivateKey' => 'Live Private-Key for Installment B2C-purchases in EUR', + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CEURPublicKey' => 'Live Public-Key for Installment B2C-purchases in EUR', + // live Paylater Installment B2C CHF + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CCHFPrivateKey' => 'Live Private-Key for Installment B2C-purchases in CHF', + 'SHOP_MODULE_production-UnzerPayLaterInstallmentB2CCHFPublicKey' => 'Live Public-Key for Installment B2C-purchases in CHF', + // sandbox Paylater Invoice B2C EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CEURPrivateKey' => 'Sandbox Private-Key for Invoice B2C-purchases in EUR', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CEURPublicKey' => 'Sandbox Public-Key for Invoice B2C-purchases in EUR', + // sandbox Paylater Invoice B2B EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BEURPrivateKey' => 'Sandbox Private-Key for Invoice B2C-purchases in EUR', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BEURPublicKey' => 'Sandbox Public-Key for Invoice B2C-purchases in EUR', + // sandbox Paylater Invoice B2C CHF + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CCHFPrivateKey' => 'Sandbox Private-Key for Invoice B2C-purchases in CHF', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2CCHFPublicKey' => 'Sandbox Public-Key for Invoice B2C-purchases in CHF', + // sandbox Paylater Invoice B2B CHF + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BCHFPrivateKey' => 'Sandbox Private-Key for Invoice B2B-purchases in CHF', + 'SHOP_MODULE_sandbox-UnzerPayLaterInvoiceB2BCHFPublicKey' => 'Sandbox Public-Key for Invoice B2B-purchases in CHF', + // sandbox Paylater Installment B2C EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CEURPrivateKey' => 'Sandbox Private-Key for Installment B2C-purchases in EUR', + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CEURPublicKey' => 'Sandbox Public-Key for Installment B2C-purchases in EUR', + // sandbox Paylater Installment B2C EUR + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CCHFPrivateKey' => 'Sandbox Private-Key for Installment B2C-purchases in CHF', + 'SHOP_MODULE_sandbox-UnzerPayLaterInstallmentB2CCHFPublicKey' => 'Sandbox Public-Key for Installment B2C-purchases in CHF', ]; diff --git a/views/admin/tpl/oscunzer_order.tpl b/views/admin/tpl/oscunzer_order.tpl index d3019810..53485878 100644 --- a/views/admin/tpl/oscunzer_order.tpl +++ b/views/admin/tpl/oscunzer_order.tpl @@ -93,7 +93,7 @@ - + [{/if}] @@ -110,7 +110,7 @@ - + @@ -130,7 +130,7 @@ - +
@@ -177,7 +177,7 @@ [{$oViewConf->getHiddenSid()}] - + @@ -220,7 +220,7 @@ [{if $canCancelAmount > 0}] [{$oViewConf->getHiddenSid()}] - +