Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function paymentdata() {
- if ($_SERVER['REQUEST_METHOD']=='POST') {
- $ttf=json_encode($_POST);
- $this->db->query("INSERT INTO PayTest (Request) VALUES ('$ttf')");
- if (@$_POST['RC']=='00' && intval(@$_POST['TRTYPE'])==0 && !empty($_POST['ORDER'])) {
- require_once realpath('public/payment').'/'.'Transaction.php';
- $ts=date('YmdHis');
- $nonce=Transaction::set_nonce();
- $req=array(
- 'TRTYPE'=>21,
- 'TERMINAL'=>$_POST['TERMINAL'],
- 'ORDER'=>$_POST['ORDER'],
- 'CURRENCY'=>$_POST['CURRENCY'],
- 'AMOUNT'=>$_POST['AMOUNT'],
- 'TIMESTAMP'=>$ts,
- 'NONCE'=>$nonce,
- 'RRN'=>$_POST['RRN'],
- 'INT_REF'=>$_POST['INT_REF']
- );
- $bins=array(676633,557484,557802,518894,558277,412043,417751,402811,402812,413061);
- $r_bin=0;
- $binfound=0;
- if (!empty($_POST['BIN'])) {
- $r_bin=intval($_POST['BIN']);
- if (in_array($r_bin,$bins)) $binfound=1;
- }
- $order=intval($_POST['ORDER'])-900000000;
- $rsaPrivKey = Transaction::_get_key(realpath('public/payment').'/'."ssl/private/privkey.pem");
- $rsaPubKey = Transaction::get_key(realpath('public/payment').'/'."ssl/cert.pem");
- $rsaKeyLength = Transaction::get_key_length($rsaPrivKey);
- $hashedData = Transaction::_create_hased_data( $rsaKeyLength , $req );
- $macsource = Transaction::_generate_mac_source( $req );
- $p_sign = Transaction::_encrypt_p_sign( $rsaPrivKey , $hashedData );
- $fieldstring = 'ORDER='.$_POST['ORDER'].'&TERMINAL='.$_POST['TERMINAL'].'&RRN='.$_POST['RRN'].'&INT_REF='.$_POST['INT_REF'].'&CURRENCY='.$_POST['CURRENCY'].'&AMOUNT='.$_POST['AMOUNT'].'&TRTYPE=21&TIMESTAMP='.$ts.'&NONCE='.$nonce.'&P_SIGN='.$p_sign;
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,'https://egateway.micb.md/cgi-bin/cgi_link?');
- curl_setopt($ch,CURLOPT_POSTFIELDS,$fieldstring);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- $res = curl_exec($ch);
- curl_close($ch);
- }
- if (@$_POST['RC']!=='00' && intval(@$_POST['TRTYPE'])==0 && !empty($_POST['ORDER'])) {
- $bank_nr_order = intval($_POST['ORDER']);
- $this->db->query("INSERT INTO PayTest (Request) VALUES ('При оплате заказа номер $bank_nr_order произошла ошибка.')");
- }
- if (@$_POST['RC']=='00' && intval(@$_POST['TRTYPE'])==21) {
- $order=intval($_POST['ORDER'])-900000000;
- $bank_nr_order = intval($_POST['ORDER']);
- $this->db->query("INSERT INTO PayTest (Request) VALUES ('Заказ номер $bank_nr_order успешно оплачен')");
- $upd = array(
- "Status" => 0,
- "transaction_id" => $this->input->post("INT_REF", true),
- "rrn_id" => $this->input->post("RRN", true),
- );
- $this->orders_model->update_order($order, $upd);
- $q=$this->db->query("SELECT * FROM UserOrder WHERE ID=".intval($order));
- $oarr=$q->row_array();
- $text_a=admletter($order);
- $text_u=userletter($order);
- if (!empty($oarr['email'])) {
- $this->email->from('no-reply@andys.md', $_SERVER['HTTP_HOST']);
- $this->email->to($oarr['email']);
- $this->email->reply_to('no-reply@andys.md');
- $this->email->subject('Comanda de la '.$_SERVER['HTTP_HOST']);
- $this->email->message($text_u);
- $this->email->send();
- }
- $admail=USERORDERMAIL;
- $amq1=$this->db->query("SELECT Country.Email
- FROM UserOrder
- INNER JOIN Country ON Country.ID=UserOrder.CityID
- WHERE UserOrder.ID=$order");
- if ($amq1->num_rows()>0) {
- $amarr=$amq1->row_array();
- if (!empty($amarr['Email'])) $admail=$amarr['Email'];
- }
- $this->email->from('no-reply@andys.md', $_SERVER['HTTP_HOST']);
- $this->email->to($admail);
- $this->email->reply_to('no-reply@andys.md');
- $this->email->subject('Comanda de la '.$_SERVER['HTTP_HOST']);
- $this->email->message($text_a);
- $this->email->send();
- }
- if (@$_POST['RC']!=='00' && intval(@$_POST['TRTYPE'])==21) {
- $bank_nr_order = intval($_POST['ORDER']);
- $this->db->query("INSERT INTO PayTest (Request) VALUES ('При оплате заказа номер $bank_nr_order произошла ошибка.')");
- }
- } else {
- $this->db->query("INSERT INTO PayTest (Request) VALUES ('Banca nu trimmite post')");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement