From 97de911f401062e97f4b570af09a4bbe3ce43513 Mon Sep 17 00:00:00 2001 From: Sebastian Bossert Date: Thu, 22 Aug 2019 12:55:46 +0200 Subject: [PATCH] Release 1.0.15 --- .../de/pfcPostFinanceCheckout_de_lang.php | 1 + .../en/pfcPostFinanceCheckout_en_lang.php | 1 + .../pfcPostFinanceCheckout_admin_de_lang.php | 4 +- Core/Adapter/AddressAdapter.php | 5 +- Core/Service/PaymentService.php | 27 +++++++- .../Controller/OrderController.php | 69 ++++++++++--------- README.md | 6 +- docs/README.md | 6 +- docs/en/documentation.html | 4 +- metadata.php | 2 +- out/src/js/postfinancecheckout.js | 12 ++++ 11 files changed, 91 insertions(+), 46 deletions(-) diff --git a/Application/translations/de/pfcPostFinanceCheckout_de_lang.php b/Application/translations/de/pfcPostFinanceCheckout_de_lang.php index ed52de7..4809034 100644 --- a/Application/translations/de/pfcPostFinanceCheckout_de_lang.php +++ b/Application/translations/de/pfcPostFinanceCheckout_de_lang.php @@ -49,6 +49,7 @@ 'pfc_postFinanceCheckout_Open in your PostFinance Checkout backend.' => 'Öffne im PostFinance Checkout backend.', 'pfc_postFinanceCheckout_Open' => 'Öffnen', 'pfc_postFinanceCheckout_PostFinance Checkout Link' => 'PostFinance Checkout Link', + 'pfc_postFinanceCheckout_You must agree to the terms and conditions.' => 'Sie müssen den AGBs und Datenschutzvereinbarung zustimmen.', // tpl translations 'pfc_postFinanceCheckout_Restock' => 'Lagerbestand wiederherstellen', diff --git a/Application/translations/en/pfcPostFinanceCheckout_en_lang.php b/Application/translations/en/pfcPostFinanceCheckout_en_lang.php index ae380fc..228fffa 100644 --- a/Application/translations/en/pfcPostFinanceCheckout_en_lang.php +++ b/Application/translations/en/pfcPostFinanceCheckout_en_lang.php @@ -49,6 +49,7 @@ 'pfc_postFinanceCheckout_Open in your PostFinance Checkout backend.' => 'Open in your PostFinance Checkout backend.', 'pfc_postFinanceCheckout_Open' => 'Open', 'pfc_postFinanceCheckout_PostFinance Checkout Link' => 'PostFinance Checkout Link', + 'pfc_postFinanceCheckout_You must agree to the terms and conditions.' => 'You must agree to the terms and conditions.', // tpl translations 'pfc_postFinanceCheckout_Restock' => 'Restock', diff --git a/Application/views/admin/de/pfcPostFinanceCheckout_admin_de_lang.php b/Application/views/admin/de/pfcPostFinanceCheckout_admin_de_lang.php index 8b35316..7e7870b 100644 --- a/Application/views/admin/de/pfcPostFinanceCheckout_admin_de_lang.php +++ b/Application/views/admin/de/pfcPostFinanceCheckout_admin_de_lang.php @@ -18,11 +18,11 @@ 'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutPostFinance CheckoutSettings' => 'PostFinance Checkout Einstellungen', 'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutShopSettings' => 'Shop Einstellungen', - 'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutSpaceViewId' => 'Space View Id', + 'SHOP_MODULE_GROUP_pfcPostFinanceCheckoutSpaceSettings' => 'Space View Id', 'SHOP_MODULE_pfcPostFinanceCheckoutAppKey' => 'Authentication Key', 'SHOP_MODULE_pfcPostFinanceCheckoutUserId' => 'Benutzer Id', 'SHOP_MODULE_pfcPostFinanceCheckoutSpaceId' => 'Space Id', - 'SHOP_MODULE_pfcPostFinanceCheckoutSpaceViewSettings' => 'Space View Optionen', + 'SHOP_MODULE_pfcPostFinanceCheckoutSpaceViewViewId' => 'Space View Optionen', 'SHOP_MODULE_pfcPostFinanceCheckoutEmailConfirm' => 'Email Bestätigung', 'SHOP_MODULE_pfcPostFinanceCheckoutInvoiceDoc' => 'Rechnung', 'SHOP_MODULE_pfcPostFinanceCheckoutPackingDoc' => 'Lieferschein', diff --git a/Core/Adapter/AddressAdapter.php b/Core/Adapter/AddressAdapter.php index 10634cd..376c773 100644 --- a/Core/Adapter/AddressAdapter.php +++ b/Core/Adapter/AddressAdapter.php @@ -79,7 +79,10 @@ private function convertAddress(\OxidEsales\Eshop\Core\Base $address) $birthdate = $address->getFieldData('oxbirthdate'); if(!empty($birthdate) && $birthdate != '0000-00-00'){ - $addressCreate->setDateOfBirth(new \DateTime($birthdate)); + $date = new \DateTime($birthdate); + if(checkdate(intval($date->format('m')), intval($date->format('d')), intval($date->format('Y')))) { + $addressCreate->setDateOfBirth($date); + } } $salutation = $address->getFieldData('oxsal'); if (strtolower($salutation) === 'mr') { diff --git a/Core/Service/PaymentService.php b/Core/Service/PaymentService.php index 827ad12..4f02529 100644 --- a/Core/Service/PaymentService.php +++ b/Core/Service/PaymentService.php @@ -16,6 +16,9 @@ use PostFinanceCheckout\Sdk\Service\PaymentMethodConfigurationService; use Pfc\PostFinanceCheckout\Core\PostFinanceCheckoutModule; use \PostFinanceCheckout\Sdk\Service\TransactionService as SdkTransactionService; +use PostFinanceCheckout\Sdk\Model\EntityQueryFilter; +use PostFinanceCheckout\Sdk\Model\EntityQueryFilterType; +use PostFinanceCheckout\Sdk\Model\CriteriaOperator; /** * Class PaymentService @@ -74,7 +77,7 @@ public function fetchAvailablePaymentMethods($transactionId, $spaceId){ * @throws \PostFinanceCheckout\Sdk\ApiException */ public function synchronize(){ - $paymentMethods = $this->getConfigurationService()->search(PostFinanceCheckoutModule::settings()->getSpaceId(), new EntityQuery()); + $paymentMethods = $this->getConfigurationService()->search(PostFinanceCheckoutModule::settings()->getSpaceId(), $this->getQueryFilter('state', \PostFinanceCheckout\Sdk\Model\CreationEntityState::ACTIVE)); $paymentList = oxNew(\OxidEsales\Eshop\Application\Model\PaymentList::class); /* @var $paymentList \Pfc\PostFinanceCheckout\Extend\Application\Model\PaymentList */ @@ -93,7 +96,27 @@ public function synchronize(){ } } } - + + private function getQueryFilter($fieldName, $fieldValue){ + $query = new EntityQuery(); + $filter = new EntityQueryFilter(); + /** + * @noinspection PhpParamsInspection + */ + $filter->setType(EntityQueryFilterType::LEAF); + /** + * @noinspection PhpParamsInspection + */ + $filter->setOperator(CriteriaOperator::EQUALS); + $filter->setFieldName($fieldName); + /** + * @noinspection PhpParamsInspection + */ + $filter->setValue($fieldValue); + $query->setFilter($filter); + return $query; + } + /** * * @param $paymentId diff --git a/Extend/Application/Controller/OrderController.php b/Extend/Application/Controller/OrderController.php index b65219c..f7a44ef 100644 --- a/Extend/Application/Controller/OrderController.php +++ b/Extend/Application/Controller/OrderController.php @@ -54,38 +54,43 @@ public function pfcConfirm() ); if ($this->isPostFinanceCheckoutTransaction()) { - try { - $transaction = Transaction::loadPendingFromSession($this->getSession()); - /* @var $order \Pfc\PostFinanceCheckout\Extend\Application\Model\Order */ - /** @noinspection PhpParamsInspection */ - $order->setConfirming(true); - $state = $order->finalizeOrder($this->getBasket(), $this->getUser()); - $order->setConfirming(false); - if ($state === 'POSTFINANCECHECKOUT_' . TransactionState::PENDING) { - $transaction->setTempBasket($this->getBasket()); - $transaction->setOrderId($order->getId()); - \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction(); - \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction(); - $transaction->updateFromSession(true); - \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction(); - $response['status'] = true; - } else if ($state == \OxidEsales\Eshop\Application\Model\Order::ORDER_STATE_ORDEREXISTS) { - // ensure new order can be created - $this->getSession()->deleteVariable('sess_challenge'); - throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Order already exists. Please check if you have already received a confirmation, then try again.")); - } else { - throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Unable to confirm order in state !state.", true, array('!state' => $state))); - } - } catch (\Exception $e) { - if (isset($transaction)) { - $state = $transaction->getState(); - } else if (!isset($state)) { - $state = 'confirmation_error_unkown'; - } - $order->PostFinanceCheckoutFail($e->getMessage(), $state, true); - PostFinanceCheckoutModule::log(Logger::ERROR, "Unable to confirm transaction: {$e->getMessage()}."); - $response['message'] = $e->getMessage(); - } + if($this->_validateTermsAndConditions()) { + try { + $transaction = Transaction::loadPendingFromSession($this->getSession()); + /* @var $order \Pfc\PostFinanceCheckout\Extend\Application\Model\Order */ + /** @noinspection PhpParamsInspection */ + $order->setConfirming(true); + $state = $order->finalizeOrder($this->getBasket(), $this->getUser()); + $order->setConfirming(false); + if ($state === 'POSTFINANCECHECKOUT_' . TransactionState::PENDING) { + $transaction->setTempBasket($this->getBasket()); + $transaction->setOrderId($order->getId()); + \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction(); + \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction(); + $transaction->updateFromSession(true); + \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction(); + $response['status'] = true; + } else if ($state == \OxidEsales\Eshop\Application\Model\Order::ORDER_STATE_ORDEREXISTS) { + // ensure new order can be created + $this->getSession()->deleteVariable('sess_challenge'); + throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Order already exists. Please check if you have already received a confirmation, then try again.")); + } else { + throw new \Exception(PostFinanceCheckoutModule::instance()->translate("Unable to confirm order in state !state.", true, array('!state' => $state))); + } + } catch (\Exception $e) { + if (isset($transaction)) { + $state = $transaction->getState(); + } else if (!isset($state)) { + $state = 'confirmation_error_unkown'; + } + $order->PostFinanceCheckoutFail($e->getMessage(), $state, true); + PostFinanceCheckoutModule::log(Logger::ERROR, "Unable to confirm transaction: {$e->getMessage()}."); + $response['message'] = $e->getMessage(); + } + } + else { + $response['message'] = PostFinanceCheckoutModule::instance()->translate("You must agree to the terms and conditions."); + } } else { $response['message'] = PostFinanceCheckoutModule::instance()->translate("Not a PostFinance Checkout order."); } diff --git a/README.md b/README.md index 9a4ef30..b6cb889 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OXID 6.0 -v1.0.14, 2019-7 +v1.0.15, 2019-8 This repository contains the OXID PostFinance Checkout payment module that enables the shop to process payments with [PostFinance Checkout](https://www.postfinance.ch/checkout). @@ -13,8 +13,8 @@ This repository contains the OXID PostFinance Checkout payment module that enab ## Documentation -* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.14/docs/en/documentation.html) +* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.15/docs/en/documentation.html) ## License -Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.14/LICENSE) for more information. \ No newline at end of file +Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.15/LICENSE) for more information. \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 9a4ef30..b6cb889 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # OXID 6.0 -v1.0.14, 2019-7 +v1.0.15, 2019-8 This repository contains the OXID PostFinance Checkout payment module that enables the shop to process payments with [PostFinance Checkout](https://www.postfinance.ch/checkout). @@ -13,8 +13,8 @@ This repository contains the OXID PostFinance Checkout payment module that enab ## Documentation -* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.14/docs/en/documentation.html) +* [English](https://plugin-documentation.postfinance-checkout.ch/pfpayments/oxid-6.0/1.0.15/docs/en/documentation.html) ## License -Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.14/LICENSE) for more information. \ No newline at end of file +Please see the [license file](https://github.com/pfpayments/oxid-6.0/blob/1.0.15/LICENSE) for more information. \ No newline at end of file diff --git a/docs/en/documentation.html b/docs/en/documentation.html index c681463..cf03727 100644 --- a/docs/en/documentation.html +++ b/docs/en/documentation.html @@ -21,7 +21,7 @@

