ajgkqsldxvkqsldkqs azelfkqsmkqsmlkdqsmld azmlekdqmskdmlqskd nkldsfkqsmldkqsmdmlskd decrypt($_GET['id']); $vendor = $mcrypt->decrypt($_GET['vendor']); $trans_id = " "; $amount = ""; if(!empty($_GET['amount'])){ $amount = $mcrypt->decrypt($_GET['amount']); } $momo_name = $_GET['momo_name']; if(!empty($momo_name)){ $momo_name = $mcrypt->decrypt($momo_name); } $momo_phone = $_GET['momo_phone']; if(!empty($momo_phone)){ $momo_phone = $mcrypt->decrypt($momo_phone); } $kuulpay_phone = $_GET['kuulpay_phone']; if(!empty($kuulpay_phone)){ $kuulpay_phone = $mcrypt->decrypt($kuulpay_phone); } $kuulpay_token = $_GET['kuulpay_token']; if(!empty($kuulpay_token)){ $kuulpay_token = $mcrypt->decrypt($kuulpay_token); } $kuulpay_pin = $_GET['kuulpay_pin']; if(!empty($kuulpay_pin)){ $kuulpay_pin = $mcrypt->decrypt($kuulpay_pin); } $kuulpay_serial = $_GET['kuulpay_serial']; if(!empty($kuulpay_serial)){ $kuulpay_serial = $mcrypt->decrypt($kuulpay_serial); } /* Fetch the information */ $con = db_connect(); $sql = session($con,$session); if(db_rows($con,$sql)>0){ /* fetch userid and create session token */ $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $userid = $row['userid']; } /* validate fields */ if(empty($vendor)){ $message = "Please select the payment method"; }else if((($vendor=="mtn")||($vendor=="kuulpay"))&&(empty($amount))){ $message = "Please enter amount."; }else if((($vendor=="mtn")||($vendor=="kuulpay"))&&(!valFloat($amount))){ $message = "Please amount must be numeric."; }else if((($vendor=="mtn")||($vendor=="kuulpay"))&&($amount<0)){ $message = "Please amount can't be negative."; }else if(($vendor=="mtn")&&(empty($momo_name))){ $message = "Please enter your name"; }else if(($vendor=="mtn")&&(empty($momo_phone))){ $message = "Please enter mobile money phone number"; }else if(($vendor=="mtn")&&(!valPhone($momo_phone))){ $message = "Please phone number is not in the correct format."; }else if(($vendor=="kuulpay")&&(empty($kuulpay_phone))){ $message = "Please the KuulPay account phone number"; }else if(($vendor=="kuulpay")&&(!valPhone($kuulpay_phone))){ $message = "Please phone number is not in the correct format."; }else if(($vendor=="kuulpay_scratch_card")&&(empty($kuulpay_pin))){ $message = "Please enter the pin number on the scratch card"; }else if(($vendor=="kuulpay_scratch_card")&&(empty($kuulpay_serial))){ $message = "Please enter the serial number on the scratch card"; }else{ /* Connect to the server to initialize payment and store the transaction detail into table to later verify if payment has been made */ $mid = mid(); $key = sec_key(); $callback = "http://closeapp.kuulchatmedia.com/api/callback.php"; $authcode = strtoupper(md5($key."|".$mid."|".$amount."|".$vendor."|".$momo_name."|".$momo_phone."|".$kuulpay_phone."|".$kuulpay_token."|".$kuulpay_pin."|".$kuulpay_serial."|".$callback)); /* instantiate a payment request on kuulpay */ $curl = curl_init(); // Set some options - we are passing in a useragent too here curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://api.kuulpay.com', CURLOPT_USERAGENT => 'Codular Sample cURL Request', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => array( 'id' => $mid, 'amount' => $amount, 'vendor' => $vendor, 'momo_name' => $momo_name, 'momo_phone' => $momo_phone, 'kuulpay_phone' => $kuulpay_phone, 'kuulpay_token' => $kuulpay_token, 'kuulpay_phone' => $kuulpay_phone, 'kuulpay_token' => $kuulpay_token, 'kuulpay_pin' => $kuulpay_pin, 'kuulpay_serial' => $kuulpay_serial, 'callback' => $callback, 'authcode' => $authcode ) )); // Send the request & save response to $resp $resp = curl_exec($curl); // Close request to clear up some resources curl_close($curl); $result = json_decode($resp); /* Analyze the response */ $status = $result->status; /* if initiated, record transaction and check status */ if($status=="initiated"){ $trans_id = $result->trans_id; $sql = record_payment($con,$userid,$vendor,$momo_name,$momo_phone,$kuulpay_phone,$kuulpay_token,$kuulpay_pin,$kuulpay_serial,$trans_id); if(mysqli_query($con,$sql)){ $success = 1; if($vendor=="mtn"){ $message = "We have sent you a confirmation token to your MTN Mobile Money phone. Please follow the steps below to confirm transaction.
Dial *170#
Select options
Wallet (Option 7)
My Approvals (Option 3)
Enter your MOMO Pin
Enter the number for the payment token shown to approve the pending transaction. "; }else if(($vendor=="kuulpay")||($vendor=="kuulpay_scratch_card")){ $message = "We are processing your payment request"; } }else{ $message = "Server error. Please try again later."; } }else{ $message = $result->message; } } } $response['success'] = $success; $response['trans_id'] = $mcrypt->encrypt($trans_id); $response['message'] = $mcrypt->encrypt($message); echo json_encode($response); db_close($con); }