Skip to content

Commit

Permalink
Merge pull request #18 from MONEI/rollback
Browse files Browse the repository at this point in the history
Rollback
  • Loading branch information
jcuervas authored Jun 13, 2023
2 parents 36a85e5 + 0da05d6 commit 93a1f63
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 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_NEW;
$orderState = Order::STATE_PROCESSING;
$order->setStatus($orderStatus)->setState($orderState);
$this->orderRepository->save($order);
}
Expand Down
2 changes: 1 addition & 1 deletion Service/SetOrderStatusAndState.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function execute(array $data): bool
break;
case Monei::ORDER_STATUS_SUCCEEDED:
$orderStatus = Monei::STATUS_MONEI_SUCCEDED;
$orderState = Order::STATE_NEW;
$orderState = Order::STATE_PROCESSING;
break;
case Monei::ORDER_STATUS_PARTIALLY_REFUNDED:
$orderStatus = Monei::STATUS_MONEI_PARTIALLY_REFUNDED;
Expand Down
33 changes: 13 additions & 20 deletions Setup/Patch/Data/SetupSales.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

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 @@ -52,7 +51,7 @@ public function getAliases(): array
*/
public static function getVersion(): string
{
return '1.2.0';
return '1.1.4';
}

public function apply(): void
Expand All @@ -77,7 +76,7 @@ public function apply(): void

$statuses = [
Monei::STATUS_MONEI_PENDING => __('Monei - pending'),
Monei::STATUS_MONEI_AUTHORIZED => __('Monei - Preauthorized'),
Monei::STATUS_MONEI_AUTHORIZED => __('Monei - pre-authorized'),
Monei::STATUS_MONEI_EXPIRED => __('Monei - expired'),
Monei::STATUS_MONEI_FAILED => __('Monei - failed'),
Monei::STATUS_MONEI_SUCCEDED => __('Monei - succeeded'),
Expand All @@ -87,31 +86,29 @@ public function apply(): void
foreach ($statuses as $code => $info) {
$data[] = ['status' => $code, 'label' => $info];
}
$this->moduleDataSetup->getConnection()->insertOnDuplicate(
$this->moduleDataSetup->getConnection()->insertArray(
$this->moduleDataSetup->getTable('sales_order_status'),
$data,
['status', 'label']
['status', 'label'],
$data
);

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

foreach ($statuses as $stateCode => $status) {
Expand All @@ -121,17 +118,13 @@ public function apply(): void
'state' => $stateCode,
'is_default' => $isDefault,
];
$this->moduleDataSetup->getConnection()->delete(
$this->moduleDataSetup->getTable('sales_order_status_state'),
["state" => $stateCode]
);
}
}

$this->moduleDataSetup->getConnection()->insertOnDuplicate(
$this->moduleDataSetup->getConnection()->insertArray(
$this->moduleDataSetup->getTable('sales_order_status_state'),
$data,
['status', 'state', 'is_default']
['status', 'state', 'is_default'],
$data
);

$this->moduleDataSetup->getConnection()->endSetup();
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</field>
<field id="confirmed_status" translate="label comment" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Confirmed Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Processing</source_model>
<comment>Selectable with all the processing order statuses</comment>
<depends>
<field id="active">1</field>
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.2.0">
<module name="Monei_MoneiPayment" setup_version="1.1.4">
<sequence>
<module name="Magento_Checkout"/>
<module name="Magento_Config"/>
Expand Down

0 comments on commit 93a1f63

Please sign in to comment.