Skip to content

Commit

Permalink
state set to new after successful payment
Browse files Browse the repository at this point in the history
version set to 1.2
  • Loading branch information
jcuervas committed Jun 5, 2023
1 parent 9cb36b3 commit cbee705
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Observer/SetOrderStatusAfterInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function execute(Observer $observer): void
$invoice = $observer->getInvoice();
if ($order->getData('monei_payment_id') !== null && $invoice->getIsPaid() === true) {
$orderStatus = Monei::STATUS_MONEI_SUCCEDED;
$orderState = Order::STATE_PROCESSING;
$orderState = Order::STATE_NEW;
$order->setStatus($orderStatus)->setState($orderState);
$this->orderRepository->save($order);
}
Expand Down
15 changes: 9 additions & 6 deletions Setup/Patch/Data/SetupSales.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Sales\Model\Order;
use Monei\MoneiPayment\Model\Payment\Monei;
use Magento\Sales\Setup\SalesSetup;

Expand Down Expand Up @@ -51,7 +52,7 @@ public function getAliases(): array
*/
public static function getVersion(): string
{
return '1.1.4';
return '1.2.0';
}

public function apply(): void
Expand Down Expand Up @@ -94,21 +95,23 @@ public function apply(): void

$data = [];
$statuses = [
'pending_payment' => [
Order::STATE_PENDING_PAYMENT => [
Monei::STATUS_MONEI_PENDING => false,
Monei::STATUS_MONEI_AUTHORIZED => false,
],
'canceled' => [
Order::STATE_CANCELED => [
Monei::STATUS_MONEI_EXPIRED => false,
Monei::STATUS_MONEI_FAILED => false,
],
'processing' => [
Monei::STATUS_MONEI_SUCCEDED => false,
Order::STATE_PROCESSING => [
Monei::STATUS_MONEI_PARTIALLY_REFUNDED => false,
],
'complete' => [
Order::STATE_COMPLETE => [
Monei::STATUS_MONEI_REFUNDED => false,
],
Order::STATE_NEW => [
Monei::STATUS_MONEI_SUCCEDED => false,
]
];

foreach ($statuses as $stateCode => $status) {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
~ @copyright Copyright © Monei (https://monei.com)
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Monei_MoneiPayment" setup_version="1.1.0">
<module name="Monei_MoneiPayment" setup_version="1.2.0">
<sequence>
<module name="Magento_Checkout"/>
<module name="Magento_Config"/>
Expand Down

0 comments on commit cbee705

Please sign in to comment.