-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathBankSelectionForm.php
36 lines (31 loc) · 1.04 KB
/
BankSelectionForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Tpay\Example\TransactionsApi;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
use Tpay\OpenApi\Forms\PaymentForms;
use Tpay\OpenApi\Utilities\TpayException;
final class BankSelectionForm extends ExamplesConfig
{
public function getBankForm()
{
$PaymentForms = new PaymentForms('en');
$form = $PaymentForms->getBankSelectionForm(
$this->getBanksList(true),
false,
true,
'RedirectPayment.php',
false
);
echo $form;
}
protected function getBanksList($onlineOnly = false)
{
$TpayApi = new TpayApi(self::MERCHANT_CLIENT_ID, self::MERCHANT_CLIENT_SECRET, true, 'read');
$result = $TpayApi->transactions()->getBankGroups($onlineOnly);
if (!isset($result['result']) || 'success' !== $result['result']) {
throw new TpayException('Unable to get banks list. Response: '.json_encode($result));
}
return $result['groups'];
}
}
(new BankSelectionForm())->getBankForm();