forked from remp2020/crm-payments-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BankTransferPresenter.php
47 lines (37 loc) · 1.61 KB
/
BankTransferPresenter.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
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Crm\PaymentsModule\Presenters;
use Crm\ApplicationModule\Presenters\FrontendPresenter;
use Crm\PaymentsModule\Gateways\BankTransfer;
use Crm\PaymentsModule\Repository\PaymentsRepository;
use Nette\Application\BadRequestException;
use Nette\Database\Table\ActiveRow;
class BankTransferPresenter extends FrontendPresenter
{
/** @var PaymentsRepository @inject */
public $paymentsRepository;
/** @persistent */
public $id;
public function renderInfo($id)
{
$payment = $this->paymentsRepository->findLastByVS($id);
if (!$payment) {
throw new BadRequestException('Payment with variable symbol not found: ' . $id);
}
if ($payment->payment_gateway->code !== BankTransfer::GATEWAY_CODE) {
throw new BadRequestException('Payment with variable symbol ' . $id . ' has payment gateway ' . $payment->payment_gateway->code . ' instead of ' . BankTransfer::GATEWAY_CODE);
}
$this->template->bankNumber = $this->applicationConfig->get('supplier_bank_account_number');
$this->template->bankIban = $this->applicationConfig->get('supplier_iban');
$this->template->bankSwift = $this->applicationConfig->get('supplier_swift');
$this->template->payment = $payment;
$this->template->note = 'VS' . $payment->variable_symbol;
}
public function getPayment(): ActiveRow
{
$payment = $this->paymentsRepository->findLastByVS($this->id);
if (!$payment) {
throw new BadRequestException('Payment with variable symbol not found: ' . $this->id);
}
return $payment;
}
}