Skip to content

Commit

Permalink
Merge pull request #438 from omise/release-v3.1.2
Browse files Browse the repository at this point in the history
Preparing release of v.3.1.2
  • Loading branch information
aashishgurung authored Jun 23, 2023
2 parents 5649dbf + 8ee692c commit a399ac0
Show file tree
Hide file tree
Showing 5 changed files with 415 additions and 38 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [v3.1.2 _(Jun, 23, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.1.2)
- Fetch the same number of orders as the value of refresh counter in the cron job. (PR: [#437](https://github.com/omise/omise-magento/pull/437))

## [v3.1.1 _(Jun, 12, 2023)_](https://github.com/omise/omise-magento/releases/tag/v3.1.1)
- Bug fixed: Atome failed to create charge with bundle product. (PR: [#433](https://github.com/omise/omise-magento/pull/433))

Expand Down
38 changes: 2 additions & 36 deletions Cron/OrderSyncStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ class OrderSyncStatus
*/
private $syncStatus;

/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
private $timezone;

/**
* @var \Omise\Payment\Model\Api\Charge
*/
Expand Down Expand Up @@ -119,24 +114,18 @@ class OrderSyncStatus
public function __construct(
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
\Omise\Payment\Model\Api\Charge $apiCharge,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Omise\Payment\Model\SyncStatus $syncStatus,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
\Magento\Framework\App\Config\Storage\WriterInterface $configWriter,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Omise\Payment\Model\Config\Config $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
) {
$this->_orderCollectionFactory = $orderCollectionFactory;
$this->orderRepository = $orderRepository;
$this->apiCharge = $apiCharge;
$this->scopeConfig = $scopeConfig;
$this->syncStatus = $syncStatus;
$this->timezone = $timezone;
$this->configWriter = $configWriter;
$this->_storeManager = $storeManager;
$this->config = $config;
$this->cacheTypeList = $cacheTypeList;
$this->cacheFrontendPool = $cacheFrontendPool;
Expand Down Expand Up @@ -206,7 +195,7 @@ public function getOrderIds()
{
$collection = $this->_orderCollectionFactory->create()
->addAttributeToSort('entity_id', 'desc')
->setPageSize(50)
->setPageSize($this->refreshCounter)
->setCurPage(1);

$collection->getSelect()
Expand All @@ -224,30 +213,6 @@ public function getOrderIds()
return $collection->getData();
}

/**
* @param \Magento\Sales\Model\Order $order
* @return string
* @deprecated
* - Method to be removed once new logic is confirmed as stable
*/
private function refreshExpiryDate($order)
{
$payment = $this->order->getPayment();
$chargeId = $payment->getAdditionalInformation('charge_id');
$expiryDate = $payment->getAdditionalInformation('omise_expiry_date');
if (!isset($expiryDate) && isset($chargeId) && $this->refreshCounter > 0) {
$this->charge = \OmiseCharge::retrieve(
$chargeId,
$this->config->getPublicKey(),
$this->config->getSecretKey()
);
$expiryDate = date("Y-m-d H:i:s", strtotime($this->charge['expires_at']));
$payment->setAdditionalInformation('omise_expiry_date', $expiryDate);
$this->refreshCounter--;
}
return $expiryDate;
}

/**
* isExpired
* - Gets fresh charge data and returns bool representing if the charge has expired or not
Expand Down Expand Up @@ -283,6 +248,7 @@ public function saveLastOrderId()
$this->lastProcessedOrderId
);
$this->cacheTypeList->cleanType('config');

foreach ($this->cacheFrontendPool as $cacheFrontend) {
$cacheFrontend->getBackend()->clean();
}
Expand Down
Loading

0 comments on commit a399ac0

Please sign in to comment.