Skip to content

Commit

Permalink
Merge branch 'MAGENTO-254'
Browse files Browse the repository at this point in the history
  • Loading branch information
zalazdi committed Feb 3, 2025
2 parents e93518a + 47a179f commit afd446a
Show file tree
Hide file tree
Showing 27 changed files with 856 additions and 233 deletions.
55 changes: 31 additions & 24 deletions Api/Data/RefundTransactionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,97 @@
interface RefundTransactionInterface
{
const ID = 'refund_id';

const ORDER_ID = 'order_id';

const REMOTE_ID = 'remote_id';

const MESSAGE_ID = 'message_id';
const REMOTE_OUT_ID = 'remote_out_id';

const AMOUNT = 'amount';

const CURRENCY = 'currency';

const IS_PARTIAL = 'is_partial';

/**
* @return string
*/
public function getOrderId();
public function getOrderId(): string;

/**
* @param string $orderId
*
* @return $this
*/
public function setOrderId(string $orderId): RefundTransactionInterface;

/**
* @return string
*/
public function getRemoteId(): string;

/**
* @param string $orderId
* @param string $remoteId
*
* @return $this
*/
public function setOrderId($orderId);
public function setRemoteId(string $remoteId): RefundTransactionInterface;

/**
* @return string
*/
public function getRemoteId();
public function getMessageId(): string;

/**
* @param string $remoteId
* @param string $messageId
*
* @return $this
*/
public function setRemoteId($remoteId);
public function setMessageId(string $messageId): RefundTransactionInterface;

/**
* @return string
*/
public function getRemoteOutId();
public function getRemoteOutId(): string;

/**
* @param string $remoteId
* @param string $remoteId
*
* @return $this
*/
public function setRemoteOutId($remoteId);
public function setRemoteOutId(string $remoteId): RefundTransactionInterface;

/**
* @return float
*/
public function getAmount();
public function getAmount(): float;

/**
* @param float $amount
* @param float $amount
*
* @return $this
*/
public function setAmount($amount);
public function setAmount(float $amount): RefundTransactionInterface;

/**
* @return string
*/
public function getCurrency();
public function getCurrency(): string;

/**
* @param string $currency
* @param string $currency
*
* @return $this
*/
public function setCurrency($currency);
public function setCurrency(string $currency): RefundTransactionInterface;

/**
* @return bool
*/
public function isPartial();
public function isPartial(): bool;

/**
* @param bool $isPartial
* @param bool $isPartial
*
* @return $this
*/
public function setIsPartial($isPartial);
public function setIsPartial(bool $isPartial): RefundTransactionInterface;

/**
* Save object data
Expand Down
13 changes: 13 additions & 0 deletions Api/RefundStatusUpdaterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace BlueMedia\BluePayment\Api;

interface RefundStatusUpdaterInterface
{
/**
* Aktualizuje statusy zwrotów
*
* @return void
*/
public function updateRefundStatuses(): void;
}
33 changes: 23 additions & 10 deletions Api/RefundTransactionRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<?php

declare(strict_types=1);

namespace BlueMedia\BluePayment\Api;

use BlueMedia\BluePayment\Api\Data\RefundTransactionInterface;
use BlueMedia\BluePayment\Api\Data\TransactionInterface;
use BlueMedia\BluePayment\Model\ResourceModel\RefundTransaction\Collection;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\SearchResultsInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Sales\Api\Data\OrderInterface;

/**
Expand All @@ -14,18 +18,18 @@
interface RefundTransactionRepositoryInterface
{
/**
* @param RefundTransactionInterface $page
* @param RefundTransactionInterface $refundTransaction
*
* @return mixed
*/
public function save(RefundTransactionInterface $page);
public function save(RefundTransactionInterface $refundTransaction);

/**
* @param int $id
* @param int $id
*
* @return mixed
*/
public function getById($id);
public function getById(int $id);

/**
* @param SearchCriteriaInterface $criteria
Expand All @@ -39,26 +43,35 @@ public function getList(SearchCriteriaInterface $criteria);
*
* @return Collection
*/
public function getListForOrder(OrderInterface $order);
public function getListForOrder(OrderInterface $order): Collection;

