diff --git a/Controller/Payment/Fallback.php b/Controller/Payment/Fallback.php
index 9a5556ef..c9a1cb1a 100644
--- a/Controller/Payment/Fallback.php
+++ b/Controller/Payment/Fallback.php
@@ -262,7 +262,7 @@ private function prepareResponse(Redirect $resultRedirect, Transaction $transact
{
if ($transaction->transactionWasCancelled()) {
$this->messageManager->addWarningMessage(__('Your order was cancelled in Vipps.'));
- } elseif ($transaction->isTransactionReserved()) {
+ } elseif ($transaction->isTransactionReserved() || $transaction->isTransactionCaptured()) {
return $resultRedirect->setPath('checkout/onepage/success', ['_secure' => true]);
} elseif ($transaction->isTransactionExpired()) {
$this->messageManager->addErrorMessage(
diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md
index 2646865a..7709114f 100644
--- a/DOCUMENTATION.md
+++ b/DOCUMENTATION.md
@@ -65,8 +65,6 @@ If you have experienced any issue with Vipps try to enable `Request Profiling` a
`Stores -> Configuration -> Sales -> Payment Methods -> Vipps`
-![Screenshot of Vipps Configuration Area](docs/images/vipps_basic.png)
-
After that, all information related to vipps payment module will be stored into two files `{project_root}/var/log/vipps_exception.log` or `{project_root}/var/log/vipps_debug.log`.
Requests Profiling is a page in Magento admin panel that helps you to track a communication between Vipps and Magento.
@@ -99,6 +97,7 @@ For information about how to find the above values, see the [Vipps Developer Por
**Environment** - Vipps API mode. Can be *production/develop*.
**Payment Action** - *Authorize*(process authorization transaction; funds are blocked on customer account, but not withdrawn) or *Capture* (withdraw previously authorized amount).
+**Order Status** - default order status before redirecting back to Magento. Can be *Pending* or *Payment Review*.
**Debug** - log all actions with Vipps Payment module into `{project_root}/var/log/vipps_debug.log` file *(not recommended in production mode)*.
**Request/Response Profiling** - log all requests/responses to Vipps API into `vipps_profiling` table.
diff --git a/Gateway/Transaction/Transaction.php b/Gateway/Transaction/Transaction.php
index 1b27ea1b..371d47c6 100644
--- a/Gateway/Transaction/Transaction.php
+++ b/Gateway/Transaction/Transaction.php
@@ -269,6 +269,19 @@ public function isTransactionReserved(): bool
return false;
}
+ /**
+ * @return bool
+ */
+ public function isTransactionCaptured(): bool
+ {
+ $item = $this->transactionLogHistory->getLastSuccessItem();
+ if ($item && $item->getOperation() == self::TRANSACTION_OPERATION_CAPTURE) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* @return bool
* @throws \Exception
diff --git a/Gateway/Validator/AvailabilityValidator.php b/Gateway/Validator/AvailabilityValidator.php
new file mode 100644
index 00000000..2114f79d
--- /dev/null
+++ b/Gateway/Validator/AvailabilityValidator.php
@@ -0,0 +1,67 @@
+storeManager = $storeManager;
+ }
+
+ /**
+ * @param array $validationSubject
+ *
+ * @return ResultInterface
+ * @throws NoSuchEntityException
+ */
+ public function validate(array $validationSubject)
+ {
+ /** @var Store $store */
+ $store = $this->storeManager->getStore();
+
+ $isValid = self::NORWEGIAN_CURRENCY == $store->getBaseCurrencyCode();
+ $errorMessages = $isValid ? [] : [__('Not allowed currency. Please, contact store administrator.')];
+
+ return $this->createResult($isValid, $errorMessages);
+ }
+}
diff --git a/INSTALL.md b/INSTALL.md
index ed40d167..2dc76920 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -69,6 +69,7 @@ For information about how to find the above values, see the [Vipps Developer Por
**Environment** - Vipps API mode. Can be *production/develop*.
**Payment Action** - *Authorize*(process authorization transaction; funds are blocked on customer account, but not withdrawn) or *Capture* (withdraw previously authorized amount).
+**Order Status** - default order status before redirecting back to Magento. Can be *Pending* or *Payment Review*.
**Debug** - log all actions with Vipps Payment module into `{project_root}/var/log/vipps_debug.log` file *(not recommended in production mode)*.
**Request/Response Profiling** - log all requests/responses to Vipps API into `vipps_profiling` table.
diff --git a/Model/Adminhtml/Source/OrderStatus.php b/Model/Adminhtml/Source/OrderStatus.php
new file mode 100644
index 00000000..3b7fadf3
--- /dev/null
+++ b/Model/Adminhtml/Source/OrderStatus.php
@@ -0,0 +1,53 @@
+ self::STATUS_PAYMENT_REVIEW,
+ 'label' => __('Payment Review'),
+ ],
+ [
+ 'value' => self::STATUS_PENDING,
+ 'label' => __('Pending'),
+ ]
+ ];
+ }
+}
diff --git a/Model/TransactionProcessor.php b/Model/TransactionProcessor.php
index 7ba26125..1efb7411 100644
--- a/Model/TransactionProcessor.php
+++ b/Model/TransactionProcessor.php
@@ -405,7 +405,7 @@ private function validateAmount(CartInterface $quote, Transaction $transaction)
*/
private function capture(OrderInterface $order)
{
- if ($order->getState() !== Order::STATE_NEW) {
+ if (!in_array($order->getState(), [Order::STATE_NEW, Order::STATE_PAYMENT_REVIEW])) {
return;
}
@@ -431,7 +431,7 @@ private function capture(OrderInterface $order)
*/
private function authorize(OrderInterface $order, Transaction $transaction)
{
- if ($order->getState() !== Order::STATE_NEW) {
+ if (!in_array($order->getState(), [Order::STATE_NEW, Order::STATE_PAYMENT_REVIEW])) {
return;
}
diff --git a/Observer/OrderPaymentAfter.php b/Observer/OrderPaymentAfter.php
new file mode 100644
index 00000000..97a802bb
--- /dev/null
+++ b/Observer/OrderPaymentAfter.php
@@ -0,0 +1,73 @@
+config = $config;
+ $this->logger = $logger;
+ }
+
+ /**
+ * @param Observer $observer
+ */
+ public function execute(Observer $observer)
+ {
+ /** @var Order\Payment $payment */
+ $payment = $observer->getPayment();
+ $order = $payment->getOrder();
+
+ $status = $this->config->getValue('order_status');
+ if ($status == OrderStatus::STATUS_PAYMENT_REVIEW) {
+ $order->setState(Order::STATE_PAYMENT_REVIEW);
+ $order->setStatus(Order::STATE_PAYMENT_REVIEW);
+ }
+
+ return;
+ }
+}
diff --git a/composer.json b/composer.json
index 2302c306..2b0a6d5b 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,7 @@
"type": "magento2-module",
"description": "Vipps Payment Method",
"license": "proprietary",
- "version": "2.4.3",
+ "version": "2.4.4",
"require": {
"magento/framework": "103.0.*",
"magento/module-sales": "103.0.*",
diff --git a/docs/images/vipps_basic.png b/docs/images/vipps_basic.png
index 6e488710..42ea54c8 100644
Binary files a/docs/images/vipps_basic.png and b/docs/images/vipps_basic.png differ
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 5d2b9d69..ca58836a 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -67,6 +67,12 @@
Vipps\Payment\Model\Adminhtml\Source\PaymentAction
1
+
+
+ Status given to newly created orders before payment result confirmation via server notifications from Vipps.
+ Vipps\Payment\Model\Adminhtml\Source\OrderStatus
+ payment/vipps/order_status
+
payment/vipps/merchant_serial_number
diff --git a/etc/config.xml b/etc/config.xml
index b430605a..4bb39d95 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -21,7 +21,7 @@
Vipps\Payment\Model\Method\Vipps
Vipps
1
- processing
+ pending
1
1
0
diff --git a/etc/di.xml b/etc/di.xml
index e381276b..d3844096 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -272,7 +272,8 @@
- Vipps\Payment\Gateway\Validator\InitiateValidator
-
+ - Vipps\Payment\Gateway\Validator\AvailabilityValidator
+
@@ -401,4 +402,10 @@
Vipps\Payment\Model\Logger
+
+
+ Vipps\Payment\Gateway\Config\Config
+ Vipps\Payment\Model\Logger
+
+
diff --git a/etc/events.xml b/etc/events.xml
index 4380a56a..c218178f 100644
--- a/etc/events.xml
+++ b/etc/events.xml
@@ -23,4 +23,7 @@
+
+
+