public function getBanks() { $show_banks = $this->_scopeConfig->getValue('payment/' . $this->_code . '/bank_selection', 'store'); if (!$show_banks) { return []; } $cache = $this->getCache(); $cacheName = 'paynl_banks_' . $this->getPaymentOptionId(); $banksJson = $cache->load($cacheName); if ($banksJson) { $banks = json_decode($banksJson); } else { $config = new Config($this->_scopeConfig); $config->configureSDK(); $banks = \Paynl\Paymentmethods::getBanks($this->getPaymentOptionId()); $cache->save(json_encode($banks), $cacheName); } array_unshift($banks, array('id' => '', 'name' => __('Choose your bank'), 'visibleName' => __('Choose your bank'))); return $banks; }
public function testGetBanksInvalidPaymentMethod() { $this->setDummyData(); \Paynl\Config::setServiceId('SL-1234-5678'); \Paynl\Config::setApiToken('123456789012345678901234567890'); $banks = \Paynl\Paymentmethods::getBanks(12345); //Non existent paymentmethod $this->assertInternalType('array', $banks); foreach ($banks as $bank) { $this->assertArrayHasKey('id', $bank); $this->assertArrayHasKey('name', $bank); $this->assertArrayHasKey('visibleName', $bank); } }