public function mapResponse($response, $statusCode)
    {
        // IPN response
        if (in_array(Arr::get($response, 'body'), ['VERIFIED', 'INVALID'])) {
            $success = $response['body'] === 'VERIFIED';

            return (new Response())->setRaw($response)->map([
                'isRedirect'      => false,
                'success'         => $success,
                'reference'       => $success ? Arr::get($response, 'invoice') : false,
                'message'         => $response['body'],
                'test'            => $this->config['test'],
                'authorization'   => $success ? Arr::get($response, 'txn_id') : '',
                'status'          => $success ?
                    $this->getPaymentStatus(Arr::get($response, 'payment_status'))
                    : new Status('failed'),
                'errorCode'       => null,
                'type'            => $success ? Arr::get($response, 'txn_type') : null,
            ]);
        }

        $isRedirect = isset($response['is_redirect']) ? $response['is_redirect'] : false;
        if ($isRedirect) {
            unset($response['is_redirect']);
        }

        // Payment request / execute response
        $type = $this->getType($response);
        $state = $this->getSuccessAndStatus($response, $statusCode, $type, $isRedirect);
        $success = $state['success'];
        $status = $state['status'];
        $reference = $state['reference'];
        $authorization = $state['authorization'];
        $message = $success ? 'Transaction approved' : Arr::get($response, 'message', '');

        return (new Response())->setRaw($response)->map([
            'isRedirect'    => $isRedirect,
            'success'       => $success,
            'reference'     => $reference,
            'message'       => $message,
            'test'          => $this->config['test'],
            'authorization' => $authorization,
            'status'        => $status,
            'errorCode'     => $success ? null : $this->getErrorCode(Arr::get($response, 'name')),
            'type'          => $type,
        ]);
    }
public function mapResponse($response, $statusCode)
    {
        // IPN response
        if (in_array(Arr::get($response, 'body'), ['VERIFIED', 'INVALID'])) {
            $success = $response['body'] === 'VERIFIED';

            return (new Response())->setRaw($response)->map([
                'isRedirect'      => false,
                'success'         => $success,
                'reference'       => $success ? Arr::get($response, 'invoice') : false,
                'message'         => $response['body'],
                'test'            => $this->config['test'],
                'authorization'   => $success ? Arr::get($response, 'txn_id') : '',
                'status'          => $success ?
                    $this->getPaymentStatus(Arr::get($response, 'payment_status'))
                    : new Status('failed'),
                'errorCode'       => null,
                'type'            => $success ? Arr::get($response, 'txn_type') : null,
            ]);
        }

        $isRedirect = isset($response['is_redirect']) ? $response['is_redirect'] : false;
        if ($isRedirect) {
            unset($response['is_redirect']);
        }

        // Payment request / execute response
        $type = $this->getType($response);
        $state = $this->getSuccessAndStatus($response, $statusCode, $type, $isRedirect);
        $success = $state['success'];
        $status = $state['status'];
        $reference = $state['reference'];
        $authorization = $state['authorization'];
        $message = $success ? 'Transaction approved' : Arr::get($response, 'message', '');

        return (new Response())->setRaw($response)->map([
            'isRedirect'    => $isRedirect,
            'success'       => $success,
            'reference'     => $reference,
            'message'       => $message,
            'test'          => $this->config['test'],
            'authorization' => $authorization,
            'status'        => $status,
            'errorCode'     => $success ? null : $this->getErrorCode(Arr::get($response, 'name')),
            'type'          => $type,
        ]);
    }
public function mapResponse ( $ response , $ statusCode ) { // IPN response if ( in_array ( Arr :: get ( $ response , 'body' ) , [ 'VERIFIED' , 'INVALID' ] ) ) { $ success = $ response [ 'body' ] === 'VERIFIED' ; return ( new Response ( ) ) -> setRaw ( $ response ) -> map ( [ 'isRedirect' => false , 'success' => $ success , 'reference' => $ success ? Arr :: get ( $ response , 'invoice' ) : false , 'message' => $ response [ 'body' ] , 'test' => $ this -> config [ 'test' ] , 'authorization' => $ success ? Arr :: get ( $ response , 'txn_id' ) : '' , 'status' => $ success ? $ this -> getPaymentStatus ( Arr :: get ( $ response , 'payment_status' ) ) : new Status ( 'failed' ) , 'errorCode' => null , 'type' => $ success ? Arr :: get ( $ response , 'txn_type' ) : null , ] ) ; } $ isRedirect = isset ( $ response [ 'is_redirect' ] ) ? $ response [ 'is_redirect' ] : false ; if ( $ isRedirect ) { unset ( $ response [ 'is_redirect' ] ) ; } // Payment request / execute response $ type = $ this -> getType ( $ response ) ; $ state = $ this -> getSuccessAndStatus ( $ response , $ statusCode , $ type , $ isRedirect ) ; $ success = $ state [ 'success' ] ; $ status = $ state [ 'status' ] ; $ reference = $ state [ 'reference' ] ; $ authorization = $ state [ 'authorization' ] ; $ message = $ success ? 'Transaction approved' : Arr :: get ( $ response , 'message' , '' ) ; return ( new Response ( ) ) -> setRaw ( $ response ) -> map ( [ 'isRedirect' => $ isRedirect , 'success' => $ success , 'reference' => $ reference , 'message' => $ message , 'test' => $ this -> config [ 'test' ] , 'authorization' => $ authorization , 'status' => $ status , 'errorCode' => $ success ? null : $ this -> getErrorCode ( Arr :: get ( $ response , 'name' ) ) , 'type' => $ type , ] ) ; }
Map the HTTP response to a response object.

@param array $response
@param int   $statusCode

@return \Shoperti\PayMe\Contracts\ResponseInterface
Map the HTTP response to a response object .