Exemplo n.º 1
0
 $res->execute();
 if ($res->rowCount() == 0) {
     //log invalid account
     $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
     $Logs->append('[Error] Invalid account, could not resolve the account id by username.');
     $Logs->save();
     exit;
 } else {
     //fetch
     $row = $res->fetch(PDO::FETCH_ASSOC);
     //save as var
     $accId = (int) $row[$columns['id']];
     //save memory
     unset($row);
     //Set the account id
     $finance->SetAccount($accId);
     //Set the currency to gold
     $finance->SetCurrency(CURRENCY_GOLD);
     /*select current gold coins*/
     $res2 = $DB->prepare("SELECT `gold` FROM `account_data` WHERE `id` = :acc LIMIT 1;");
     $res2->bindParam(':acc', $accId, PDO::PARAM_INT);
     $res2->execute();
     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
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
if (!empty($userId) && !empty($credits) && isset($type) && !empty($refId) && !empty($signature)) {
    //Let's generate the signature
    $signatureParams = array('uid' => $userId, 'currency' => $credits, 'type' => $type, 'ref' => $refId);
    $signatureCalculated = calculatePingbackSignature($signatureParams, SECRET);
    //check if IP is in whitelist and if signature matches
    if (in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist) && $signature == $signatureCalculated) {
        //Success
        $result = true;
        //Log this transaction
        $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
Exemplo n.º 4
0
$CORE->load_CoreModule('purchaseLog');
//prepare the log
$logs = new purchaseLog();
//start logging
$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;