/**
* @param RefundTransactionInterface $page
* @param RefundTransactionInterface $refundTransaction
*
* @return mixed
*/
public function delete(RefundTransactionInterface $page);
public function delete(RefundTransactionInterface $refundTransaction);

/**
* @param int $id
* @param int $id
*
* @return mixed
*/
public function deleteById($id);
public function deleteById(int $id);

/**
* @param TransactionInterface $transaction
*
* @return float
*/
public function getTotalRefundAmountOnTransaction(TransactionInterface $transaction);
public function getTotalRefundAmountOnTransaction(TransactionInterface $transaction): float;


/**
* Get all pending refund transactions
*
* @return SearchResultsInterface
* @throws NoSuchEntityException
*/
public function getPendingRefundTransactions(): SearchResultsInterface;
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Co nowego w module bramki płatności Autopay?

## Wersja 2.25.0
- Zmieniliśmy sposób tworzenia zwrotów płatności. Dokonaliśmy modyfikacji w zarządzaniu parametrem związanym ze statusem transakcji zwrotu (RemoteOutId – dotychczas identyfikator i status były automatycznie przypisywane przy generowaniu zwrotu). Aktualnie Magento asynchronicznie pobiera status zwrotu za pomocą CRONa.

## Wersja 2.24.1
- Poprawiliśmy błąd z tłumaczeniem tekstów dla metody Apple Pay.

Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG_EN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# What's new in the Autopay payment gateway module?

## Version 2.25.0
We have changed the way of creating payment returns. We have made modifications to the handling of the parameter related to the status of the return transaction (RemoteOutId - previously, the ID and status were automatically assigned when the return was generated). Currently, Magento asynchronously retrieves the status of the return using CRON.

## Version 2.24.1
- Poprawiliśmy błąd z tłumaczeniem tekstów dla metody Apple Pay.
- We have corrected an error with text translation for the Apple Pay method.

## Version 2.24.0
- We have added possibility for asynchronous ITN processing.
Expand Down
65 changes: 65 additions & 0 deletions Console/Command/UpdateRefundStatusCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace BlueMedia\BluePayment\Console\Command;

use BlueMedia\BluePayment\Api\RefundStatusUpdaterInterface;
use Magento\Framework\App\Area;
use Magento\Framework\App\State;
use Magento\Framework\Exception\LocalizedException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UpdateRefundStatusCommand extends Command
{
/**
* @var RefundStatusUpdaterInterface
*/
protected $refundStatusUpdater;

/**
* @var State
*/
protected $state;

public function __construct(
RefundStatusUpdaterInterface $refundStatusUpdater,
State $state
) {
$this->refundStatusUpdater = $refundStatusUpdater;
$this->state = $state;
parent::__construct();
}

/**
* Initialization of the command.
*/
protected function configure()
{
$this->setName('bluepayment:refund:update-status');
$this->setDescription('Refresh refund statuses from the external Autopay API.');
parent::configure();
}

/**
* CLI command description.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
* @throws LocalizedException
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->state->setAreaCode(Area::AREA_ADMINHTML);

$this->refundStatusUpdater->updateRefundStatuses();

$output->writeln('Refund statuses updated.');

return 0;
}
}
27 changes: 27 additions & 0 deletions Cron/RefundStatusUpdater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace BlueMedia\BluePayment\Cron;

use BlueMedia\BluePayment\Api\RefundStatusUpdaterInterface;
use BlueMedia\BluePayment\Service\RefundStatusUpdaterService as RefundStatusUpdaterService;

class RefundStatusUpdater
{
/**
* @var RefundStatusUpdaterService
*/
protected $refundStatusUpdater;

public function __construct(
RefundStatusUpdaterInterface $refundStatusUpdater
) {
$this->refundStatusUpdater = $refundStatusUpdater;
}

public function execute()
{
$this->refundStatusUpdater->updateRefundStatuses();
}
}
Loading

0 comments on commit afd446a

Please sign in to comment.