Skip to content

Commit

Permalink
Merge branch 'decrease-code-complexity'
Browse files Browse the repository at this point in the history
  • Loading branch information
khanzadimahdi committed May 14, 2024
2 parents 15b0782 + e5788fb commit f1c78e3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/Drivers/Rayanpay/Rayanpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public function purchase()
$xp = new \DOMXPath($dom);
$nodes = $xp->query('//input[@name="RefId"]');
$node = $nodes->item(0);
session()->put('RefId', $node->getAttribute('value'));
$_SESSION['RefId'] = $node->getAttribute('value');

return $this->invoice->getTransactionId();
}

Expand All @@ -154,7 +155,7 @@ public function pay(): RedirectionForm
{
return $this->redirectWithForm($this->settings->apiPurchaseUrl, [
'x_GateChanged' => 0,
'RefId' => session('RefId')
'RefId' => !empty($_SESSION['RefId']) ? $_SESSION['RefId'] : null,
], 'POST');
}

Expand Down
6 changes: 3 additions & 3 deletions src/Drivers/Sepehr/Sepehr.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public function pay(): RedirectionForm
*/
public function verify(): ReceiptInterface
{
$resp_code = Request::input('respcode');
$responseCode = Request::input('respcode');
$amount = $this->invoice->getAmount() * ($this->settings->currency == 'T' ? 10 : 1); // convert to rial

if ($resp_code != 0) {
$this->notVerified($resp_code);
if ($responseCode != 0) {
$this->notVerified($responseCode);
}

$data_query = 'digitalreceipt=' . Request::input('digitalreceipt') . '&Tid=' . $this->settings->terminalId;
Expand Down
18 changes: 10 additions & 8 deletions src/Drivers/Toman/Toman.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Shetabit\Multipay\Abstracts\Driver;
use Shetabit\Multipay\Contracts\ReceiptInterface;
use Shetabit\Multipay\Exceptions\InvalidPaymentException;
use Shetabit\Multipay\Request;

class Toman extends Driver
{
Expand Down Expand Up @@ -70,20 +71,21 @@ public function pay(): RedirectionForm
// Verify the payment (we must verify to ensure that user has paid the invoice).
public function verify(): ReceiptInterface
{
$inputs = request()->all();
$state = Request::input('state');

$transactionId = $this->invoice->getTransactionId();
$verifyUrl = $this->base_url . "/users/me/shops/" . $this->shop_slug . "/deals/" . $transactionId . "/verify";

if ($inputs['state'] == 'funded') {
$result = Http::withHeaders([
'Authorization' => "Basic {$this->auth_token}",
"Content-Type" => 'application/json'
])->patch($verifyUrl);
return $this->createReceipt($transactionId);
} else {
if ($state != 'funded') {
throw new InvalidPaymentException('پرداخت انجام نشد');
}

Http::withHeaders([
'Authorization' => "Basic {$this->auth_token}",
"Content-Type" => 'application/json'
])->patch($verifyUrl);

return $this->createReceipt($transactionId);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/InteractsWithRedirectionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function setRedirectionFormViewPath(string $path)
/**
* Retrieve default view path of redirection form.
*
* @return void
* @return string
*/
public static function getRedirectionFormDefaultViewPath() : string
{
Expand All @@ -31,7 +31,7 @@ public static function getRedirectionFormDefaultViewPath() : string
/**
* Retrieve current view path of redirection form.
*
* @return void
* @return string
*/
public static function getRedirectionFormViewPath() : string
{
Expand Down

0 comments on commit f1c78e3

Please sign in to comment.