caute, neviem si stale s niecim poradit. robim platobný modul (cardpay) pre nemenovany e-shop. mam problem s tym, ze ten hash sa mi nechce vobec vypisat, kde moze byt problem? diky
Kód:
function computeSign($sharedSecret) {
if (!$this->isValid)
throw new Exception(__METHOD__.": Message was not validated.");
try {
$bytesHash = sha1($this->GetSignatureBase(), true);
// uprava pre PHP < 5.0
if (strlen($bytesHash) != 20) {
$bytes = "";
for ($i = 0; $i < strlen($bytesHash); $i+=2)
$bytes .= chr(hexdec(substr($str, $i, 2)));
$bytesHash = $bytes;
}
$des = mcrypt_module_open(MCRYPT_DES, "", MCRYPT_MODE_ECB, "");
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($des), MCRYPT_RAND);
mcrypt_generic_init($des, $sharedSecret, $iv);
$bytesSign = mcrypt_generic($des, substr($bytesHash, 0, 8));
mcrypt_generic_deinit($des);
mcrypt_module_close($des);
$sign = strtoupper(bin2hex($bytesSign));
} catch (Exception $e) {
return false;
}
return $sign;
}
function getSignatureBase() {
$sb = "{$this->data['mid']}{$this->data['amt']}{$this->data['curr']}{$this->data['vs']}{$this->data['cs']}{$this->data['rurl']}{$this->data['ipc']}{$this->data['name']}";
return $sb;
}
$this->data['mid'] = $this->config->get('cardpay_merchant_key');
$this->data['amt'] = $this->currency->format($order_info['total'], $order_info['currency'], 1.00000, FALSE);
$this->data['curr'] = $this->currency->getCode();
$this->data['vs'] = $this->session->data['order_id'];
$this->data['rurl'] = HTTP_SERVER . 'index.php?route=checkout/success';
$this->data['ipc'] = $this->request->server['REMOTE_ADDR'];
$this->data['name'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
$this->data['sign'] = $sign;
$this->data['rsms'] = $order_info['telephone'];
$this->data['rem'] = $order_info['email'];
$this->data['desc'] = substr($this->config->get('config_name'), 0, 100);
$this->data['lang'] = $this->session->data['language'];
$this->data['action'] = 'https://moja.tatrabanka.sk/cgi-bin/e-commerce/start/example.jsp?PT=CardPay&MID='. $this->data['mid'] . '&AMT='. $this->data['amt'] . '&CURR='. $this->data['curr'] . '&VS='. $this->data['vs'] . '&CS=0008&RURL='. $this->data['rurl'] . '&IPC='. $this->data['ipc'] . '&NAME='. $this->data['name'] . '&SIGN='. $this->data['sign'] . '&RSMS='. $this->data['rsms'] . '&REM='. $this->data['rem'] . '&DESC='. $this->data['desc'] . '&AREDIR=1&LANG='. $this->data['lang']; '';