diff --git a/Block/Payment/Confirm.php b/Block/Payment/Confirm.php deleted file mode 100644 index 71e291b..0000000 --- a/Block/Payment/Confirm.php +++ /dev/null @@ -1,51 +0,0 @@ -getViewFileUrl('Paynow_PaymentGateway::images/confirm-blik.png'); - } - - /** - * @return string|null - */ - public function getPaymentId(): ?string - { - return $this->getData('payment_id'); - } - - /** - * @return array|mixed|null - */ - public function getPaymentStatus(): ?string - { - return $this->getData('payment_status'); - } - - /** - * @return Phrase|null - */ - public function getPaymentStatusLabel(): ?Phrase - { - $paymentStatus = $this->getPaymentStatus(); - if ($paymentStatus) { - return __(PaymentStatusLabel::${$paymentStatus}); - } - return null; - } -} diff --git a/Controller/Checkout/Redirect.php b/Controller/Checkout/Redirect.php index 891c526..11ba7bb 100644 --- a/Controller/Checkout/Redirect.php +++ b/Controller/Checkout/Redirect.php @@ -74,7 +74,7 @@ public function execute() $redirectUrl = $order->getPayment()->getAdditionalInformation(PaymentField::REDIRECT_URL_FIELD_NAME); $paymentId = $order->getPayment()->getAdditionalInformation(PaymentField::PAYMENT_ID_FIELD_NAME); if ($redirectUrl) { - $this->logger->info( + $this->logger->debug( 'Redirecting to payment provider page', [ PaymentField::EXTERNAL_ID_FIELD_NAME => $order->getRealOrderId(), diff --git a/Controller/Checkout/Success.php b/Controller/Checkout/Success.php index f45590d..73e7428 100644 --- a/Controller/Checkout/Success.php +++ b/Controller/Checkout/Success.php @@ -5,13 +5,19 @@ use Magento\Checkout\Model\Session as CheckoutSession; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; +use Magento\Framework\App\CsrfAwareActionInterface; +use Magento\Framework\App\Request\Http; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\Result\Redirect as ResponseRedirect; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\UrlInterface; use Magento\Sales\Model\Order; use Paynow\PaymentGateway\Helper\NotificationProcessor; use Paynow\PaymentGateway\Helper\PaymentField; -use Paynow\PaymentGateway\Helper\PaymentStatusService; +use Paynow\PaymentGateway\Helper\PaymentHelper; use Paynow\PaymentGateway\Model\Logger\Logger; +use Paynow\Service\Payment; /** * Class Return @@ -39,6 +45,10 @@ class Success extends Action * @var Order */ private $order; + /** + * @var \Magento\Framework\App\RequestInterface + */ + private $request; /** * @var UrlInterface @@ -46,14 +56,14 @@ class Success extends Action protected $urlBuilder; /** - * @var NotificationProcessor + * @var PaymentHelper */ - private $notificationProcessor; + private $paymentHelper; /** - * @var PaymentStatusService + * @var NotificationProcessor */ - private $paymentStatusService; + private $notificationProcessor; /** * Redirect constructor. @@ -62,7 +72,7 @@ class Success extends Action * @param Logger $logger * @param UrlInterface $urlBuilder * @param NotificationProcessor $notificationProcessor - * @param PaymentStatusService $paymentStatusService + * @param PaymentHelper $paymentHelper */ public function __construct( Context $context, @@ -70,26 +80,25 @@ public function __construct( Logger $logger, UrlInterface $urlBuilder, NotificationProcessor $notificationProcessor, - PaymentStatusService $paymentStatusService + PaymentHelper $paymentHelper ) { parent::__construct($context); $this->checkoutSession = $checkoutSession; $this->logger = $logger; $this->redirectResult = $this->resultRedirectFactory->create(); + $this->request = $this->getRequest(); $this->urlBuilder = $urlBuilder; $this->notificationProcessor = $notificationProcessor; + $this->paymentHelper = $paymentHelper; $this->order = $this->checkoutSession->getLastRealOrder(); - $this->paymentStatusService = $paymentStatusService; } /** - * @return ResponseRedirect + * @return ResponseInterface|ResponseRedirect|ResultInterface */ - public function execute(): ResponseRedirect + public function execute() { - $isRetry = $this->order && - $this->order->getPayment() && - $this->order->getPayment()->hasAdditionalInformation(PaymentField::IS_PAYMENT_RETRY_FIELD_NAME); + $isRetry = $this->order->getPayment()->hasAdditionalInformation(PaymentField::IS_PAYMENT_RETRY_FIELD_NAME); if ($this->shouldRetrieveStatus() && ! $isRetry) { $this->retrievePaymentStatusAndUpdateOrder(); @@ -99,10 +108,6 @@ public function execute(): ResponseRedirect return $this->redirectResult; } - /** - * @param bool $forRetryPayment - * @return string - */ public function getRedirectUrl(bool $forRetryPayment): string { if ($forRetryPayment) { @@ -116,10 +121,27 @@ private function retrievePaymentStatusAndUpdateOrder() { $allPayments = $this->order->getAllPayments(); $lastPaymentId = end($allPayments)->getAdditionalInformation(PaymentField::PAYMENT_ID_FIELD_NAME); - $status = $this->paymentStatusService->getStatus($lastPaymentId); $loggerContext = [PaymentField::PAYMENT_ID_FIELD_NAME => $lastPaymentId]; + $this->logger->info( + "Retrieving payment status", + $loggerContext + ); + try { + $service = new Payment($this->paymentHelper->initializePaynowClient()); + $paymentStatusObject = $service->status($lastPaymentId); + $status = $paymentStatusObject ->getStatus(); + $this->logger->info( + "Retrieved payment status response", + array_merge( + $loggerContext, + [ + PaymentField::STATUS_FIELD_NAME => $status + ] + ) + ); $this->notificationProcessor->process($lastPaymentId, $status, $this->order->getIncrementId()); + } catch (\Exception $exception) { $this->logger->error($exception->getMessage(), $loggerContext); } diff --git a/Controller/Payment/Confirm.php b/Controller/Payment/Confirm.php deleted file mode 100644 index dc9427a..0000000 --- a/Controller/Payment/Confirm.php +++ /dev/null @@ -1,115 +0,0 @@ -pageFactory = $pageFactory; - $this->checkoutSession = $checkoutSession; - $this->logger = $logger; - $this->redirectResult = $this->resultRedirectFactory->create(); - $this->urlBuilder = $urlBuilder; - } - - public function execute() - { - $paymentData = $this->preparePaymentData(); - if ($paymentData) { - $resultPage = $this->pageFactory->create(); - $resultPage->addHandle(self::CONFIRM_BLOCK_NAME); - $paymentData = $this->preparePaymentData(); - $block = $resultPage->getLayout()->getBlock(self::CONFIRM_BLOCK_NAME); - $block->setData('payment_id', $paymentData['payment_id']); - $block->setData('payment_status', $paymentData['payment_status']); - $resultPage->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0', true); - return $resultPage; - } - - return $this->redirectResult->setUrl($this->urlBuilder->getUrl('paynow/checkout/success')); - } - - /** - * @return array - */ - private function preparePaymentData(): ?array - { - /** @var Order */ - $order = $this->checkoutSession->getLastRealOrder(); - if ($order) { - $allPayments = $order->getAllPayments(); - $lastPayment = end($allPayments); - if ($lastPayment) { - $paymentId = $lastPayment->getAdditionalInformation(PaymentField::PAYMENT_ID_FIELD_NAME); - $paymentStatus = $lastPayment->getAdditionalInformation(PaymentField::STATUS_FIELD_NAME); - - $this->logger->debug( - "Retrieved payment data from checkout session", - ["paymentId" => $paymentId, - "paymentStatus" => $paymentStatus, - "orderId" => $order->getIncrementId() - ] - ); - - return ["payment_id" => $paymentId, "payment_status" => $paymentStatus]; - } - } - return null; - } -} diff --git a/Controller/Payment/Notifications.php b/Controller/Payment/Notifications.php index 1279446..ccacad0 100644 --- a/Controller/Payment/Notifications.php +++ b/Controller/Payment/Notifications.php @@ -90,7 +90,7 @@ public function execute() { $payload = $this->getRequest()->getContent(); $notificationData = json_decode($payload, true); - $this->logger->debug("Received payment status notification", $notificationData); + $this->logger->info("Received payment status notification", $notificationData); $storeId = $this->storeManager->getStore()->getId(); $signatureKey = $this->configHelper->getSignatureKey($storeId, $this->configHelper->isTestMode($storeId)); @@ -118,7 +118,10 @@ public function execute() ); $this->getResponse()->setHttpResponseCode(400); } catch (OrderHasBeenAlreadyPaidException $exception) { - $this->logger->info($exception->getMessage() . ' Skip processing the notification.'); + $this->logger->info( + $exception->getMessage() . ' Skip processing the notification.', + $notificationData + ); $this->getResponse()->setHttpResponseCode(200); } } diff --git a/Controller/Payment/Status.php b/Controller/Payment/Status.php deleted file mode 100644 index 0bfc609..0000000 --- a/Controller/Payment/Status.php +++ /dev/null @@ -1,81 +0,0 @@ -checkoutSession = $checkoutSession; - $this->resultJsonFactory = $resultJsonFactory; - $this->paymentStatusService = $paymentStatusService; - } - - public function execute() - { - $resultJson = $this->resultJsonFactory->create(); - - /** @var Order */ - $order = $this->checkoutSession->getLastRealOrder(); - if (!$order) { - return $resultJson->setStatusHeader(404, null, 'Not Found'); - } - $allPayments = $order->getAllPayments(); - $lastPaymentId = end($allPayments)->getAdditionalInformation(PaymentField::PAYMENT_ID_FIELD_NAME); - $status = $this->paymentStatusService->getStatus($lastPaymentId); - - if ($status) { - return $resultJson->setData([ - 'paymentId' => $lastPaymentId, - 'payment_status' => $status, - 'payment_status_label' => __(PaymentStatusLabel::${$status}) - ]); - } - - return $resultJson->setStatusHeader(404, null, 'Not Found'); - } -} diff --git a/Gateway/Http/Client/PaymentAuthorization.php b/Gateway/Http/Client/PaymentAuthorization.php index da45471..b1aa5d3 100644 --- a/Gateway/Http/Client/PaymentAuthorization.php +++ b/Gateway/Http/Client/PaymentAuthorization.php @@ -48,14 +48,13 @@ public function placeRequest(TransferInterface $transferObject) $loggerContext = [ PaymentField::EXTERNAL_ID_FIELD_NAME => $transferObject->getBody()[PaymentField::EXTERNAL_ID_FIELD_NAME] ]; - try { $service = new Payment($this->client); $apiResponseObject = $service->authorize( $transferObject->getBody(), $transferObject->getHeaders()[PaymentField::IDEMPOTENCY_KEY_FIELD_NAME] ); - $this->logger->debug( + $this->logger->info( "Retrieved authorization response", array_merge($loggerContext, [ PaymentField::STATUS_FIELD_NAME => $apiResponseObject->getStatus(), @@ -66,19 +65,22 @@ public function placeRequest(TransferInterface $transferObject) PaymentField::REDIRECT_URL_FIELD_NAME => $apiResponseObject->getRedirectUrl(), PaymentField::STATUS_FIELD_NAME => $apiResponseObject->getStatus(), PaymentField::PAYMENT_ID_FIELD_NAME => $apiResponseObject->getPaymentId(), + PaymentField::EXTERNAL_ID_FIELD_NAME => $transferObject->getBody()[PaymentField::EXTERNAL_ID_FIELD_NAME] ]; } catch (PaynowException $exception) { $this->logger->error( - $exception->getMessage(), + 'An error occurred during payment authorization', array_merge($loggerContext, [ 'service' => 'Payment', - 'action' => 'authorize' + 'action' => 'authorize', + 'message' => $exception->getMessage(), + 'errors' => $exception->getPrevious()->getErrors() ]) ); foreach ($exception->getErrors() as $error) { $this->logger->debug($error->getType() . ' - ' . $error->getMessage(), $loggerContext); } - return ['errors' => $exception->getErrors()]; + return $response['errors'] = $exception->getErrors(); } } } diff --git a/Gateway/Http/Client/PaymentCapture.php b/Gateway/Http/Client/PaymentCapture.php index ff8a0c7..4e275ff 100644 --- a/Gateway/Http/Client/PaymentCapture.php +++ b/Gateway/Http/Client/PaymentCapture.php @@ -49,19 +49,24 @@ public function placeRequest(TransferInterface $transferObject) PaymentField::STATUS_FIELD_NAME => $apiResponseObject->getStatus(), PaymentField::PAYMENT_ID_FIELD_NAME => $apiResponseObject->getPaymentId(), ]; - $this->logger->debug( + $this->logger->info( "Retrieved capture response", array_merge($loggerContext, $response) ); } catch (PaynowException $exception) { $response['errors'] = $exception->getMessage(); - $this->logger->error($exception->getMessage(), array_merge( - $loggerContext, - [ - 'service' => 'Payment', - 'action' => 'status' - ] - )); + $this->logger->error( + 'An error occurred during payment capture', + array_merge( + $loggerContext, + [ + 'service' => 'Payment', + 'action' => 'status', + 'message' => $exception->getMessage(), + 'errors' => $exception->getPrevious()->getErrors() + ] + ) + ); } return $response; diff --git a/Gateway/Http/Client/PaymentRefund.php b/Gateway/Http/Client/PaymentRefund.php index 2c84d00..7cab967 100644 --- a/Gateway/Http/Client/PaymentRefund.php +++ b/Gateway/Http/Client/PaymentRefund.php @@ -49,15 +49,21 @@ public function placeRequest(TransferInterface $transferObject) $loggerContext = [ PaymentField::EXTERNAL_ID_FIELD_NAME => $transferObject->getBody()[PaymentField::EXTERNAL_ID_FIELD_NAME] ]; + $data = $transferObject->getBody(); + $this->logger->info( + "Processing create refund", + array_merge($loggerContext, [ + PaymentField::PAYMENT_ID_FIELD_NAME => $data[PaymentField::PAYMENT_ID_FIELD_NAME], + RefundField::AMOUNT_FIELD_NAME => $data[RefundField::AMOUNT_FIELD_NAME] + ]) + ); try { - $service = new Refund($this->client); - $data = $transferObject->getBody(); - $apiResponseObject = $service->create( + $apiResponseObject = (new Refund($this->client))->create( $data[PaymentField::PAYMENT_ID_FIELD_NAME], $transferObject->getHeaders()[PaymentField::IDEMPOTENCY_KEY_FIELD_NAME], $data[RefundField::AMOUNT_FIELD_NAME] ); - $this->logger->debug( + $this->logger->info( "Retrieved create refund response", array_merge($loggerContext, [ RefundField::STATUS_FIELD_NAME => $apiResponseObject->getStatus(), @@ -71,10 +77,12 @@ public function placeRequest(TransferInterface $transferObject) ]; } catch (PaynowException $exception) { $this->logger->error( - $exception->getMessage(), + 'An error occurred during refund create', array_merge($loggerContext, [ 'service' => 'Refund', - 'action' => 'create' + 'action' => 'create', + 'message' => $exception->getMessage(), + 'errors' => $exception->getPrevious()->getErrors() ]) ); foreach ($exception->getErrors() as $error) { diff --git a/Gateway/Request/Payment/AuthorizeRequest.php b/Gateway/Request/Payment/AuthorizeRequest.php index c4737d7..016f91f 100644 --- a/Gateway/Request/Payment/AuthorizeRequest.php +++ b/Gateway/Request/Payment/AuthorizeRequest.php @@ -80,14 +80,8 @@ public function build(array $buildSubject) } } - if ($this->payment->hasAdditionalInformation(PaymentDataAssignObserver::BLIK_CODE) - && ! empty($this->payment->getAdditionalInformation(PaymentDataAssignObserver::BLIK_CODE))) { - $request['body'][PaymentField::AUTHORIZATION_CODE] = $this->payment - ->getAdditionalInformation(PaymentDataAssignObserver::BLIK_CODE); - } - $request['headers'] = [ - PaymentField::IDEMPOTENCY_KEY_FIELD_NAME => uniqid(substr($referenceId, 0, 22), true) + PaymentField::IDEMPOTENCY_KEY_FIELD_NAME => uniqid($referenceId, true) ]; return $request; diff --git a/Gateway/Request/Refund/RefundRequest.php b/Gateway/Request/Refund/RefundRequest.php index 3a44d33..f540346 100644 --- a/Gateway/Request/Refund/RefundRequest.php +++ b/Gateway/Request/Refund/RefundRequest.php @@ -46,7 +46,7 @@ public function build(array $buildSubject) ]; $request['headers'] = [ - PaymentField::IDEMPOTENCY_KEY_FIELD_NAME => uniqid(substr($referenceId, 0, 22), true) + PaymentField::IDEMPOTENCY_KEY_FIELD_NAME => uniqid($referenceId, true) ]; return $request; diff --git a/Gateway/Validator/Payment/AuthorizationValidator.php b/Gateway/Validator/Payment/AuthorizationValidator.php index 574d539..59b97b3 100644 --- a/Gateway/Validator/Payment/AuthorizationValidator.php +++ b/Gateway/Validator/Payment/AuthorizationValidator.php @@ -9,7 +9,6 @@ use Paynow\Model\Payment\Status; use Paynow\PaymentGateway\Helper\PaymentField; use Paynow\PaymentGateway\Model\Logger\Logger; -use Paynow\PaymentGateway\Observer\PaymentDataAssignObserver; /** * Class PaymentAuthorizationValidator @@ -38,33 +37,24 @@ public function __construct(ResultInterfaceFactory $resultFactory, Logger $logge * @param array $validationSubject * @return ResultInterface */ - public function validate(array $validationSubject): ResultInterface + public function validate(array $validationSubject) { $response = SubjectReader::readResponse($validationSubject); - $payment = SubjectReader::readPayment($validationSubject); - - $isWhiteLabelPayment = $payment->getPayment()->hasAdditionalInformation(PaymentDataAssignObserver::BLIK_CODE) - && ! empty($payment->getPayment()->getAdditionalInformation(PaymentDataAssignObserver::BLIK_CODE)); - $isResponseValid = array_key_exists(PaymentField::PAYMENT_ID_FIELD_NAME, $response) && + array_key_exists(PaymentField::REDIRECT_URL_FIELD_NAME, $response) && array_key_exists(PaymentField::STATUS_FIELD_NAME, $response) && - in_array($response[PaymentField::STATUS_FIELD_NAME], [ - Status::STATUS_NEW, - Status::STATUS_PENDING - ]); + $response[PaymentField::STATUS_FIELD_NAME] === Status::STATUS_NEW; - if (! $isWhiteLabelPayment) { - $isResponseValid= $isResponseValid && - array_key_exists(PaymentField::REDIRECT_URL_FIELD_NAME, $response) && - ! empty($response[PaymentField::REDIRECT_URL_FIELD_NAME]); - } - - $this->logger->debug("Validating authorization response", ['valid' => $isResponseValid]); + $this->logger->debug("Validating authorization response", [ + PaymentField::EXTERNAL_ID_FIELD_NAME => $response[PaymentField::EXTERNAL_ID_FIELD_NAME], + PaymentField::PAYMENT_ID_FIELD_NAME => $response[PaymentField::PAYMENT_ID_FIELD_NAME], + PaymentField::STATUS_FIELD_NAME => $response[PaymentField::STATUS_FIELD_NAME], + 'valid' => $isResponseValid + ]); return $this->createResult( $isResponseValid, - $isResponseValid ? [] : [__('Error occurred during the payment process.')], - $isResponseValid || !$isWhiteLabelPayment ? [] : [$response['errors'][0]->getType()] + $isResponseValid ? [] : [__('Error occurred during the payment process.')] ); } } diff --git a/Gateway/Validator/Payment/CaptureValidator.php b/Gateway/Validator/Payment/CaptureValidator.php index 1c727a7..6f92888 100644 --- a/Gateway/Validator/Payment/CaptureValidator.php +++ b/Gateway/Validator/Payment/CaptureValidator.php @@ -40,19 +40,28 @@ public function __construct(ResultInterfaceFactory $resultFactory, Logger $logge public function validate(array $validationSubject) { $response = SubjectReader::readResponse($validationSubject); - $isResponseValid = array_key_exists(PaymentField::PAYMENT_ID_FIELD_NAME, $response) && - array_key_exists(PaymentField::STATUS_FIELD_NAME, $response) && - $response[PaymentField::STATUS_FIELD_NAME] === Status::STATUS_CONFIRMED; - $this->logger->debug( + $this->logger->info( "Validating capture response", [ - 'valid' => $isResponseValid, 'paymentId' => $response[PaymentField::PAYMENT_ID_FIELD_NAME], 'status' => $response[PaymentField::STATUS_FIELD_NAME] ] ); + $isResponseValid = array_key_exists(PaymentField::PAYMENT_ID_FIELD_NAME, $response) && + array_key_exists(PaymentField::STATUS_FIELD_NAME, $response) && + $response[PaymentField::STATUS_FIELD_NAME] === Status::STATUS_CONFIRMED; + + $this->logger->info( + "Capture response has been validated", + [ + PaymentField::PAYMENT_ID_FIELD_NAME => $response[PaymentField::PAYMENT_ID_FIELD_NAME], + PaymentField::STATUS_FIELD_NAME => $response[PaymentField::STATUS_FIELD_NAME], + 'valid' => $isResponseValid, + ] + ); + return $this->createResult( $isResponseValid, $isResponseValid ? [] : [__('Error occurred during the capture process.')] diff --git a/Gateway/Validator/Refund/RefundValidator.php b/Gateway/Validator/Refund/RefundValidator.php index e45401a..ec4f87e 100644 --- a/Gateway/Validator/Refund/RefundValidator.php +++ b/Gateway/Validator/Refund/RefundValidator.php @@ -40,11 +40,26 @@ public function __construct(ResultInterfaceFactory $resultFactory, Logger $logge public function validate(array $validationSubject) { $response = SubjectReader::readResponse($validationSubject); + $this->logger->info( + "Validating refund response", + [ + RefundField::REFUND_ID_FIELD_NAME => $response[RefundField::REFUND_ID_FIELD_NAME], + RefundField::STATUS_FIELD_NAME => $response[RefundField::STATUS_FIELD_NAME], + ] + ); + $isResponseValid = array_key_exists(RefundField::REFUND_ID_FIELD_NAME, $response) && array_key_exists(RefundField::STATUS_FIELD_NAME, $response) && $response[RefundField::STATUS_FIELD_NAME] === Status::STATUS_PENDING; - $this->logger->debug("Validating refund response", ['valid' => $isResponseValid]); + $this->logger->info( + "Refund response has been validated", + [ + RefundField::REFUND_ID_FIELD_NAME => $response[RefundField::REFUND_ID_FIELD_NAME], + RefundField::STATUS_FIELD_NAME => $response[RefundField::STATUS_FIELD_NAME], + 'valid' => $isResponseValid + ] + ); return $this->createResult( $isResponseValid, diff --git a/Helper/GDPRHelper.php b/Helper/GDPRHelper.php deleted file mode 100644 index cadb769..0000000 --- a/Helper/GDPRHelper.php +++ /dev/null @@ -1,119 +0,0 @@ -paymentHelper = $paymentHelper; - $this->logger = $logger; - $this->cache = $cache; - $this->serializer = $serializer; - $this->client = $this->paymentHelper->initializePaynowClient(); - } - - /** - * @return array - */ - public function getNotices(): array - { - $cacheKey = GDPRNoticesCache::TYPE_IDENTIFIER . '-' . $this->paymentHelper->getStoreLocale(); - $cacheTag = GDPRNoticesCache::CACHE_TAG; - $notices = []; - $gdpr_notices = $this->cache->load($cacheKey); - if (!$gdpr_notices) { - $gdpr_notices = $this->retrieve(); - foreach ($gdpr_notices as $notice) { - $notices[] = [ - 'title' => $notice->getTitle(), - 'content' => $notice->getContent() - ]; - } - $this->cache->save( - $this->serializer->serialize($notices), - $cacheKey, - [$cacheTag], - 1440 - ); - } else { - $this->logger->info("Retrieving GDPR notices from cache"); - $unserialized = $this->serializer->unserialize($gdpr_notices); - if ($unserialized) { - foreach ($unserialized as $notice) { - $notices[] = [ - 'title' => $notice["title"], - 'content' => $notice["content"] - ]; - } - } - } - - return $notices; - } - - /** - * @return array|null - */ - private function retrieve(): ?array - { - try { - $this->logger->info("Retrieving GDPR notices"); - return (new DataProcessing($this->client)) - ->getNotices($this->paymentHelper->getStoreLocale()) - ->getAll(); - } catch (PaynowException $exception) { - $this->logger->error($exception->getMessage()); - } - - return null; - } -} diff --git a/Helper/NotificationProcessor.php b/Helper/NotificationProcessor.php index 873a20b..0f606c9 100644 --- a/Helper/NotificationProcessor.php +++ b/Helper/NotificationProcessor.php @@ -72,9 +72,11 @@ public function __construct( public function process($paymentId, $status, $externalId) { $this->loggerContext = [ + PaymentField::EXTERNAL_ID_FIELD_NAME => $externalId, PaymentField::PAYMENT_ID_FIELD_NAME => $paymentId, - PaymentField::EXTERNAL_ID_FIELD_NAME => $externalId + PaymentField::STATUS_FIELD_NAME => $status ]; + $this->logger->info("Processing payment status notification", $this->loggerContext); /** @var Order */ $this->order = $this->orderFactory->create()->loadByIncrementId($externalId); @@ -86,8 +88,17 @@ public function process($paymentId, $status, $externalId) $orderPaymentStatus = $paymentAdditionalInformation[PaymentField::STATUS_FIELD_NAME]; $finalPaymentStatus = $orderPaymentStatus == Status::STATUS_CONFIRMED; + $this->logger->debug( + "Current order state", + array_merge( + [ + 'currentStatus' => $orderPaymentStatus + ], + $this->loggerContext + ) + ); + if ($finalPaymentStatus) { - $this->logger->info('Order has paid status. Skipped notification processing', $this->loggerContext); throw new OrderHasBeenAlreadyPaidException($externalId, $paymentId); } @@ -121,6 +132,7 @@ public function process($paymentId, $status, $externalId) break; } $this->orderRepository->save($this->order); + $this->logger->info("Finished processing payment status notification", $this->loggerContext); } private function paymentNew($paymentId) @@ -203,7 +215,7 @@ private function paymentRejected() $this->order->addCommentToStatusHistory($message); } - $this->order->getPayment()->setIsClosed(true); + $this->order->getPayment()->setIsClosed(true); } /** @@ -241,6 +253,7 @@ private function isCorrectStatus($previousStatus, $nextStatus): bool { $paymentStatusFlow = [ Status::STATUS_NEW => [ + Status::STATUS_NEW, Status::STATUS_PENDING, Status::STATUS_ERROR, Status::STATUS_EXPIRED, diff --git a/Helper/PaymentField.php b/Helper/PaymentField.php index e3a563c..c56ef5c 100644 --- a/Helper/PaymentField.php +++ b/Helper/PaymentField.php @@ -27,5 +27,4 @@ class PaymentField const STATUS_FIELD_NAME = 'status'; const ORDER_ITEMS = 'orderItems'; const VALIDITY_TIME = 'validityTime'; - const AUTHORIZATION_CODE = 'authorizationCode'; } diff --git a/Helper/PaymentStatusLabel.php b/Helper/PaymentStatusLabel.php deleted file mode 100644 index 8f9654a..0000000 --- a/Helper/PaymentStatusLabel.php +++ /dev/null @@ -1,19 +0,0 @@ -logger = $logger; - $this->paymentHelper = $paymentHelper; - } - - /** - * @param $paymentId - * @return string|void - */ - public function getStatus($paymentId) - { - $loggerContext = [PaymentField::PAYMENT_ID_FIELD_NAME => $paymentId]; - - try { - $paymentStatusObject = (new Payment($this->paymentHelper->initializePaynowClient()))->status($paymentId); - $status = $paymentStatusObject->getStatus(); - $this->logger->debug( - "Retrieved status response", - array_merge($loggerContext, ['status' => $status]) - ); - - return $status; - } catch (\Exception $exception) { - $this->logger->error($exception->getMessage(), $loggerContext); - } - } -} diff --git a/Model/Cache/GDPRNoticesCache.php b/Model/Cache/GDPRNoticesCache.php deleted file mode 100644 index ff53933..0000000 --- a/Model/Cache/GDPRNoticesCache.php +++ /dev/null @@ -1,25 +0,0 @@ -get(self::TYPE_IDENTIFIER), self::CACHE_TAG); - } -} diff --git a/Model/Exception/OrderHasBeenAlreadyPaidException.php b/Model/Exception/OrderHasBeenAlreadyPaidException.php index d3f9198..49d5bf9 100644 --- a/Model/Exception/OrderHasBeenAlreadyPaidException.php +++ b/Model/Exception/OrderHasBeenAlreadyPaidException.php @@ -11,7 +11,7 @@ */ class OrderHasBeenAlreadyPaidException extends Exception { - const EXCEPTION_MESSAGE = 'Order %s has been already paid in %s.'; + const EXCEPTION_MESSAGE = 'An order %s has been already paid in %s.'; public function __construct($orderId, $paymentId) { diff --git a/Model/Ui/BlikConfigProvider.php b/Model/Ui/BlikConfigProvider.php index 37bcc57..cf4992e 100644 --- a/Model/Ui/BlikConfigProvider.php +++ b/Model/Ui/BlikConfigProvider.php @@ -3,7 +3,6 @@ namespace Paynow\PaymentGateway\Model\Ui; use Magento\Checkout\Model\ConfigProviderInterface; -use Paynow\Model\PaymentMethods\AuthorizationType; /** * Class ConfigProvider @@ -29,8 +28,6 @@ public function getConfig(): array && $this->configHelper->isBlikActive() && $blikPaymentMethod && $blikPaymentMethod->isEnabled(); - $GDPRNotices = $this->GDPRHelper->getNotices(); - $isWhiteLabel = $blikPaymentMethod && $blikPaymentMethod->getAuthorizationType() === AuthorizationType::CODE; return [ 'payment' => [ @@ -38,10 +35,7 @@ public function getConfig(): array 'isActive' => $isActive, 'logoPath' => $blikPaymentMethod ? $blikPaymentMethod->getImage() : null, 'redirectUrl' => $this->getRedirectUrl(), - 'paymentMethodId' => $blikPaymentMethod ? $blikPaymentMethod->getId(): null, - 'GDPRNotices' => $GDPRNotices, - 'isWhiteLabel' => $isWhiteLabel, - 'blikConfirmUrl' => $this->getConfirmBlikUrl() + 'paymentMethodId' => $blikPaymentMethod ? $blikPaymentMethod->getId(): null ] ] ]; diff --git a/Model/Ui/ConfigProvider.php b/Model/Ui/ConfigProvider.php index b0c6874..5278172 100644 --- a/Model/Ui/ConfigProvider.php +++ b/Model/Ui/ConfigProvider.php @@ -6,7 +6,6 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\UrlInterface; use Paynow\PaymentGateway\Helper\ConfigHelper; -use Paynow\PaymentGateway\Helper\GDPRHelper; use Paynow\PaymentGateway\Helper\PaymentHelper; use Paynow\PaymentGateway\Helper\PaymentMethodsHelper; @@ -44,11 +43,6 @@ class ConfigProvider */ protected $paymentMethodsHelper; - /** - * @var GDPRHelper - */ - protected $GDPRHelper; - /** * @var CheckoutSession */ @@ -59,7 +53,6 @@ public function __construct( RequestInterface $request, PaymentHelper $paymentHelper, PaymentMethodsHelper $paymentMethodsHelper, - GDPRHelper $GDPRHelper, ConfigHelper $configHelper, CheckoutSession $checkoutSession ) { @@ -69,7 +62,6 @@ public function __construct( $this->paymentMethodsHelper = $paymentMethodsHelper; $this->configHelper = $configHelper; $this->checkoutSession = $checkoutSession; - $this->GDPRHelper = $GDPRHelper; } /** @@ -81,15 +73,6 @@ protected function getRedirectUrl() return $this->urlBuilder->getUrl('paynow/checkout/redirect', ['_secure' => $this->getRequest()->isSecure()]); } - /** - * Return url for BLIK confirmation page - * @return string - */ - protected function getConfirmBlikUrl(): string - { - return $this->urlBuilder->getUrl('paynow/payment/confirm', ['_secure' => $this->getRequest()->isSecure()]); - } - /** * Retrieve request object * @return RequestInterface diff --git a/Observer/PaymentDataAssignObserver.php b/Observer/PaymentDataAssignObserver.php index bcf52e4..69ecbab 100644 --- a/Observer/PaymentDataAssignObserver.php +++ b/Observer/PaymentDataAssignObserver.php @@ -15,14 +15,11 @@ class PaymentDataAssignObserver extends AbstractDataAssignObserver { const PAYMENT_METHOD_ID = 'payment_method_id'; - const BLIK_CODE = 'blik_code'; - /** * @var array */ protected $additionalInformationList = [ - self::PAYMENT_METHOD_ID, - self::BLIK_CODE + self::PAYMENT_METHOD_ID ]; /** diff --git a/Test/Unit/Gateway/Response/Payment/AuthorizationHandlerTest.php b/Test/Unit/Gateway/Response/Payment/AuthorizationHandlerTest.php index 044e816..497af8e 100644 --- a/Test/Unit/Gateway/Response/Payment/AuthorizationHandlerTest.php +++ b/Test/Unit/Gateway/Response/Payment/AuthorizationHandlerTest.php @@ -34,6 +34,7 @@ public function testHandle() PaymentField::PAYMENT_ID_FIELD_NAME => 'testPaymentId', PaymentField::STATUS_FIELD_NAME => 'NEW', PaymentField::REDIRECT_URL_FIELD_NAME => 'testRedirectUrl', + PaymentField::EXTERNAL_ID_FIELD_NAME => 'testExternalId', ]; $paymentDO->expects(static::atLeastOnce()) diff --git a/Test/Unit/Gateway/Validator/Payment/AuthorizationValidatorTest.php b/Test/Unit/Gateway/Validator/Payment/AuthorizationValidatorTest.php index 6240a4b..be0279a 100644 --- a/Test/Unit/Gateway/Validator/Payment/AuthorizationValidatorTest.php +++ b/Test/Unit/Gateway/Validator/Payment/AuthorizationValidatorTest.php @@ -3,15 +3,11 @@ namespace Paynow\PaymentGateway\Test\Unit\Gateway\Validator\Payment; use Magento\Framework\Phrase; -use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; use Magento\Payment\Gateway\Validator\Result; use Magento\Payment\Gateway\Validator\ResultInterface; use Magento\Payment\Gateway\Validator\ResultInterfaceFactory; -use Magento\Sales\Model\Order\Payment; -use Paynow\Exception\Error; use Paynow\PaymentGateway\Gateway\Validator\Payment\AuthorizationValidator; use Paynow\PaymentGateway\Helper\PaymentField; -use Paynow\PaymentGateway\Observer\PaymentDataAssignObserver; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -74,7 +70,7 @@ public function testValidateReadResponseException() * * @dataProvider dataProviderTestValidate */ - public function testValidate(array $validationSubject, $isValid, $messages, $messageCodes) + public function testValidate(array $validationSubject, $isValid, $messages) { /** @var ResultInterface|MockObject $result */ $result = new Result($isValid, $messages); @@ -84,7 +80,7 @@ public function testValidate(array $validationSubject, $isValid, $messages, $mes [ 'isValid' => $isValid, 'failsDescription' => $messages, - 'errorCodes' => $messageCodes + 'errorCodes' => [] ] ) ->willReturn($result); @@ -99,97 +95,32 @@ public function testValidate(array $validationSubject, $isValid, $messages, $mes */ public function dataProviderTestValidate() { - $error = $this->getMockBuilder(Error::class) - ->disableOriginalConstructor() - ->getMock(); - - $error - ->expects($this->any()) - ->method('getType') - ->willReturn('WRONG_BLIK_CODE'); - return [ [ 'validationSubject' => [ 'response' => [ PaymentField::PAYMENT_ID_FIELD_NAME => 'testPaymentId', PaymentField::STATUS_FIELD_NAME => 'NEW', - PaymentField::REDIRECT_URL_FIELD_NAME => 'testRedirectUrl' - ], - 'payment' => $this->getPaymentDataObject('') - ], - 'isValid' => true, - [], - [] - ], - [ - 'validationSubject' => [ - 'response' => [ - PaymentField::PAYMENT_ID_FIELD_NAME => 'testPaymentId', - PaymentField::STATUS_FIELD_NAME => 'NEW' + PaymentField::REDIRECT_URL_FIELD_NAME => 'testRedirectUrl', + PaymentField::EXTERNAL_ID_FIELD_NAME => 'testExternalId' ], - 'payment' => $this->getPaymentDataObject('111111') ], 'isValid' => true, - [], [] ], [ 'validationSubject' => [ 'response' => [ PaymentField::PAYMENT_ID_FIELD_NAME => 'testPaymentId', - PaymentField::STATUS_FIELD_NAME => 'NEW' - ], - 'payment' => $this->getPaymentDataObject('') - ], - 'isValid' => false, - [ - __('Error occurred during the payment process.') - ], - [] - ], - [ - 'validationSubject' => [ - 'response' => [ - 'errors' => [$error] - ], - 'payment' => $this->getPaymentDataObject('123123') + PaymentField::STATUS_FIELD_NAME => 'NEW', + PaymentField::EXTERNAL_ID_FIELD_NAME => 'testExternalId' + ] ], 'isValid' => false, [ __('Error occurred during the payment process.') - ], - ['WRONG_BLIK_CODE'] + ] ] ]; } - - private function getPaymentDataObject($blikCode) - { - $paymentInfo = $this->getMockBuilder(Payment::class) - ->disableOriginalConstructor() - ->getMock(); - - $paymentInfo - ->expects($this->any()) - ->method('getAdditionalInformation') - ->willReturn([PaymentDataAssignObserver::BLIK_CODE => $blikCode]); - - $paymentInfo - ->expects($this->any()) - ->method('hasAdditionalInformation') - ->with(PaymentDataAssignObserver::BLIK_CODE) - ->willReturn(boolval($blikCode)); - - $paymentDO = $this->getMockBuilder(PaymentDataObjectInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $paymentDO - ->expects($this->any()) - ->method('getPayment') - ->willReturn($paymentInfo); - - return $paymentDO; - } } diff --git a/composer.json b/composer.json index 0949b2e..77c2a51 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "pay-now/paynow-magento2", "description": "Module for Paynow payments", "type": "magento2-module", - "version": "1.2.0", + "version": "1.1.2", "license": "MIT", "keywords": [ "paynow", @@ -24,7 +24,7 @@ "magento/module-payment": ">=100.2", "magento/module-sales": ">=101", "nyholm/psr7": "^1.2", - "pay-now/paynow-php-sdk": "^2.2", + "pay-now/paynow-php-sdk": "^2.1.3", "php": ">=7.1", "php-http/curl-client": "^2.1", "ext-json": "*" diff --git a/etc/cache.xml b/etc/cache.xml deleted file mode 100644 index f80289c..0000000 --- a/etc/cache.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - Paynow GDPR notices cache. - - \ No newline at end of file diff --git a/etc/di.xml b/etc/di.xml index 9f37900..8c0aa7c 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -48,7 +48,6 @@ Paynow\PaymentGateway\Gateway\Http\Client\PaymentAuthorization Paynow\PaymentGateway\Gateway\Response\Payment\AuthorizationHandler Paynow\PaymentGateway\Gateway\Validator\Payment\AuthorizationValidator - Paynow\PaymentGateway\Gateway\ErrorMapper\VirtualErrorMessageMapper @@ -142,21 +141,4 @@ - - - - - error_mapping.xml - - - - - Paynow\PaymentGateway\Gateway\ErrorMapper\VirtualConfigReader - - - - - Paynow\PaymentGateway\Gateway\ErrorMapper\VirtualMappingData - - \ No newline at end of file diff --git a/etc/error_mapping.xml b/etc/error_mapping.xml deleted file mode 100644 index 6b34adb..0000000 --- a/etc/error_mapping.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - Wrong BLIK code - BLIK code has expired - BLIK code already used - - \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index 9c3826c..5f8deb7 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,7 +1,7 @@ - + diff --git a/i18n/pl_PL.csv b/i18n/pl_PL.csv index 89b8017..e87acef 100644 --- a/i18n/pl_PL.csv +++ b/i18n/pl_PL.csv @@ -55,19 +55,4 @@ Information,Informacje "Your payment has been completed.", "Twoja płatnośc zakończyła się sukcesem." "Use the button below to retry payment:", "Użyj poniższego przycisku, aby ponowić próbę płatności:" "Your payment has been expired.", "Twoja płatność wygasła." -"New payment created for order. Transaction ID: ", "Utworzono nową płatność dla zamówienia. ID transakcji: " -"Confirm the payment using the app on your phone.", "Potwierdź płatność w swojej aplikacji bankowej." -"Your payment ID: ", "Numer płatności: " -"Current payment status: ", "Status płatności: " -"processing", "w trakcie realizacji" -"expired", "przeterminowana" -"succeeded", "zrealizowana" -"failed", "nieudana" -"rejected", "odrzucona" -"abandoned", "porzucona" -"Enter the BLIK code", "Wprowadź kod BLIK" -" Read more", " Czytaj więcej" -"Wrong BLIK code", "Nieprawidłowy kod BLIK" -"BLIK code has expired", "Kod BLIK jest nieaktualny" -"BLIK code already used", "Kod BLIK był wcześniej wykorzystany" - +"New payment created for order. Transaction ID: ", "Utworzono nową płatność dla zamówienia. ID transakcji: " \ No newline at end of file diff --git a/view/frontend/layout/paynow_payment_confirm.xml b/view/frontend/layout/paynow_payment_confirm.xml deleted file mode 100644 index c03914e..0000000 --- a/view/frontend/layout/paynow_payment_confirm.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/view/frontend/templates/onepage/success_message_button.phtml b/view/frontend/templates/onepage/success_message_button.phtml index 7ba2e22..60d9b62 100644 --- a/view/frontend/templates/onepage/success_message_button.phtml +++ b/view/frontend/templates/onepage/success_message_button.phtml @@ -5,7 +5,7 @@ if ($block->getPaymentStatusPhrase()) : ?>

escapeHtml($block->getPaymentStatusPhrase()); ?>

canRetryPayment()) : ?> -

escapeHtml(__('Use the button below to retry payment:')); ?>

+

escapeHtml(__('Use the button below to retry payment')); ?>

escapeHtml(__('Retry payment')); ?> diff --git a/view/frontend/templates/payment/blik/confirm.phtml b/view/frontend/templates/payment/blik/confirm.phtml deleted file mode 100644 index 008ef71..0000000 --- a/view/frontend/templates/payment/blik/confirm.phtml +++ /dev/null @@ -1,38 +0,0 @@ - -
-

escapeHtml(__('Confirm the payment using the app on your phone.')) ?>

- -
-

- escapeHtml(__('Your payment ID: ')) ?> - - escapeHtml($block->getPaymentId()) ?> - -

-

- escapeHtml(__('Current payment status: ')) ?> - - escapeHtml($block->getPaymentStatusLabel()); ?> - -

-
-
- - diff --git a/view/frontend/web/css/checkout.css b/view/frontend/web/css/checkout.css index f6c634f..6093032 100644 --- a/view/frontend/web/css/checkout.css +++ b/view/frontend/web/css/checkout.css @@ -46,46 +46,4 @@ .paynow-payment-option.disabled div { cursor: not-allowed; -} - -.paynow-payment-option-blik { - padding: 1rem; -} - -.paynow-payment-option-blik .paynow-data-processing-info { - margin-top: 1rem; -} - -.paynow-payment-option-blik label { - display: inline-block; - text-align: left; - font-weight: 700; - margin-right: 2rem; -} - -.paynow-payment-option-blik input[type=text] { - letter-spacing: 10px; - display: inline-block; - width: 150px; - text-align: center; - padding: 1.75rem; - background: #f6f6f6; -} - -.paynow-data-processing-info { - color: #797979; - text-align: justify; -} - -.payment-form .paynow-data-processing-info { - font-size: 0.7rem; -} - -.paynow-data-processing-info ul { - list-style-type: lower-alpha; - margin: 0 1rem; -} - -.paynow-data-processing-info .expand { - cursor: pointer; } \ No newline at end of file diff --git a/view/frontend/web/css/confirm_blik.css b/view/frontend/web/css/confirm_blik.css deleted file mode 100644 index f7196f7..0000000 --- a/view/frontend/web/css/confirm_blik.css +++ /dev/null @@ -1,16 +0,0 @@ -.paynow-confirm-blik { - text-align: center; - background: #fff; - padding: 1.5rem; - margin-bottom: 1rem; -} - -.paynow-confirm-blik img { - max-width: 35%; -} - -.paynow-confirm-blik .headline { - font-size: 1.8125rem; - color: #232323; - font-weight: 700; -} \ No newline at end of file diff --git a/view/frontend/web/images/confirm-blik.png b/view/frontend/web/images/confirm-blik.png deleted file mode 100644 index 93f59ef..0000000 Binary files a/view/frontend/web/images/confirm-blik.png and /dev/null differ diff --git a/view/frontend/web/js/view/payment/paynow_blik_gateway.js b/view/frontend/web/js/view/payment/paynow_blik_gateway.js index 57c9838..0ee79aa 100644 --- a/view/frontend/web/js/view/payment/paynow_blik_gateway.js +++ b/view/frontend/web/js/view/payment/paynow_blik_gateway.js @@ -1,7 +1,6 @@ define( [ 'jquery', - 'ko', 'Magento_Checkout/js/view/payment/default', 'Magento_Checkout/js/model/url-builder', 'Magento_Checkout/js/action/place-order', @@ -9,11 +8,10 @@ define( 'Magento_Customer/js/model/customer', 'Magento_Checkout/js/checkout-data', 'Magento_Checkout/js/model/payment/additional-validators', - 'mage/url' + 'mage/url', ], function ( $, - ko, Component, urlBuilder, placeOrderAction, @@ -29,7 +27,6 @@ define( template: 'Paynow_PaymentGateway/payment/paynow_blik_gateway', paymentMethodId: null }, - blikCodeValue: ko.observable(''), getCode: function () { return 'paynow_blik_gateway'; }, @@ -48,9 +45,9 @@ define( if (emailValidationResult && this.validate() && additionalValidators.validate()) { this.isPlaceOrderActionAllowed(false); placeOrder = placeOrderAction(this.getData(), false, this.messageContainer); + $.when(placeOrder).fail(function () { self.isPlaceOrderActionAllowed(true); - self.blikCodeValue(''); }).done(this.afterPlaceOrder.bind(this)); return true; } @@ -63,33 +60,19 @@ define( return true; }, afterPlaceOrder: function () { - if(this.isWhiteLabelEnabled()){ - window.location.replace(window.checkoutConfig.payment.paynow_blik_gateway.blikConfirmUrl); - } else { - window.location.replace(window.checkoutConfig.payment.paynow_blik_gateway.redirectUrl); - } + window.location.replace(window.checkoutConfig.payment.paynow_blik_gateway.redirectUrl); }, getLogoPath: function () { return window.checkoutConfig.payment.paynow_blik_gateway.logoPath; }, - isPaymentMethodActive:function () { - return this.getCode() === this.isChecked(); - }, isButtonActive: function () { - return this.isWhiteLabelEnabled() ? this.blikCodeValue().length === 6 && !isNaN(this.blikCodeValue()) && parseInt(this.blikCodeValue()) : true}, - getGDPRNotices: function () { - return window.checkoutConfig.payment.paynow_blik_gateway.GDPRNotices; - }, - isWhiteLabelEnabled: function () { - return window.checkoutConfig.payment.paynow_blik_gateway.isWhiteLabel + return this.getCode() === this.isChecked(); }, getData: function () { - const blikCode = $('#paynow_blik_code').val(); return { 'method': this.item.method, 'additional_data': { - 'payment_method_id': this.paymentMethodId, - 'blik_code': blikCode + 'payment_method_id': this.paymentMethodId } }; } diff --git a/view/frontend/web/js/view/payment/paynow_confirm_blik.js b/view/frontend/web/js/view/payment/paynow_confirm_blik.js deleted file mode 100644 index 8763459..0000000 --- a/view/frontend/web/js/view/payment/paynow_confirm_blik.js +++ /dev/null @@ -1,60 +0,0 @@ -define([ - 'jquery', - 'ko', - 'uiComponent', - 'mage/url' -], function ($, ko, Component, url) { - 'use strict'; - return Component.extend({ - initialize: function (config) { - this._super(); - self = this; - this.INTERVAL = 5000; - this.timeout = null; - this.currentReq = null; - this.paymentStatus = ko.observable(config.paymentStatus); - this.paymentStatusLabel = ko.observable(config.paymentStatusLabel); - this.paymentId = ko.observable(config.paymentId); - - this.fetchNewData(); - setTimeout(() => { - self.redirectToReturn(self.paymentStatus, self.paymentId) - }, 60000); - }, - redirectToReturn: function (paymentStatus, paymentId) { - const successUrl = url.build('paynow/checkout/success'); - window.location.replace(successUrl + '?paymentStatus=' + paymentStatus + '&paymentId=' + paymentId); - }, - fetchNewData : function () { - self.currentReq = $.ajax({ - url: url.build('paynow/payment/status'), - dataType: 'json', - type: 'get'}); - - self.currentReq - .done(self.processNewData) - .always(self.scheduleNewDataFetch); - }, - processNewData: function (data) { - self.paymentStatus(data.payment_status); - self.paymentId(data.paymentId); - self.paymentStatusLabel(data.payment_status_label); - - if (!["PENDING", "NEW"].includes(data.payment_status)) { - self.redirectToReturn(data.payment_status, data.paymentId); - } - }, - scheduleNewDataFetch: function () { - if (self.currentReq) { - self.currentReq.abort(); - } - - if (self.timeout) { - clearTimeout(self.timeout); - } - - self.currentReq = null; - self.timeout = setTimeout(self.fetchNewData, self.INTERVAL); - } - }); -}); diff --git a/view/frontend/web/template/payment/data_processing_info.html b/view/frontend/web/template/payment/data_processing_info.html deleted file mode 100644 index 562985b..0000000 --- a/view/frontend/web/template/payment/data_processing_info.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
- - - -
-

-
- -
- -
\ No newline at end of file diff --git a/view/frontend/web/template/payment/paynow_blik_gateway.html b/view/frontend/web/template/payment/paynow_blik_gateway.html index 719d716..87a49aa 100644 --- a/view/frontend/web/template/payment/paynow_blik_gateway.html +++ b/view/frontend/web/template/payment/paynow_blik_gateway.html @@ -1,4 +1,4 @@ -
+
- -
- - - - -
- -
- -