Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shaxzodbek-uzb committed Feb 4, 2022
1 parent 9b4c5e8 commit 423dc65
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/PayUz.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public function __construct()
* @param null $driver
* @return $this
*/
public function driver($driver = null){
switch ($driver){
public function driver($driver = null)
{
switch ($driver) {
case PaymentSystem::PAYME:
$this->driverClass = new Payme;
break;
Expand All @@ -55,7 +56,8 @@ public function driver($driver = null){
* @return PayUz
* @throws \Exception
*/
public function redirect($model, $amount, $currency_code = Transaction::CURRENCY_CODE_UZS, $url = null){
public function redirect($model, $amount, $currency_code = Transaction::CURRENCY_CODE_UZS, $url = null)
{
$this->validateDriver();
$driver = $this->driverClass;
$params = $driver->getRedirectParams($model, $amount, $currency_code, $url);
Expand All @@ -69,11 +71,12 @@ public function redirect($model, $amount, $currency_code = Transaction::CURRENCY
* @return $this
* @throws \Exception
*/
public function handle(){
public function handle()
{
$this->validateDriver();
try{
try {
return $this->driverClass->run();
}catch(PaymentException $e){
} catch (PaymentException $e) {
return $e->response();
}

Expand All @@ -86,7 +89,8 @@ public function handle(){
* @param $currency_code
* @throws \Exception
*/
public function validateModel($model, $amount, $currency_code){
public function validateModel($model, $amount, $currency_code)
{
if (is_null($model))
throw new \Exception('Modal can\'t be null');
if (is_null($amount) || $amount == 0)
Expand All @@ -98,8 +102,13 @@ public function validateModel($model, $amount, $currency_code){
/**
* @throws \Exception
*/
public function validateDriver(){
public function validateDriver()
{
if (is_null($this->driverClass))
throw new \Exception('Driver not selected');
}
}
public function setDescription($hasDescription)
{
$this->driverClass->setDescription($hasDescription);
}
}

0 comments on commit 423dc65

Please sign in to comment.