protected function getErrorCode(array $response)
    {
        $code = Arr::get($response, 'error_code', 1001);
        if (!isset($codeMap[$code])) {
            $code = 1001;
        }

        $codeMap = [
            1000 => 'processing_error',     // OpenPay internal server error
            1001 => 'config_error',         // Malformed JSON, invalid fields, not required fields
            1002 => 'config_error',         // Invalid or not authenticated request
            1003 => 'config_error',         // Unable to complete as at least one of the params is incorrect
            1004 => 'processing_error',     // A required service for processing the transaction isn't available
            1005 => 'config_error',         // One of the required resources does not exist
            1006 => 'processing_error',     // There's already a transaction with the same order id
            1007 => 'card_declined',        // Transfer between bank account and OpenPay was rejected
            1008 => 'config_error',         // One of the accounts required in the request is deactivated
            1009 => 'processing_error',     // The request body is too large
            1010 => 'config_error',         // Using wrong key (private when should be public and vs)
            1012 => 'processing_error',     // The transaction amount exceeds your allowed transaction limit
            2001 => 'config_error',         // The bank account with this CLABE is already registered on the customer
            2002 => 'config_error',         // The card with this number is already registered on the customer
            2003 => 'config_error',         // Customer with this external identifier (External ID) already exists
            2004 => 'incorrect_number',     // The check digit card number is invalid according to the Luhn algorithm
            2005 => 'invalid_expiry_date',  // The expiration date of the card is prior to the current date
            2006 => 'incorrect_cvc',        // Security code card (CVV2) was not provided
            2007 => 'invalid_number',       // The card number is a test number and can only be used in Sandbox
            2008 => 'card_declined',        // The consulted card is not valid for points
            3001 => 'card_declined',        // The card was declined
            3002 => 'invalid_expiry_date',  // The card has expired
            3003 => 'insufficient_funds',   // The card has insufficient funds
            3004 => 'suspected_fraud',      // The card has been identified as a stolen card
            3005 => 'suspected_fraud',      // The card has been identified as a fraudulent card
            3006 => 'card_declined',        // The operation is not allowed for this customer or this transaction
            3008 => 'card_declined',        // The card is not supported in online transactions
            3009 => 'card_declined',        // The card was reported missing
            3010 => 'call_issuer',          // The bank has restricted the card
            3011 => 'call_issuer',          // The bank has requested that the card is retained. Contact the bank
            3012 => 'card_declined',        // A bank authorization is required to make this payment
            4001 => 'insufficient_funds',   // The Openpay account has not enough
        ];

        return new ErrorCode($codeMap[$code]);
    }
protected function getErrorCode(array $response)
    {
        $code = Arr::get($response, 'error_code', 1001);
        if (!isset($codeMap[$code])) {
            $code = 1001;
        }

        $codeMap = [
            1000 => 'processing_error',     // OpenPay internal server error
            1001 => 'config_error',         // Malformed JSON, invalid fields, not required fields
            1002 => 'config_error',         // Invalid or not authenticated request
            1003 => 'config_error',         // Unable to complete as at least one of the params is incorrect
            1004 => 'processing_error',     // A required service for processing the transaction isn't available
            1005 => 'config_error',         // One of the required resources does not exist
            1006 => 'processing_error',     // There's already a transaction with the same order id
            1007 => 'card_declined',        // Transfer between bank account and OpenPay was rejected
            1008 => 'config_error',         // One of the accounts required in the request is deactivated
            1009 => 'processing_error',     // The request body is too large
            1010 => 'config_error',         // Using wrong key (private when should be public and vs)
            1012 => 'processing_error',     // The transaction amount exceeds your allowed transaction limit
            2001 => 'config_error',         // The bank account with this CLABE is already registered on the customer
            2002 => 'config_error',         // The card with this number is already registered on the customer
            2003 => 'config_error',         // Customer with this external identifier (External ID) already exists
            2004 => 'incorrect_number',     // The check digit card number is invalid according to the Luhn algorithm
            2005 => 'invalid_expiry_date',  // The expiration date of the card is prior to the current date
            2006 => 'incorrect_cvc',        // Security code card (CVV2) was not provided
            2007 => 'invalid_number',       // The card number is a test number and can only be used in Sandbox
            2008 => 'card_declined',        // The consulted card is not valid for points
            3001 => 'card_declined',        // The card was declined
            3002 => 'invalid_expiry_date',  // The card has expired
            3003 => 'insufficient_funds',   // The card has insufficient funds
            3004 => 'suspected_fraud',      // The card has been identified as a stolen card
            3005 => 'suspected_fraud',      // The card has been identified as a fraudulent card
            3006 => 'card_declined',        // The operation is not allowed for this customer or this transaction
            3008 => 'card_declined',        // The card is not supported in online transactions
            3009 => 'card_declined',        // The card was reported missing
            3010 => 'call_issuer',          // The bank has restricted the card
            3011 => 'call_issuer',          // The bank has requested that the card is retained. Contact the bank
            3012 => 'card_declined',        // A bank authorization is required to make this payment
            4001 => 'insufficient_funds',   // The Openpay account has not enough
        ];

        return new ErrorCode($codeMap[$code]);
    }
