本文整理汇总了PHP中Braintree_Transaction::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Transaction::find方法的具体用法?PHP Braintree_Transaction::find怎么用?PHP Braintree_Transaction::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Braintree_Transaction
的用法示例。
在下文中一共展示了Braintree_Transaction::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transSettlement
/**
* Transaction Settlement
*
* @param $trans_id
* @return object
*/
public function transSettlement($trans_id)
{
$transaction = Braintree_Transaction::find($trans_id);
if ($transaction->status == Braintree_Transaction::SETTLED) {
$result = array('status' => $transaction->status, 'is_settlement' => true);
return $result;
} else {
$result = array('status' => $transaction->status, 'is_settlement' => false);
return $result;
}
}
示例2: transactionSettlement
/**
* Transaction settlement method
* for cronjob
* @param $trans_id
* @return object
*/
public function transactionSettlement($trans_id)
{
$transaction = Braintree_Transaction::find($trans_id);
//return $transaction;
if ($transaction->status == Braintree_Transaction::SETTLED) {
$result = array('is_settlement' => true);
} else {
$result = array('is_settlement' => false);
}
$result['recurring'] = $transaction->recurring;
$result['status'] = $transaction->status;
$result['package_id'] = $transaction->planId;
$result['subscription_id'] = $transaction->subscriptionId;
return $result;
}
示例3: find
/**
* @param string $id
* @return \Braintree_Transaction
*/
public function find($id)
{
return \Braintree_Transaction::find($id);
}
示例4: testIncludeProcessorSettlementResponseForSettlementPendingTransaction
function testIncludeProcessorSettlementResponseForSettlementPendingTransaction()
{
$result = Braintree_Transaction::sale(array("paymentMethodNonce" => Braintree_Test_Nonces::$paypalFuturePayment, "amount" => "100", "options" => array("submitForSettlement" => true)));
$this->assertTrue($result->success);
$transaction = $result->transaction;
Braintree_TestHelper::settlementPending($transaction->id);
$inline_transaction = Braintree_Transaction::find($transaction->id);
$this->assertEquals($inline_transaction->status, Braintree_Transaction::SETTLEMENT_PENDING);
$this->assertEquals($inline_transaction->processorSettlementResponseCode, "4002");
$this->assertEquals($inline_transaction->processorSettlementResponseText, "Settlement Pending");
}
示例5: json_encode
echo '<input type="hidden" name="_act" value="refund_process" />';
echo '</br>Transaction ID: <input type="text" name="id" value="" />';
echo '</br>Amount: <input type="text" name="amt" value="" />';
echo '</br><input type="submit" name="" value="Proceed to Refund " />';
echo "</form>";
echo "--------------------------------------------------------------------------------------------------------------------------";
} else {
if ($_REQUEST['_act'] == 'refund_process') {
$result = Braintree_Transaction::refund((string) $_POST['id'], (string) $_POST['amt']);
echo "<div style='height:300px; overflow-y:scroll; background-color:#fff;'> <h3>API response</h3>";
echo json_encode($result, JSON_PRETTY_PRINT);
echo "</div>";
exit;
} else {
if ($_POST['_act'] == 'find') {
$result = Braintree_Transaction::find($_POST['id']);
print_r($result);
} else {
if ($_POST['_act'] == 'clone') {
$result = Braintree_Transaction::cloneTransaction($_POST['id'], array('amount' => '10.00', 'options' => array('submitForSettlement' => true)));
print_r($result);
} else {
if ($_POST['_act'] == 'createCustomer') {
if (isset($_POST['data'])) {
$postData = explode("&", urldecode($_POST['data']));
//[SETTING UP POST DATA TO SUPPORT AJAX]
foreach ($postData as $key => $value) {
$postValue = explode("=", $value);
$_POST[$postValue[0]] = $postValue[1];
}
unset($_POST['data']);
示例6: void
/**
* Voids transaction
*
* @param Varien_Object $payment
* @return Braintree_Payments_Model_Paymentmethod
*/
public function void(Varien_Object $payment)
{
$transactionIds = array();
$invoice = Mage::registry('current_invoice');
$message = false;
if ($invoice && $invoice->getId() && $invoice->getTransactionId()) {
$transactionIds[] = Mage::helper('braintree_payments')->clearTransactionId($invoice->getTransactionId());
} else {
$collection = Mage::getModel('sales/order_payment_transaction')->getCollection()->addFieldToSelect('txn_id')->addOrderIdFilter($payment->getOrder()->getId())->addTxnTypeFilter(array(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE));
$fetchedIds = $collection->getColumnValues('txn_id');
foreach ($fetchedIds as $transactionId) {
$txnId = Mage::helper('braintree_payments')->clearTransactionId($transactionId);
if (!in_array($txnId, $transactionIds)) {
$transactionIds[] = $txnId;
}
}
}
foreach ($transactionIds as $transactionId) {
$transaction = Braintree_Transaction::find($transactionId);
if ($transaction->status !== Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT && $transaction->status !== Braintree_Transaction::AUTHORIZED) {
$message = Mage::helper('braintree_payments')->__('Some transactions are already settled or voided and cannot be voided.');
throw new Mage_Core_Exception($message, self::VOID_ALREADY_SETTLED_EXCEPTION);
}
if ($transaction->status === Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT) {
$message = Mage::helper('braintree_payments')->__('Voided capture.');
}
}
$errors = '';
foreach ($transactionIds as $transactionId) {
$this->_debug('void-' . $transactionId);
$result = Braintree_Transaction::void($transactionId);
$this->_debug($result);
if (!$result->success) {
$errors .= ' ' . Mage::helper('braintree_payments/error')->parseBraintreeError($result);
} else {
if ($message) {
$payment->setMessage($message);
}
}
}
if ($errors) {
Mage::throwException(Mage::helper('braintree_payments')->__('There was an error voiding the transaction.') . $errors);
} else {
$match = true;
foreach ($transactionIds as $transactionId) {
$collection = Mage::getModel('sales/order_payment_transaction')->getCollection()->addFieldToFilter('parent_txn_id', array('eq' => $transactionId))->addFieldToFilter('txn_type', Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
if ($collection->getSize() < 1) {
$match = false;
}
}
if ($match) {
$payment->setIsTransactionClosed(1);
}
}
return $this;
}
示例7: test_rangeNode_settledAt
function test_rangeNode_settledAt()
{
$transaction = Braintree_Transaction::saleNoValidate(array('amount' => '1000.00', 'creditCard' => array('number' => '4111111111111111', 'expirationDate' => '05/12'), 'options' => array('submitForSettlement' => true)));
Braintree_Http::put('/transactions/' . $transaction->id . '/settle');
$transaction = Braintree_Transaction::find($transaction->id);
$twenty_min_ago = date_create("now -20 minutes", new DateTimeZone("UTC"));
$ten_min_ago = date_create("now -10 minutes", new DateTimeZone("UTC"));
$ten_min_from_now = date_create("now +10 minutes", new DateTimeZone("UTC"));
$collection = Braintree_Transaction::search(array(Braintree_TransactionSearch::id()->is($transaction->id), Braintree_TransactionSearch::settledAt()->between($twenty_min_ago, $ten_min_ago)));
$this->assertEquals(0, $collection->maximumCount());
$collection = Braintree_Transaction::search(array(Braintree_TransactionSearch::id()->is($transaction->id), Braintree_TransactionSearch::settledAt()->between($ten_min_ago, $ten_min_from_now)));
$this->assertEquals(1, $collection->maximumCount());
$this->assertEquals($transaction->id, $collection->firstItem()->id);
}
示例8: refund
public function refund(Varien_Object $payment, $amount)
{
try {
$transaction = Braintree_Transaction::find($payment->getCcTransId());
if ($transaction->amount != $amount && $transaction->status === Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT) {
Mage::throwException('This refund is for a partial amount but the Transaction has not settled. Please wait 24 hours before trying to issue a partial refund.');
}
$result = $transaction->status === Braintree_Transaction::SETTLED ? Braintree_Transaction::refund($payment->getCcTransId(), $amount) : Braintree_Transaction::void($payment->getCcTransId());
if ($result->success) {
$payment->setIsTransactionClosed(1);
} else {
Mage::throwException($result->message);
}
} catch (Exception $e) {
Mage::throwException(sprintf('There was an error refunding the transaction. (%s)', $e->getMessage()));
}
return $this;
}
示例9: read
/**
* Reads from the API
*
* @param object $model
* @param array $queryData
* @return array
*/
public function read(Model $model, $queryData = array(), $recursive = NULL)
{
$queryData = array_merge(array('conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => 1, 'offset' => null, 'order' => array(0 => null), 'page' => 1, 'group' => null, 'callbacks' => 1, 'contain' => false, 'recursive' => -1), $queryData);
extract($queryData);
if (!empty($fields) && is_string($fields) && $fields == 'count') {
$is_count = true;
} else {
$is_count = false;
}
if (!$this->_readErrors($model, $queryData, array('is_count' => $is_count))) {
return false;
}
if (!empty($conditions[$model->alias . '.' . $model->primaryKey]) && ($limit == 1 || empty($limit) && $is_count)) {
$entity = $this->_getModelEntity($model);
try {
switch ($entity) {
case 'Customer':
$customer = Braintree_Customer::find($conditions[$model->alias . '.' . $model->primaryKey]);
$result = array(0 => array($model->alias => array('id' => $customer->id, 'first_name' => $customer->firstName, 'last_name' => $customer->lastName, 'company' => $customer->company, 'email' => $customer->email, 'phone' => $customer->phone, 'fax' => $customer->fax, 'website' => $customer->website, 'created' => $customer->createdAt->format('Y-m-d H:i:s'), 'modified' => $customer->updatedAt->format('Y-m-d H:i:s'))));
break;
case 'Transaction':
$exploded = explode('|', $conditions[$model->alias . '.' . $model->primaryKey]);
$braintree_transaction_id = isset($exploded[1]) ? $exploded[1] : $conditions[$model->alias . '.' . $model->primaryKey];
$transaction = Braintree_Transaction::find($braintree_transaction_id);
$result = array(0 => array($model->alias => array('id' => $transaction->customer['id'] . '|' . $transaction->id, 'customer_id' => $transaction->customer['id'], 'payment_method_token' => $transaction->creditCard['token'], 'type' => $transaction->type, 'amount' => $transaction->amount, 'status' => $transaction->status, 'created' => $transaction->createdAt->format('Y-m-d H:i:s'), 'modified' => $transaction->updatedAt->format('Y-m-d H:i:s'))));
$result[0][$model->alias . 'Status'] = array();
$count = 0;
foreach ($transaction->statusHistory as $status) {
$result[0][$model->alias . 'Status'][$count] = array('status' => $status->status, 'amount' => $status->amount, 'user' => $status->user, 'transaction_source' => $status->transactionSource, 'created' => $status->timestamp->format('Y-m-d H:i:s'));
$count++;
}
break;
case 'CreditCard':
$credit_card = Braintree_CreditCard::find($conditions[$model->alias . '.' . $model->primaryKey]);
$result = array(0 => array($model->alias => array('token' => $credit_card->token, 'customer_id' => $credit_card->customerId, 'cardholder_name' => $credit_card->cardholderName, 'card_type' => $credit_card->cardType, 'masked_number' => $credit_card->maskedNumber, 'expiration_date' => date('Y-m', strtotime($credit_card->expirationDate)) . '-01', 'is_default' => $credit_card->default, 'created' => $credit_card->createdAt->format('Y-m-d H:i:s'), 'modified' => $credit_card->updatedAt->format('Y-m-d H:i:s'))));
break;
case 'Address':
$exploded = explode('|', $conditions[$model->alias . '.' . $model->primaryKey]);
if (count($exploded) != 2) {
return false;
}
list($customer_id, $address_id) = $exploded;
$address = Braintree_Address::find($customer_id, $address_id);
$result = array(0 => array($model->alias => array('id' => $address->customerId . '|' . $address->id, 'first_name' => $address->firstName, 'last_name' => $address->lastName, 'company' => $address->company, 'street_address' => $address->streetAddress, 'extended_address' => $address->extendedAddress, 'locality' => $address->locality, 'region' => $address->region, 'postal_code' => $address->postalCode, 'country_code_alpha_2' => $address->countryCodeAlpha2, 'country_code_alpha_3' => $address->countryCodeAlpha3, 'country_code_numeric' => $address->countryCodeNumeric, 'country_name' => $address->countryName, 'created' => $address->createdAt->format('Y-m-d H:i:s'), 'modified' => $address->updatedAt->format('Y-m-d H:i:s'))));
break;
default:
$result = false;
break;
}
} catch (Exception $e) {
$result = false;
}
if ($is_count) {
return array(0 => array(0 => array('count' => $result ? 1 : 0)));
}
return $result;
}
if (empty($conditions)) {
try {
$all_customers = Braintree_Customer::all();
} catch (Exception $e) {
$this->showError(print_r($e, true));
return array();
}
$return = array();
$count = 0;
foreach ($all_customers->_ids as $id) {
$return[$count][$model->alias]['id'] = $id;
$count++;
}
return $return;
}
}
示例10: getTransaction
/**
* wrapper for getting subscriptions from braintree
* @param string - id of the transaction
* @param object - user
*
* @return object - the searched transaction
*/
private static function getTransaction($transactionId, $user)
{
self::setBraintreeCredentials($user);
$transaction = Braintree_Transaction::find($transactionId);
return $transaction;
}
示例11: void
/**
* Void payment abstract method
*
* @param Varien_Object $payment
*
* @return Mage_Payment_Model_Abstract
*/
public function void(Varien_Object $payment)
{
try {
// Init the environment
$this->_getWrapper()->init($payment->getOrder()->getStoreId());
// Retrieve the transaction ID
$transactionId = $this->_getWrapper()->getCleanTransactionId($payment->getLastTransId());
// Load the transaction from Braintree
$transaction = Braintree_Transaction::find($transactionId);
// If the transaction hasn't yet settled we can't do partial refunds
if ($transaction->status !== Braintree_Transaction::AUTHORIZED || $transaction->status !== Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT) {
Mage::throwException($this->_getHelper()->__('You can only void authorized/submitted for settlement payments, please setup a credit memo if you wish to refund this order.'));
}
// Swap between refund and void
$result = Braintree_Transaction::void($transactionId);
// If it's a success close the transaction
if ($result->success) {
$payment->setIsTransactionClosed(1);
} else {
if ($result->errors->deepSize() > 0) {
Mage::throwException($this->_getWrapper()->parseErrors($result->errors->deepAll()));
} else {
Mage::throwException('Unknown');
}
}
} catch (Exception $e) {
Mage::throwException($this->_getHelper()->__('An error occurred whilst trying to void the transaction: ') . $e->getMessage());
}
return $this;
}
示例12: voidTransaction
/**
* @param $transactionId
*
* @return array
*/
public function voidTransaction($transactionId)
{
try {
$transaction = \Braintree_Transaction::find($transactionId);
} catch (\Exception $e) {
return false;
}
if ($transaction) {
if ($transaction->status == \Braintree_Transaction::AUTHORIZED || $transaction->status == \Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT) {
$result = \Braintree_Transaction::void($transactionId);
} else {
$result = \Braintree_Transaction::refund($transactionId);
}
if ($result->success == true) {
return true;
}
}
return false;
}
示例13: braintree_refund
function braintree_refund()
{
$result = Braintree_Transaction::refund('fbysy6');
$result->success;
# true
print_r($result);
exit;
$refund = $result->transaction;
$refund->type;
# 'credit'
$refund->refundedTransactionId;
# original transaction ID
Braintree_Transaction::find($transaction->id)->refundId;
# ID of refund associated to a transaction, if any
/* $result = Braintree_Customer::create(array(
'creditCard' => array(
'number' => '4111111111111111'
)
));
foreach($result->errors->deepAll() AS $error) {
print_r($error->code . ": " . $error->message . "\n");
} */
}
示例14: testMultipleRefundsWithPartialAmounts
function testMultipleRefundsWithPartialAmounts()
{
$transaction = $this->createTransactionToRefund();
$transaction1 = Braintree_Transaction::refund($transaction->id, '50.00')->transaction;
$this->assertEquals(Braintree_Transaction::CREDIT, $transaction1->type);
$this->assertEquals("50.00", $transaction1->amount);
$transaction2 = Braintree_Transaction::refund($transaction->id, '50.00')->transaction;
$this->assertEquals(Braintree_Transaction::CREDIT, $transaction2->type);
$this->assertEquals("50.00", $transaction2->amount);
$transaction = Braintree_Transaction::find($transaction->id);
$expectedRefundIds = array($transaction1->id, $transaction2->id);
$refundIds = $transaction->refundIds;
sort($expectedRefundIds);
sort($refundIds);
$this->assertEquals($expectedRefundIds, $refundIds);
}
示例15: get_transaction
public function get_transaction($id)
{
return Braintree_Transaction::find($id);
}