Skip to content

Commit

Permalink
Compensate reservation when order is canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrzyzewski authored and cieslix committed Jun 16, 2020
1 parent 6faf124 commit 28c2961
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Model/OrderImporter/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ public function processOrder(CheckoutFormInterface $checkoutForm): bool
try {
$connection->beginTransaction();

if ($checkoutForm->getStatus() !== 'READY_FOR_PROCESSING') {
$this->allegroReservation->placeReservation($checkoutForm);
} else {
if ($checkoutForm->getStatus() === Status::ALLEGRO_READY_FOR_PROCESSING) {
if (!$this->tryToGetOrder($checkoutForm->getId())) {
$this->allegroReservation->compensateReservation($checkoutForm);
$this->tryCreateOrder($checkoutForm);
$this->removeErrorLogIfExist($checkoutForm);
}
} elseif ($checkoutForm->getStatus() === Status::ALLEGRO_CANCELLED) {
$this->allegroReservation->compensateReservation($checkoutForm);
} else {
$this->allegroReservation->placeReservation($checkoutForm);
}

$connection->commit();
Expand Down
3 changes: 2 additions & 1 deletion Model/OrderImporter/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Status
const STATE_KEY = 'state';
const PAID_KEY = 'paid';
const STATUS_STATE_SEPARATOR = ':';
const ALLEGRO_READY_FOR_PROCESSING = "READY_FOR_PROCESSING";
const ALLEGRO_READY_FOR_PROCESSING = 'READY_FOR_PROCESSING';
const ALLEGRO_CANCELLED = 'CANCELLED';

/** @var ScopeConfigInterface */
private $scopeConfig;
Expand Down

0 comments on commit 28c2961

Please sign in to comment.