| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function validate($number, $callback = null) |
||
| 22 | { |
||
| 23 | $number = $this->formatPhoneNumber($number); |
||
| 24 | $time = Carbon::now()->format('YmdHis'); |
||
| 25 | $shortCode = \config('samerior.mpesa.c2b.short_code'); |
||
| 26 | $passkey = \config('samerior.mpesa.c2b.passkey'); |
||
| 27 | $defaultCallback = \config('samerior.mpesa.id_validation_callback'); |
||
| 28 | $initiator = \config('samerior.mpesa.initiator'); |
||
| 29 | $password = \base64_encode($shortCode . $passkey . $time); |
||
| 30 | $body = [ |
||
| 31 | 'Initiator' => $initiator, |
||
| 32 | 'BusinessShortCode' => $shortCode, |
||
| 33 | 'Password' => $password, |
||
| 34 | 'Timestamp' => $time, |
||
| 35 | 'TransactionType' => 'CheckIdentity', |
||
| 36 | 'PhoneNumber' => $number, |
||
| 37 | 'CallBackURL' => $callback ?: $defaultCallback, |
||
| 38 | 'TransactionDesc' => ' ' |
||
| 39 | ]; |
||
| 40 | return $this->sendRequest($body, 'id_check'); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |