public function push($amount = null, $number = null, $reference = null, $description = null, $account = null)
    {
        $account = $account ?: $this->account;
        $time = Carbon::now()->format('YmdHis');
        $configs = (new ConfigurationRepository)->useAccount($account);

        $shortCode = $configs->getAccountKey('lnmo.shortcode');
        $passkey   = $configs->getAccountKey('lnmo.passkey');
        $callback  = $configs->getAccountKey('lnmo.callback');

        $body = [
            'BusinessShortCode' => $shortCode,
            'Password'          => $this->getPassword($shortCode, $passkey, $time),
            'Timestamp'         => $time,
            'TransactionType'   => 'CustomerPayBillOnline',
            'Amount'            => $amount ?: $this->amount,
            'PartyA'            => $number ?: $this->number,
            'PartyB'            => $shortCode,
            'PhoneNumber'       => $number ?: $this->number,
            'CallBackURL'       => $callback,
            'AccountReference'  => $reference ?: $this->reference,
            'TransactionDesc'   => $description ?: $this->description,
        ];

        try {
            $response = $this->makeRequest(
                $body,
                Core::instance()->getEndpoint(MPESA_LNMO, $account),
                $account
            );

            return json_decode($response->getBody());
        } catch (RequestException $exception) {
            return json_decode($exception->getResponse()->getBody());
        }
    }
public function push($amount = null, $number = null, $reference = null, $description = null, $account = null)
    {
        $account = $account ?: $this->account;
        $time = Carbon::now()->format('YmdHis');
        $configs = (new ConfigurationRepository)->useAccount($account);

        $shortCode = $configs->getAccountKey('lnmo.shortcode');
        $passkey   = $configs->getAccountKey('lnmo.passkey');
        $callback  = $configs->getAccountKey('lnmo.callback');

        $body = [
            'BusinessShortCode' => $shortCode,
            'Password'          => $this->getPassword($shortCode, $passkey, $time),
            'Timestamp'         => $time,
            'TransactionType'   => 'CustomerPayBillOnline',
            'Amount'            => $amount ?: $this->amount,
            'PartyA'            => $number ?: $this->number,
            'PartyB'            => $shortCode,
            'PhoneNumber'       => $number ?: $this->number,
            'CallBackURL'       => $callback,
            'AccountReference'  => $reference ?: $this->reference,
            'TransactionDesc'   => $description ?: $this->description,
        ];

        try {
            $response = $this->makeRequest(
                $body,
                Core::instance()->getEndpoint(MPESA_LNMO, $account),
                $account
            );

            return json_decode($response->getBody());
        } catch (RequestException $exception) {
            return json_decode($exception->getResponse()->getBody());
        }
    }
public function push ( $ amount = null , $ number = null , $ reference = null , $ description = null , $ account = null ) { $ account = $ account ? : $ this -> account ; $ time = Carbon :: now ( ) -> format ( 'YmdHis' ) ; $ configs = ( new ConfigurationRepository ) -> useAccount ( $ account ) ; $ shortCode = $ configs -> getAccountKey ( 'lnmo.shortcode' ) ; $ passkey = $ configs -> getAccountKey ( 'lnmo.passkey' ) ; $ callback = $ configs -> getAccountKey ( 'lnmo.callback' ) ; $ body = [ 'BusinessShortCode' => $ shortCode , 'Password' => $ this -> getPassword ( $ shortCode , $ passkey , $ time ) , 'Timestamp' => $ time , 'TransactionType' => 'CustomerPayBillOnline' , 'Amount' => $ amount ? : $ this -> amount , 'PartyA' => $ number ? : $ this -> number , 'PartyB' => $ shortCode , 'PhoneNumber' => $ number ? : $ this -> number , 'CallBackURL' => $ callback , 'AccountReference' => $ reference ? : $ this -> reference , 'TransactionDesc' => $ description ? : $ this -> description , ] ; try { $ response = $ this -> makeRequest ( $ body , Core :: instance ( ) -> getEndpoint ( MPESA_LNMO , $ account ) , $ account ) ; return json_decode ( $ response -> getBody ( ) ) ; } catch ( RequestException $ exception ) { return json_decode ( $ exception -> getResponse ( ) -> getBody ( ) ) ; } }
Prepare the STK Push request

@param int    $amount
@param int    $number
@param string $reference
@param string $description
@param string $account

@return mixed
Prepare the STK Push request