protected function getClientMessage(array $response)
    {
        if (isset($response['message'])) {
            return $response['message'];
        }

        $codeMap = [
            // status_detail messages
            'accredited'                           => 'Done, your payment was approved! You will see the amount charged in your bill as statement_descriptor.',
            'pending_contingency'                  => 'We are processing the payment. In less than an hour we will e-mail you the results.',
            'pending_review_manual'                => 'We are processing the payment. In less than 2 business days we will tell you by e-mail whether it was approved or if we need more information.',
            'cc_rejected_bad_filled_card_number'   => 'Check the card number.',
            'cc_rejected_bad_filled_date'          => 'Check the expiration date.',
            'cc_rejected_bad_filled_other'         => 'Check the information.',
            'cc_rejected_bad_filled_security_code' => 'Check the security code.',
            'cc_rejected_blacklist'                => 'We could not process your payment.',
            'cc_rejected_call_for_authorize'       => 'You must authorize payment_method_id to pay the amount to MercadoPago',
            'cc_rejected_card_disabled'            => 'Call payment_method_id to activate your card. The phone number is on the back of your card.',
            'cc_rejected_card_error'               => 'We could not process your payment.',
            'cc_rejected_duplicated_payment'       => 'You already made a payment for that amount. If you need to repay, use another card or other payment method.',
            'cc_rejected_high_risk'                => 'Your payment was declined. Choose another payment method.',
            'cc_rejected_insufficient_amount'      => 'Your payment_method_id do not have sufficient funds.',
            'cc_rejected_invalid_installments'     => 'payment_method_id does not process payments in installments.',
            'cc_rejected_max_attempts'             => 'You have reached the limit of allowed attempts. Choose another card or another payment method.',
            'cc_rejected_other_reason'             => 'payment_method_id did not process the payment.',
            // undocumented status_detail
            'pending_waiting_payment'              => 'Please perform your payment using the given information.',
            // status without status_detail docs
            'pending'                              => 'Your payment is pending.',
            'authorized'                           => 'Your payment was authorized but not approved yet.',
        ];

        $values = [
            'payment_method_id'    => Arr::get($response, 'payment_method_id', 'card issuer'),
            'statement_descriptor' => Arr::get($response, 'statement_descriptor'),
        ];

        $code = Arr::get($response, 'status_detail', Arr::get($response, 'status'));

        // when requesting Account::info() status is an array
        if (is_array($code)) {
            $code = '';
        }

        $message = $code === 'accredited'
            ? !empty($values['statement_descriptor']) ? Arr::get($codeMap, $code) : 'Transaction approved'
            : Arr::get($codeMap, $code);

        $message = $message
            ? str_replace(array_keys($values), array_values($values), $message)
            : str_replace('_', ' ', $code);

        return ucfirst($message);
    }
protected function getClientMessage(array $response)
    {
        if (isset($response['message'])) {
            return $response['message'];
        }

        $codeMap = [
            // status_detail messages
            'accredited'                           => 'Done, your payment was approved! You will see the amount charged in your bill as statement_descriptor.',
            'pending_contingency'                  => 'We are processing the payment. In less than an hour we will e-mail you the results.',
            'pending_review_manual'                => 'We are processing the payment. In less than 2 business days we will tell you by e-mail whether it was approved or if we need more information.',
            'cc_rejected_bad_filled_card_number'   => 'Check the card number.',
            'cc_rejected_bad_filled_date'          => 'Check the expiration date.',
            'cc_rejected_bad_filled_other'         => 'Check the information.',
            'cc_rejected_bad_filled_security_code' => 'Check the security code.',
            'cc_rejected_blacklist'                => 'We could not process your payment.',
            'cc_rejected_call_for_authorize'       => 'You must authorize payment_method_id to pay the amount to MercadoPago',
            'cc_rejected_card_disabled'            => 'Call payment_method_id to activate your card. The phone number is on the back of your card.',
            'cc_rejected_card_error'               => 'We could not process your payment.',
            'cc_rejected_duplicated_payment'       => 'You already made a payment for that amount. If you need to repay, use another card or other payment method.',
            'cc_rejected_high_risk'                => 'Your payment was declined. Choose another payment method.',
            'cc_rejected_insufficient_amount'      => 'Your payment_method_id do not have sufficient funds.',
            'cc_rejected_invalid_installments'     => 'payment_method_id does not process payments in installments.',
            'cc_rejected_max_attempts'             => 'You have reached the limit of allowed attempts. Choose another card or another payment method.',
            'cc_rejected_other_reason'             => 'payment_method_id did not process the payment.',
            // undocumented status_detail
            'pending_waiting_payment'              => 'Please perform your payment using the given information.',
            // status without status_detail docs
            'pending'                              => 'Your payment is pending.',
            'authorized'                           => 'Your payment was authorized but not approved yet.',
        ];

        $values = [
            'payment_method_id'    => Arr::get($response, 'payment_method_id', 'card issuer'),
            'statement_descriptor' => Arr::get($response, 'statement_descriptor'),
        ];

        $code = Arr::get($response, 'status_detail', Arr::get($response, 'status'));

        // when requesting Account::info() status is an array
        if (is_array($code)) {
            $code = '';
        }

        $message = $code === 'accredited'
            ? !empty($values['statement_descriptor']) ? Arr::get($codeMap, $code) : 'Transaction approved'
            : Arr::get($codeMap, $code);

        $message = $message
            ? str_replace(array_keys($values), array_values($values), $message)
            : str_replace('_', ' ', $code);

        return ucfirst($message);
    }
