@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | |
63 | 63 | $mode = config('laravel-daraja.mode'); |
64 | 64 | |
65 | - $baseUrl = $this->removeLastSlash(config('laravel-daraja.base_uri.'.$mode)); |
|
65 | + $baseUrl = $this->removeLastSlash(config('laravel-daraja.base_uri.' . $mode)); |
|
66 | 66 | |
67 | 67 | $options = [ |
68 | - 'base_uri' => $baseUrl.'/', |
|
68 | + 'base_uri' => $baseUrl . '/', |
|
69 | 69 | 'verify' => $mode === 'sandbox' ? false : true, |
70 | 70 | ]; |
71 | 71 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function securityCredential($plaintext) |
143 | 143 | { |
144 | - $publicKey = file_get_contents(__DIR__.'/../cert.cer'); |
|
144 | + $publicKey = file_get_contents(__DIR__ . '/../cert.cer'); |
|
145 | 145 | |
146 | 146 | openssl_public_encrypt($plaintext, $encrypted, $publicKey, OPENSSL_PKCS1_PADDING); |
147 | 147 | return base64_encode($encrypted); |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | * @return mixed |
157 | 157 | * @throws MpesaApiRequestException |
158 | 158 | */ |
159 | - protected function call($url, $options = [], $method = 'POST') |
|
159 | + protected function call($url, $options = [ ], $method = 'POST') |
|
160 | 160 | { |
161 | 161 | if (isset($this->accessToken)) { |
162 | - $options['headers'] = ['Authorization' => 'Bearer '.$this->accessToken]; |
|
162 | + $options[ 'headers' ] = [ 'Authorization' => 'Bearer ' . $this->accessToken ]; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | try { |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | } catch (ServerException $e) { |
169 | 169 | $response = json_decode($e->getResponse()->getBody()->getContents()); |
170 | 170 | if (isset($response->Envelope)) { |
171 | - $message = 'Safaricom APIs: '.$response->Envelope->Body->Fault->faultstring; |
|
171 | + $message = 'Safaricom APIs: ' . $response->Envelope->Body->Fault->faultstring; |
|
172 | 172 | throw new MpesaApiRequestException($message, $e->getCode()); |
173 | 173 | } |
174 | - throw new MpesaApiRequestException('Safaricom APIs: '.$response->errorMessage, $e->getCode()); |
|
174 | + throw new MpesaApiRequestException('Safaricom APIs: ' . $response->errorMessage, $e->getCode()); |
|
175 | 175 | } catch (ClientException $e) { |
176 | 176 | $response = json_decode($e->getResponse()->getBody()->getContents()); |
177 | 177 | throw new MpesaApiRequestException('Safaricom APIs: ' |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $this->initiatorName = config('laravel-daraja.initiator.name'); |
82 | 82 | $this->securityCredential = $this->securityCredential(config('laravel-daraja.initiator.credential')); |
83 | 83 | $this->partyA = config('laravel-daraja.initiator.short_code'); |
84 | - $this->senderIdentifierType = $this->identifier[config('laravel-daraja.initiator.type')]; |
|
84 | + $this->senderIdentifierType = $this->identifier[ config('laravel-daraja.initiator.type') ]; |
|
85 | 85 | |
86 | 86 | $this->queueTimeOutURL = $this->setUrl(config('laravel-daraja.queue_timeout_url.b2b')); |
87 | 87 | $this->resultURL = $this->setUrl(config('laravel-daraja.result_url.b2b')); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function setShortCode($code, $type) |
119 | 119 | { |
120 | 120 | $this->partyA = $code; |
121 | - $this->senderIdentifierType = $this->identifier[$type]; |
|
121 | + $this->senderIdentifierType = $this->identifier[ $type ]; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function payToPayBill($payBillNo, $amount, $remarks, $accountReference = '') |
156 | 156 | { |
157 | 157 | $this->setCommandId('BusinessPayBill'); |
158 | - $this->receiverIdentifierType = $this->identifier['paybill']; |
|
158 | + $this->receiverIdentifierType = $this->identifier[ 'paybill' ]; |
|
159 | 159 | return $this->pay($payBillNo, $amount, $remarks, $accountReference); |
160 | 160 | } |
161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public function payToBuyGoods($tillNo, $amount, $remarks) |
172 | 172 | { |
173 | 173 | $this->setCommandId('BusinessBuyGoods'); |
174 | - $this->receiverIdentifierType = $this->identifier['till']; |
|
174 | + $this->receiverIdentifierType = $this->identifier[ 'till' ]; |
|
175 | 175 | return $this->pay($tillNo, $amount, $remarks); |
176 | 176 | } |
177 | 177 | |
@@ -205,6 +205,6 @@ discard block |
||
205 | 205 | 'ResultURL' => $this->resultURL, |
206 | 206 | ]; |
207 | 207 | |
208 | - return $response = $this->call($this->endPoint, ['json' => $parameters]); |
|
208 | + return $response = $this->call($this->endPoint, [ 'json' => $parameters ]); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -196,6 +196,6 @@ |
||
196 | 196 | 'Occassion' => $occasion, |
197 | 197 | ]; |
198 | 198 | |
199 | - return $response = $this->call($this->endPoint, ['json' => $parameters]); |
|
199 | + return $response = $this->call($this->endPoint, [ 'json' => $parameters ]); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | \ No newline at end of file |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'ConfirmationURL' => $this->setUrl($confirmationUrl), |
56 | 56 | 'ValidationURL' => $this->setUrl($validationUrl), |
57 | 57 | ]; |
58 | - return $this->call($this->urlRegistrationEndPoint, ['json' => $parameters]); |
|
58 | + return $this->call($this->urlRegistrationEndPoint, [ 'json' => $parameters ]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -116,6 +116,6 @@ discard block |
||
116 | 116 | 'Msisdn' => $phoneNumber, |
117 | 117 | 'BillRefNumber' => $reference, |
118 | 118 | ]; |
119 | - return $this->call($this->simulationEndpoint, ['json' => $parameters]); |
|
119 | + return $this->call($this->simulationEndpoint, [ 'json' => $parameters ]); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | \ No newline at end of file |
@@ -109,7 +109,7 @@ |
||
109 | 109 | 'QueueTimeOutURL' => $this->queueTimeoutURL, |
110 | 110 | 'ResultURL' => $this->resultURL, |
111 | 111 | ]; |
112 | - return $this->call($this->queryEndPoint, ['json' => $parameters]); |
|
112 | + return $this->call($this->queryEndPoint, [ 'json' => $parameters ]); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | \ No newline at end of file |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function toPayBillStatus($transactionID, $remarks, $occasion = '') |
108 | 108 | { |
109 | - $this->identifierType = $this->identifier['paybill']; |
|
109 | + $this->identifierType = $this->identifier[ 'paybill' ]; |
|
110 | 110 | return $this->status($transactionID, $remarks, $occasion); |
111 | 111 | } |
112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function toTillStatus($transactionID, $remarks, $occasion = '') |
122 | 122 | { |
123 | - $this->identifierType = $this->identifier['till']; |
|
123 | + $this->identifierType = $this->identifier[ 'till' ]; |
|
124 | 124 | return $this->status($transactionID, $remarks, $occasion); |
125 | 125 | } |
126 | 126 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function toMsisdnStatus($transactionID, $remarks, $occasion = '') |
136 | 136 | { |
137 | - $this->identifierType = $this->identifier['msisdn']; |
|
137 | + $this->identifierType = $this->identifier[ 'msisdn' ]; |
|
138 | 138 | return $this->status($transactionID, $remarks, $occasion); |
139 | 139 | } |
140 | 140 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function fromMsisdnStatus($msisdn, $transactionID, $remarks, $occasion = '') |
152 | 152 | { |
153 | 153 | $this->partyA = $msisdn; |
154 | - $this->identifierType = $this->identifier['msisdn']; |
|
154 | + $this->identifierType = $this->identifier[ 'msisdn' ]; |
|
155 | 155 | return $this->status($transactionID, $remarks, $occasion); |
156 | 156 | } |
157 | 157 | |
@@ -178,6 +178,6 @@ discard block |
||
178 | 178 | 'Remarks' => $remarks, |
179 | 179 | 'Occasion' => $occasion, |
180 | 180 | ]; |
181 | - return $this->call($this->queryEndPoint, ['json' => $parameters]); |
|
181 | + return $this->call($this->queryEndPoint, [ 'json' => $parameters ]); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | \ No newline at end of file |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function generatePassword($shortCode, $passKey, $timestamp) |
100 | 100 | { |
101 | - return base64_encode($shortCode.$passKey.$timestamp); |
|
101 | + return base64_encode($shortCode . $passKey . $timestamp); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | 'TransactionDesc' => str_limit($description, 20, ''), |
130 | 130 | ]; |
131 | 131 | |
132 | - return $this->call($this->stkEndpoint, ['json' => $parameters]); |
|
132 | + return $this->call($this->stkEndpoint, [ 'json' => $parameters ]); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'CheckoutRequestID' => $checkoutRequestId, |
151 | 151 | ]; |
152 | 152 | |
153 | - return $this->call($this->statusEndPoint, ['json' => $parameters]); |
|
153 | + return $this->call($this->statusEndPoint, [ 'json' => $parameters ]); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | } |
157 | 157 | \ No newline at end of file |
@@ -116,7 +116,7 @@ |
||
116 | 116 | 'Occasion' => str_limit($occasion, 100, ''), |
117 | 117 | ]; |
118 | 118 | |
119 | - return $this->call($this->reversalEndPoint, ['json' => $parameters]); |
|
119 | + return $this->call($this->reversalEndPoint, [ 'json' => $parameters ]); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | } |
123 | 123 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Package path to config. |
11 | 11 | */ |
12 | - const CONFIG_PATH = __DIR__.'/../config/laravel-daraja.php'; |
|
12 | + const CONFIG_PATH = __DIR__ . '/../config/laravel-daraja.php'; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Perform post-registration booting of services. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | 'laravel-daraja' |
42 | 42 | ); |
43 | 43 | |
44 | - $this->app->bind('mpesa-api', function () { |
|
44 | + $this->app->bind('mpesa-api', function() { |
|
45 | 45 | return new MpesaApi(); |
46 | 46 | }); |
47 | 47 | } |