function set_cb_number($cb, $dateval) { if (!eregi("^[0-9]{16}\$", $cb)) { fianet_insert_log("fianet_payment_xml.php - set_cb_number() <br />Cb number format is invalid, must be 00001111222233334444\n"); } elseif (!eregi("^[0-9]{2}/[0-9]{4}\$", $dateval)) { fianet_insert_log("fianet_payment_xml.php - set_cb_number() <br />Validity date format is invalid, must be MM/YYYY\n"); } else { $crypt = new HashMD5(); $this->numcb = $crypt->hash($cb); $this->dateval = $crypt->hash($dateval); } }
function get_formular($url_call = null, $url_sys = null, $ParamCallBack = array(), $typeIHM = 3, $enProd = false, $auto_send = true) { $flux = $this->get_xml(); $flux = clean_xml($flux); $flux = str_replace('"', "'", $flux); $flux = str_replace('&', '&amp;', $flux); $flux = str_replace('<', '&lt;', $flux); $flux = str_replace('>', '&gt;', $flux); $my_hashmd5 = new HashMD5(); //$toto = html_entity_decode($flux); //debug($toto); $checksum = $my_hashmd5->hash(html_entity_decode($flux)); if (is_array($ParamCallBack) && count($ParamCallBack) > 0) { $XMLParam = new fianet_xml_paracallback_builder(); foreach ($ParamCallBack as $index => $value) { $XMLParam->add_param(new fianet_paraobject_xml($index, urlencode(htmlentities($value)))); } } if ($enProd) { $url = URL_RNP_PROD; } else { $url = URL_RNP_TEST; } $url .= URL_RNP_FRONTLINE; $form = ''; $form .= '<form name="RnPform" action="' . $url . '" method="post">'; $form .= '<input type="hidden" name="MerchID" value="' . $this->info_commande->siteid . '">' . "\n"; $form .= '<input type="hidden" name="XMLInfo" value="' . $flux . '">' . "\n"; if ($url_call != null && $url_call != '') { $form .= '<input type="hidden" name="URLCall" value="' . $url_call . '">' . "\n"; } if ($url_sys != null && $url_sys != '') { $form .= '<input type="hidden" name="URLSys" value="' . $url_sys . '">' . "\n"; } if (isset($XMLParam)) { $form .= '<input type="hidden" name="XMLParam" value="' . clean_xml(str_replace('"', "'", $XMLParam->get_xml())) . '">' . "\n"; } $form .= '<input type="hidden" name="CheckSum" value="' . $checksum . '">' . "\n"; $form .= '<input type="hidden" name="TypeIHM" value="' . $typeIHM . '">' . "\n"; $form .= '</form>'; if ($auto_send) { $form .= '<script>document.RnPform.submit();</script>'; } return $form; }
<?php require_once dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; require_once dirname(__FILE__) . '/kwixo.php'; if (!class_exists('HashMD5')) { require_once dirname(__FILE__) . '/fianet_key_64bits.php'; } $payment = new kwixo(); $rnp_md5 = new HashMD5(); $verification_hash = $rnp_md5->hash(Configuration::get('RNP_MERCHID') . Tools::getValue('RefID') . Tools::getValue('TransactionID')); if (!Tools::getValue('Tag') and Tools::getValue('Tag') != 1) { $errors .= $payment->displayName . ' ' . $payment->l('payment canceled') . "\n"; } if (!Tools::getValue('HashControl')) { $errors .= $payment->displayName . ' ' . $payment->l('hash control not specified') . "\n"; } else { $hashControl = Tools::getValue('HashControl'); } if (!Tools::getValue('custom')) { $errors .= $payment->displayName . ' ' . $payment->l('key "custom" not specified, can\'t rely to cart') . "\n"; } else { $id_cart = intval(Tools::getValue('custom')); } if (!Tools::getValue('id_module')) { $errors .= $payment->displayName . ' ' . $payment->l('key "module" not specified, can\'t rely to payment module') . "\n"; } else { $id_module = intval(Tools::getValue('id_module')); } if (!isset($_POST['amount'])) { $errors .= $payment->displayName . ' ' . $payment->l('"amount" not specified, can\'t control the amount paid') . "\n";
/** * creates an object KwixoXMLElement representing the element <paiement> then adds it as a child of root, then adds the sub-children given in param, then returns the child * * @param string $type payment type * @param string $name name of the card carrier if $type=cb or $type=cb en n fois * @param string $cb_number number of the bank card if $type=cb or $type=cb en n fois * @param string $date_valid validity date of the card if $type=cb or $type=cb en n fois. Format has to be mm/yyyy * @param string $bin six firsts digits of the card number if $type=cb or $type=cb en n fois * @param string $bin4 four firsts digits of the card number if $type=cb or $type=cb en n fois * @param string $bin42 four firsts and two lats digits of the card number if $type=cb or $type=cb en n fois * @return KwixoXMLElement */ public function createPayment($type, $name = null, $cb_number = null, $date_valid = null, $bin = null, $bin4 = null, $bin42 = null) { $payment = $this->root->appendChild(new KwixoXMLElement('paiement')); if (!is_null($cb_number) or !is_null($date_valid)) { $hash = new HashMD5(); } $payment->createChild('type', $type); if (!is_null($name)) { $payment->createChild('nom', $name); } if (!is_null($cb_number)) { $hash_cb = $hash->hash($cb_number); $payment->createChild('numcb', $hash_cb); } if (!is_null($date_valid)) { $hash_date = $hash->hash($date_valid); $payment->createChild('dateval', $hash_date); } if (!is_null($bin)) { $payment->createChild('bin', $bin); } if (!is_null($bin4)) { $payment->createChild('bin4', $bin4); } if (!is_null($bin42)) { $payment->createChild('bin42', $bin42); } return $payment; }
if (!Tools::getValue('HashControl')) { $orderState = _PS_OS_ERROR_; } else { $hashControl = Tools::getValue('HashControl'); } if (!Tools::getValue('custom')) { exit; } $id_cart = intval(Tools::getValue('custom')); $amount = floatval(Tools::getValue('amount')); $cart = new Cart($id_cart); if (!$cart->id) { exit; } $rnp_md5 = new HashMD5(); $controlHash = $rnp_md5->hash(Configuration::get('RNP_CRYPTKEY') . Tools::getValue('RefID') . Tools::getValue('TransactionID')); if ($controlHash != $hashControl) { $orderState = _PS_OS_CANCELED_; $errors .= $payment->displayName . $payment->l('hash control invalid (data do not come from Receive&Pay)') . "\n"; } global $cookie, $cart; if (!Order::getOrderByCartId($cart->id)) { $feedback = 'Order Create'; $payment->validateOrder(intval($cart->id), intval(Configuration::get('RNP_ID_ORDERSTATE')), $amount, 'kwixo', $feedback, NULL, $cart->id_currency); if ($cookie->id_cart == intval($cookie->last_id_cart)) { unset($cookie->id_cart); } } if ($id_order = Order::getOrderByCartId(intval($cart->id))) { $order = new Order(intval($id_order)); }
function getHashKwixo($refid, $montant_total, $email, $nom) { if (!class_exists('HashMD5', false)) { require_once dirname(__FILE__) . '/fianet_key_64bits.php'; } $MD5 = new HashMD5(); $modulo = date("s") % 4; switch ($modulo) { case 0: $select = $montant_total; break; case 1: $select = $email; break; case 2: $select = $refid; break; case 3: $select = $nom; break; default: break; } $crypt = $MD5->hash(Configuration::get('RNP_CRYPTKEY') . $refid . $montant_total . $email . $select); return $crypt; }