protected function getClientMessage ( array $ response ) { if ( isset ( $ response [ 'message' ] ) ) { return $ response [ 'message' ] ; } $ codeMap = [ // status_detail messages 'accredited' => 'Done, your payment was approved! You will see the amount charged in your bill as statement_descriptor.' , 'pending_contingency' => 'We are processing the payment. In less than an hour we will e-mail you the results.' , 'pending_review_manual' => 'We are processing the payment. In less than 2 business days we will tell you by e-mail whether it was approved or if we need more information.' , 'cc_rejected_bad_filled_card_number' => 'Check the card number.' , 'cc_rejected_bad_filled_date' => 'Check the expiration date.' , 'cc_rejected_bad_filled_other' => 'Check the information.' , 'cc_rejected_bad_filled_security_code' => 'Check the security code.' , 'cc_rejected_blacklist' => 'We could not process your payment.' , 'cc_rejected_call_for_authorize' => 'You must authorize payment_method_id to pay the amount to MercadoPago' , 'cc_rejected_card_disabled' => 'Call payment_method_id to activate your card. The phone number is on the back of your card.' , 'cc_rejected_card_error' => 'We could not process your payment.' , 'cc_rejected_duplicated_payment' => 'You already made a payment for that amount. If you need to repay, use another card or other payment method.' , 'cc_rejected_high_risk' => 'Your payment was declined. Choose another payment method.' , 'cc_rejected_insufficient_amount' => 'Your payment_method_id do not have sufficient funds.' , 'cc_rejected_invalid_installments' => 'payment_method_id does not process payments in installments.' , 'cc_rejected_max_attempts' => 'You have reached the limit of allowed attempts. Choose another card or another payment method.' , 'cc_rejected_other_reason' => 'payment_method_id did not process the payment.' , // undocumented status_detail 'pending_waiting_payment' => 'Please perform your payment using the given information.' , // status without status_detail docs 'pending' => 'Your payment is pending.' , 'authorized' => 'Your payment was authorized but not approved yet.' , ] ; $ values = [ 'payment_method_id' => Arr :: get ( $ response , 'payment_method_id' , 'card issuer' ) , 'statement_descriptor' => Arr :: get ( $ response , 'statement_descriptor' ) , ] ; $ code = Arr :: get ( $ response , 'status_detail' , Arr :: get ( $ response , 'status' ) ) ; // when requesting Account::info() status is an array if ( is_array ( $ code ) ) { $ code = '' ; } $ message = $ code === 'accredited' ? ! empty ( $ values [ 'statement_descriptor' ] ) ? Arr :: get ( $ codeMap , $ code ) : 'Transaction approved' : Arr :: get ( $ codeMap , $ code ) ; $ message = $ message ? str_replace ( array_keys ( $ values ) , array_values ( $ values ) , $ message ) : str_replace ( '_' , ' ' , $ code ) ; return ucfirst ( $ message ) ; }
Gets the message to present to the client.

@param array $response

@see https://www.mercadopago.com.mx/developers/en/api-docs/custom-checkout/create-payments/
@see https://www.mercadopago.com.mx/developers/en/guides/payments/api/handling-responses/

@return string
Gets the message to present to the client .