Prestashop:从SHA1迁移到SHA2

时间:2019-06-19 00:27:47

标签: php cryptography prestashop sha2

我需要在Prestashop中升级POS模块的安全性,现在我面临一个问题:获取付款签名时出现错误。

旧代码

  static public function getFirma($orderId, $importe, $tipoMondea, $exponente, $urlOK, $urlNOK ) {
        //Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operacion+Importe+Tipo Moneda+Exponente+'SHA1'+URL_OK+URL_NOK

        $cryptKey = self::getCryptKey();
        $merchantId = Configuration::get('CECA_MERCHANT_ID');
        $acquirerBIN = Configuration::get('CECA_ACQUIRER_BIN');
        $terminalId = Configuration::get('CECA_TERMINAL_ID');

        return sha1($cryptKey.$merchantId.$acquirerBIN.$terminalId.$orderId.$importe.$tipoMondea.$exponente.'SHA1'.$urlOK.$urlNOK);
    }

    static public function getFirmaIPN($orderId, $importe, $tipoMondea, $exponente, $referencia ) {
        //Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operacion+Importe+TipoMoneda+Exponente+Referencia

        $cryptKey = self::getCryptKey();
        $merchantId = Configuration::get('CECA_MERCHANT_ID');
        $acquirerBIN = Configuration::get('CECA_ACQUIRER_BIN');
        $terminalId = Configuration::get('CECA_TERMINAL_ID');

        return sha1($cryptKey.$merchantId.$acquirerBIN.$terminalId.$orderId.$importe.$tipoMondea.$exponente.$referencia);
    }

我尝试过:

static public function getFirma($orderId, $importe, $tipoMondea, $exponente, $urlOK, $urlNOK ) {
        //Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operacion+Importe+Tipo Moneda+Exponente+'SHA2'+URL_OK+URL_NOK

        $cryptKey = self::getCryptKey();
        $merchantId = Configuration::get('CECA_MERCHANT_ID');
        $acquirerBIN = Configuration::get('CECA_ACQUIRER_BIN');
        $terminalId = Configuration::get('CECA_TERMINAL_ID');

        return hash('sha2', $cryptKey.$merchantId.$acquirerBIN.$terminalId.$orderId.$importe.$tipoMondea.$exponente.'SHA2'.$urlOK.$urlNOK);
    }

    static public function getFirmaIPN($orderId, $importe, $tipoMondea, $exponente, $referencia ) {
        //Clave_encriptacion+MerchantID+AcquirerBIN+TerminalID+Num_operacion+Importe+TipoMoneda+Exponente+Referencia

        $cryptKey = self::getCryptKey();
        $merchantId = Configuration::get('CECA_MERCHANT_ID');
        $acquirerBIN = Configuration::get('CECA_ACQUIRER_BIN');
        $terminalId = Configuration::get('CECA_TERMINAL_ID');

        return hash('sha2', $cryptKey.$merchantId.$acquirerBIN.$terminalId.$orderId.$importe.$tipoMondea.$exponente.$referencia);
    }

但是在缺少参数时出现错误。missing parameters

我们将不胜感激。

0 个答案:

没有答案