Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function result_cc(){
- $m = explode("?", $_SERVER['REQUEST_URI'] );
- $m = count($m)>0?explode("&",$m[1]):$m[0];
- $arr = array();
- if( count($m) > 0 ){
- foreach($m as $r){
- $t = explode("=",$r);
- $arr[$t[0]] = urldecode($t[1]);
- }
- }
- $px = get_cd_from_order($this->jCfg['trans']['order_id']);
- $SECURE_SECRET = $px->security_key;
- $accessCode = $px->access_code;
- $merchantId = $px->merchant_id;
- $md5HashData = $SECURE_SECRET;
- foreach($arr as $key => $value) {
- if (trim($key) != "vpc_SecureHash" && strlen($value) > 0) {
- $md5HashData .= urldecode($value);
- }
- }
- $signature = strtoupper(md5($md5HashData));
- $order_id = "0";
- $status = 0;
- $pesan = isset($arr['vpc_Message'])?$arr['vpc_Message']:'';
- if( isset($arr['vpc_SecureHash']) && $arr['vpc_SecureHash']== $signature){
- if( $arr['vpc_TxnResponseCode'] == 0 && strtolower($arr['vpc_Message'])=="approved" ){
- //$order_id = isset($arr['vpc_MerchTxnRef'])?$arr['vpc_MerchTxnRef']:'';
- $order_id = trim($this->jCfg['trans']['order_id'])?$this->jCfg['trans']['order_id']:'';
- //if success.... cek API Payable..
- $paycode = $arr['vpc_ReceiptNo'];
- $partner_key = get_cfg_app('blitz_partner_key');
- $partner_code = get_cfg_app('blitz_partner_code');
- $bookingcode = $order_id;
- $paytype = get_cfg_app('blitz_paytype');
- $signature = sha1($bookingcode.$paytype.$paycode.$partner_code.$partner_key);
- $data_insert = array(
- "cc_status" => isset($arr['vpc_TxnResponseCode'])?$arr['vpc_TxnResponseCode']:'',
- "cc_message" => isset($arr['vpc_Message'])?$arr['vpc_Message']:'',
- "cc_hash" => isset($arr['vpc_SecureHash'])?$arr['vpc_SecureHash']:'',
- "cc_booking_id" => $order_id ,
- "cc_paycode" => $paycode,
- "cc_date" => date("Y-m-d H:i:s")
- );
- $this->db->insert("blitz_result_cc",$data_insert);
- // get email…
- $em = $this->db->get_where("blitz_trans",array(
- 'order_id' => $bookingcode
- ))->row();
- $email_order = '';
- if(count($m)>0 && isset($em->order_email) && trim($em->order_email)!=''){
- $email_order = $em->order_email;
- }
- // post booking..
- $arr_data = array(
- 'bookingcode' => $bookingcode,
- 'paytype' => $paytype,
- 'paycode' => $paycode,
- 'customeremail' => $email_order,
- 'partnercode' => $partner_code,
- 'signature' => $signature
- );
- $post_data = http_build_query($arr_data);
- $opts = array('http' =>
- array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' => $post_data
- )
- );
- $context = stream_context_create($opts);
- $result = file_get_contents(get_cfg_app('blitz_url_payable'), false, $context);
- $payable_result = json_decode(xml2json($result));
- if(!isset($payable_result->{'@attributes'}->bookingcode)){
- $msg = "";
- if(count($payable_result) > 0){
- foreach($payable_result as $k=>$v){
- $msg = isset($v)?$v:'';
- }
- }
- $this->setMessage(array(
- "class" =>"error",
- "msg" => $msg
- ));
- }
- //insert payable…..
- //debug($payable_result);
- if( isset($payable_result->{'@attributes'}->bookingcode) ){
- $data_payable = array(
- 'pay_bookingcode' => $payable_result->{'@attributes'}->bookingcode,
- 'pay_passkey' => $payable_result->{'@attributes'}->passkey,
- 'pay_paytype' => $payable_result->{'@attributes'}->paytype,
- 'pay_paycode' => $payable_result->{'@attributes'}->paycode,
- 'pay_total' => $payable_result->{'@attributes'}->total - $px->order_price_discount,
- 'pay_time' => date("Y-m-d H:i:s"),
- 'pay_status' => 'SUCCESS'
- );
- $this->db->insert('blitz_payable',$data_payable);
- }
- }else{
- //echo "Access Denied!";
- //insert error to db cc_result..
- $order_id = trim($this->jCfg['trans']['order_id'])?$this->jCfg['trans']['order_id']:'';
- $this->db->insert("blitz_result_cc",array(
- "cc_status" => 'ERROR',
- "cc_date" => date("Y-m-d H:i:s"),
- "cc_booking_id" => $order_id,
- "cc_error" => json_encode($arr)
- ));
- _go_to_error_page();
- }
- }else{
- //insert error to db cc_result..
- $order_id = trim($this->jCfg['trans']['order_id'])?$this->jCfg['trans']['order_id']:'';
- $this->db->insert("blitz_result_cc",array(
- "cc_status" => 'ERROR',
- "cc_date" => date("Y-m-d H:i:s"),
- "cc_booking_id" => $order_id,
- "cc_error" => json_encode($arr)
- ));
- _go_to_error_page();
- }
- // confirm to cek API….
- redirect(base_url()."multilang/".$this->LANG."/blitz/confirm-cc/");
- }
Add Comment
Please, Sign In to add comment