Documentation

  • - + Source
  • @@ -48,7 +48,7 @@

    1. -

      Download the extension.

      +

      Download the extension.

    2. Extract the files and upload them to the root directory of your store using FTP/SSH.

      diff --git a/metadata.php b/metadata.php index c61f3dd..58331dd 100644 --- a/metadata.php +++ b/metadata.php @@ -29,7 +29,7 @@ 'en' => 'PFC PostFinanceCheckout Module' ), 'thumbnail' => 'out/pictures/picture.png', - 'version' => '1.0.14', + 'version' => '1.0.15', 'author' => 'customweb GmbH', 'url' => 'https://www.customweb.com', 'email' => 'info@customweb.com', diff --git a/out/src/js/postfinancecheckout.js b/out/src/js/postfinancecheckout.js index bc8cf84..318c9e9 100644 --- a/out/src/js/postfinancecheckout.js +++ b/out/src/js/postfinancecheckout.js @@ -31,6 +31,17 @@ $('#PostFinanceCheckout-iframe-container').parent().parent().hide(); } }, + + getAgbParameter: function() { + var agb = $('#checkAgbTop'); + if(!agb.length) { + agb = $('#checkAgbBottom'); + } + if(agb.length && agb[0].checked) { + return '&ord_agb=1'; + } + return ''; + }, submit: function () { if (PostFinanceCheckout.running) { @@ -40,6 +51,7 @@ var params = '&stoken=' + $('input[name=stoken]').val(); params += '&sDeliveryAddressMD5=' + $('input[name=sDeliveryAddressMD5]').val(); params += '&challenge=' + $('input[name=challenge]').val(); + params += this.getAgbParameter(), $.getJSON('index.php?cl=order&fnc=pfcConfirm' + params, '', function (data, status, jqXHR) { if (data.status) { PostFinanceCheckout.handler.submit();