Beispiel #1
0
             $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
             //append message to the log
             $Logs->append("The deduction of coins failed, error returned: " . $Deduct . ". ");
         }
         unset($Deduct);
     } else {
         $Logs->append('The transaction is a Reward Type.');
         /*add points, but compare money donated with itemcout*/
         if ($AmountCoins != $Quantity) {
             $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
             $Logs->append('[Error] Amount of Coins calculated (' . $AmountCoins . ') are not equal to the number of items (' . $Quantity . ').');
             $Logs->save();
             exit;
         } else {
             //Give coins to the user
             $Reward = $finance->Reward('Purchased Gold Coins', CA_SOURCE_TYPE_PURCHASE);
             //check if it was updated
             if ($Reward === true) {
                 $Logs->append('[Success] The gold was successfully added, value: ' . $gold . ' was updated to: ' . ($gold + $AmountCoins) . '.');
                 $Logs->save();
             } else {
                 $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
                 $Logs->append('[Error] Failed to apply new gold value, value: ' . $gold . ' was going to be updated to: ' . ($gold + $AmountCoins) . '. Return: ' . $Reward);
                 $Logs->save();
                 exit;
             }
             unset($Reward);
         }
     }
 }
 unset($res2);
             break;
         case 1:
             $TransactionType = 'Credit is given as a customer service.';
             $CA_SourceType = CA_SOURCE_TYPE_REWARD;
             $CA_SourceString = 'Earned Gold Coins';
             break;
         default:
             $TransactionType = 'Uknown type ' . $type;
             $CA_SourceType = CA_SOURCE_TYPE_NONE;
             $CA_SourceString = 'Received gold coins from unknown source';
             break;
     }
     //append message to the log
     $Logs->append("The transaction is reward type, type: \"" . $TransactionType . "\". ");
     //Give coins to the user
     $Reward = $finance->Reward($CA_SourceString, $CA_SourceType);
     //check if the reward was successful
     if ($Reward) {
         //Reward success
         $Logs->SetLogType(TRANSACTION_LOG_TYPE_NORMAL);
         //append message to the log
         $Logs->append("The rewarding was successfull. ");
     } else {
         //Reward failed
         $Logs->SetLogType(TRANSACTION_LOG_TYPE_URGENT);
         //append message to the log
         $Logs->append("The rewarding with coins failed, error returned: " . $Reward . ". ");
     }
     unset($TransactionType, $CA_SourceType, $CA_SourceString, $Reward);
 }
 unset($finance);
Beispiel #3
0
    //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
    if ($Reward !== true) {
        $logs->update(false, 'The website failed to reward the user.', 'error');
    } else {
        $logs->update(false, 'The user was rewarded.', 'ok');
    }
    unset($CA_Source, $Reward, $finance);
}
//free mem
unset($app, $status, $RewardAmount, $logs);
exit;
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
//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;
    }
}