Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed Dec 26, 2019
1 parent 2443f04 commit a97164c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
4 changes: 1 addition & 3 deletions src/Drivers/Ipay/Idpay.php
Expand Up @@ -73,13 +73,11 @@ public function purchase()
$mail = $details['email'];
}

$desc = null;
$desc = $this->settings->description;
if (!empty($details['desc'])) {
$desc = $details['desc'];
} elseif (!empty($details['description'])) {
$desc = $details['description'];
} else {
$desc = $this->settings->description;
}

$data = array(
Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/Nextpay/Nextpay.php
Expand Up @@ -80,10 +80,10 @@ public function purchase()
if (empty($body['code']) || $body['code'] != -1) {
// error has happened
throw new PurchaseFailedException($body['message']);
} else {
$this->invoice->transactionId($body['trans_id']);
}

$this->invoice->transactionId($body['trans_id']);

// return the transaction's id
return $this->invoice->getTransactionId();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Drivers/Payir/Payir.php
Expand Up @@ -91,13 +91,13 @@ public function purchase()
);
$body = json_decode($response->getBody()->getContents(), true);

if ($body['status'] == 1) {
$this->invoice->transactionId($body['token']);
} else {
if ($body['status'] != 1) {
// some error has happened
throw new PurchaseFailedException($body['errorMessage']);
}

$this->invoice->transactionId($body['token']);

// return the transaction's id
return $this->invoice->getTransactionId();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/Paystar/Paystar.php
Expand Up @@ -84,10 +84,10 @@ public function purchase()
if (is_numeric($body)) {
// some error has happened
throw new PurchaseFailedException($this->translateStatus($body));
} else {
$this->invoice->transactionId($body);
}

$this->invoice->transactionId($body);

// return the transaction's id
return $this->invoice->getTransactionId();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/Poolam/Poolam.php
Expand Up @@ -78,10 +78,10 @@ public function purchase()
if (empty($body['status']) || $body['status'] != 1) {
// some error has happened
throw new PurchaseFailedException($body['status']);
} else {
$this->invoice->transactionId($body['invoice_key']);
}

$this->invoice->transactionId($body['invoice_key']);

// return the transaction's id
return $this->invoice->getTransactionId();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Drivers/Yekpay/Yekpay.php
Expand Up @@ -90,13 +90,13 @@ public function purchase()

$response = json_decode($client->request($data));

if ($response->Code == 100) {
$this->invoice->transactionId($response->Authority);
} else {
if ($response->Code != 100) {
//"Request failed with Error code: $response->Code and Error message: $response->Description";
throw new PurchaseFailedException($response->Description);
}

$this->invoice->transactionId($response->Authority);

// return the transaction's id
return $this->invoice->getTransactionId();
}
Expand Down
7 changes: 3 additions & 4 deletions src/Drivers/Zibal/Zibal.php
Expand Up @@ -61,12 +61,11 @@ public function purchase()
// convert to toman
$toman = $this->invoice->getAmount() * 10;

$orderId = crc32($this->invoice->getUuid()).time();
if (!empty($details['orderId'])) {
$orderId = $details['orderId'];
} elseif (!empty($details['order_id'])) {
$orderId = $details['order_id'];
} else {
$orderId = crc32($this->invoice->getUuid()).time();
}

$mobile = null;
Expand Down Expand Up @@ -99,10 +98,10 @@ public function purchase()
if ($body->result != 100) {
// some error has happened
throw new PurchaseFailedException($body->message);
} else {
$this->invoice->transactionId($body->trackId);
}

$this->invoice->transactionId($body->trackId);

// return the transaction's id
return $this->invoice->getTransactionId();
}
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentManager.php
Expand Up @@ -226,7 +226,7 @@ public function pay($initializeCallback = null)
/**
* Verifies the payment
*
* @param null $finalizeCallback
* @param $finalizeCallback|null
*
* @return ReceiptInterface
*
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasDetail.php
Expand Up @@ -15,7 +15,7 @@ trait HasDetail
* Set a piece of data to the details.
*
* @param $key
* @param $value |null
* @param $value|null
*
* @return $this
*/
Expand Down

0 comments on commit a97164c

Please sign in to comment.