src/Mpesa/B2B/PayMerchant.php
/**
     * Initiate the B2B transaction.
     *
     * @return mixed
     */
Initiate the B2B transaction.
@return mixed
Initiate the B2B transaction . @return mixed
public function transact()
    {
        $paybill    = $this->engine->config->get('mpesa.paybill_number');
        $initiator  = $this->engine->config->get('mpesa.initiator');
        $credential = (new Generator($this->engine))->generate();
        $body       = [
            'Initiator'              => $initiator,
            'SecurityCredential'     => $credential,
            'CommandID'              => $this->command,
            'Amount'                 => $this->amount,
            'PartyA'                 => $paybill,
            'PartyB'                 => $this->partyB,
            'Remarks'                => $this->remarks,
            'SenderIdentifierType'   => $this->engine->config->get('mpesa.identifier_type') ?: 4,
            'RecieverIdentifierType' => $this->identifierType,
            'QueueTimeOutURL'        => $this->callback('mpesa.queue_timeout_callback'),
            'ResultURL'              => $this->callback('mpesa.b2b_result_url'),
        ];
        if ('BusinessPayBill' === $body['CommandID']) {
            if (null === $this->reference) {
                throw new \InvalidArgumentException('Account Reference is mandatory for “BusinessPaybill” CommandID.');
            }
            $body['AccountReference'] = $this->reference;
        }
        return $this->handleRequest($body);
    }
public function transact ( ) { $ paybill = $ this -> engine -> config -> get ( 'mpesa.paybill_number' ) ; $ initiator = $ this -> engine -> config -> get ( 'mpesa.initiator' ) ; $ credential = ( new Generator ( $ this -> engine ) ) -> generate ( ) ; $ body = [ 'Initiator' => $ initiator , 'SecurityCredential' => $ credential , 'CommandID' => $ this -> command , 'Amount' => $ this -> amount , 'PartyA' => $ paybill , 'PartyB' => $ this -> partyB , 'Remarks' => $ this -> remarks , 'SenderIdentifierType' => $ this -> engine -> config -> get ( 'mpesa.identifier_type' ) ? : 4 , 'RecieverIdentifierType' => $ this -> identifierType , 'QueueTimeOutURL' => $ this -> callback ( 'mpesa.queue_timeout_callback' ) , 'ResultURL' => $ this -> callback ( 'mpesa.b2b_result_url' ) , ] ; if ( 'BusinessPayBill' === $ body [ 'CommandID' ] ) { if ( null === $ this -> reference ) { throw new \ InvalidArgumentException ( 'Account Reference is mandatory for “BusinessPaybill” CommandID.'); } $ body [ 'AccountReference' ] = $ this -> reference ; } return $ this -> handleRequest ( $ body ) ; }
Initiate the B2B transaction.
Initiate the B2B transaction .
// dd($body);