@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function __construct(Invoice $invoice, $settings) |
| 47 | 47 | { |
| 48 | 48 | $this->invoice($invoice); |
| 49 | - $this->settings = (object)$settings; |
|
| 49 | + $this->settings = (object) $settings; |
|
| 50 | 50 | $this->client = new Client(); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $data = [ |
| 69 | 69 | "CorporationPin" => $this->settings->CorporationPin, |
| 70 | 70 | "Amount" => $amount, |
| 71 | - "OrderId" => intval(1, time()) . crc32($this->invoice->getUuid()), |
|
| 71 | + "OrderId" => intval(1, time()).crc32($this->invoice->getUuid()), |
|
| 72 | 72 | "CallBackUrl" => $this->settings->callbackUrl, |
| 73 | 73 | "AdditionalData" => $description, |
| 74 | 74 | ]; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | if (isset($result['errors'])) { |
| 91 | 91 | throw new PurchaseFailedException($result['title'] ?? 'اطلاعات وارد شده اشتباه می باشد.', $result['status'] ?? 400); |
| 92 | 92 | } |
| 93 | - if (!isset($result['status']) || (string)$result['status'] !== '0') { |
|
| 93 | + if (!isset($result['status']) || (string) $result['status'] !== '0') { |
|
| 94 | 94 | throw new PurchaseFailedException($result['message'] ?? "خطای ناشناخته رخ داده است. در صورت کسر مبلغ از حساب حداکثر پس از 72 ساعت به حسابتان برمیگردد", $result['status'] ?? 400); |
| 95 | 95 | } |
| 96 | 96 | $this->invoice->transactionId($result['token']); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $transactionId = $this->invoice->getTransactionId(); |
| 109 | 109 | $paymentUrl = $this->settings->apiPaymentUrl; |
| 110 | 110 | |
| 111 | - $payUrl = $paymentUrl . $transactionId; |
|
| 111 | + $payUrl = $paymentUrl.$transactionId; |
|
| 112 | 112 | |
| 113 | 113 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 114 | 114 | } |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | ); |
| 139 | 139 | $result = json_decode($response->getBody()->getContents(), true); |
| 140 | 140 | if (!isset($result['status']) |
| 141 | - || ((string)$result['status'] !== '0' |
|
| 142 | - && (string)$result['status'] !== '2') |
|
| 143 | - || (string)$result['rrn'] === '0') { |
|
| 141 | + || ((string) $result['status'] !== '0' |
|
| 142 | + && (string) $result['status'] !== '2') |
|
| 143 | + || (string) $result['rrn'] === '0') { |
|
| 144 | 144 | throw new InvalidPaymentException("خطای ناشناخته رخ داده است. در صورت کسر مبلغ از حساب حداکثر پس از 72 ساعت به حسابتان برمیگردد", $result['status'] ?? 400); |
| 145 | 145 | } |
| 146 | 146 | $refId = $result['rrn']; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function pay(): RedirectionForm |
| 112 | 112 | { |
| 113 | - $payUrl = $this->getPaymentUrl() . $this->invoice->getTransactionId(); |
|
| 113 | + $payUrl = $this->getPaymentUrl().$this->invoice->getTransactionId(); |
|
| 114 | 114 | |
| 115 | 115 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 116 | 116 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $refId = $body['result']['refid']; |
| 162 | - $receipt = $this->createReceipt($refId); |
|
| 162 | + $receipt = $this->createReceipt($refId); |
|
| 163 | 163 | |
| 164 | 164 | $receipt->detail([ |
| 165 | 165 | 'refid' => $refId, |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function pay(): RedirectionForm |
| 108 | 108 | { |
| 109 | - $payUrl = $this->getPaymentUrl() . $this->invoice->getTransactionId(); |
|
| 109 | + $payUrl = $this->getPaymentUrl().$this->invoice->getTransactionId(); |
|
| 110 | 110 | |
| 111 | 111 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 112 | 112 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $refId = $body['refId']; |
| 155 | - $receipt = $this->createReceipt($refId); |
|
| 155 | + $receipt = $this->createReceipt($refId); |
|
| 156 | 156 | |
| 157 | 157 | $receipt->detail([ |
| 158 | 158 | 'message' => $body['message'], |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | $this->base_url = $this->settings->base_url; |
| 37 | 37 | $this->shop_slug = $this->settings->shop_slug; |
| 38 | 38 | $this->auth_code = $this->settings->auth_code; |
| 39 | - $this->code = $this->shop_slug . ':' . $this->auth_code; |
|
| 40 | - $this->auth_token = base64_encode($this->code); |
|
| 39 | + $this->code = $this->shop_slug.':'.$this->auth_code; |
|
| 40 | + $this->auth_token = base64_encode($this->code); |
|
| 41 | 41 | $this->client = new Client(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Purchase the invoice, save its transactionId and finaly return it. |
| 45 | 45 | public function purchase() |
| 46 | 46 | { |
| 47 | - $url = $this->base_url . "/users/me/shops/" . $this->shop_slug . "/deals"; |
|
| 47 | + $url = $this->base_url."/users/me/shops/".$this->shop_slug."/deals"; |
|
| 48 | 48 | $data = $this->settings->data; |
| 49 | 49 | |
| 50 | 50 | $response = $this->client |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function pay(): RedirectionForm |
| 75 | 75 | { |
| 76 | 76 | $transactionId = $this->invoice->getTransactionId(); |
| 77 | - $redirect_url = $this->base_url . '/deals/' . $transactionId . '/redirect'; |
|
| 77 | + $redirect_url = $this->base_url.'/deals/'.$transactionId.'/redirect'; |
|
| 78 | 78 | |
| 79 | 79 | return $this->redirectWithForm($redirect_url, [], 'GET'); |
| 80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $state = Request::input('state'); |
| 86 | 86 | |
| 87 | 87 | $transactionId = $this->invoice->getTransactionId(); |
| 88 | - $verifyUrl = $this->base_url . "/users/me/shops/" . $this->shop_slug . "/deals/" . $transactionId . "/verify"; |
|
| 88 | + $verifyUrl = $this->base_url."/users/me/shops/".$this->shop_slug."/deals/".$transactionId."/verify"; |
|
| 89 | 89 | |
| 90 | 90 | if ($state != 'funded') { |
| 91 | 91 | throw new InvalidPaymentException('پرداخت انجام نشد'); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->invoice->transactionId($body['payment_id']); |
| 121 | 121 | |
| 122 | - $this->cache->set('payment_link_' . $body['payment_id'], $body['link'], $this->settings->cacheExpireTTL); |
|
| 122 | + $this->cache->set('payment_link_'.$body['payment_id'], $body['link'], $this->settings->cacheExpireTTL); |
|
| 123 | 123 | |
| 124 | 124 | // return the transaction's id |
| 125 | 125 | return $this->invoice->getTransactionId(); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function pay(): RedirectionForm |
| 134 | 134 | { |
| 135 | - $payUrl = $this->cache->get('payment_link_' . $this->invoice->getTransactionId()); |
|
| 135 | + $payUrl = $this->cache->get('payment_link_'.$this->invoice->getTransactionId()); |
|
| 136 | 136 | |
| 137 | 137 | return $this->redirectWithForm($payUrl, [], 'GET'); |
| 138 | 138 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | throw new InvalidPaymentException($body['message'], $body['error_code'] ?? 0); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $receipt = $this->createReceipt($paymentReceiptNumber); |
|
| 180 | + $receipt = $this->createReceipt($paymentReceiptNumber); |
|
| 181 | 181 | |
| 182 | 182 | $receipt->detail([ |
| 183 | 183 | 'id' => $body['id'], |
@@ -150,7 +150,7 @@ |
||
| 150 | 150 | |
| 151 | 151 | $refId = $result['data']['ref_id']; |
| 152 | 152 | |
| 153 | - $receipt = $this->createReceipt($refId); |
|
| 153 | + $receipt = $this->createReceipt($refId); |
|
| 154 | 154 | $receipt->detail([ |
| 155 | 155 | 'code' => $result['data']['code'], |
| 156 | 156 | 'message' => $result['data']['message'] ?? null, |