Issues (8)

src/Drivers/Pasargad.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Sinarajabpour1998\Gateway\Drivers;
4
5
use Sinarajabpour1998\PasargadGateway\PasargadIpg;
0 ignored issues
show
The type Sinarajabpour1998\PasargadGateway\PasargadIpg was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Sinarajabpour1998\Gateway\Abstracts\Driver;
7
8
class Pasargad extends Driver
9
{
10
    public function init($amount, $orderId, $callbackUrl, $detail = [])
11
    {
12
        // Create new transaction
13
        $transaction = $this->createNewTransaction($orderId, $amount);
14
15
        // Create object from Pasargad Driver
16
        $class = new PasargadIpg($this->getInformation());
17
        $class->verifySSL(config('gateway.information')['pasargad']['options']['verifySSL']);
18
19
        $result = $class->getToken( $amount, $transaction->id, $transaction->created_at->format('Y/m/d H:i:s'), $callbackUrl );
20
21
        if(isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result->status == 'success') {
22
            $result->token  = $result->token;
23
            $result->url    = 'https://pep.shaparak.ir/payment.aspx?n=' . $result->token;
24
            return $result;
25
26
        } elseif($result->status == 'success') {
27
            $this->updateTransactionData($transaction->id, ['token' => $result->token]);
28
            header( 'Location: https://pep.shaparak.ir/payment.aspx?n=' . $result->token );
29
            die();
30
31
        }
32
33
        return $result;
34
    }
35
36
    public function verify($request)
37
    {
38
        $class = new PasargadIpg($this->getInformation());
39
        $class->verifySSL(config('gateway.information')['pasargad']['options']['verifySSL']);
40
41
        $check = $class->checkTransaction( $request['iN'], $request['iD'] );
42
43
        if ($check->status == 'success') {
44
            $transaction = $this->getTransaction($request['iN']);
45
            $result = $class->verifyTransaction( (int) $transaction->amount, $request['iN'], $request['iD'] );
46
47
            if ($result->status == 'success') {
48
                $this->updateTransactionData($request['iN'], ['status' => 'successful', 'ref_no' => $request['tref']]);
49
            } else {
50
                $this->updateTransactionData($request['iN'], ['status' => 'failed', 'ref_no' => $request['tref']]);
51
            }
52
            return $result;
53
        }
54
55
        $this->updateTransactionData($request['iN'], ['status' => 'failed', 'ref_no' => $request['tref']]);
56
        return $check;
57
    }
58
}
59