@@ -51,7 +51,7 @@ |
||
| 51 | 51 | * @param string $card |
| 52 | 52 | * @param string $hash |
| 53 | 53 | */ |
| 54 | - public function __construct($driver, $referenceId,$card="",$hash="") |
|
| 54 | + public function __construct($driver, $referenceId, $card = "", $hash = "") |
|
| 55 | 55 | { |
| 56 | 56 | $this->driver = $driver; |
| 57 | 57 | $this->referenceId = $referenceId; |
@@ -65,21 +65,21 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | $data = array( |
| 67 | 67 | 'merchant_id' => $this->settings->merchantId, |
| 68 | - 'amount' => $this->invoice->getAmount()*10, |
|
| 68 | + 'amount' => $this->invoice->getAmount() * 10, |
|
| 69 | 69 | 'callback_url' => $this->settings->callbackUrl, |
| 70 | 70 | 'description' => $description, |
| 71 | 71 | ); |
| 72 | - if($mobile) |
|
| 72 | + if ($mobile) |
|
| 73 | 73 | { |
| 74 | 74 | $data["metadata"]["mobile"] = $mobile; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if($email) |
|
| 77 | + if ($email) |
|
| 78 | 78 | { |
| 79 | 79 | $data["metadata"]["email"] = $email; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - $data = json_encode($data,JSON_UNESCAPED_UNICODE); |
|
| 82 | + $data = json_encode($data, JSON_UNESCAPED_UNICODE); |
|
| 83 | 83 | $ch = curl_init($this->getPurchaseUrl()); |
| 84 | 84 | curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v4'); |
| 85 | 85 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 88 | 88 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
| 89 | 89 | 'Content-Type: application/json', |
| 90 | - 'Content-Length: ' . strlen($data) |
|
| 90 | + 'Content-Length: '.strlen($data) |
|
| 91 | 91 | )); |
| 92 | 92 | |
| 93 | 93 | $result = curl_exec($ch); |
| 94 | 94 | $result = json_decode($result); |
| 95 | 95 | if (!isset($result->data->code) || $result->data->code != 100 || empty($result->data->authority)) { |
| 96 | 96 | // some error has happened |
| 97 | - $message = $this->translateStatus( $result->errors->code); |
|
| 98 | - throw new PurchaseFailedException($message, $result->errors->code); |
|
| 97 | + $message = $this->translateStatus($result->errors->code); |
|
| 98 | + throw new PurchaseFailedException($message, $result->errors->code); |
|
| 99 | 99 | } |
| 100 | 100 | $this->invoice->transactionId($result->data->authority); |
| 101 | 101 | |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | $data = [ |
| 136 | 136 | 'merchant_id' => $this->settings->merchantId, |
| 137 | 137 | 'authority' => $authority, |
| 138 | - 'amount' => $this->invoice->getAmount()*10, |
|
| 138 | + 'amount' => $this->invoice->getAmount() * 10, |
|
| 139 | 139 | ]; |
| 140 | 140 | |
| 141 | 141 | if ($status != 'OK') { |
| 142 | 142 | throw new InvalidPaymentException('عملیات پرداخت توسط کاربر لغو شد.', -22); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $data = json_encode($data,JSON_UNESCAPED_UNICODE); |
|
| 145 | + $data = json_encode($data, JSON_UNESCAPED_UNICODE); |
|
| 146 | 146 | $ch = curl_init($this->getVerificationUrl()); |
| 147 | 147 | curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v4'); |
| 148 | 148 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 151 | 151 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
| 152 | 152 | 'Content-Type: application/json', |
| 153 | - 'Content-Length: ' . strlen($data) |
|
| 153 | + 'Content-Length: '.strlen($data) |
|
| 154 | 154 | )); |
| 155 | 155 | $result = curl_exec($ch); |
| 156 | 156 | $result = json_decode($result); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $message = $this->translateStatus($result->errors->code); |
| 160 | 160 | throw new InvalidPaymentException($message, $result->errors->code); |
| 161 | 161 | } |
| 162 | - return $this->createReceipt($result->data->ref_id,$result->data->card_pan,$result->data->card_hash); |
|
| 162 | + return $this->createReceipt($result->data->ref_id, $result->data->card_pan, $result->data->card_hash); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * @param $hash |
| 171 | 171 | * @return Receipt |
| 172 | 172 | */ |
| 173 | - public function createReceipt($referenceId , $card , $hash) |
|
| 173 | + public function createReceipt($referenceId, $card, $hash) |
|
| 174 | 174 | { |
| 175 | - return new Receipt('zarinpal', $referenceId,$card,$hash); |
|
| 175 | + return new Receipt('zarinpal', $referenceId, $card, $hash); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |