Skip to content

Commit

Permalink
Resolve faild test
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammad3250 committed Aug 18, 2024
1 parent 4b0b2c2 commit 9faa6d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
'terminalCode' => '',
'username' => '',
'password' => '',
'callbackUrl' => env('BANK_CALLBACK_URL'),
'callbackUrl' => '',
'currency' => 'T' ////Can be R, T (Rial, Toman)
],
'payir' => [
Expand Down
11 changes: 6 additions & 5 deletions src/Drivers/Pasargad/Pasargad.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public function verify(): ReceiptInterface
throw new InvalidPaymentException("This transaction is fail.");
}

if($payment_inquiry['data']['transactionId'] !== $transactionId) {
throw new InvalidPaymentException("This transaction is fail.");
}

$verifyResult = $this->request(
$this->settings->verifyPayment,
[
Expand Down Expand Up @@ -239,7 +243,7 @@ protected function prepareInvoiceData(): array
protected function request(string $url, array $body, string $method = 'POST', string $token = null): array
{
$body = json_encode($body);
$token = $token != null ? 'Bearer '.$token : null;
$token = $token !== null ? 'Bearer '.$token : null;

$response = $this->client->request(
'POST',
Expand Down Expand Up @@ -278,10 +282,7 @@ protected function createToken(): string
$getTokenUrl = $this->settings->apiGetToken;

try {
return $this->request(
$getTokenUrl,
$data
)['token'];
return $this->request($getTokenUrl, $data)['token'];
} catch (GuzzleException|InvalidPaymentException $e) {
throw new InvalidPaymentException($e->getMessage());
}
Expand Down

0 comments on commit 9faa6d9

Please sign in to comment.