sinarajabpour1998 /
gateway
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Sinarajabpour1998\Gateway\Drivers; |
||||
| 4 | |||||
| 5 | use Sinarajabpour1998\Gateway\Abstracts\Driver; |
||||
| 6 | |||||
| 7 | class Poolam extends Driver |
||||
| 8 | { |
||||
| 9 | public function init($amount, $orderId, $callbackUrl, $detail = []) |
||||
| 10 | { |
||||
| 11 | // Create new transaction |
||||
| 12 | $transaction = $this->createNewTransaction($orderId, $amount); |
||||
| 13 | |||||
| 14 | $result = $this->payment_request($amount, $callbackUrl); |
||||
| 15 | |||||
| 16 | if(isset($detail['auto_redirect']) && $detail['auto_redirect'] == false && $result['status'] == 1) { |
||||
| 17 | $result['token'] = $result['invoice_key']; |
||||
| 18 | $this->updateTransactionData($transaction->id, ['token' => $result['invoice_key']]); |
||||
| 19 | $result['url'] = config('gateway.information')['poolam']['constructor']['api_url'] . "pay/" . $result['token']; |
||||
| 20 | return $result; |
||||
| 21 | |||||
| 22 | } elseif($result['status'] == 1) { |
||||
| 23 | $this->updateTransactionData($transaction->id, ['token' => $result['invoice_key']]); |
||||
| 24 | header( 'Location: ' . config('gateway.information')['poolam']['constructor']['api_url'] . "pay/" . $result['invoice_key']); |
||||
| 25 | die(); |
||||
| 26 | |||||
| 27 | } |
||||
| 28 | |||||
| 29 | return $result; |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | public function verify($request) |
||||
| 33 | { |
||||
| 34 | $check = $this->check_payment($request['invoice_key']); |
||||
| 35 | $transaction = $this->getTransactionByToken($request['invoice_key']); |
||||
| 36 | $check['order'] = null; |
||||
| 37 | if (!is_null($transaction)) { |
||||
| 38 | $check['order'] = $transaction->parent; |
||||
|
0 ignored issues
–
show
|
|||||
| 39 | if ($check['status'] == 1) { |
||||
| 40 | $this->updateTransactionData($transaction->id, ['status' => 'successful', 'ref_no' => $check['bank_code']]); |
||||
| 41 | }else { |
||||
| 42 | $this->updateTransactionData($transaction->id, ['status' => 'failed', 'ref_no' => $check['errorCode'], 'description' => $check['errorDescription']]); |
||||
| 43 | } |
||||
| 44 | } |
||||
| 45 | return $check; |
||||
| 46 | } |
||||
| 47 | |||||
| 48 | protected function check_payment($inv_key){ |
||||
| 49 | $ch = curl_init(); |
||||
| 50 | curl_setopt($ch,CURLOPT_URL,config('gateway.information')['poolam']['constructor']['api_url'] . 'check/'.$inv_key); |
||||
| 51 | curl_setopt($ch,CURLOPT_POSTFIELDS,"api_key=" . config('gateway.information')['poolam']['constructor']['api_key']); |
||||
| 52 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
||||
| 53 | curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); |
||||
| 54 | $res = curl_exec($ch); |
||||
| 55 | curl_close($ch); |
||||
| 56 | return json_decode($res,1); |
||||
|
0 ignored issues
–
show
It seems like
$res can also be of type true; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 57 | } |
||||
| 58 | |||||
| 59 | protected function payment_request($amount,$redirect){ |
||||
| 60 | $ch = curl_init(); |
||||
| 61 | curl_setopt($ch,CURLOPT_URL,config('gateway.information')['poolam']['constructor']['api_url'] . 'request'); |
||||
| 62 | curl_setopt($ch,CURLOPT_POSTFIELDS,"api_key=" . config('gateway.information')['poolam']['constructor']['api_key'] . "&amount=$amount&return_url=$redirect"); |
||||
| 63 | curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE); |
||||
| 64 | curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); |
||||
| 65 | $res = curl_exec($ch); |
||||
| 66 | curl_close($ch); |
||||
| 67 | return json_decode($res,1); |
||||
|
0 ignored issues
–
show
It seems like
$res can also be of type true; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 68 | } |
||||
| 69 | } |
||||
| 70 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.