Skip to content

Commit

Permalink
fix: Two pending status
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkwr committed Oct 24, 2024
1 parent 8586d6d commit 8afa72e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Model/Two.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ 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';
/**
* @var RequestInterface
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Setup/Patch/Data/OrderStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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) {
Expand Down
10 changes: 9 additions & 1 deletion Setup/Patch/Data/PendingPaymentStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
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
*/
Expand All @@ -25,8 +31,10 @@ class PendingPaymentStatus implements DataPatchInterface
* @param ModuleDataSetupInterface $moduleDataSetup
*/
public function __construct(
ConfigRepository $configRepository,
ModuleDataSetupInterface $moduleDataSetup
) {
$this->configRepository = $configRepository;
$this->moduleDataSetup = $moduleDataSetup;
}

Expand All @@ -44,7 +52,7 @@ public function apply()

$this->moduleDataSetup->getConnection()->insert(
$this->moduleDataSetup->getTable('sales_order_status'),
['status' => Two::STATUS_TWO_PENDING, 'label' => 'Two Pending']
['status' => Two::STATUS_TWO_PENDING, 'label' => sprintf('%s Pending', $this->configRepository::PROVIDER)]
);

$this->moduleDataSetup->getConnection()->insert(
Expand Down
2 changes: 0 additions & 2 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 0 additions & 2 deletions i18n/nb_NO.csv
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 0 additions & 2 deletions i18n/nl_NL.csv
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 0 additions & 2 deletions i18n/sv_SE.csv
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 8afa72e

Please sign in to comment.