public function testSetExternalIdValid() { $externalId = 'abc'; $customer = new Transaction(); $customer->setExternalId($externalId); $this->assertEquals($externalId, $customer->getExternalId()); }
function display() { Load::model('transaction'); $Transaction = new Transaction(); $param['data'] = $Transaction->viewAll(); Load::view('request', $param); }
public function delete() { $Transaction = new Transaction($this->data->id); $Transaction->delete(); $go = '>auth/Transaction/formFind'; $this->renderPrompt('information', "Transaction [{$this->data->idTransaction}] removido.", $go); }
function createSinkTransaction($ledgerEntries, $loginId, $txDate) { $txDateString = $txDate->format('m/d/Y'); $sinkTransaction = new Transaction(); $sinkTransaction->Init_transaction($loginId, "EOM auto-sink", $txDateString, $txDateString, '', NULL, NULL, NULL, NULL, 1, 0, 0, -1, 1, '', NULL, -1, -1, 0.0, $ledgerEntries, array()); return $sinkTransaction; }
function test() { global $apiContext; // IncludeConfig('paypal/bootstrap.php'); $payer = new Payer(); $payer->setPaymentMethod("paypal"); $item1 = new Item(); $item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setPrice(7.5); $item2 = new Item(); $item2->setName('Granola bars')->setCurrency('USD')->setQuantity(5)->setPrice(2); $itemList = new ItemList(); $itemList->setItems(array($item1, $item2)); $details = new Details(); $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5); $amount = new Amount(); $amount->setCurrency("USD")->setTotal(20)->setDetails($details); $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid()); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl("{$baseUrl}/donate.php/execute_payment_test?success=true")->setCancelUrl("{$baseUrl}/donate.php/execute_payment_test?success=false"); $payment = new Payment(); $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); $request = clone $payment; try { $payment->create($apiContext); } catch (Exception $ex) { ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex); exit(1); } $approvalUrl = $payment->getApprovalLink(); ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='{$approvalUrl}' >{$approvalUrl}</a>", $request, $payment); return $payment; }
/** * Get All notifications of a user. * * @author Kuldeep Dangi <*****@*****.**> */ public function actionEarned($userId) { $model = new Transaction(); $this->result['data'] = $model->getAmount($userId, array(5)); $this->result['success'] = true; $this->sendResponse($this->result); }
/** * Override BundlableLabelableBaseModelWithAttributes::changeType() to update * current location "subclass" (ie. type) value when type change is used. * This should be invoked by any model that can be used to indicate object * storage location. This includes, for now at least, ca_loans, ca_movements, * ca_occurrences and ca_objects_x_storage_locations. * * @param mixed $pm_type The type_id or code to change the current type to * @return bool True if change succeeded, false if error */ public function changeType($pm_type) { if (!$this->getPrimaryKey()) { return false; } // row must be loaded if (!($vb_already_in_transaction = $this->inTransaction())) { $this->setTransaction($o_t = new Transaction($this->getDb())); } if ($vn_rc = parent::changeType($pm_type)) { $o_db = $this->getDb(); $o_db->query("\n\t\t\t\t\tUPDATE ca_objects SET current_loc_subclass = ? \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tcurrent_loc_class = ? AND current_loc_id = ?\n\t\t\t\t", array($this->get('type_id'), $this->tableNum(), $this->getPrimaryKey())); if ($o_db->numErrors()) { $this->errors = $o_db->errors; if (!$vb_already_in_transaction) { $o_t->rollback(); } return false; } } if (!$vb_already_in_transaction) { $o_t->commit(); } return $vn_rc; }
public static function quantita_history($isin, $username, $month_from) { $conn = Db::get_connection(); $transaction_factory = new Transaction(); $transactions = $transaction_factory->find_all(array('where_clause' => "`utente` = '{$conn->escape($username)}' " . "AND `isin` = '{$conn->escape($isin)}' " . "AND `data` >= '{$conn->escape($month_from)}' ", 'order_by' => '`data` DESC')); // print_r($transactions); $portfolio_stock_factory = new PortfolioStock(); $portfolio_stock = $portfolio_stock_factory->find_all(array('where_clause' => "`utente` = '{$conn->escape($username)}' " . "AND `isin` = '{$conn->escape($isin)}' "))[0]; // print_r($portfolio_stock); $quantita_history = array(); $quantita_history[date('Y-m-d')] = $q = $portfolio_stock->quantita; $i = 0; do { if ($transactions[$i]->azione == 'acquisto') { $q -= $transactions[$i]->quantita; } else { $q += $transactions[$i]->quantita; } $quantita_history[$transactions[$i]->data] = $q; $i++; } while ($transactions[$i]->data > $_REQUEST['month-from']); // print_r($quantita_history); Db::close_connection($conn); return $quantita_history; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($for = null, $mass_id = null) { $model = new MassBooking(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['MassBooking'])) { $tr = Yii::app()->db->beginTransaction(); $acct = Account::get('Mass Bookings'); $trans = new Transaction(); $trans->type = 'credit'; $trans->account_id = $acct->id; $trans->amount = $_POST['amount']; $trans->created = Yii::app()->dateFormatter->formatDateTime(time(), 'short', 'medium'); $trans->creator = Yii::app()->user->id; $trans->descr = "Mass booking"; if ($trans->save()) { $model->attributes = $_POST['MassBooking']; $model->trans_id = $trans->id; if ($model->save()) { $trans->saveAttributes(array('descr' => "Mass booking #" . $model->id)); $tr->commit(); $this->redirect(array('view', 'id' => $model->id)); return; } } $tr->rollback(); } $parms = array('model' => $model); $parms['mass_dt'] = isset($for) ? $for : ''; $parms['mass_id'] = isset($mass_id) ? $mass_id : ''; $this->render('create', $parms); }
/** * @param Transaction $transaction * @param DOMDocument $document * @return \DOMElement */ private function createCancellationRequest($transaction, DOMDocument $document) { $requisicao = $document->createElementNS(self::NS, 'requisicao-cancelamento'); $requisicao->setAttribute('id', $transaction->getCancellationId()); $requisicao->setAttribute('versao', RequestSerializer::VERSION); $this->createElementAndAppendWithNs($requisicao, 'tid', $transaction->tid); $requisicao->appendChild($this->createDadosEc($transaction, $document)); return $requisicao; }
private static function validateTransaction(Transaction $transaction) { global $wpdb; $transactionStatus = $transaction->getStatus(); $reference = $transaction->getReference(); if ($reference && function_exists('automatic_return')) { automatic_return($transactionStatus, $reference); } }
public function actionIndex() { $user = Yii::app()->user->data(); if (Yii::app()->user->isGuest) { $this->layout = '//layouts/landing'; $this->render('index'); } elseif ($user->isActivated()) { if ($user->isVerified()) { $buyform = new BuyBtcForm(); // $transactions = Transaction::model ()->findAllByAttributes(array('id_user' => $user->id, 'type' => 1)); $avail_balance_local = money_format('%.2n', count($user->balance) > 0 ? $user->balance->local : 0); $avail_balance_usd = money_format('%.2n', count($user->balance) > 0 ? $user->balance->usd : 0); $avail_balance_btc = money_format('%.2n', count($user->balance) > 0 ? $user->balance->btc : 0); $request = Yii::app()->request; $formData = $request->getPost(get_class($buyform), false); if ($formData) { $buyform->amount_btc = $formData['amount_btc']; $buyform->amount_fiat = $formData['amount_fiat']; $buyform->type_trans = $formData['type_trans']; /*if ($buyform->hasErrors ()) { } else{ */ if ($buyform->validate(array(''))) { $tran = new Transaction(); $tran->id_user = $user->id; $tran->status = 0; if ($buyform->type_trans == "BUY") { $tran->type = 4; $tran->descr = "You purchased Bitcoins"; $tran->currency = "USD"; $tran->amount = $buyform->amount_btc; } elseif ($buyform->type_trans == "SELL") { $tran->type = 3; $tran->descr = "You sold Bitcoins"; $tran->currency = "BTC"; $tran->amount = $buyform->amount_fiat; } else { Yii::app()->user->setFlash('error', Yii::t('translation', 'Error! Unable to create transaction')); } if (!$tran->save()) { Yii::app()->user->setFlash('error', Yii::t('translation', 'Error! Unable to create transaction')); } } else { Yii::app()->user->setFlash('error', Yii::t('translation', 'Error in the fields')); } } $this->render('index-activated', compact('avail_balance_local', 'user', 'buyform', 'avail_balance_local', 'avail_balance_usd', 'avail_balance_btc')); } else { $this->render('notverified'); } } else { $this->render('index'); } }
public function actionAdmin() { $model = new Transaction('search'); $model->unsetAttributes(); if (isset($_GET['Transaction'])) { $model->setAttributes($_GET['Transaction']); } $this->render('admin', array('model' => $model)); }
/** * Sum all Child Transactions * * Sum all Child Transactions related to one parent * * @param string $transaction_id is a long specifying a transaction * * @url GET /sum/{transaction_id} */ function getSum($transaction_id) { $trans = new Transaction(); $sum = $trans->getSumOfChildren($transaction_id); if ($sum != 0) { return $sum; } return array('status' => 'fail'); }
function by_isin() { $conn = $this->get_connection(); $this->totale = 0; $this->bilancio = 0; $transaction_factory = new Transaction(); $this->transactions = $transaction_factory->find_by_query('SELECT `creso_transazioni`.`id`, `creso_transazioni`.`azione`, `creso_transazioni`.`negot_id`, `creso_transazioni`.`prezzo`, `creso_transazioni`.`quantita`, `creso_transazioni`.`isin`, `creso_titoli`.`title` ' . 'FROM `creso_transazioni` ' . 'LEFT JOIN `creso_titoli` ON `creso_transazioni`.`isin` = `creso_titoli`.`isin` ' . "WHERE `utente` = '{$conn->escape($_COOKIE['username'])}' " . "AND `creso_transazioni`.`isin` = '{$conn->escape($_GET['id'])}' " . "AND `azione` = 'vendita' " . 'GROUP BY `negot_id` ' . 'ORDER BY ' . sprintf('`%s` %s ', $this->get_sort('data'), $this->get_dir(TRUE)) . "LIMIT {$conn->escape($this->get_start())}, {$conn->escape($this->get_limit())}"); $this->_populate_transactions(); $this->render(array('action' => 'index')); }
public function puserDailyPayment() { $aTariffs = SettingTable::getAllTariffs(); $oBalanceSystem = BalanceSystem::getCurrentBalanceInstance(); $aPUsers = UserTable::getPUsersActive(); foreach ($aPUsers as $oPUser) { $transaction = new Transaction(); $transaction->puserDailyPayment($oPUser, $oBalanceSystem, $aTariffs); } }
public function createAction() { $this->logger->entering(); $paramTerms = $this->_getParam('terms'); $paramUser = $this->_getParam('user'); $this->logger->info('Validating user from params'); $validity = User::isValid($paramUser); if ($paramTerms != 1 || !$validity) { $this->logger->notice('Invalid User'); $this->flash->notice = "Please complete all fields and agree to the terms and conditions"; if (!$validity) { foreach ($paramUser['errors'] as $k => $v) { $this->flash->notice = $this->flash->notice . ", {$k} {$v}"; } } $this->logger->info('Loading view parameters'); $this->view->assign(array('title' => "New User", 'user' => $paramUser, 'states' => $this->states, 'terms' => $paramTerms)); $this->logger->info('Render view'); /* echo $this->view->render('applicationTemplate.phtml'); */ $this->render(); $this->logger->info('Clearing flash notice'); $this->flash->keep = 1; unset($this->flash->notice); } else { $this->logger->info('Building a new user from request'); $users = new User(); $user = $users->fetchNew(); $paramUser = $users->filterColumns($paramUser); $user->setFromArray($paramUser); $this->logger->info('Inserting the user'); if ($user->save()) { $this->logger->notice('Crediting signup bonus'); $transactions = new Transaction(); $transactions->signupUser($user); $this->logger->notice('Sending welcome message'); $mail = new Zend_Mail(); $mail->setBodyText('Welcome to swaplady.'); $mail->setFrom('*****@*****.**', 'Some Sender'); $mail->addTo($user->email, $user->name); $mail->setSubject('Welcome to Swaplady'); $mail->send(); $this->logger->notice('Marking as logged in'); $this->session->user_id = $user->id; if (isset($this->flash->redirectedFrom)) { $intendedAction = $this->flash->redirectedFrom; $this->logger->info("Redirecting to intended action '{$intendedAction['controller']}::{$intendedAction['action']}'"); $this->_redirect('/' . $intendedAction['controller'] . '/' . $intendedAction['action']); } else { $this->logger->info("Redirecting to show user {$user->id}"); $this->_redirect("user/show/{$user->id}"); } } } $this->logger->exiting(); }
public function testWritingATransactionWillReturnTransactionWithIdSet() { //txn before the write $this->assertNull($this->transaction->getId()); $this->journalist->expects($this->once())->method('writeTransaction')->will($this->returnValue(new IntType(1))); $txn = $this->sut->write($this->transaction); //txn after the write $this->assertInstanceOf('SAccounts\\Transaction\\SimpleTransaction', $txn); $this->assertInstanceOf('Chippyash\\Type\\Number\\IntType', $txn->getId()); $this->assertEquals(1, $txn->getId()->get()); }
public function report($wins, $opponentWins) { if (!$this->awaitingResult()) { $msg = 'Tried to report when not awaiting result.'; throw new IllegalStateException($msg); } $t = new Transaction(); $entries = [$this->playerId => $wins, $this->opponentId => $opponentWins]; foreach ($entries as $playerId => $playerWins) { $sql = 'UPDATE player_match SET wins = ' . Q($playerWins) . ' WHERE match_id = ' . Q($this->matchId) . ' AND player_id = ' . Q($playerId); $t->execute($sql); } $t->commit(); }
function deleteWidget($id) { try { $transaction = new Transaction(); $result = DAOFactory::getAfiliadoWidgetDAO()->delete($id); $transaction->commit(); return $result; } catch (Exception $e) { print_r($e); if ($transaction) { $transaction->rollback(); } return false; } }
public function deductAmount($userId, $amount, $type = 9) { $model = $this->findByAttributes(array('fk_user' => $userId)); if ($model) { if ($model->amount >= $amount) { $model->amount = $model->amount - $amount; $model->save(); $transObj = new Transaction(); $transObj->attributes = array('fk_user' => $userId, 'type' => $type, 'amount' => $amount); $transObj->save(); return true; } } return false; }
function use_buycodes() { Load::model('codes'); Load::model('transaction'); $Codes = new Codes(); $Transaction = new Transaction(); if ($_POST['source'] == "Commission Deduction") { $Transaction->add_buycodes($_POST['amount']); $Codes->add($_POST['howmany'], $_POST['acc_type']); } else { $Transaction->add_buycodes_request($_POST['howmany'], $_POST['acc_type'], $_POST['amount']); } echo 1; exit; }
/** * Get array with read-only properties * @return array */ public function GetReadOnlyProperties() { $properties = parent::GetReadOnlyProperties(); array_push($properties, 'PaymentType'); array_push($properties, 'ExecutionType'); return $properties; }
/** * @param User $user * @param Invitation $invitation * @return void * @throws Runtime\DuplicateUsernameException * @throws Runtime\DuplicateEmailException * @throws Runtime\InvitationNotFoundException * @throws Runtime\InvitationExpiredException * @throws Runtime\InvitationTokenMatchException * @throws \DibiException */ public function registerNewUser(User $user, Invitation $invitation) { if (!$user->isDetached()) { throw new InvalidArgumentException('Only detached instances of Entity ' . User::class . ' can pass.'); } $this->checkInvitation($user->email, $invitation->token); try { $this->transaction->begin(); $this->userRepository->persist($user); $this->removeInvitation($invitation); $this->transaction->commit(); } catch (\DibiException $e) { if ($e->getCode() == 1062) { try { $this->userRepository->checkUsername($user->username); } catch (Runtime\UserAlreadyExistsException $usernameException) { $this->transaction->rollback(); throw new Runtime\DuplicateUsernameException(); } try { $this->userRepository->checkEmail($user->email); } catch (Runtime\UserAlreadyExistsException $emailException) { $this->transaction->rollback(); throw new Runtime\DuplicateEmailException(); } } $this->transaction->rollback(); Debugger::log($e, Debugger::ERROR); throw $e; } }
/** * Check if: * controller - is first parameter * method - is second parameter * rest of parameters - are sorted * * @author Jakub Olek <*****@*****.**> * * @throws WikiaException */ public final function init() { $webRequest = F::app()->wg->Request; $accessService = new ApiAccessService($this->getRequest()); $controller = $webRequest->getVal('controller'); $method = $webRequest->getVal('method'); $accessService->checkUse($controller . 'Controller', $method); //this is used for monitoring purposes, do not change unless you know what you are doing //should set api/v1 as the transaction name if (!$this->request->isInternal()) { Transaction::setEntryPoint(Transaction::ENTRY_POINT_API_V1); } if (!$this->request->isInternal()) { if ($this->hideNonCommercialContent()) { $this->blockIfNonCommercialOnly(); } $paramKeys = array_keys($webRequest->getQueryValues()); $count = count($paramKeys); if ($count >= 2 && $paramKeys[0] === 'controller' && $paramKeys[1] === 'method') { if ($count > 2) { $origParam = $paramKeys = array_flip(array_slice($paramKeys, 2)); ksort($paramKeys); ksort($origParam); if ($paramKeys !== $origParam) { throw new BadRequestApiException('The parameters\' order is incorrect'); } } } else { throw new BadRequestApiException('Controller and/or method missing'); } } }
function logout() { fireEvent("Logout"); Acl::clearAcl(); Transaction::clear(); session_destroy(); }
function testTransactionCurrencyConverting() { $eur = Currency::getNewInstance('EUR'); $eur->rate->set('3.4528'); $eur->save(); $this->products[0]->setPrice($this->usd, '9.99'); $this->order->addProduct($this->products[0], 1); $this->order->save(); $this->order->changeCurrency($this->usd); //$this->order->finalize(); ActiveRecord::clearPool(); $order = CustomerOrder::getInstanceByID($this->order->getID(), true); $order->loadAll(); $details = new LiveCartTransaction($order, $eur); ActiveRecord::clearPool(); $order = CustomerOrder::getInstanceByID($this->order->getID(), true); $order->loadAll(); $this->assertEquals($details->amount->get(), '2.89'); $result = new TransactionResult(); $result->amount->set($details->amount->get()); $result->currency->set($details->currency->get()); $transaction = Transaction::getNewInstance($order, $result); $transaction->type->set(Transaction::TYPE_SALE); $this->assertEquals($transaction->amount->get(), '9.99'); $this->assertEquals($transaction->realAmount->get(), '2.89'); $transaction->save(); $this->assertFalse((bool) $order->isFinalized->get()); $order->finalize(); $this->assertTrue((bool) $order->isFinalized->get()); $this->assertEquals($order->getPaidAmount(), '9.99'); $this->assertEquals($order->totalAmount->get(), '9.99'); $this->assertTrue((bool) $order->isPaid->get()); }
protected function processForm(sfWebRequest $request, sfForm $form) { $parameters = $request->getParameter($form->getName()); $form->bind($parameters, $request->getFiles($form->getName())); if ($form->isValid()) { $this->getContext()->getConfiguration()->loadHelpers('Number'); // On crée la transaction correspondante $transaction = new Transaction(); $transaction->asso_id = $parameters['asso_id']; $transaction->compte_id = $parameters['compte_id']; $transaction->libelle = 'Remboursement ' . $parameters['nom']; $transaction->commentaire = "Remboursement des achats suivants :\n"; // Voir ci-dessous $transaction->montant = 0; // On fera le total plus tard ! $transaction->date_transaction = date('Y-m-d'); $transaction->moyen_id = $parameters['moyen_id']; $transaction->moyen_commentaire = $parameters['moyen_commentaire']; $transaction->save(); $form->setValue('transaction_id', $transaction->getPrimaryKey()); $note_de_frais = $form->save(); foreach ($parameters['transactions'] as $transaction_id) { $transaction2 = $note_de_frais->addAchatFromId($transaction_id); $transaction->commentaire .= $this->format_transaction($transaction2) . "\n"; } $transaction->save(); $this->redirect('ndf', $note_de_frais->getAsso()); } }
/** * Generate license */ public function postGenerateLicense() { $rules = array('transaction_id' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('admin/utilities/generate-license')->withErrors($validator)->withInput(); } else { $transaction_id = Input::get('transaction_id'); if ($transaction = Transaction::where('id', '=', $transaction_id)->first()) { if ($license = License::where('transaction_id', '=', $transaction_id)->first()) { Session::flash('alert_error', '<strong>Ooops!</strong> License for given transaction already exists.'); return Redirect::to('admin/licenses?q=' . $license->license_key . '¶m=key'); } $plan = Plan::where('id', '=', $transaction->plan_id)->first(); if ($plan->has_license) { $product = Product::where('id', '=', $plan->product_id)->first(); $license_key = License::generate($product->code); // Save license $license = new License(); $license->license_key = $license_key; $license->transaction_id = $transaction_id; $license->allowed_usage = $plan->license_allowed_usage; $license->save(); Session::flash('alert_message', '<strong>Well done!</strong> You successfully have generated license key.'); return Redirect::to('admin/licenses?q=' . $license_key . '¶m=key'); } else { Session::flash('alert_error', '<strong>Ooops!</strong> This plan does not allow to generate a license key.'); return Redirect::to('admin/utilities/generate-license'); } } else { Session::flash('alert_error', '<strong>Ooops!</strong> Transaction was not found.'); return Redirect::to('admin/utilities/generate-license'); } } }
function deleteFaq($id) { try { $transaction = new Transaction(); $faq = DAOFactory::getFaqDAO()->load($id); DAOFactory::getFaqDAO()->delete($id); $transaction->commit(); return true; } catch (Exception $e) { var_dump($e); if ($transaction) { $transaction->rollback(); } return false; } }