}
// Widthdraw this amount
-function WERNIS_EXECUTE_WITHDRAW($userId, $userMd5, $amount) {
+function WERNIS_EXECUTE_WITHDRAW ($wdsId, $userMd5, $amount) {
global $_CONFIG;
$result = false;
// Prepare the request data
$requestData = array(
'sub_request' => "receive",
- 't_uid' => bigintval($userId),
+ 't_uid' => bigintval($wdsId),
't_md5' => $userMd5,
'r_uid' => $_CONFIG['wernis_refid'],
'amount' => bigintval($amount),
if ($return['status'] == "OK") {
// All fine!
$result = true;
+
+ // Log the transfer
+ WERNIS_LOG_TRANSFER($wdsId, $amount, 'IN');
} else {
// Status failture text
WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
+
+ // Log the transfer
+ WERNIS_LOG_TRANSFER($wdsId, $amount, 'FAILED', $return['message'], $return['status']);
}
// Return result
// Payout this amount
-function WERNIS_EXECUTE_PAYOUT($userId, $userMd5, $amount) {
+function WERNIS_EXECUTE_PAYOUT ($wdsId, $userMd5, $amount) {
global $_CONFIG;
$result = false;
// Prepare the request data
$requestData = array(
'sub_request' => "send",
- 't_uid' => bigintval($userId),
+ 't_uid' => bigintval($wdsId),
't_md5' => $userMd5,
'r_uid' => $_CONFIG['wernis_refid'],
'amount' => bigintval($amount),
if ($return['status'] == "OK") {
// All fine!
$result = true;
+
+ // Log the transfer
+ WERNIS_LOG_TRANSFER($wdsId, $amount, 'OUT');
} else {
// Status failture text
WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
+
+ // Log the transfer
+ WERNIS_LOG_TRANSFER($wdsId, $amount, 'FAILED', $return['message'], $return['status']);
}
// Return result
}
// Translate the status IN/OUT
-function WERNIS_TRANSFER_STATUS($status) {
+function WERNIS_TRANSFER_STATUS ($status) {
// Default status
$return = sprintf(WERNIS_STATUS_UNKNWOWN, $status);
switch ($status) {
case "OUT": // Payout
$return = WERNIS_STATUS_PAYOUT;
break;
+
+ case "FAILED": // Payout
+ $return = WERNIS_STATUS_FAILED;
+ break;
}
// Return the status
return $return;
}
+function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = null, $status = null) {
+ // Register this wernis movement
+ $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_wernis (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES(%d, %d, %d, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
+ array($GLOBALS['userid'], bigintval($wdsId), bigintval($amount), $type, $message, $status), __FILE__, __LINE__);
+}
+
//
?>