-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for redirect resolvers in bank transfer process
The default return handler was moved and flow is redirected via redirect resolver to `BankTransferPresenter`. CRM users can now register their own redirect resolvers and direct bank transfer users to their own landing pages. remp/crm#1095
- Loading branch information
Showing
8 changed files
with
103 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/model/SuccessPageResolver/BankTransferPaymentCompleteRedirectResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Crm\PaymentsModule; | ||
|
||
use Crm\PaymentsModule\Model\PaymentCompleteRedirectResolver; | ||
use Nette\Database\Table\ActiveRow; | ||
|
||
class BankTransferPaymentCompleteRedirectResolver implements PaymentCompleteRedirectResolver | ||
{ | ||
public function wantsToRedirect(?ActiveRow $payment, string $status): bool | ||
{ | ||
if ($payment && $payment->payment_gateway->code === 'bank_transfer') { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public function redirectArgs(?ActiveRow $payment, string $status): array | ||
{ | ||
if (!$payment || $payment->payment_gateway->code !== 'bank_transfer') { | ||
throw new \Exception('unhandled status when requesting redirectArgs (did you check wantsToRedirect first?): ' . $status); | ||
} | ||
|
||
return [ | ||
':Payments:BankTransfer:info', | ||
[ | ||
'id' => $payment->variable_symbol, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Crm\PaymentsModule\Presenters; | ||
|
||
use Crm\ApplicationModule\Presenters\FrontendPresenter; | ||
use Crm\PaymentsModule\Repository\PaymentsRepository; | ||
use Nette\Application\BadRequestException; | ||
|
||
class BankTransferPresenter extends FrontendPresenter | ||
{ | ||
/** @var PaymentsRepository @inject */ | ||
public $paymentsRepository; | ||
|
||
public function renderInfo($id) | ||
{ | ||
$payment = $this->paymentsRepository->findLastByVS($id); | ||
if (!$payment) { | ||
throw new BadRequestException('Payment with variable symbol not found: ' . $id); | ||
} | ||
|
||
$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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.