当前位置: 首页>>代码示例>>PHP>>正文


PHP Braintree_Transaction::void方法代码示例

本文整理汇总了PHP中Braintree_Transaction::void方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Transaction::void方法的具体用法?PHP Braintree_Transaction::void怎么用?PHP Braintree_Transaction::void使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Braintree_Transaction的用法示例。


在下文中一共展示了Braintree_Transaction::void方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: voidTransaction

 public function voidTransaction()
 {
     $transaction = Braintree_Transaction::void($transaction_id);
     if ($transaction) {
         return $transaction;
     } else {
         return false;
     }
 }
开发者ID:pmward,项目名称:Codeigniter-Braintree-v.zero-test-harness,代码行数:9,代码来源:braintree_model.php

示例2: refund

 /**
  * Refund transaction
  *
  * @param $transaction_id
  * @param null $amount
  * @param bool $void
  * @return object
  */
 public function refund($transaction_id, $amount = NULL, $void = TRUE)
 {
     //try void
     if ($void == TRUE) {
         $result = Braintree_Transaction::void($transaction_id);
         if ($result->success == TRUE) {
             return $result;
         }
     }
     //if already settled, do refund
     $result = Braintree_Transaction::refund($transaction_id, $amount);
     return $result;
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:21,代码来源:BraintreeComponent.php

示例3: test_rangeNode_voidedAt

 function test_rangeNode_voidedAt()
 {
     $transaction = Braintree_Transaction::saleNoValidate(array('amount' => '1000.00', 'creditCard' => array('number' => '4111111111111111', 'expirationDate' => '05/12')));
     $transaction = Braintree_Transaction::void($transaction->id)->transaction;
     $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::voidedAt()->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::voidedAt()->between($ten_min_ago, $ten_min_from_now)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($transaction->id, $collection->firstItem()->id);
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:13,代码来源:TransactionAdvancedSearchTest.php

示例4: switch

<?php

require 'template/header.php';
?>

<?php 
require 'credentials.php';
$id = $_GET['id'];
$method = $_GET['method'];
switch ($method) {
    case 'capture':
        $result = Braintree_Transaction::submitForSettlement($id);
        break;
    case 'void':
        $result = Braintree_Transaction::void($id);
        break;
    case 'refund':
        $result = Braintree_Transaction::refund($id);
        break;
    default:
        die('invalid request');
        break;
}
?>

<div class="page-header">
  <h1><?php 
echo $method . " " . $id;
?>
</h1>
</div>
开发者ID:joseph-peng,项目名称:braintree-chicago,代码行数:31,代码来源:action.php

示例5: void

 /**
  * @param string $transactionId
  * @return \Braintree_Result_Successful|\Braintree_Result_Error
  */
 public function void($transactionId)
 {
     return \Braintree_Transaction::void($transactionId);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:BraintreeTransaction.php

示例6: testVoid_withValidationError

 function testVoid_withValidationError()
 {
     $transaction = Braintree_Transaction::saleNoValidate(array('amount' => '100.00', 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12')));
     $this->assertEquals(Braintree_Transaction::AUTHORIZED, $transaction->status);
     $voided = Braintree_Transaction::voidNoValidate($transaction->id);
     $this->assertEquals(Braintree_Transaction::VOIDED, $voided->status);
     $result = Braintree_Transaction::void($transaction->id);
     $this->assertEquals(false, $result->success);
     $errors = $result->errors->forKey('transaction')->onAttribute('base');
     $this->assertEquals(Braintree_Error_Codes::TRANSACTION_CANNOT_BE_VOIDED, $errors[0]->code);
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:11,代码来源:TransactionTest.php

示例7: _processMethodSpecificTransactionSuccess

 /**
  * Makes method specific manipulations after authorize/clone transaction success
  * 
  * @param Varien_Object $payment $payment
  * @param array $result
  */
 protected function _processMethodSpecificTransactionSuccess($payment, $result)
 {
     // Saving token if applicable, additional manipulations for multishipping
     if (isset($result->transaction->creditCard['token']) && $result->transaction->creditCard['token']) {
         $token = $result->transaction->creditCard['token'];
         $payment->setTransactionAdditionalInfo('token', $token);
         if ($payment->getIsMultishipping()) {
             if (!Mage::registry(self::REGISTER_NAME)) {
                 Mage::register(self::REGISTER_NAME, $token);
             }
             if (Mage::getSingleton('checkout/session')->getBraintreeDeleteCard() === true) {
                 Mage::getSingleton('checkout/session')->setBraintreeDeleteCard($token);
             }
         }
     }
     // Advanced fraud protection data
     if (isset($result->transaction->riskData) && $this->getConfigData('fraudprotection')) {
         $decision = $result->transaction->riskData->decision;
         $helper = Mage::helper('braintree_payments');
         if ($decision == self::RISK_DATA_NOT_EVALUATED || $decision == self::RISK_DATA_REVIEW) {
             $payment->setIsTransactionPending(true);
             $payment->setIsFraudDetected(true);
         } else {
             if ($decision == self::RISK_DATA_DECLINE) {
                 Braintree_Transaction::void($result->transaction->id);
                 throw new Mage_Payment_Model_Info_Exception($helper->__('Try another card'));
             }
         }
         $system = $this->getConfigData('kount_id') ? 'Kount' : $helper->__('Braintree Advanced Fraud Protection Tool');
         $id = '';
         if ($result->transaction->riskData->id) {
             $id = $helper->__(', ID is "%s"', $result->transaction->riskData->id);
         }
         $comment = $helper->__('Transaction was evaluated with %s: decision is "%s"', $system, $decision) . $id;
         $payment->getOrder()->addStatusHistoryComment($comment);
     }
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:43,代码来源:Creditcard.php

示例8: json_encode

    //echo "<a href='?_act=settlement&id=".$result -> transaction -> _attributes['id']."'>Do the settlement</a>";
    echo '<input type="hidden" name="_act" value="clone" />';
    echo '</br>Transaction ID: <input type="text" name="id" value="' . $result->transaction->_attributes['id'] . '" />';
    echo '</br><input type="submit" name="" value="Proceed to clone transaction " />';
    echo "</form>";
    echo "--------------------------------------------------------------------------------------------------------------------------";
    exit;
} else {
    if ($_POST['_act'] == 'settlement') {
        $result = Braintree_Transaction::submitForSettlement($_POST['id'], $_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>";
    } else {
        if ($_POST['_act'] == 'void') {
            $result = Braintree_Transaction::void($_POST['id']);
            print_r($result);
        } else {
            if ($_REQUEST['_act'] == 'refund') {
                echo "</br></br><form method='POST' action=''><h2>Proceed to refund</h2></br>";
                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);
开发者ID:KLBombaStick,项目名称:BrainTree,代码行数:31,代码来源:createTrans.php

示例9: 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;
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:62,代码来源:Paymentmethod.php

示例10: update

 /**
  * Updates an existing record via the API
  *
  * @param   object  $model
  * @param   array   $fields
  * @param   array   $values
  * @return  bool
  */
 public function update(Model $model, $fields = null, $values = null, $conditions = null)
 {
     $to_save = $this->_createSaveArray($fields, $values);
     if (!empty($to_save['id'])) {
         $model->id = $to_save['id'];
         unset($to_save['id']);
     }
     if (empty($model->id)) {
         false;
     }
     $entity = $this->_getModelEntity($model);
     try {
         switch ($entity) {
             case 'Customer':
                 $result = Braintree_Customer::update($model->id, $to_save);
                 break;
             case 'Transaction':
                 $transaction = $this->read($model, array('conditions' => array($model->alias . '.' . $model->primaryKey => $model->id)));
                 if (empty($transaction)) {
                     return false;
                 }
                 $exploded = explode('|', $model->id);
                 $braintree_transaction_id = isset($exploded[1]) ? $exploded[1] : $model->id;
                 if (!empty($to_save['status']) && $to_save['status'] == 'voided') {
                     if ($transaction[0][$model->alias]['status'] != 'authorized' && $transaction[0][$model->alias]['status'] != 'submitted_for_settlement') {
                         $this->showError(__('A transaction can only be VOIDED when the status is AUTHORIZED or SUBMITTED FOR SETTLEMENT.', true));
                         return false;
                     }
                     $result = Braintree_Transaction::void($braintree_transaction_id);
                     if (!$result->success) {
                         $this->showError($result->message);
                         return false;
                     }
                 } elseif (!empty($to_save['status']) && $to_save['status'] == 'submitted_for_settlement') {
                     if ($transaction[0][$model->alias]['status'] != 'authorized') {
                         $this->showError(__('A transaction can only be SUBMITTED FOR SETTLEMENT when the status is AUTHORIZED.', true));
                         return false;
                     }
                     if (!empty($to_save['amount'])) {
                         $result = Braintree_Transaction::submitForSettlement($braintree_transaction_id, $to_save['amount']);
                     } else {
                         $result = Braintree_Transaction::submitForSettlement($braintree_transaction_id);
                     }
                     if (!$result->success) {
                         $this->showError($result->message);
                         return false;
                     }
                 } else {
                     $this->showError(__('The only update that can be made to a transaction is a VOID.', true));
                     return false;
                 }
                 break;
             case 'CreditCard':
                 return false;
                 break;
             case 'Address':
                 return false;
                 break;
             default:
                 $result = false;
                 break;
         }
     } catch (Exception $e) {
         $this->showError(print_r($e, true));
         return false;
     }
     $success = $result->success;
     if (!$success) {
         return false;
     }
     return $success;
 }
开发者ID:sime,项目名称:cakephp-braintree-plugin,代码行数:80,代码来源:BraintreeSource.php

示例11: refund

 /**
  * Refund specified amount for payment
  *
  * @param \Varien_Object $payment
  * @param float          $amount
  *
  * @return $this
  * @throws \Mage_Core_Exception
  */
 public function refund(Varien_Object $payment, $amount)
 {
     try {
         // Attempt to load the invoice
         /* @var $invoice Mage_Sales_Model_Order_Invoice */
         $invoice = $payment->getCreditmemo()->getInvoice();
         if (!$invoice) {
             Mage::throwException('Unable to load invoice from credit memo.');
         }
         // Init the environment
         $this->_getWrapper()->init($payment->getOrder()->getStoreId());
         // Convert the refund amount
         $refundAmount = $this->_getWrapper()->getCaptureAmount($payment->getOrder(), $amount);
         // Retrieve the transaction ID
         $transactionId = $this->_getWrapper()->getCleanTransactionId($invoice->getTransactionId());
         // 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::SUBMITTED_FOR_SETTLEMENT) {
             // If we're doing a partial refund and it's not settled it's a no go
             if ($transaction->amount != $refundAmount) {
                 Mage::throwException($this->_getHelper()->__('This transaction has not yet settled, please wait until the transaction has settled to process a partial refund.'));
             }
         }
         // Swap between refund and void
         $result = $transaction->status === Braintree_Transaction::SETTLED || $transaction->status == Braintree_Transaction::SETTLING || isset($transaction->paypal) && isset($transaction->paypal['paymentId']) && !empty($transaction->paypal['paymentId']) ? Braintree_Transaction::refund($transactionId, $refundAmount) : Braintree_Transaction::void($transactionId);
         // If it's a success close the transaction
         if ($result->success) {
             // Pass over the transaction ID
             $payment->getCreditmemo()->setRefundTransactionId($result->transaction->id);
             // Only close the transaction once the
             if ($transaction->amount == $refundAmount) {
                 $payment->setIsTransactionClosed(1);
                 // Mark the invoice as canceled if the invoice was completely refunded
                 $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_CANCELED);
             }
         } else {
             if ($result->errors->deepSize() > 0) {
                 Mage::throwException($this->_getWrapper()->parseErrors($result->errors->deepAll()));
             } else {
                 Mage::throwException('An unknown error has occurred whilst trying to process the transaction');
             }
         }
     } catch (Exception $e) {
         Mage::throwException($this->_getHelper()->__('An error occurred whilst trying to process the refund: ') . $e->getMessage());
     }
     return $this;
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:57,代码来源:Abstract.php

示例12: void

 public function void(Varien_Object $payment)
 {
     try {
         $result = 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 voiding the transaction. (%s)', $e->getMessage()));
     }
     return $this;
 }
开发者ID:technomagegithub,项目名称:inmed-magento,代码行数:14,代码来源:Paymentmethod.php

示例13: 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;
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:37,代码来源:Creditcard.php

示例14: voidTransaction

 public function voidTransaction()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $id_order = isset($_POST['id_order']) ? addslashes($_POST['id_order']) : "";
     if (!$id_order) {
         Generic::errorMsg("ID Order not found!");
     }
     $transaction_id = isset($_POST['transaction_id']) ? addslashes($_POST['transaction_id']) : "";
     if (!$transaction_id) {
         Generic::errorMsg("Transaction ID not found");
     }
     $json = array();
     $result = Braintree_Transaction::void($transaction_id);
     if ($result->success) {
         $json = array();
         $json['status_code'] = 1;
         $orderObj = new MasterOrderModel();
         $orderObj->getByID($id_order);
         $orderObj->transaction_id = "";
         $orderObj->nonce_cc = "";
         $orderObj->load = 1;
         $orderObj->save();
         $json['results'] = "Success!";
     } else {
         Generic::errorMsg($result->errors);
     }
     echo json_encode($json);
     die;
 }
开发者ID:CapsuleCorpIndonesia,项目名称:martabak_revolution,代码行数:31,代码来源:Payment.php

示例15: 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;
 }
开发者ID:yii-ext,项目名称:payment,代码行数:24,代码来源:BraintreeRecurringGateway.php


注:本文中的Braintree_Transaction::void方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。