$CORE->load_CoreModule('transaction.logging');
 //Setup the log class
 $Logs = new TransactionLogging();
 //Save the variables
 $Logs->SetVariables($_GET);
 //Set the account id
 $finance->SetAccount($userId);
 //Set the currency to gold
 $finance->SetCurrency(CURRENCY_GOLD);
 //Check if it's deduction, Paymentwall send amount value with "-"
 if ($type == CREDIT_TYPE_CHARGEBACK) {
     //remove the minus
     $credits = (int) trim($credits, '-');
 }
 //Set the amount we are Giving/Taking
 $finance->SetAmount($credits);
 if ($type == CREDIT_TYPE_CHARGEBACK) {
     // Deduct credits from user
     // This is optional, but we recommend this type of crediting to be implemented as well
     // Note that currency amount sent for chargeback is negative, e.g. -5, so be caferul about the sign
     // Don’t deduct negative number, otherwise user will get credits instead of losing them
     //Resolve the deduction reason by id
     switch ($_GET['reason']) {
         case 1:
             $reason = 'Chargeback';
             $reasonUser = '******';
             break;
         case 2:
             $reason = 'Credit Card fraud Ban user';
             $reasonUser = '******';
             break;
Beispiel #2
0
 if ($res2->rowCount() == 0) {
     $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
     $Logs->append('[Error] Invalid account, could not get the gold value by account id.');
     $Logs->save();
     exit;
 } else {
     //fetch
     $row = $res2->fetch(PDO::FETCH_ASSOC);
     //var
     $gold = $row['gold'];
     //save memory
     unset($row);
     //We might have a formula to calculate the Coins by Amount Donated
     $AmountCoins = abs($Amount);
     //Set the amount we are Giving/Taking
     $finance->SetAmount($AmountCoins);
     //Detect if the payment is a deduction or not
     if ($Amount < 0) {
         $Logs->append('The transaction is a Deduction Type.');
         //Take the coins from the user
         $Deduct = $finance->Charge('Deduction of Gold Coins', CA_SOURCE_TYPE_DEDUCTION);
         //Check if the deduction was successfull
         if ($Deduct === true) {
             //Deduction success
             $Logs->SetLogType(TRANSACTION_LOG_TYPE_NORMAL);
             //append message to the log
             $Logs->append("The deduction was successfull.");
         } else {
             //Deduction failed
             $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
             //append message to the log
Beispiel #3
0
}
$ERRORS->Check('/index.php?page=purchase_gold');
//Calculate the cost
//get the left overs
$leftOver = $GoldAmount % 1000;
//any left over costs +1 gold coin
if ($leftOver > 0) {
    $GoldAmount -= $leftOver;
    $GoldAmount += 1000;
}
//calculate the price
$price = $GoldAmount / 1000;
######################################
######### CHECK FINANCES #############
$finance->SetCurrency(CURRENCY_GOLD);
$finance->SetAmount($price);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
$ERRORS->Check('/index.php?page=purchase_gold');
####################################################################
Beispiel #4
0
 private function ProcessCurrencyReward($currency, $amount)
 {
     global $CORE;
     //Verify the currency
     $Currencies = array(CURRENCY_SILVER, CURRENCY_GOLD);
     if (!in_array($currency, $Currencies)) {
         $this->errors[] = 'The code seems to have invalid reward type.';
         return false;
     }
     //Load the Finances module if not loaded
     if (!$CORE->isLoaded_CoreModule('accounts.finances')) {
         $CORE->load_CoreModule('accounts.finances');
     }
     //Setup the finances class
     $finance = new AccountFinances();
     //Add the currency to the user
     //Set the account id
     $finance->SetAccount($this->account);
     //Set the currency to gold
     $finance->SetCurrency($currency);
     //Set the amount we are Giving
     $finance->SetAmount($amount);
     //Give coins to the user
     $Reward = $finance->Reward('Promotion Code', CA_SOURCE_TYPE_REWARD);
     //check if it was updated
     if ($Reward !== true) {
         $this->errors[] = 'The website was unable to deliver your reward due to reason: ' . $Reward;
         return false;
     }
     unset($finance);
     return true;
 }
Beispiel #5
0
}
if (!$currency) {
    //no currency is selected
    $ERRORS->Add('Please select a currency for the purchase.');
} else {
    if (!$finance->IsValidCurrency($currency)) {
        //invalid currency
        $ERRORS->Add('Error, invalid currency selected.');
    }
}
//Check for errors
$ERRORS->Check('/index.php?page=changedname');
######################################
######### CHECK FINANCES #############
$finance->SetCurrency($currency);
$finance->SetAmount($currency == CURRENCY_GOLD ? $PurchaseCost_Gold : $PurchaseCost_Silver);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
//Check for errors
$ERRORS->Check('/index.php?page=changedname');
Beispiel #6
0
//prepare the log
$logs = new purchaseLog();
//prepare multi errors
$ERRORS->NewInstance('pStore_faction');
//bind the onsuccess message
$ERRORS->onSuccess('Successfull character faction change.', '/index.php?page=factionchange');
$character = isset($_POST['character']) ? $_POST['character'] : false;
$RealmId = $CURUSER->GetRealm();
//define how much a faction change is going to cost
$factionChangePrice = 5;
if (!$character) {
    $ERRORS->Add("Please select a character first.");
}
//Set the currency and price
$finance->SetCurrency(CURRENCY_GOLD);
$finance->SetAmount($factionChangePrice);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
$ERRORS->Check('/index.php?page=factionchange');
####################################################################
Beispiel #7
0
$logs->add('SOCIAL_BUTTONS', 'Starting log session. Application: ' . $app . ', status variable: ' . $status . '.', 'pending');
//Update the user social button status
if ($CURUSER->setSocial($app, $status)) {
    //If the status was update reward the user
    //log successful status update
    $logs->update(false, 'The user status was update.', 'pending');
    //Load the most important module
    $CORE->load_CoreModule('accounts.finances');
    //Setup the finances class
    $finance = new AccountFinances();
    //Set the account id
    $finance->SetAccount($CURUSER->get('id'));
    //Set the currency to gold
    $finance->SetCurrency(CURRENCY_SILVER);
    //Set the amount we are Giving
    $finance->SetAmount($RewardAmount);
    //Resolve the source [facebook, twitter etc...]
    switch ($app) {
        case APP_FACEBOOK:
            $CA_Source = 'You liked us on Facebook';
            break;
        case APP_TWITTER:
            $CA_Source = 'You followed us on Twitter';
            break;
        default:
            $CA_Source = 'Unknown action';
            break;
    }
    //Finally reward the user
    $Reward = $finance->Reward($CA_Source, CA_SOURCE_TYPE_REWARD);
    //Make sure the reward was given, otherwise log this failure
Beispiel #8
0
//Get the character name by the guid
$charName = $chars->getCharacterName($row['character']);
//try unsticking
$refund = $command->RefundItem($row['entry'], $charName, $RealmId);
//unset the class
unset($chars, $command, $charName);
//Check if the item was destroyed
if ($refund === false) {
    echo 'The website failed to refund the item. Please try again later or contact the administration.';
    die;
} else {
    if ($refund === true) {
        //Set the currency
        $finance->SetCurrency((int) $row['currency']);
        //Set the amount we are Giving
        $set = $finance->SetAmount((int) $row['price']);
        //Give coins to the user
        $Reward = $finance->Reward('Item Refund');
        //check if the coins ware not given
        if ($Reward !== true) {
            ItemRefundSystem::SetError($row['id'], 'The finance class failed to add the required amount to the user.');
            echo 'The website failed to update your account balance. Please contact the administration.';
            die;
        }
        ItemRefundSystem::RefundableSetStatus($row['id'], IRS_STATUS_REFUNDED);
        //register success message
        $ERRORS->registerSuccess('The item has been successfully refunded.');
        echo 'OK';
    } else {
        echo 'The system encoutenred the following error: ' . $refund;
        die;
Beispiel #9
0
    $ERRORS->Add("Please select a character first.");
}
if (!$level) {
    $ERRORS->Add("Please select your desired level.");
} else {
    if (!$LevelsData->get($level)) {
        $ERRORS->Add("There was a problem with your level selection, if the problem persists please contact the administration.");
    }
}
//overright the variable with the actual data
$level = $LevelsData->get($level);
unset($LevelsData);
######################################
######### CHECK FINANCES #############
$finance->SetCurrency($level['priceCurrency']);
$finance->SetAmount($level['price']);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
$ERRORS->Check('/index.php?page=levels');
####################################################################
$logs = new purchaseLog();
//prepare multi errors
$ERRORS->NewInstance('pStore_recustomization');
//bind the onsuccess message
$ERRORS->onSuccess('Successfull character re-customization.', '/index.php?page=recustomization');
$character = isset($_POST['character']) ? $_POST['character'] : false;
//assume the realm is 1 (for now)
$RealmId = $CURUSER->GetRealm();
//define how much a faction change is going to cost
$recustomizationPrice = 5;
if (!$character) {
    $ERRORS->Add("Please select a character first.");
}
//Set the currency and price
$finance->SetCurrency(CURRENCY_GOLD);
$finance->SetAmount($recustomizationPrice);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
//Check for errors
$ERRORS->Check('/index.php?page=recustomization');
Beispiel #11
0
        $ERRORS->Add('Error, invalid currency selected.');
    }
}
if (!$DurationId) {
    $ERRORS->Add('Please select boost duration.');
} else {
    if (!in_array($DurationId, array(BOOST_DURATION_10, BOOST_DURATION_15, BOOST_DURATION_30))) {
        $ERRORS->Add('The selected boost duration is invalid.');
    }
}
//Check for errors
$ERRORS->Check('/index.php?page=changedname');
######################################
######### CHECK FINANCES #############
$finance->SetCurrency($currency);
$finance->SetAmount($config['BOOSTS']['PRICEING'][$DurationId][$currency]);
//check if the user has enough balance
if ($BalanceError = $finance->CheckBalance()) {
    if (is_array($BalanceError)) {
        //insufficient amount
        foreach ($BalanceError as $currency) {
            $ERRORS->Add("You do not have enough " . ucfirst($currency) . " Coins.");
        }
    } else {
        //technical error
        $ERRORS->Add('Error, the website failed to verify your account balance.');
    }
}
unset($BalanceError);
//Check for errors
$ERRORS->Check('/index.php?page=boosts');