diff --git a/Model/Two.php b/Model/Two.php index b1e93d99..ca7398e4 100755 --- a/Model/Two.php +++ b/Model/Two.php @@ -45,8 +45,7 @@ class Two extends AbstractMethod public const STATUS_NEW = 'two_new'; public const STATUS_FAILED = 'two_failed'; - public const STATUS_APPROVED = 'APPROVED'; - public const STATUS_TWO_PENDING = 'pending_two_payment'; + public const STATUS_PENDING = 'pending_two_payment'; /** * @var RequestInterface */ @@ -218,7 +217,7 @@ public function authorize(InfoInterface $payment, $amount) throw new LocalizedException($error); } - if ($response['status'] !== static::STATUS_APPROVED) { + if ($response['status'] !== 'APPROVED') { $this->logRepository->addDebugLog( sprintf('Order was not accepted by %s', $this->configRepository::PROVIDER), $response diff --git a/Plugin/Model/Sales/AfterPlaceOrder.php b/Plugin/Model/Sales/AfterPlaceOrder.php index 9017b51a..0b928455 100644 --- a/Plugin/Model/Sales/AfterPlaceOrder.php +++ b/Plugin/Model/Sales/AfterPlaceOrder.php @@ -33,7 +33,7 @@ public function afterPlace(Order $subject, Order $order) { if ($order->getPayment()->getMethod() == Two::CODE) { $order->setState(Order::STATE_PENDING_PAYMENT); - $order->setStatus(Two::STATUS_TWO_PENDING); + $order->setStatus(Two::STATUS_PENDING); $this->orderRepository->save($order); } return $order; diff --git a/Setup/Patch/Data/OrderStatuses.php b/Setup/Patch/Data/OrderStatuses.php index d6345429..22de6ce7 100755 --- a/Setup/Patch/Data/OrderStatuses.php +++ b/Setup/Patch/Data/OrderStatuses.php @@ -28,6 +28,7 @@ class OrderStatuses implements DataPatchInterface private $moduleDataSetup; /** + * @param ConfigRepository $configRepository * @param ModuleDataSetupInterface $moduleDataSetup */ public function __construct( @@ -47,8 +48,8 @@ public function apply() $data = []; $statuses = [ - Two::STATUS_NEW => __('%1 New Order', $this->configRepository::PROVIDER), - Two::STATUS_FAILED => __('%1 Failed', $this->configRepository::PROVIDER), + Two::STATUS_NEW => sprintf('%s New Order', $this->configRepository::PROVIDER), + Two::STATUS_FAILED => sprintf('%s Failed', $this->configRepository::PROVIDER), ]; foreach ($statuses as $code => $info) { diff --git a/Setup/Patch/Data/PendingPaymentStatus.php b/Setup/Patch/Data/PendingPaymentStatus.php index 28deaafb..06161459 100644 --- a/Setup/Patch/Data/PendingPaymentStatus.php +++ b/Setup/Patch/Data/PendingPaymentStatus.php @@ -10,23 +10,32 @@ use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\DataPatchInterface; use Two\Gateway\Model\Two; +use Two\Gateway\Api\Config\RepositoryInterface as ConfigRepository; /** * PendingPaymentStatus Data Patch */ class PendingPaymentStatus implements DataPatchInterface { + /** + * @var ConfigRepository + */ + private $configRepository; + /** * @var ModuleDataSetupInterface */ private $moduleDataSetup; /** + * @param ConfigRepository $configRepository * @param ModuleDataSetupInterface $moduleDataSetup */ public function __construct( + ConfigRepository $configRepository, ModuleDataSetupInterface $moduleDataSetup ) { + $this->configRepository = $configRepository; $this->moduleDataSetup = $moduleDataSetup; } @@ -44,13 +53,13 @@ public function apply() $this->moduleDataSetup->getConnection()->insert( $this->moduleDataSetup->getTable('sales_order_status'), - ['status' => Two::STATUS_TWO_PENDING, 'label' => 'Two Pending'] + ['status' => Two::STATUS_PENDING, 'label' => sprintf('%s Pending', $this->configRepository::PROVIDER)] ); $this->moduleDataSetup->getConnection()->insert( $this->moduleDataSetup->getTable('sales_order_status_state'), [ - 'status' => Two::STATUS_TWO_PENDING, + 'status' => Two::STATUS_PENDING, 'state' => 'pending_payment', 'is_default' => 1, 'visible_on_front' => 0 @@ -87,7 +96,7 @@ private function isStatusAdded(): bool $select = $this->moduleDataSetup->getConnection()->select() ->from($this->moduleDataSetup->getTable('sales_order_status'), 'status') ->where('status = :status'); - $bind = [':status' => Two::STATUS_TWO_PENDING]; + $bind = [':status' => Two::STATUS_PENDING]; return (bool)$this->moduleDataSetup->getConnection()->fetchOne($select, $bind); } } diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 7e9efecf..d160fc00 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 Credit Note" "%1 Decline reason: %2","%1 Decline reason: %2" "%1 Details","%1 Details" -"%1 Failed","%1 Failed" "%1 Invoice","%1 Invoice" -"%1 New Order","%1 New Order" "%1 Order ID","%1 Order ID" "%1 [Trace ID: %2]","%1 [Trace ID: %2]" "%1 order has been marked as cancelled","%1 order has been marked as cancelled" diff --git a/i18n/nb_NO.csv b/i18n/nb_NO.csv index ab205798..c382837c 100644 --- a/i18n/nb_NO.csv +++ b/i18n/nb_NO.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 kreditnota" "%1 Decline reason: %2","%1 Årsak til avvisning: %2" "%1 Details","%1 Detaljer" -"%1 Failed","%1 Mislyktes" "%1 Invoice","%1 Faktura" -"%1 New Order","%1 Ny ordre" "%1 Order ID","%1 Bestillings-ID" "%1 [Trace ID: %2]","%1 [Sporings-ID: %2]" "%1 order has been marked as cancelled","%1 ordre er merket som kansellert" diff --git a/i18n/nl_NL.csv b/i18n/nl_NL.csv index c0b5bd18..543ea195 100644 --- a/i18n/nl_NL.csv +++ b/i18n/nl_NL.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 Creditnota" "%1 Decline reason: %2","%1 Reden voor afwijzing: %2" "%1 Details","%1 Gegevens" -"%1 Failed","%1 Mislukt" "%1 Invoice","%1 Factuur" -"%1 New Order","%1 Nieuwe bestelling" "%1 Order ID","%1 Bestelnummer" "%1 [Trace ID: %2]","%1 [Trace-ID: %2]" "%1 order has been marked as cancelled","%1 bestelling is gemarkeerd als geannuleerd" diff --git a/i18n/sv_SE.csv b/i18n/sv_SE.csv index 52b6aea4..0ea3c2c5 100644 --- a/i18n/sv_SE.csv +++ b/i18n/sv_SE.csv @@ -1,9 +1,7 @@ "%1 Credit Note","%1 Kreditnota" "%1 Decline reason: %2","%1 Orsak till avslag: %2" "%1 Details","%1 Detaljer" -"%1 Failed","%1 Misslyckades" "%1 Invoice","%1 Faktura" -"%1 New Order","%1 Ny beställning" "%1 Order ID","%1 Beställnings-ID" "%1 [Trace ID: %2]","%1 [Spår-ID: %2]" "%1 order has been marked as cancelled","%1 beställning har markerats som avbruten"