protected function getStatus(array $response)
    {
        $payments = Arr::get($response, 'payments');

        if (empty($payments)) {
            return new Status('pending');
        }

        $newResponse = $response;

        if (count($payments) > 1) {
            $totalPaid = 0;
            $totalRefund = 0;
            $total = $newResponse['shipping_cost'] + $newResponse['total_amount'];

            foreach ($payments as $payment) {
                if ($payment['status'] === 'approved') {
                    // Get the total paid amount, considering only approved incomings.
                    $totalPaid += $payment['total_paid_amount'] - $payment['amount_refunded'];
                } elseif ($payment['status'] === 'refunded') {
                    // Get the total refunded amount.
                    $totalRefund += $payment['amount_refunded'];
                }
            }

            if ($totalPaid >= $total) {
                $newResponse['status'] = 'approved';
            } elseif ($totalRefund >= $total) {
                $newResponse['status'] = 'refunded';
            } elseif ($totalRefund > 0) {
                $newResponse['status'] = 'partially_refunded';
            } else {
                $newResponse['status'] = 'pending';
            }

            return parent::getStatus($newResponse);
        }

        $newResponse['status'] = $payments[0]['amount_refunded'] > 0 ? 'partially_refunded' : $payments[0]['status'];

        return parent::getStatus($newResponse);
    }
protected function getStatus(array $response)
    {
        $payments = Arr::get($response, 'payments');

        if (empty($payments)) {
            return new Status('pending');
        }

        $newResponse = $response;

        if (count($payments) > 1) {
            $totalPaid = 0;
            $totalRefund = 0;
            $total = $newResponse['shipping_cost'] + $newResponse['total_amount'];

            foreach ($payments as $payment) {
                if ($payment['status'] === 'approved') {
                    // Get the total paid amount, considering only approved incomings.
                    $totalPaid += $payment['total_paid_amount'] - $payment['amount_refunded'];
                } elseif ($payment['status'] === 'refunded') {
                    // Get the total refunded amount.
                    $totalRefund += $payment['amount_refunded'];
                }
            }

            if ($totalPaid >= $total) {
                $newResponse['status'] = 'approved';
            } elseif ($totalRefund >= $total) {
                $newResponse['status'] = 'refunded';
            } elseif ($totalRefund > 0) {
                $newResponse['status'] = 'partially_refunded';
            } else {
                $newResponse['status'] = 'pending';
            }

            return parent::getStatus($newResponse);
        }

        $newResponse['status'] = $payments[0]['amount_refunded'] > 0 ? 'partially_refunded' : $payments[0]['status'];

        return parent::getStatus($newResponse);
    }
protected function getStatus ( array $ response ) { $ payments = Arr :: get ( $ response , 'payments' ) ; if ( empty ( $ payments ) ) { return new Status ( 'pending' ) ; } $ newResponse = $ response ; if ( count ( $ payments ) > 1 ) { $ totalPaid = 0 ; $ totalRefund = 0 ; $ total = $ newResponse [ 'shipping_cost' ] + $ newResponse [ 'total_amount' ] ; foreach ( $ payments as $ payment ) { if ( $ payment [ 'status' ] === 'approved' ) { // Get the total paid amount, considering only approved incomings. $ totalPaid += $ payment [ 'total_paid_amount' ] - $ payment [ 'amount_refunded' ] ; } elseif ( $ payment [ 'status' ] === 'refunded' ) { // Get the total refunded amount. $ totalRefund += $ payment [ 'amount_refunded' ] ; } } if ( $ totalPaid >= $ total ) { $ newResponse [ 'status' ] = 'approved' ; } elseif ( $ totalRefund >= $ total ) { $ newResponse [ 'status' ] = 'refunded' ; } elseif ( $ totalRefund > 0 ) { $ newResponse [ 'status' ] = 'partially_refunded' ; } else { $ newResponse [ 'status' ] = 'pending' ; } return parent :: getStatus ( $ newResponse ) ; } $ newResponse [ 'status' ] = $ payments [ 0 ] [ 'amount_refunded' ] > 0 ? 'partially_refunded' : $ payments [ 0 ] [ 'status' ] ; return parent :: getStatus ( $ newResponse ) ; }
Map MercadoPago response to status object.

@param array $response

@return \Shoperti\PayMe\Status|null
Map MercadoPago response to status object .