本文整理汇总了PHP中Transaction类的典型用法代码示例。如果您正苦于以下问题:PHP Transaction类的具体用法?PHP Transaction怎么用?PHP Transaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetExternalIdValid
public function testSetExternalIdValid()
{
$externalId = 'abc';
$customer = new Transaction();
$customer->setExternalId($externalId);
$this->assertEquals($externalId, $customer->getExternalId());
}
示例2: display
function display()
{
Load::model('transaction');
$Transaction = new Transaction();
$param['data'] = $Transaction->viewAll();
Load::view('request', $param);
}
示例3: delete
public function delete()
{
$Transaction = new Transaction($this->data->id);
$Transaction->delete();
$go = '>auth/Transaction/formFind';
$this->renderPrompt('information', "Transaction [{$this->data->idTransaction}] removido.", $go);
}
示例4: createSinkTransaction
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;
}
示例5: test
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;
}
示例6: actionEarned
/**
* Get All notifications of a user.
*
* @author Kuldeep Dangi <kuldeep.dangi@yiifrmae.com>
*/
public function actionEarned($userId)
{
$model = new Transaction();
$this->result['data'] = $model->getAmount($userId, array(5));
$this->result['success'] = true;
$this->sendResponse($this->result);
}
示例7: changeType
/**
* 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;
}
示例8: quantita_history
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;
}
示例9: actionCreate
/**
* 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);
}
示例10: createCancellationRequest
/**
* @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;
}
示例11: validateTransaction
private static function validateTransaction(Transaction $transaction)
{
global $wpdb;
$transactionStatus = $transaction->getStatus();
$reference = $transaction->getReference();
if ($reference && function_exists('automatic_return')) {
automatic_return($transactionStatus, $reference);
}
}
示例12: actionIndex
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');
}
}
示例13: actionAdmin
public function actionAdmin()
{
$model = new Transaction('search');
$model->unsetAttributes();
if (isset($_GET['Transaction'])) {
$model->setAttributes($_GET['Transaction']);
}
$this->render('admin', array('model' => $model));
}
示例14: getSum
/**
* 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');
}
示例15: by_isin
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'));
}