diff --git a/Block/Checkout/Script.php b/Block/Checkout/Script.php index 5589c75..574c991 100644 --- a/Block/Checkout/Script.php +++ b/Block/Checkout/Script.php @@ -42,6 +42,15 @@ class Script extends Template */ protected $_dataStorageHelper; + /** + * @var \Wirecard\CheckoutSeamless\Helper\Data + */ + protected $_dataHelper; + + /** + * @var \Magento\Quote\Model\Quote + */ + protected $_checkoutSession; /** * Constructor @@ -53,14 +62,30 @@ class Script extends Template public function __construct( Template\Context $context, \Wirecard\CheckoutSeamless\Helper\DataStorage $helper, + \Magento\Checkout\Model\Session $checkoutSession, + \Wirecard\CheckoutSeamless\Helper\Data $dataHelper, array $data = [] ) { parent::__construct($context, $data); $this->_dataStorageHelper = $helper; + $this->_checkoutSession = $checkoutSession; + $this->_dataHelper = $dataHelper; } public function getDataStorageUrl() { return $this->_dataStorageHelper->init(); } + + public function getConsumerDeviceId() + { + if (!strlen($this->_checkoutSession->getData('consumerDeviceId'))) { + $customerId = $this->_dataHelper->getConfigArray()['CUSTOMER_ID']; + $consumerDeviceId = md5($customerId . "_" . microtime()); + + $this->_checkoutSession->setData('consumerDeviceId', $consumerDeviceId); + } + + return $this->_checkoutSession->getData('consumerDeviceId'); + } } diff --git a/Model/AbstractPayment.php b/Model/AbstractPayment.php index 8843b23..0de3f67 100644 --- a/Model/AbstractPayment.php +++ b/Model/AbstractPayment.php @@ -149,6 +149,7 @@ public function initPaymentByCart(CheckoutCart $cart, $urls, \Magento\Framework\ $init->setConfirmUrl($urls['confirm']); $quote->reserveOrderId(); + $checkoutSession = $cart->getCheckoutSession(); $quote->save(); $orderId = $quote->getReservedOrderId(); @@ -170,13 +171,18 @@ public function initPaymentByCart(CheckoutCart $cart, $urls, \Magento\Framework\ ->setFailureUrl($returnUrl) ->setServiceUrl($this->_dataHelper->getConfigData('options/service_url')) ->setConsumerData($this->_getConsumerData($quote)) - ->setStorageid($this->_dataStorageHelper->getStorageId()) + ->setStorageId($this->_dataStorageHelper->getStorageId()) ->setOrderIdent($quote->getId()); $init->mage_orderId = $orderId; $init->mage_quoteId = $quote->getId(); $init->mage_orderCreation = $this->_dataHelper->getConfigData('options/order_creation'); + if (strlen($checkoutSession->getData('consumerDeviceId'))) { + $init->consumerDeviceId = $checkoutSession->getData('consumerDeviceId'); + $checkoutSession->unsetData('consumerDeviceId'); + } + $init->generateCustomerStatement($this->_dataHelper->getConfigData('options/shopname'), sprintf('%010d', $orderId)); $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); @@ -441,25 +447,6 @@ public function assignData(\Magento\Framework\DataObject $data) */ protected function _isAvailablePayolution($quote) { - $dob = $quote->getCustomer()->getDob(); - - //we only need to check the dob if it's set. Else we ask for dob on payment selection page. - if ($dob) { - $dobObject = new \DateTime($dob); - $currentYear = date('Y'); - $currentMonth = date('m'); - $currentDay = date('d'); - $ageCheckDate = ( $currentYear - 17 ) . '-' . $currentMonth . '-' . $currentDay; - $ageCheckObject = new \DateTime($ageCheckDate); - if ($ageCheckObject < $dobObject) { - return false; - } - } - - if ($quote->hasVirtualItems()) { - return false; - } - if ($this->getConfigData('billing_shipping_address_identical') && !$this->compareAddresses($quote)) { return false; } @@ -476,18 +463,6 @@ protected function _isAvailablePayolution($quote) } } - if (strlen($this->getConfigData('max_basket_size'))) { - if ($quote->getItemsQty() > $this->getConfigData('max_basket_size')) { - return false; - } - } - - if (strlen($this->getConfigData('min_basket_size'))) { - if ($quote->getItemsQty() < $this->getConfigData('min_basket_size')) { - return false; - } - } - return parent::isAvailable($quote); } @@ -498,31 +473,6 @@ protected function _isAvailablePayolution($quote) */ protected function _isAvailableRatePay($quote) { - $dob = $quote->getCustomer()->getDob(); - $minAge = (int) $this->getConfigData('min_age'); - - if ($minAge <= 0) { - $this->_logger->debug(__METHOD__ . ':warning min-age not set for ratepay'); - return false; - } - - //we only need to check the dob if it's set. Else we ask for dob on payment selection page. - if ($dob) { - $dobObject = new \DateTime($dob); - $currentYear = date('Y'); - $currentMonth = date('m'); - $currentDay = date('d'); - $ageCheckDate = ( $currentYear - $minAge ) . '-' . $currentMonth . '-' . $currentDay; - $ageCheckObject = new \DateTime($ageCheckDate); - if ($ageCheckObject < $dobObject) { - return false; - } - } - - if ($quote->hasVirtualItems()) { - return false; - } - if ($this->getConfigData('billing_shipping_address_identical') && !$this->compareAddresses($quote)) { return false; } @@ -539,18 +489,6 @@ protected function _isAvailableRatePay($quote) } } - if (strlen($this->getConfigData('max_basket_size'))) { - if ($quote->getItemsQty() > $this->getConfigData('max_basket_size')) { - return false; - } - } - - if (strlen($this->getConfigData('min_basket_size'))) { - if ($quote->getItemsQty() < $this->getConfigData('min_basket_size')) { - return false; - } - } - return parent::isAvailable($quote); } diff --git a/Model/ConfigProvider.php b/Model/ConfigProvider.php index 3a0c585..6efd1ce 100644 --- a/Model/ConfigProvider.php +++ b/Model/ConfigProvider.php @@ -53,9 +53,7 @@ class ConfigProvider implements ConfigProviderInterface Payment\Ideal::CODE, Payment\Giropay::CODE, Payment\Tatrapay::CODE, - Payment\Skrilldirect::CODE, Payment\Skrillwallet::CODE, - Payment\Mpass::CODE, Payment\Bmc::CODE, Payment\P24::CODE, Payment\Poli::CODE, @@ -204,17 +202,6 @@ public function getConfig() $config['payment'][Payment\Invoiceb2b::CODE]['consenttxt'] = sprintf($txt, $payolutionLink); } - $config['payment'][Payment\Invoice::CODE]['min_age'] = $this->methods[Payment\Invoice::CODE]->getConfigData('min_age'); - $config['payment'][Payment\Installment::CODE]['min_age'] = $this->methods[Payment\Installment::CODE]->getConfigData('min_age'); - - if ($this->methods[Payment\Invoice::CODE]->getProvider() == 'payolution') { - $config['payment'][Payment\Invoice::CODE]['min_age'] = 18; - } - - if ($this->methods[Payment\Installment::CODE]->getProvider() == 'payolution') { - $config['payment'][Payment\Installment::CODE]['min_age'] = 18; - } - $payolutionLink = $this->_dataHelper->getPayolutionLink($this->methods[Payment\Installment::CODE]->getConfigData('payolution_mid')); if ($this->methods[Payment\Installment::CODE]->getProvider() == 'payolution' && $this->methods[Payment\Installment::CODE]->getConfigData('payolution_terms')) { $config['payment'][Payment\Installment::CODE]['consenttxt'] = sprintf($txt, $payolutionLink); diff --git a/Model/Payment/Installment.php b/Model/Payment/Installment.php index 66f289f..da4f154 100644 --- a/Model/Payment/Installment.php +++ b/Model/Payment/Installment.php @@ -74,7 +74,7 @@ public function assignData(\Magento\Framework\DataObject $data) /** * Determine method availability based on quote amount and config data * - * @param \Magento\Quote\Api\Data\CartInterface|null $quote + * @param \Magento\Quote\Model\Quote|\Magento\Quote\Api\Data\CartInterface|null $quote * * @return bool */ @@ -88,6 +88,10 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) if ($quote === null) return false; + if ($quote->hasVirtualItems()) { + return false; + } + if ($this->getConfigData('provider') == 'ratepay') { return $this->_isAvailableRatePay($quote); } diff --git a/Model/Payment/Invoice.php b/Model/Payment/Invoice.php index 7d5bd6c..71456e6 100644 --- a/Model/Payment/Invoice.php +++ b/Model/Payment/Invoice.php @@ -74,7 +74,7 @@ public function assignData(\Magento\Framework\DataObject $data) /** * Determine method availability based on quote amount and config data * - * @param \Magento\Quote\Api\Data\CartInterface|null $quote + * @param \Magento\Quote\Model\Quote|\Magento\Quote\Api\Data\CartInterface|null $quote * * @return bool */ @@ -89,6 +89,10 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null) return false; } + if ($quote->hasVirtualItems()) { + return false; + } + if ($this->getConfigData('provider') == 'ratepay') { return $this->_isAvailableRatePay($quote); } elseif ($this->getConfigData('provider') == 'payolution') { diff --git a/composer.json b/composer.json index ecaeaaf..47a6787 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "wirecard/magento2-wcs", "description": "Wirecard Checkout Seamless", "type": "magento2-module", - "version": "1.0.4", + "version": "1.0.5", "license": [ "MIT" ], diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 7fc9f04..b69ca72 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -372,7 +372,7 @@ - + Magento\Config\Model\Config\Source\Yesno @@ -630,43 +630,6 @@ - - - - - Magento\Config\Model\Config\Source\Yesno - - - - - - - Magento\Shipping\Model\Config\Source\Allmethods - - - - Magento\Payment\Model\Config\Source\Allspecificcountries - - - - Magento\Directory\Model\Config\Source\Country - 1 - - - - - - - validate-number - - - - - - - - - @@ -938,12 +901,6 @@ Magento\Config\Model\Config\Source\Locale\Currency 1 - - - validate-greater-than-zero - 1 - Only applicable for RatePay. - Magento\Config\Model\Config\Source\Yesno @@ -962,14 +919,6 @@ - - - validate-greater-than-zero - - - - validate-greater-than-zero - @@ -1030,14 +979,6 @@ - - - validate-greater-than-zero - - - - validate-greater-than-zero - @@ -1089,12 +1030,6 @@ Magento\Config\Model\Config\Source\Locale\Currency 1 - - - validate-greater-than-zero - 1 - Only applicable for RatePay. - Magento\Config\Model\Config\Source\Yesno @@ -1113,14 +1048,6 @@ - - - validate-greater-than-zero - - - - validate-greater-than-zero - @@ -1324,43 +1251,6 @@ - - - - - Magento\Config\Model\Config\Source\Yesno - - - - - - - Magento\Shipping\Model\Config\Source\Allmethods - - - - Magento\Payment\Model\Config\Source\Allspecificcountries - - - - Magento\Directory\Model\Config\Source\Country - 1 - - - - - - - validate-number - - - - - - - - - diff --git a/etc/config.xml b/etc/config.xml index 4855510..13609a2 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -86,7 +86,7 @@ 0 - Wirecard Checkout Seamless Bancontact/Mister Cash + Wirecard Checkout Seamless Bancontact You will be redirected to Wirecard Checkout Seamless when you place an order. Wirecard\CheckoutSeamless\Model\Payment\Bmc 130 @@ -141,14 +141,6 @@ 190 - - 0 - Wirecard Checkout Seamless Skrill Direct - You will be redirected to Wirecard Checkout Seamless when you place an order. - Wirecard\CheckoutSeamless\Model\Payment\Skrilldirect - 200 - - 1 Wirecard Checkout Seamless SOFORT Banking @@ -289,14 +281,6 @@ SINGLE - - 0 - Wirecard Checkout Seamless mpass - You will be redirected to Wirecard Checkout Seamless when you place an order. - Wirecard\CheckoutSeamless\Model\Payment\Mpass - 350 - - 0 Wirecard Checkout Seamless paybox diff --git a/i18n/de_AT.csv b/i18n/de_AT.csv index f2d7bf4..e091612 100644 --- a/i18n/de_AT.csv +++ b/i18n/de_AT.csv @@ -56,7 +56,7 @@ "Void not possible anymore for this payment, please try cancel instead!","Das Aufheben der Authorisierung ist nicht mehr möglich!" "Wirecard Checkout Seamless Fund Transfer","Wirecard Checkout Seamless Auszahlungr" "Wirecard Checkout Seamless @Quick","Wirecard Checkout Seamless @Quick" -"Wirecard Checkout Seamless Bancontact/Mister Cash","Wirecard Checkout Seamless Bancontact/Mister Cash" +"Wirecard Checkout Seamless Bancontact","Wirecard Checkout Seamless Bancontact" "Wirecard Checkout Seamless Credit Card - Mail Order / Telephone Order","Wirecard Checkout Page Kreditkarte - Post / Telefonbestellung" "Wirecard Checkout Seamless Credit Card","Wirecard Checkout Seamless Kreditkarte" "Wirecard Checkout Seamless eKonto","Wirecard Checkout Seamless eKonto" @@ -69,7 +69,6 @@ "Wirecard Checkout Seamless Invoice","Wirecard Checkout Seamless Rechnung" "Wirecard Checkout Seamless Maestro SecureCode","Wirecard Checkout Seamless Maestro SecureCode" "Wirecard Checkout Seamless moneta.ru","Wirecard Checkout Seamless moneta.ru" -"Wirecard Checkout Seamless mpass","Wirecard Checkout Seamless mpass" "Wirecard Checkout Seamless My Voucher","Wirecard Checkout Seamless Mein Gutschein" "Wirecard Checkout Seamless paybox","Wirecard Checkout Seamless paybox" "Wirecard Checkout Seamless PayPal","Wirecard Checkout Seamless PayPal" diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 70e5c6d..71adfcd 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -55,7 +55,7 @@ "Version: %product","Version: %product" "Void not possible anymore for this payment, please try cancel instead!","Void not possible anymore for this payment, please try cancel instead!" "Wirecard Checkout Seamless @Quick","Wirecard Checkout Seamless @Quick" -"Wirecard Checkout Seamless Bancontact/Mister Cash","Wirecard Checkout Seamless Bancontact/Mister Cash" +"Wirecard Checkout Seamless Bancontact","Wirecard Checkout Seamless Bancontact" "Wirecard Checkout Seamless Credit Card - Mail Order / Telephone Order","Wirecard Checkout Seamless Credit Card - Mail Order / Telephone Order" "Wirecard Checkout Seamless Credit Card","Wirecard Checkout Seamless Credit Card" "Wirecard Checkout Seamless eKonto","Wirecard Checkout Seamless eKonto" @@ -69,7 +69,6 @@ "Wirecard Checkout Seamless Invoice","Wirecard Checkout Seamless Invoice" "Wirecard Checkout Seamless Maestro SecureCode","Wirecard Checkout Seamless Maestro SecureCode" "Wirecard Checkout Seamless moneta.ru","Wirecard Checkout Seamless moneta.ru" -"Wirecard Checkout Seamless mpass","Wirecard Checkout Seamless mpass" "Wirecard Checkout Seamless My Voucher","Wirecard Checkout Seamless My Voucher" "Wirecard Checkout Seamless paybox","Wirecard Checkout Seamless paybox" "Wirecard Checkout Seamless PayPal","Wirecard Checkout Seamless PayPal" diff --git a/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml index 5ceb178..2677692 100644 --- a/view/frontend/layout/checkout_index_index.xml +++ b/view/frontend/layout/checkout_index_index.xml @@ -81,9 +81,6 @@ true - - true - true @@ -117,9 +114,6 @@ true - - true - true diff --git a/view/frontend/templates/script.phtml b/view/frontend/templates/script.phtml index d8fc008..94762a7 100644 --- a/view/frontend/templates/script.phtml +++ b/view/frontend/templates/script.phtml @@ -35,3 +35,17 @@ +getConsumerDeviceId()){ ?> + + + + + + + + + diff --git a/view/frontend/web/images/bmc.png b/view/frontend/web/images/bmc.png index 4d8362f..142e9d3 100644 Binary files a/view/frontend/web/images/bmc.png and b/view/frontend/web/images/bmc.png differ diff --git a/view/frontend/web/images/cc.png b/view/frontend/web/images/cc.png index 6fadc06..f15cae7 100644 Binary files a/view/frontend/web/images/cc.png and b/view/frontend/web/images/cc.png differ diff --git a/view/frontend/web/images/ccMoto.png b/view/frontend/web/images/ccMoto.png index 6fadc06..f15cae7 100644 Binary files a/view/frontend/web/images/ccMoto.png and b/view/frontend/web/images/ccMoto.png differ diff --git a/view/frontend/web/images/epaybg.png b/view/frontend/web/images/epaybg.png index 8755bcf..f9e6439 100644 Binary files a/view/frontend/web/images/epaybg.png and b/view/frontend/web/images/epaybg.png differ diff --git a/view/frontend/web/images/eps.png b/view/frontend/web/images/eps.png index 8aedd9b..24907d8 100644 Binary files a/view/frontend/web/images/eps.png and b/view/frontend/web/images/eps.png differ diff --git a/view/frontend/web/images/mpass.png b/view/frontend/web/images/mpass.png deleted file mode 100644 index 843a3bb..0000000 Binary files a/view/frontend/web/images/mpass.png and /dev/null differ diff --git a/view/frontend/web/images/paysafecard.png b/view/frontend/web/images/paysafecard.png index 186cbe4..4bc9b77 100644 Binary files a/view/frontend/web/images/paysafecard.png and b/view/frontend/web/images/paysafecard.png differ diff --git a/view/frontend/web/images/skrilldirect.png b/view/frontend/web/images/skrilldirect.png deleted file mode 100644 index fc6116b..0000000 Binary files a/view/frontend/web/images/skrilldirect.png and /dev/null differ diff --git a/view/frontend/web/js/action/set-payment-method.js b/view/frontend/web/js/action/set-payment-method.js index 416c837..63f05c8 100644 --- a/view/frontend/web/js/action/set-payment-method.js +++ b/view/frontend/web/js/action/set-payment-method.js @@ -39,10 +39,11 @@ define( 'Magento_Checkout/js/model/error-processor', 'Magento_Customer/js/model/customer', 'Magento_Checkout/js/model/full-screen-loader', + 'Magento_CheckoutAgreements/js/model/agreements-assigner', 'jquery/ui', 'Magento_Ui/js/modal/modal' ], - function ($, quote, urlBuilder, url, storage, errorProcessor, customer, fullScreenLoader) { + function ($, quote, urlBuilder, url, storage, errorProcessor, customer, fullScreenLoader, agreementsAssigner) { 'use strict'; return function (messageContainer, displaymode, iframe) { @@ -67,6 +68,7 @@ define( }; } else { serviceUrl = urlBuilder.createUrl('/carts/mine/set-payment-information', {}); + agreementsAssigner(paymentData); payload = { cartId: quote.getQuoteId(), paymentMethod: paymentData, diff --git a/view/frontend/web/js/model/min-age-validator.js b/view/frontend/web/js/model/min-age-validator.js index 9902697..6401cd2 100644 --- a/view/frontend/web/js/model/min-age-validator.js +++ b/view/frontend/web/js/model/min-age-validator.js @@ -40,17 +40,12 @@ define( 'use strict'; return { - - minage: 0, - /** * Validate checkout agreements * * @returns {Boolean} */ validate: function (dob) { - if (this.minage == 0) - return true; var birthdate = new Date(dob); @@ -60,7 +55,7 @@ define( return false; } - var limit = new Date((today.getFullYear() - this.minage), today.getMonth(), today.getDate()); + var limit = new Date((today.getFullYear() - 18), today.getMonth(), today.getDate()); return birthdate < limit; } }; diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index e338fff..c786d48 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -72,18 +72,10 @@ define( type: 'wirecard_checkoutseamless_sofortbanking', component: 'Wirecard_CheckoutSeamless/js/view/payment/method-renderer/standard' }, - { - type: 'wirecard_checkoutseamless_skrilldirect', - component: 'Wirecard_CheckoutSeamless/js/view/payment/method-renderer/standard' - }, { type: 'wirecard_checkoutseamless_skrillwallet', component: 'Wirecard_CheckoutSeamless/js/view/payment/method-renderer/standard' }, - { - type: 'wirecard_checkoutseamless_mpass', - component: 'Wirecard_CheckoutSeamless/js/view/payment/method-renderer/standard' - }, { type: 'wirecard_checkoutseamless_bmc', component: 'Wirecard_CheckoutSeamless/js/view/payment/method-renderer/standard' diff --git a/view/frontend/web/js/view/payment/method-renderer/invoiceinstallment.js b/view/frontend/web/js/view/payment/method-renderer/invoiceinstallment.js index 2e98763..1777bcb 100644 --- a/view/frontend/web/js/view/payment/method-renderer/invoiceinstallment.js +++ b/view/frontend/web/js/view/payment/method-renderer/invoiceinstallment.js @@ -62,23 +62,17 @@ define( additionalData = {}; additionalData.customerDob = this.customerDob(); + console.log(additionalData); return $.extend(true, parent, {'additional_data': additionalData}); }, - getMinAge: function() { - if (!window.checkoutConfig.payment[this.getCode()]) - return 0; - - return window.checkoutConfig.payment[this.getCode()].min_age - }, isB2B: function() { return this.getCode() == 'wirecard_checkoutseamless_invoiceb2b'; }, validate: function () { - minAgeValidator.minage = this.getMinAge(); if (!this.isB2B() && !minAgeValidator.validate(this.customerDob())) { var errorPane = $('#' + this.getCode() + '-dob-error'); - errorPane.html($t('You have to be %age% years or older to use this payment.'.replace('%age%', minAgeValidator.minage))); + errorPane.html($t('You have to be 18 years or older to use this payment.')); errorPane.css('display', 'block'); return false; } diff --git a/view/frontend/web/template/payment/method-invoiceinstallment.html b/view/frontend/web/template/payment/method-invoiceinstallment.html index 4084f89..d3cc2bd 100644 --- a/view/frontend/web/template/payment/method-invoiceinstallment.html +++ b/view/frontend/web/template/payment/method-invoiceinstallment.html @@ -72,8 +72,8 @@ - + @@ -89,7 +89,7 @@