diff --git a/Block/Customer/Tab.php b/Block/Customer/Tab.php deleted file mode 100644 index 0ec486c..0000000 --- a/Block/Customer/Tab.php +++ /dev/null @@ -1,54 +0,0 @@ -dataHelper = $dataHelper; - - parent::__construct($context, $defaultPath, $data); - } - - /** - * Render block HTML. - * - * @return string - */ - protected function _toHtml() - { - if (! $this->dataHelper->isOneClickActive()) { - return ''; - } - - return parent::_toHtml(); - } -} diff --git a/Block/Customer/Index.php b/Block/Customer/Wallet.php similarity index 60% rename from Block/Customer/Index.php rename to Block/Customer/Wallet.php index 1aac4c4..665c612 100644 --- a/Block/Customer/Index.php +++ b/Block/Customer/Wallet.php @@ -9,7 +9,7 @@ */ namespace Lyranetwork\Payzen\Block\Customer; -class Index extends \Magento\Framework\View\Element\Template +class Wallet extends \Magento\Vault\Block\Customer\CreditCards { /** * @var \Lyranetwork\Payzen\Helper\Data @@ -21,21 +21,27 @@ class Index extends \Magento\Framework\View\Element\Template */ protected $customerSession; + protected $method; + /** * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Vault\Model\CustomerTokenManagement $customerTokenManagement, * @param \Magento\Customer\Model\Session $customerSession * @param \Lyranetwork\Payzen\Helper\Data $dataHelper * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, + \Magento\Vault\Model\CustomerTokenManagement $customerTokenManagement, \Magento\Customer\Model\Session $customerSession, \Lyranetwork\Payzen\Helper\Data $dataHelper, array $data = [] ) { $this->customerSession = $customerSession; $this->dataHelper = $dataHelper; - parent::__construct($context, $data); + parent::__construct($context, $customerTokenManagement); + + $this->method = $this->dataHelper->getMethodInstance(\Lyranetwork\Payzen\Helper\Data::METHOD_STANDARD); } /** @@ -43,7 +49,7 @@ public function __construct( * * @return array */ - public function getStoredPaymentMeans() + public function getStoredPaymentMeans($identifier = null) { $means = []; @@ -58,6 +64,11 @@ public function getStoredPaymentMeans() 'payzen_sepa_identifier' => 'payzen_sepa_iban_bic' ]; + if ($identifier) { + $identifierToUnset = ($identifier == 'payzen_identifier') ? 'payzen_sepa_identifier' : 'payzen_identifier'; + unset($aliasIds[$identifierToUnset]); + } + foreach ($aliasIds as $aliasId => $maskedId) { // Check if there is a saved alias. if (! $customer->getCustomAttribute($aliasId)) { @@ -69,11 +80,16 @@ public function getStoredPaymentMeans() $card['pm'] = $maskedId; $maskedPan = $customer->getCustomAttribute($maskedId)->getValue(); - $pos = strpos($maskedPan, '|'); - - if ($pos !== false) { + if ($pos = strpos($maskedPan, '|')) { $card['brand'] = substr($maskedPan, 0, $pos); - $card['number'] = substr($maskedPan, $pos + 1); + $number = substr($maskedPan, $pos + 1); + + if ($pos = strpos($number, '-')) { + $card['expiry'] = substr($number, $pos + 2); + $number = substr($number, 0, $pos); + } + + $card['number'] = $number; } else { $card['brand'] = ''; $card['number'] = $maskedPan; @@ -96,6 +112,40 @@ public function getCcTypeImageSrc($card) return $this->dataHelper->getCcTypeImageSrc($card); } + public function getAccountToken() + { + if (! $this->useCustomerWallet()) { + return null; + } + + return $this->method->getAccountToken(); + } + + public function getLanguage() + { + return $this->method->getPaymentLanguage(); + } + + public function hideWalletElements() + { + return $this->dataHelper->onVaultTab() && ! $this->method->isRestMode(); + } + + public function hasIdentifiers() + { + return ! empty($this->getStoredPaymentMeans()); + } + + private function useCustomerWallet() + { + $customer = $this->method->getCurrentCustomer(); + if (! $customer || ! $this->method->isOneClickActive()) { + return false; + } + + return true; + } + /** * Render block HTML. * @@ -109,4 +159,4 @@ protected function _toHtml() return parent::_toHtml(); } -} +} \ No newline at end of file diff --git a/Block/Payment/Rest/Head.php b/Block/Payment/Rest/Head.php index 01c6541..802e24a 100644 --- a/Block/Payment/Rest/Head.php +++ b/Block/Payment/Rest/Head.php @@ -118,7 +118,7 @@ public function getCardLabel() */ protected function _toHtml() { - if (! $this->method->isRestMode()) { + if (! $this->method->isRestMode() && ! $this->dataHelper->onVaultTab()) { return ''; } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ec6b26..e6e9836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +2.10.0, 2024-09-17: +- [embedded] Use customer wallet functionality to manage payment by alias on buyer account. +- [alias] Improve alias validity check. + 2.9.2, 2024-07-30: - Bug fix: Do not override CSP module configured mode. - Some fixes by plugin variant. diff --git a/Controller/Customer/Cancel.php b/Controller/Customer/Cancel.php index 88b7e93..7f97589 100644 --- a/Controller/Customer/Cancel.php +++ b/Controller/Customer/Cancel.php @@ -42,9 +42,10 @@ public function execute() $customerId = $this->customerSession->getCustomer()->getId(); $attribute = $this->getRequest()->getPost('alias_attr', false); $maskedAttribute = $this->getRequest()->getPost('pm_attr', false); + $alias = $this->getRequest()->getPost('alias', false); if ($customerId && $attribute && $maskedAttribute) { - if ($this->paymentHelper->deleteIdentifier($customerId, $attribute, $maskedAttribute)) { + if ($this->paymentHelper->deleteIdentifier($customerId, $attribute, $maskedAttribute, $alias)) { $this->messageManager->addSuccessMessage(__('The stored means of payment was successfully deleted.')); } else { $this->messageManager->addErrorMessage(__('The stored means of payment could not be deleted.')); @@ -53,7 +54,8 @@ public function execute() /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); - $resultRedirect->setPath('*/*/index', ['_secure' => true]); + $resultRedirect->setPath('vault/cards/listaction', ['_secure' => true]); + return $resultRedirect; } } diff --git a/Controller/Customer/Index.php b/Controller/Customer/Index.php deleted file mode 100644 index 8ebfeb3..0000000 --- a/Controller/Customer/Index.php +++ /dev/null @@ -1,42 +0,0 @@ -resultPageFactory = $resultPageFactory; - - parent::__construct($context, $customerSession); - } - - public function execute() - { - return $this->resultPageFactory->create(); - } -} diff --git a/Controller/Payment/Response.php b/Controller/Payment/Response.php index c477394..0a4f184 100644 --- a/Controller/Payment/Response.php +++ b/Controller/Payment/Response.php @@ -62,6 +62,10 @@ public function execute() $params = $this->getRequest()->getParams(); $data = $this->prepareResponse($params); + if (isset($data['from_account'])) { + return $this->redirectToAccount($data['response']); + } + $order = $data['order']; $response = $data['response']; $result = $this->responseProcessor->execute($order, $response); @@ -179,6 +183,20 @@ protected function redirectResponse($order, $case, $checkUrlWarn = false) return $resultRedirect; } + protected function redirectToAccount($response) + { + // Clear all messages in session. + $this->messageManager->getMessages(true); + + if ($response->get('identifier') || ($response->get('identifier_status') == 'CREATED')) { + $this->messageManager->addSuccessMessage(__('Payment means successfully added.')); + } else { + $this->messageManager->addErrorMessage(__('Unable to add payment means to your account.')); + } + + return $this->createResult('vault/cards/listaction', ['_scope' => '1']); + } + private function createResult($path, $params) { if ($this->getRequest()->getParam('iframe', false)) { diff --git a/Controller/Payment/Rest/Response.php b/Controller/Payment/Rest/Response.php index 8102b9f..ab8e31d 100644 --- a/Controller/Payment/Rest/Response.php +++ b/Controller/Payment/Rest/Response.php @@ -102,6 +102,18 @@ protected function prepareResponse($params) ] ); + if ($response->getExtInfo('from_account')) { + $storeId = $response->getExtInfo('store_id'); + + // Check the authenticity of the request. + $this->checkResponseHash($params, $storeId); + + return [ + 'response' => $response, + 'from_account' => true + ]; + } + $orderId = (int) $response->get('order_id'); if (! $orderId) { $this->dataHelper->log("Received empty Order ID.", \Psr\Log\LogLevel::ERROR); @@ -127,16 +139,21 @@ protected function prepareResponse($params) $storeId = $order->getStore()->getId(); // Check the authenticity of the request. + $this->checkResponseHash($params, $storeId); + + return [ + 'response' => $response, + 'order' => $order + ]; + } + + private function checkResponseHash($params, $storeId) + { if (! $this->restHelper->checkResponseHash($params, $this->restHelper->getReturnKey($storeId))) { // Authentication failed. throw new ResponseException( "{$this->dataHelper->getIpAddress()} tries to access payzen/payment_rest/response page without valid signature with parameters: " . json_encode($params) ); } - - return [ - 'response' => $response, - 'order' => $order - ]; } } diff --git a/Helper/Data.php b/Helper/Data.php index 98b4fb5..f8b2d4d 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -292,6 +292,11 @@ public function getCheckoutStoreId() return $session->getStoreId(); } + public function getCurrentStore() + { + return $this->storeManager->getStore(); + } + /** * Return store obeject by ID. * @@ -360,6 +365,17 @@ public function isPublishFileImageExists($fileName) return $this->fileExists($filePath); } + /** + * Check if image file is published to pub/static directory. + * + * @param string $fileName + * @return string + */ + public function onVaultTab() + { + return (strpos($this->storeManager->getStore()->getCurrentUrl(), 'vault/cards/listaction') !== false); + } + /** * Returns a configuration parameter from XML files. * @@ -607,7 +623,8 @@ public function isOneClickActive() $standardMethod = $this->getMethodInstance(\Lyranetwork\Payzen\Helper\Data::METHOD_STANDARD); $sepaMethod = $this->getMethodInstance(\Lyranetwork\Payzen\Helper\Data::METHOD_SEPA); - return $standardMethod->isOneClickActive() || $sepaMethod->isOneClickActive(); + return ($standardMethod->isAvailable() && $standardMethod->isOneClickActive()) || + ($sepaMethod->isAvailable() && $sepaMethod->isOneClickActive()); } private function convertCardDataEntryMode($code) { diff --git a/Helper/Payment.php b/Helper/Payment.php index 4417b24..0681083 100644 --- a/Helper/Payment.php +++ b/Helper/Payment.php @@ -600,6 +600,10 @@ public function saveIdentifier( return; } + if ($response->getExtInfo('is_customer_wallet')) { + return; + } + if ($response->get('identifier') && ( $response->get('identifier_status') === 'CREATED' /* page_action REGISTER_PAY or ASK_REGISTER_PAY */ || $response->get('identifier_status') === 'UPDATED' /* page_action REGISTER_UPDATE_PAY */ @@ -676,7 +680,7 @@ public function saveSepaIdentifier( } } - public function deleteIdentifier($customerId, $attribute, $maskedAttribute) + public function deleteIdentifier($customerId, $attribute, $maskedAttribute, $walletIdentifier = false) { $customer = $this->customerFactory->create()->load($customerId); $customerData = $customer->getDataModel(); @@ -689,6 +693,17 @@ public function deleteIdentifier($customerId, $attribute, $maskedAttribute) $identifier = $customerData->getCustomAttribute($attribute)->getValue(); + if ($walletIdentifier) { + if ($walletIdentifier == $identifier) { + // Delete identifier from Magento. + $this->deleteIdentifierAttribute($customer, $attribute, $maskedAttribute); + + return true; + } else { + return false; + } + } + try { if ($this->restHelper->getPrivateKey()) { $requestData = ['paymentMethodToken' => $identifier]; diff --git a/Model/Method/Other.php b/Model/Method/Other.php index e809520..46a44f7 100644 --- a/Model/Method/Other.php +++ b/Model/Method/Other.php @@ -29,20 +29,20 @@ protected function setExtraFields($order) $option = @unserialize($info->getAdditionalInformation(\Lyranetwork\Payzen\Helper\Payment::OTHER_OPTION)); // Check if capture_delay and validation_mode are overriden. - if (is_numeric($option['capture_delay'])) { + if (isset($option['capture_delay']) && is_numeric($option['capture_delay'])) { $this->payzenRequest->set('capture_delay', $option['capture_delay']); } - if ($option['validation_mode'] !== '-1') { + if (isset($option['validation_mode']) && ($option['validation_mode'] !== '-1')) { $this->payzenRequest->set('validation_mode', $option['validation_mode']); } // Add cart data. - if ($option['cart_data'] === '1') { + if (isset($option['cart_data']) && ($option['cart_data'] === '1')) { $this->checkoutHelper->setCartData($order, $this->payzenRequest, true); } - if ($option['embedded_mode'] === '1') { + if (isset($option['embedded_mode']) && ($option['embedded_mode'] === '1')) { $this->payzenRequest->set('embedded_mode', $option['embedded_mode']); } } diff --git a/Model/Method/Sepa.php b/Model/Method/Sepa.php index 2144a0c..7f892c6 100644 --- a/Model/Method/Sepa.php +++ b/Model/Method/Sepa.php @@ -154,11 +154,11 @@ protected function setExtraFields($order) ' will be asked for card data registration on payment page.'); $this->payzenRequest->set('page_action', 'ASK_REGISTER_PAY'); } - - $this->customerSession->unsValidSepaAlias(); } else { $this->payzenRequest->set('page_action', $this->getMandateMode()); } + + $this->customerSession->unsValidSepaAlias(); } public function isOneclickAvailable() @@ -180,6 +180,11 @@ public function isOneclickAvailable() return false; } + // Customer identifier has already checked. + if ($this->customerSession->getValidSepaAlias()) { + return true; + } + try { $aliasEnabled = $this->restHelper->checkIdentifier($identifier->getValue(), $this->getCurrentCustomer()->getEmail()); } catch (\Exception $e) { diff --git a/Model/Method/Standard.php b/Model/Method/Standard.php index ab68be5..3c5bda1 100644 --- a/Model/Method/Standard.php +++ b/Model/Method/Standard.php @@ -177,7 +177,7 @@ protected function setExtraFields($order) } } - $this->customerSession->unsetValidAlias(); + $this->customerSession->unsValidAlias(); } /** @@ -236,6 +236,11 @@ public function isOneclickAvailable() return false; } + // Customer identifier has already checked. + if ($this->customerSession->getValidAlias()) { + return true; + } + try { $aliasEnabled = $this->restHelper->checkIdentifier($identifier->getValue(), $customer->getEmail()); } catch (\Exception $e) { @@ -418,7 +423,7 @@ protected function getRestApiFormTokenData($quote) 'paymentSource' => 'EC' ] ], - 'contrib' => $this->dataHelper->getContribParam(), + 'contrib' => $this->dataHelper->getContribParam(), 'strongAuthentication' => $strongAuth, 'currency' => $currency->getAlpha3(), 'amount' => $currency->convertAmountToInteger($amount), @@ -573,6 +578,7 @@ protected function getTokenDataForOrder($order) if ($this->isOneClickActive() && $customer) { $data['formAction'] = 'CUSTOMER_WALLET'; + $data['metadata']['is_customer_wallet'] = true; } if ($this->isSmartform()) { @@ -659,6 +665,88 @@ public function getRestApiFormToken($renew = false) } } + protected function getAccountTokenData() + { + $customer = $this->customerSession->getCustomer(); + $billingAddress = $customer->getDefaultBillingAddress(); + $currency = $this->dataHelper->getCurrentStore()->getCurrentCurrencyCode(); + + $data = [ + 'formAction' => 'CUSTOMER_WALLET', + 'customer' => [ + 'email' => $customer->getEmail(), + 'reference' => $customer->getId() + ], + 'contrib' => $this->dataHelper->getContribParam(), + 'currency' => $currency, + 'metadata' => [ + 'is_customer_wallet' => true, + 'from_account' => true, + 'store_id' => $this->dataHelper->getCurrentStore()->getId() + ] + ]; + + if ($billingAddress) { + $data['customer']['billingDetails'] = [ + 'firstName' => $billingAddress->getFirstname(), + 'lastName' => $billingAddress->getLastname(), + 'address' => $billingAddress->getStreetLine(1), + 'address2' => $billingAddress->getStreetLine(2), + 'zipCode' => $billingAddress->getPostcode(), + 'city' => $billingAddress->getCity(), + 'state' => $billingAddress->getRegion(), + 'phoneNumber' => $billingAddress->getTelephone(), + 'country' => $billingAddress->getCountryId() + ]; + } + + if ($this->isSmartform()) { + // Filter payment means when creating the payment token. + $data['paymentMethods'] = $this->getPaymentMeansForSmartform(null); + } + + return json_encode($data); + } + + public function getAccountToken() + { + $customerId = $this->customerSession->getCustomer()->getId(); + + $params = $this->getAccountTokenData(); + $this->dataHelper->log("Creating form token for customer #{$customerId} with parameters: {$params}"); + + try { + // Perform our request. + $client = new \Lyranetwork\Payzen\Model\Api\Rest\Api( + $this->dataHelper->getCommonConfigData('rest_url'), + $this->dataHelper->getCommonConfigData('site_id'), + $this->restHelper->getPrivateKey() + ); + + $response = $client->post('V4/Charge/CreateToken', $params); + + if ($response['status'] !== 'SUCCESS') { + $msg = "Error while creating payment form token for customer #{$customerId}: " . $response['answer']['errorMessage'] . ' (' . $response['answer']['errorCode'] . ').'; + + if (isset($response['answer']['detailedErrorMessage']) && ! empty($response['answer']['detailedErrorMessage'])) { + $msg .= ' Detailed message: ' . $response['answer']['detailedErrorMessage'] . ' (' . $response['answer']['detailedErrorCode'] . ').'; + } + + $this->dataHelper->log($msg, \Psr\Log\LogLevel::WARNING); + + return false; + } else { + $this->dataHelper->log("Form token created successfully for customer #{$customerId}."); + + return $response['answer']['formToken']; + } + } catch (\Exception $e) { + $this->dataHelper->log($e->getMessage(), \Psr\Log\LogLevel::ERROR); + + return false; + } + } + public function getTokenForOrder($order) { if (! $order || ! $order->getId()) { diff --git a/composer.json b/composer.json index c908cd4..37f7f09 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php" : "~7|~8" }, "type" : "magento2-module", - "version" : "2.9.2", + "version" : "2.10.0", "license" : "OSL-3.0", "autoload" : { "files" : [ diff --git a/etc/config.xml b/etc/config.xml index 57c7850..de8c8df 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -15,7 +15,7 @@ - 2.9.2 + 2.10.0 V2 Magento_2.x 1 diff --git a/etc/module.xml b/etc/module.xml index ca87aea..15f28a6 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -15,6 +15,7 @@ + \ No newline at end of file diff --git a/i18n/de_DE.csv b/i18n/de_DE.csv index 19768f8..132b061 100644 --- a/i18n/de_DE.csv +++ b/i18n/de_DE.csv @@ -420,6 +420,8 @@ "The payment was successful. Your order was registered successfully.","Die Zahlung wurde erfolgreich abgeschlossen. Ihre Zahlung wurde erfolgreich gespeichert." "An error has occurred during the payment process.","Ein Fehler ist während dem Zahlungsvorgang unterlaufen." "Payment cancelled.","Zahlung storniert." +"Payment means successfully added.", "Das Zahlungsmittel wurde erfolgreich hinzugefügt." +"Unable to add payment means to your account.", "as Zahlungsmittel konnte Ihrem Konto nicht hinzugefügt werden" "Capture delay column","Einzugsfrist" "Compact mode","Kompakter Modus" "This option allows to display the Smartform in a compact mode.","Diese Option ermöglicht es, die Smartform in einem kompakten Modus anzuzeigen." diff --git a/i18n/en_US.csv b/i18n/en_US.csv index fe8951e..1181c2a 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -419,6 +419,8 @@ "The payment was successful. Your order was registered successfully.","The payment was successful. Your order was registered successfully." "An error has occurred during the payment process.","An error has occurred during the payment process." "Payment cancelled.","Payment cancelled." +"Payment means successfully added.", "Payment means successfully added." +"Unable to add payment means to your account.", "Unable to add payment means to your account." "Capture delay column","Capture delay" "Compact mode","Compact mode" "This option allows to display the Smartform in a compact mode.","This option allows to display the Smartform in a compact mode." diff --git a/i18n/es_ES.csv b/i18n/es_ES.csv index 8d44065..e58d733 100644 --- a/i18n/es_ES.csv +++ b/i18n/es_ES.csv @@ -418,6 +418,8 @@ "The payment was successful. Your order was registered successfully.","El pago fue exitoso. Su pedido se registró correctamente." "An error has occurred during the payment process.","Ocurrió un error durante el proceso de pago." "Payment cancelled.","Pago cancelado." +"Payment means successfully added.", "El medio de pago se agregó correctamente." +"Unable to add payment means to your account.", "No se puede agregar el medio de pago a su cuenta." "Capture delay column","Plazo de captura" "Compact mode","Modo compacto" "This option allows to display the Smartform in a compact mode.","Esta opción muestra el Smartform en modo compacto." diff --git a/i18n/fr_FR.csv b/i18n/fr_FR.csv index 8be715e..fe5c5b6 100644 --- a/i18n/fr_FR.csv +++ b/i18n/fr_FR.csv @@ -419,6 +419,8 @@ "The payment was successful. Your order was registered successfully.","Le paiement a réussi. Votre commande est enregistrée avec succès." "An error has occurred during the payment process.","Une erreur est survenue durant le processus de paiement." "Payment cancelled.","Paiement annulé." +"Payment means successfully added.", "Moyen de paiement ajouté avec succès." +"Unable to add payment means to your account.", "Impossble d'ajouter le moyen de paiement à votre compte." "Capture delay column","Délai de remise" "Compact mode","Mode compact" "This option allows to display the Smartform in a compact mode.","Cette option permet d'afficher le Smartform en mode compact." diff --git a/i18n/pt_BR.csv b/i18n/pt_BR.csv index b5e0f2e..a4dcf86 100644 --- a/i18n/pt_BR.csv +++ b/i18n/pt_BR.csv @@ -419,6 +419,8 @@ "The payment was successful. Your order was registered successfully.","O pagamento foi realizado com sucesso. Seu pedido foi salvo com sucesso." "An error has occurred during the payment process.","Ocorreu um erro durante o pagamento." "Payment cancelled.","Pagamento cancelado." +"Payment means successfully added.", "O meio de pagamento adicionado com sucesso." +"Unable to add payment means to your account.", "Não é possível adicionar o meio de pagamento à sua conta." "Capture delay column","Prazo de captura" "Compact mode","Modo compacto" "This option allows to display the Smartform in a compact mode.","Esta opção permite exibir o Smartform em modo compacto." diff --git a/view/base/web/images/multi-logo.png b/view/base/web/images/multi-logo.png index bd23abf..c4bdc34 100644 Binary files a/view/base/web/images/multi-logo.png and b/view/base/web/images/multi-logo.png differ diff --git a/view/base/web/images/standard-logo.png b/view/base/web/images/standard-logo.png index bd23abf..c4bdc34 100644 Binary files a/view/base/web/images/standard-logo.png and b/view/base/web/images/standard-logo.png differ diff --git a/view/frontend/layout/customer_account.xml b/view/frontend/layout/customer_account.xml deleted file mode 100644 index 7548a1a..0000000 --- a/view/frontend/layout/customer_account.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - payzen/customer/index - My payment means - 140 - - - - - \ No newline at end of file diff --git a/view/frontend/layout/payzen_customer_index.xml b/view/frontend/layout/vault_cards_listaction.xml similarity index 62% rename from view/frontend/layout/payzen_customer_index.xml rename to view/frontend/layout/vault_cards_listaction.xml index afccdd8..dbc26c0 100644 --- a/view/frontend/layout/payzen_customer_index.xml +++ b/view/frontend/layout/vault_cards_listaction.xml @@ -9,6 +9,7 @@ * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ --> + @@ -17,13 +18,12 @@ - - - My payment means - - + + + + - + \ No newline at end of file diff --git a/view/frontend/templates/customer/payment_means.phtml b/view/frontend/templates/customer/payment_means.phtml index c53b2f0..7d8fc7f 100644 --- a/view/frontend/templates/customer/payment_means.phtml +++ b/view/frontend/templates/customer/payment_means.phtml @@ -8,12 +8,163 @@ * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$means = $block->getStoredPaymentMeans(); +$hasVaultTokens = ! empty($block->getPaymentTokens()); +$accountToken = $block->getAccountToken(); +if ($accountToken): + echo $block->setTemplate('Lyranetwork_Payzen::customer/rest.phtml')->toHtml(); ?> - + +hasIdentifiers())): +?> + + + + getStoredPaymentMeans('payzen_identifier'); + + if (! empty($means)): + $card = reset($means); + ?> +
+ + + + + + + + + + + + + + + getCcTypeImageSrc($card['brand'])): ?> + + + + + + + +
escapeHtml(__('Stored Payment Methods')) ?>
escapeHtml(__('Card Number')) ?>escapeHtml(__('Expiration Date')) ?>escapeHtml(__('Type')) ?> 
escapeHtml($card['number']); ?>escapeHtml($card['expiry']); ?><?php echo $block->escapeHtml($card['brand']); ?> + escapeHtml($card['brand']); ?> +
+ getBlockHtml('formkey'); ?> + + + +
+
+
+ + + +getStoredPaymentMeans('payzen_sepa_identifier'); + +if (! empty($means)): + $card = reset($means); +?> +
- +
@@ -22,23 +173,22 @@ $means = $block->getStoredPaymentMeans(); - getCcTypeImageSrc($card['brand'])): ?> - - - - - - + + + -
escapeHtml(__('Type')); ?>
<?php echo $block->escapeHtml($card['brand']); ?> + <?php echo $block->escapeHtml($card['brand']); ?> escapeHtml($card['brand']); ?>escapeHtml($card['number']); ?> + + escapeHtml($card['brand']); ?>escapeHtml($card['number']); ?>
- getBlockHtml('formkey'); ?> + action="escapeUrl($block->getUrl('payzen/customer/cancel')); ?>" + method="post"> + getBlockHtml('formkey'); ?>
- -
escapeHtml(__('You have no stored payment means.')); ?>
\ No newline at end of file diff --git a/view/frontend/templates/customer/rest.phtml b/view/frontend/templates/customer/rest.phtml new file mode 100644 index 0000000..154f609 --- /dev/null +++ b/view/frontend/templates/customer/rest.phtml @@ -0,0 +1,14 @@ + + +
+
+
\ No newline at end of file diff --git a/view/frontend/web/css/payzen.css b/view/frontend/web/css/payzen.css index 3afc3b1..76df128 100644 --- a/view/frontend/web/css/payzen.css +++ b/view/frontend/web/css/payzen.css @@ -85,6 +85,14 @@ button.kr-popin-button { display: none !important; } +div.kr-smart-form-list-section-name { + font-weight: bold !important; +} + +div.payzen-hide-wallet-elements { + display: none !important; +} + .payzen-card { display: inline !important; } @@ -120,4 +128,4 @@ button.kr-popin-button { left: 50%; margin-top: -50px; margin-left: -100px; -} \ No newline at end of file +} diff --git a/view/frontend/web/js/view/payment/method-renderer/payzen-abstract.js b/view/frontend/web/js/view/payment/method-renderer/payzen-abstract.js index 725cbed..3267098 100644 --- a/view/frontend/web/js/view/payment/method-renderer/payzen-abstract.js +++ b/view/frontend/web/js/view/payment/method-renderer/payzen-abstract.js @@ -118,7 +118,7 @@ define( }, getPaymentMeansUrl: function() { - return url.build('payzen/customer/index'); + return url.build('vault/cards/listaction'); } }); }