protected function _isAvailable() { $configured = $this->_config->configureSDK(); if ($configured) { $paymentOptionId = $this->_config->getPaymentOptionId($this->_code); $list = Paymentmethods::getList(); if (isset($list[$paymentOptionId])) { return true; } } return false; }
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; }
<?php /* * Copyright (C) 2015 Andy Pieters <*****@*****.**> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once '../../vendor/autoload.php'; require_once '../config.php'; try { $paymentMethods = \Paynl\Paymentmethods::getList(); var_dump($paymentMethods); } catch (\Paynl\Error\Error $e) { echo "Fout: " . $e->getMessage(); }
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); } }