Skip to content

Commit

Permalink
Catching error if instore is not activated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Pieters committed Jul 26, 2017
1 parent 1dc84ac commit 56acafe
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions Model/Paymentmethod/Instore.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,27 @@ public function getBanks()

$cache = $this->getCache();
$cacheName = 'paynl_terminals_' . $this->getPaymentOptionId();

$banksJson = $cache->load($cacheName);
if ($banksJson) {
$banks = json_decode($banksJson);
} else {
$banks = [];
try {
$config = new Config($this->_scopeConfig);

$config = new Config($this->_scopeConfig);
$config->configureSDK();

$config->configureSDK();
$terminals = \Paynl\Instore::getAllTerminals();
$terminals = $terminals->getList();

$terminals = \Paynl\Instore::getAllTerminals();
$terminals = $terminals->getList();
$banks = [];
foreach ($terminals as $terminal) {
$terminal['visibleName'] = $terminal['name'];
array_push($banks, $terminal);
foreach ($terminals as $terminal) {
$terminal['visibleName'] = $terminal['name'];
array_push($banks, $terminal);
}
$cache->save(json_encode($banks), $cacheName);
} catch (\Paynl\Error\Error $e) {
// Probably instore is not activated, no terminals present
}
$cache->save(json_encode($banks), $cacheName);
}
array_unshift($banks, array(
'id' => '',
Expand All @@ -105,23 +108,4 @@ private function getCache()
$cache = $om->get('Magento\Framework\App\CacheInterface');
return $cache;
}

private function registerPayment(Order $order, Transaction $transaction)
{
$skipFraudDetection = false;
$payment = $order->getPayment();
$payment->setTransactionId(
$transaction->getId()
);

$payment->setPreparedMessage('Pay.nl - ');
$payment->setIsTransactionClosed(
0
);
$payment->registerCaptureNotification(
$transaction->getPaidCurrencyAmount(), $skipFraudDetection
);
$order->save();

}
}

0 comments on commit 56acafe

Please sign in to comment.