protected function getErrorCode ( array $ response ) { $ code = Arr :: get ( $ response , 'error_code' , 1001 ) ; if ( ! isset ( $ codeMap [ $ code ] ) ) { $ code = 1001 ; } $ codeMap = [ 1000 => 'processing_error' , // OpenPay internal server error 1001 => 'config_error' , // Malformed JSON, invalid fields, not required fields 1002 => 'config_error' , // Invalid or not authenticated request 1003 => 'config_error' , // Unable to complete as at least one of the params is incorrect 1004 => 'processing_error' , // A required service for processing the transaction isn't available 1005 => 'config_error' , // One of the required resources does not exist 1006 => 'processing_error' , // There's already a transaction with the same order id 1007 => 'card_declined' , // Transfer between bank account and OpenPay was rejected 1008 => 'config_error' , // One of the accounts required in the request is deactivated 1009 => 'processing_error' , // The request body is too large 1010 => 'config_error' , // Using wrong key (private when should be public and vs) 1012 => 'processing_error' , // The transaction amount exceeds your allowed transaction limit 2001 => 'config_error' , // The bank account with this CLABE is already registered on the customer 2002 => 'config_error' , // The card with this number is already registered on the customer 2003 => 'config_error' , // Customer with this external identifier (External ID) already exists 2004 => 'incorrect_number' , // The check digit card number is invalid according to the Luhn algorithm 2005 => 'invalid_expiry_date' , // The expiration date of the card is prior to the current date 2006 => 'incorrect_cvc' , // Security code card (CVV2) was not provided 2007 => 'invalid_number' , // The card number is a test number and can only be used in Sandbox 2008 => 'card_declined' , // The consulted card is not valid for points 3001 => 'card_declined' , // The card was declined 3002 => 'invalid_expiry_date' , // The card has expired 3003 => 'insufficient_funds' , // The card has insufficient funds 3004 => 'suspected_fraud' , // The card has been identified as a stolen card 3005 => 'suspected_fraud' , // The card has been identified as a fraudulent card 3006 => 'card_declined' , // The operation is not allowed for this customer or this transaction 3008 => 'card_declined' , // The card is not supported in online transactions 3009 => 'card_declined' , // The card was reported missing 3010 => 'call_issuer' , // The bank has restricted the card 3011 => 'call_issuer' , // The bank has requested that the card is retained. Contact the bank 3012 => 'card_declined' , // A bank authorization is required to make this payment 4001 => 'insufficient_funds' , // The Openpay account has not enough ] ; return new ErrorCode ( $ codeMap [ $ code ] ) ; }
Map OpenPay response to error code object.

@param array $response

@return \Shoperti\PayMe\ErrorCode
@return \Shoperti\PayMe\ErrorCode
Map OpenPay response to error code object .