本文整理汇总了PHP中Transaction::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::find方法的具体用法?PHP Transaction::find怎么用?PHP Transaction::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTransaction
/**
* fetch all Transaction details from hypercharge server.
* @return Hypercharge\Transaction null if Notification has no Transaction
*/
function getTransaction()
{
if (!$this->hasTransaction()) {
return null;
}
return Transaction::find($this->payment_transaction_channel_token, $this->payment_transaction_unique_id);
}
示例2: testPayment
public function testPayment()
{
$userBalance = Balance::find(1);
$userBalance->balance = 75000;
$userBalance->save();
$this->assertEquals(75000, $userBalance->balance);
$response = $this->call('GET', 'api/7xDsRLyXEd1PgJ6Glrhs6d/payment?password=strong_pass_plz&to=mrcpH23MHKweJmzNWNbPKMxtVKMJYVpKgr&amount=50000¬e=xxx');
$jsonResult = json_decode($response->getContent());
$this->assertEquals("Sent 0.0005, crypto type id: 1 to mrcpH23MHKweJmzNWNbPKMxtVKMJYVpKgr", $jsonResult->message);
$transactionModel = Transaction::find(1);
$this->assertEquals('151f9b43343c5cd4f2064b5ac2a722f67cc53a845d05cdf9979379fa4ed19160', $transactionModel->tx_id);
$this->assertEquals(20080, $transactionModel->network_fee);
// to, amount, note
// address valid
// user has enough balance
//
}
示例3: searchAction
/**
* Searches for transaction
*/
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Transaction", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "id";
$transaction = Transaction::find($parameters);
if (count($transaction) == 0) {
$this->flash->notice("The search did not find any transaction");
return $this->dispatcher->forward(array("controller" => "transaction", "action" => "index"));
}
$paginator = new Paginator(array("data" => $transaction, "limit" => 10, "page" => $numberPage));
$this->view->page = $paginator->getPaginate();
}
示例4: destroy
/**
* Remove the specified transaction from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$data = Input::all();
$transaction = Transaction::find($id);
$transactions = $transaction->getRecurringTransactions->filter(function ($t) {
if ($t->user_id == Auth::id()) {
return $t;
}
});
if ($transaction->user_id == Auth::id()) {
/**
* DESTROY ONLY...
*/
switch (@$data['apply_changes_to']) {
case 'this':
Transaction::destroy($transaction->id);
break;
case 'next':
$transactions = $transactions->filter(function ($t) use($transaction) {
if ($t->date >= $transaction->date) {
return $t;
}
});
// DESTROY THE ITEMS
foreach ($transactions as $transaction) {
Transaction::destroy($transaction->id);
}
break;
case 'unpaid':
$transactions = $transactions->filter(function ($t) {
if ($t->done != 1) {
return $t;
}
});
// DESTROY THE ITEMS
foreach ($transactions as $t) {
Transaction::destroy($t->id);
}
break;
case 'all':
// DESTROY THE ITEMS
// echo "<pre>";
// print_r($transactions->count());
// exit;
foreach ($transactions as $t) {
$t->destroy($t->id);
}
break;
default:
// SAME OF 'THIS'
Transaction::destroy($transaction->id);
break;
}
$alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Lançamento excluído!'];
} else {
$alert[] = ['class' => 'alert-danger', 'message' => '<strong><i class="fa fa-check"></i></strong> Sem permissão para excluir o lançamento!'];
}
Session::flash('alerts', $alert);
return Redirect::to(URL::previous());
}
示例5: saveFee
private function saveFee($new_transaction)
{
$db_tx_id = $new_transaction->id;
/* get for that transaction a miners fee, at this point we know it already */
Queue::push(function ($job) use($db_tx_id) {
$tx = Transaction::find($db_tx_id);
// get_transaction from bitcoin core
$tx_info = $this->bitcoin_core->gettransaction($tx->tx_id);
$fee = isset($tx_info['fee']) ? abs(bcmul($tx_info['fee'], SATOSHIS_FRACTION)) : null;
$tx->network_fee = $fee;
$tx->save();
$job->delete();
});
}
示例6: refund
/**
* Refund the transaction
*/
static function refund($id, $force_refund = FALSE)
{
$transaction = Transaction::find($id);
// Get Plan data
$plan = Plan::where('id', '=', $transaction->plan_id)->first();
// Get purchase data
$purchase = Purchase::where('id', '=', $transaction->purchase_id)->first();
if ($transaction->purchase->pay_method == 1) {
// Add Stripe library
require_once app_path() . "/libraries/stripe-php-1.9.0/lib/Stripe.php";
// Add Stripe library
Stripe::setApiKey(Config::get('project.stripe_secret_key'));
try {
$ch = Stripe_Charge::retrieve($transaction->pay_id);
$ch->refund();
} catch (Exception $e) {
$error = TRUE;
}
// If Split pay then cancel subscription as well
if ($plan->has_split_pay) {
$at_period_end = FALSE;
$customer = $purchase->stripe_token;
$subscription_id = NULL;
try {
$cu = Stripe_Customer::retrieve($customer);
$subscriptions = $cu->subscriptions->all(array('count' => 100));
foreach ($subscriptions->data as $subscription) {
if ($subscription->plan->id == $plan_id) {
if ($subscription->status == 'active') {
$subscription_id = $subscription->id;
break;
}
}
}
$cu->subscriptions->retrieve($subscription_id)->cancel(array('at_period_end' => $at_period_end));
} catch (Exception $e) {
$error = TRUE;
}
}
} elseif ($transaction->purchase->pay_method == 2) {
$config = array('mode' => Config::get('project.paypal_mode'), 'acct1.UserName' => Config::get('project.paypal_api_username'), 'acct1.Password' => Config::get('project.paypal_api_password'), 'acct1.Signature' => Config::get('project.paypal_api_signature'));
/*
* The RefundTransaction API operation issues a refund to the PayPal account holder associated with a transaction.
This sample code uses Merchant PHP SDK to make API call
*/
$refundReqest = new PayPal\PayPalAPI\RefundTransactionRequestType();
/*
* Type of refund you are making. It is one of the following values:
* `Full` - Full refund (default).
* `Partial` - Partial refund.
* `ExternalDispute` - External dispute. (Value available since
version
82.0)
* `Other` - Other type of refund. (Value available since version
82.0)
*/
$refundReqest->RefundType = 'Full';
/*
* Either the `transaction ID` or the `payer ID` must be specified.
PayerID is unique encrypted merchant identification number
For setting `payerId`,
`refundTransactionRequest.setPayerID("A9BVYX8XCR9ZQ");`
Unique identifier of the transaction to be refunded.
*/
$refundReqest->TransactionID = $transaction->pay_id;
/*
* (Optional)Type of PayPal funding source (balance or eCheck) that can be used for auto refund. It is one of the following values:
any – The merchant does not have a preference. Use any available funding source.
default – Use the merchant's preferred funding source, as configured in the merchant's profile.
instant – Use the merchant's balance as the funding source.
eCheck – The merchant prefers using the eCheck funding source. If the merchant's PayPal balance can cover the refund amount, use the PayPal balance.
*/
//$refundReqest->RefundSource = $_REQUEST['refundSource'];
$refundReqest->Memo = "Refunded from Digital Kickstart App";
/*
*
(Optional) Maximum time until you must retry the refund.
*/
//$refundReqest->RetryUntil = $_REQUEST['retryUntil'];
$refundReq = new PayPal\PayPalAPI\RefundTransactionReq();
$refundReq->RefundTransactionRequest = $refundReqest;
/*
* ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPal\Service\PayPalAPIInterfaceServiceService($config);
try {
/* wrap API method calls on the service object with a try catch */
$refundResponse = $paypalService->RefundTransaction($refundReq);
} catch (Exception $ex) {
$error = TRUE;
}
// If Split pay then cancel subscription as well
if ($plan->has_split_pay) {
//.........这里部分代码省略.........
示例7: getTransaction
/**
* Get transaction.
*
* @param string $transactionId Transaction ID.
*
* @return Transaction transaction or false on error
* @access public
*/
public function getTransaction($transactionId)
{
$t = new Transaction();
$t->transaction_id = $transactionId;
return $t->find(true) ? $t : false;
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$this->transaction->find($id)->delete();
return Redirect::route('admin.transactions.index');
}
示例9: testFind
function testFind()
{
$sale = $this->testSale();
$trx = Transaction::find($this->channelToken, $sale->unique_id);
$this->assertIsA($trx, 'Hypercharge\\Transaction');
$this->assertEqual($trx, $sale);
}
示例10: postCancelSubscription
/**
* Cancel Subscription process
*/
public function postCancelSubscription($id, $at_period_end = FALSE)
{
$transaction = Transaction::find($id);
if (Input::get('pay_method') == 'Stripe') {
$at_period_end = !$at_period_end ? FALSE : TRUE;
$customer = Input::get('stripe_customer_id');
$subscription_id = Input::get('subscription_id');
// Add Stripe library
require_once app_path() . "/libraries/stripe-php-1.9.0/lib/Stripe.php";
// Add Stripe library
Stripe::setApiKey(Config::get('project.stripe_secret_key'));
try {
$cu = Stripe_Customer::retrieve($customer);
$cu->subscriptions->retrieve($subscription_id)->cancel(array('at_period_end' => $at_period_end));
Session::flash('alert_message', '<strong>Done!</strong> You successfully have cancelled the subscription.');
return Redirect::to("admin/transactions/detail/{$transaction->id}");
} catch (Exception $e) {
Session::flash('alert_error', '<strong>Ooops!</strong> Subscription was not cancelled, try again.');
return Redirect::to("admin/transactions/cancel-subscription/{$transaction->id}/{$at_period_end}");
}
}
if (Input::get('pay_method') == 'PayPal') {
$config = array('mode' => Config::get('project.paypal_mode'), 'acct1.UserName' => Config::get('project.paypal_api_username'), 'acct1.Password' => Config::get('project.paypal_api_password'), 'acct1.Signature' => Config::get('project.paypal_api_signature'));
$purchase = $transaction->purchase;
$paypal_sub_id = $purchase->paypal_sub_id;
/*
* The ManageRecurringPaymentsProfileStatus API operation cancels, suspends, or reactivates a recurring payments profile.
*/
$manageRPPStatusReqestDetails = new ManageRecurringPaymentsProfileStatusRequestDetailsType();
/*
* (Required) The action to be performed to the recurring payments profile. Must be one of the following:
Cancel – Only profiles in Active or Suspended state can be canceled.
Suspend – Only profiles in Active state can be suspended.
Reactivate – Only profiles in a suspended state can be reactivated.
*/
$manageRPPStatusReqestDetails->Action = 'Cancel';
/*
* (Required) Recurring payments profile ID returned in the CreateRecurringPaymentsProfile response.
*/
$manageRPPStatusReqestDetails->ProfileID = $paypal_sub_id;
$manageRPPStatusReqest = new ManageRecurringPaymentsProfileStatusRequestType();
$manageRPPStatusReqest->ManageRecurringPaymentsProfileStatusRequestDetails = $manageRPPStatusReqestDetails;
$manageRPPStatusReq = new ManageRecurringPaymentsProfileStatusReq();
$manageRPPStatusReq->ManageRecurringPaymentsProfileStatusRequest = $manageRPPStatusReqest;
/*
* ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService($config);
try {
/* wrap API method calls on the service object with a try catch */
$manageRPPStatusResponse = $paypalService->ManageRecurringPaymentsProfileStatus($manageRPPStatusReq);
} catch (Exception $ex) {
Session::flash('alert_error', '<strong>Ooops!</strong> Subscription was not cancelled, try again.');
return Redirect::to("admin/transactions/cancel-subscription/{$transaction->id}/{$at_period_end}");
}
if (isset($manageRPPStatusResponse) and $manageRPPStatusResponse->Ack == 'Success') {
Session::flash('alert_message', '<strong>Done!</strong> You successfully have cancelled the subscription.');
return Redirect::to("admin/transactions/detail/{$transaction->id}");
} else {
Session::flash('alert_error', '<strong>Ooops!</strong> Subscription was not cancelled, try again.');
return Redirect::to("admin/transactions/cancel-subscription/{$transaction->id}/{$at_period_end}");
}
}
}
示例11: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$transaction = Transaction::find($id);
$transaction->delete();
Session::flash('message', 'Deleted ' . $transaction->item . '.');
return Redirect::to('transactions');
}