function verify_payment($address, $user, $fiatcurrency) { global $mysqli; global $getinsert; //Retrieve address balance $stmt = $mysqli->prepare("Select doge_last_balance from user_receive_address where doge_address = '{$address}'"); $stmt->execute(); $stmt->bind_result($last_balance); $stmt->fetch(); $stmt->close(); //echo "1"; $validbid = check_valid($address, $last_balance); if ($validbid) { //update adress balance //echo $validbid."--".$address; $stmt = $mysqli->query("Update user_receive_address SET doge_last_balance = doge_last_balance+{$validbid} WHERE doge_address = '{$address}'"); //echo "(" . $address . "==" . $validbid . "==" . $user . ")"; $fiat = get_doge_conversion(1, $fiatcurrency, true); $fiat = $fiat * $validbid; $insertid = log_transaction($address, $validbid, $fiat, $fiatcurrency, 'DOGE', $user, "na"); echo $validbid; if ($getinsert == true) { echo ":::" . $insertid; } } }
function verify_payment($address, $user, $fiatcurrency) { global $mysqli; //Retrieve address balance $stmt = $mysqli->prepare("Select btc_last_balance from user_receive_address where btc_address = '{$address}'"); $stmt->execute(); $stmt->bind_result($last_balance); $stmt->fetch(); $stmt->close(); //echo "1"; $validbid = check_valid($address, $last_balance); if ($validbid) { //update adress balance $stmt = $mysqli->query("Update user_receive_address SET btc_last_balance = btc_last_balance+{$validbid} WHERE btc_address = '{$address}'"); $fiat = get_btc_conversion(1, $fiatcurrency, true); $fiat = $fiat * $validbid; log_transaction($address, $validbid, $fiat, $fiatcurrency, 'BTC', $user, "na"); echo $validbid; } }
<?php try { /** ** @param: $postArr converted from wechat XML request ** for example: ** array(6) { ** ["ToUserName"]=> string(6) "toUser" ** ["FromUserName"]=> string(8) "fromUser" ** ["CreateTime"]=> string(10) "1348831860" ** ["MsgType"]=> string(4) "text" ** ["Content"]=> string(14) "this is a test" ** ["MsgId"]=> string(16) "1234567890123456" ** } **/ /* * @param $matchList From process_keyword.php contain the list of id of matched keyword */ $transaction = array('user_id' => $postArr['FromUserName'], 'MsgId' => isset($postArr['MsgId']) ? $postArr['MsgId'] : null, 'media_id' => null, 'keyword_id' => sizeof($matchList) > 0 ? $matchList[0] : null, 'media_type' => $postArr['MsgType'], 'request' => 1, 'content' => $postArr['Content'], 'raw_data' => $wechat->raw_json_encode($postArr)); log_transaction($transaction); } catch (Exception $ex) { # log the exception log_error('snippet: process_text', json_encode($postArr), $ex->getMessage()); }
function log_response($responseXML = '', $responseArr = '') { $responseObj = simplexml_load_string($responseXML, 'SimpleXMLElement', LIBXML_NOCDATA); $data = array('userID' => $responseObj->ToUserName, 'media_type' => $responseObj->MsgType, 'request' => 0, 'content' => $responseArr, 'MsgId' => null, 'raw' => json_encode($responseObj)); log_transaction($data); }
function withdraw($userid, $currency, $amount, $address = NULL, $fiatcurrency = "USD") { global $handshake; global $dogeWalletServer; global $btcWalletServer; if ($address == NULL) { $userdetails = fetchUserDetails(NULL, NULL, $userid); $address = $userdetails[$currency . 'address']; } $params = $address . '@@@' . $amount . '@@@' . 'dogepos-' . $userid; $key = $params . $handshake; $key = sha1($key); if (strtoupper($currency) == "DOGE") { //generate api call $url = $dogeWalletServer . 'index.php?call=withdraw¶ms=' . $params . '&key=' . $key; //do conversion $fiat = get_doge_conversion($amount, $fiatcurrency, true); } else { if (strtoupper($currency) == "BTC") { $url = $btcWalletServer . 'index.php?call=withdraw¶ms=' . $params . '&key=' . $key; //do conversion $fiat = get_btc_conversion($amount, $fiatcurrency, true); } } echo "[fiat=" . $fiat . $fiatcurrency . " || amount=" . $amount . $currency; echo $url; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($ch); //print_r($result); if (strlen($result) > 20) { $logamount = 0 - $amount; $logfiat = 0 - $fiat; log_transaction($address, $logamount, $logfiat, $fiatcurrency, strtoupper($currency), $userid, $result); } //close connection curl_close($ch); //echo "result".$result; return $result; /* part of pin check } */ }
// if me, check to see if the dest account is a valid account if (!($stmt = $mysqli->prepare("SELECT accountNum FROM accounts where accountNum = ?"))) { echo "acct check Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error; } // bind new account num param if (!$stmt->bind_param("i", $dst_account_num)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } // bind the results of the query to each field // if $dst_routing_num === $my_routing_num $stmt->bind_result($dst_acct); // if the account number is invalid in the local database, die $result = $stmt->store_result(); if ($stmt->num_rows() !== 1) { echo "Unable to validate account number."; die; } // subtract the amount from the current balance, and set the new account balance $new_src_bal = get_balance(get_accountNum($_SESSION['username'])) - $amount; update_balance(get_accountNum($_SESSION['username']), $new_src_bal); // add new amount to dest balance $new_dst_bal = get_balance($dst_account_num) + $amount; update_balance($dst_account_num, $new_dst_bal); // write transaction log to the DB log_transaction("12345", get_accountNum($_SESSION['username']), $dst_routing_num, 3988282199, $amount); echo "Done processing transaction."; // if different bank, ask fed if account num is valid }
} // get_balance returns NULL if the account number is invalid if (is_null($current_balance)) { echo "Invalid Source Account number."; die; } // is $dst_acct balance is null, account doesn't exist if (is_null(get_balance($dst_account_num))) { echo "Invalid Destination Account number."; die; } // error check to see if the amount is valid if ($amount < 0) { echo "Invalid amount. Must be a positive number."; die; } if ($amount > $current_balance) { echo "Invalid amount. Must be less than or equal to the current account balance."; die; } // subtract the amount from the current balance, and set the new account balance $new_src_bal = get_balance($src_acct) - $amount; update_balance($src_acct, $new_src_bal); // add new amount to dest balance $new_dst_bal = get_balance($dst_account_num) + $amount; update_balance($dst_account_num, $new_dst_bal); // write transaction log to the DB log_transaction(LOCAL_ROUTING_NUMBER, $src_acct, LOCAL_ROUTING_NUMBER, $dst_account_num, $amount); echo "Done processing transaction."; // if different bank, ask fed if account num is valid }