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


PHP Braintree_Transaction::refund方法代码示例

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


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

示例1: refundTransaction

 public function refundTransaction($transaction_id, $amount)
 {
     $transaction = Braintree_Transaction::refund($transaction_id, $amount);
     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: switch

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>

<div class="list-group">
开发者ID:joseph-peng,项目名称:braintree-chicago,代码行数:31,代码来源:action.php

示例4: refund

 public function refund($transaction_id, $amount = null)
 {
     return Braintree_Transaction::refund($transaction_id, $amount);
 }
开发者ID:sahartak,项目名称:storage,代码行数:4,代码来源:Braintree_lib.php

示例5: testRefund_multiplePartialWithPayPal

 function testRefund_multiplePartialWithPayPal()
 {
     $nonce = Braintree_Test_Nonces::$paypalOneTimePayment;
     $transactionResult = Braintree_Transaction::sale(array('amount' => Braintree_Test_TransactionAmounts::$authorize, 'paymentMethodNonce' => $nonce, 'options' => array('submitForSettlement' => true)));
     $this->assertTrue($transactionResult->success);
     $originalTransaction = $transactionResult->transaction;
     Braintree_TestHelper::settle($originalTransaction->id);
     $firstRefund = Braintree_Transaction::refund($transactionResult->transaction->id, $transactionResult->transaction->amount / 2);
     $this->assertTrue($firstRefund->success);
     $firstRefundTransaction = $firstRefund->transaction;
     $secondRefund = Braintree_Transaction::refund($transactionResult->transaction->id, $transactionResult->transaction->amount / 2);
     $this->assertTrue($secondRefund->success);
     $secondRefundTransaction = $secondRefund->transaction;
     $updatedOriginalTransaction = Braintree_Transaction::find($originalTransaction->id);
     $expectedRefundIds = array($secondRefundTransaction->id, $firstRefundTransaction->id);
     $updatedRefundIds = $updatedOriginalTransaction->refundIds;
     $this->assertTrue(in_array($expectedRefundIds[0], $updatedRefundIds));
     $this->assertTrue(in_array($expectedRefundIds[1], $updatedRefundIds));
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:19,代码来源:TransactionTest.php

示例6: print_r

 } 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);
                 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'])) {
开发者ID:KLBombaStick,项目名称:BrainTree,代码行数:31,代码来源:createTrans.php

示例7: 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

示例8: testRefundWithUnsuccessfulPartialAmount

 function testRefundWithUnsuccessfulPartialAmount()
 {
     $transaction = $this->createTransactionToRefund();
     $result = Braintree_Transaction::refund($transaction->id, '150.00');
     $this->assertFalse($result->success);
     $errors = $result->errors->forKey('transaction')->onAttribute('amount');
     $this->assertEquals(Braintree_Error_Codes::TRANSACTION_REFUND_AMOUNT_IS_TOO_LARGE, $errors[0]->code);
 }
开发者ID:robelkin,项目名称:braintree_php,代码行数:8,代码来源:TransactionTest.php

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

示例10: create

 /**
  * Creates a new record via the API
  *
  * @param   object  $model
  * @param   array   $fields
  * @param   array   $values
  * @return  bool
  */
 public function create(Model $model, $fields = null, $values = null)
 {
     $to_save = $this->_createSaveArray($fields, $values);
     if (!empty($model->id) && empty($return[$model->primaryKey])) {
         $to_save = array_merge(array($model->primaryKey => $model->id), $to_save);
     }
     $entity = $this->_getModelEntity($model);
     try {
         switch ($entity) {
             case 'Customer':
                 $result = Braintree_Customer::create($to_save);
                 if (!$result->success) {
                     $this->showError($result->message);
                     return false;
                 }
                 $id = $result->customer->id;
                 break;
             case 'Transaction':
                 unset($to_save['id']);
                 if (!empty($to_save['type']) && $to_save['type'] == 'credit') {
                     if (empty($to_save['braintreeTransactionId'])) {
                         $this->showError(__('A refundable transaction ID must be provided.', true));
                         return false;
                     }
                     $transaction_valid = $this->_checkTransaction($model, $to_save['braintreeTransactionId'], array('type' => 'sale', 'not_found_msg' => __('The transaction attempting to be refunded could not be found.', true), 'type_mismatch_msg' => __('The transaction attempting to be refunded is a credit, not a sale.', true)));
                     if (!$transaction_valid) {
                         return false;
                     }
                     $exploded = explode('|', $to_save['braintreeTransactionId']);
                     $braintree_transaction_id = isset($exploded[1]) ? $exploded[1] : $to_save['braintreeTransactionId'];
                     $result = Braintree_Transaction::refund($braintree_transaction_id, $to_save['amount']);
                 } elseif (!empty($to_save['type']) && $to_save['type'] == 'authorization') {
                     unset($to_save['type'], $to_save['braintreeTransactionId']);
                     $result = Braintree_Transaction::sale(array_merge(array('options' => array('submitForSettlement' => false)), $to_save));
                 } else {
                     // it's a a sale
                     unset($to_save['type'], $to_save['braintreeTransactionId']);
                     $result = Braintree_Transaction::sale(array_merge(array('options' => array('submitForSettlement' => true)), $to_save));
                 }
                 if (!$result->success) {
                     $this->showError($result->message);
                     return false;
                 }
                 $id = $result->transaction->id;
                 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;
     }
     $model->setInsertID($id);
     $model->id = $id;
     return true;
 }
开发者ID:sime,项目名称:cakephp-braintree-plugin,代码行数:71,代码来源:BraintreeSource.php

示例11: process_refund

 public function process_refund($order_id, $amount = null, $reason = '')
 {
     $order = new WC_Order($order_id);
     require_once 'includes/Braintree.php';
     Braintree_Configuration::environment($this->environment);
     Braintree_Configuration::merchantId($this->merchant_id);
     Braintree_Configuration::publicKey($this->public_key);
     Braintree_Configuration::privateKey($this->private_key);
     $transation_id = get_post_meta($order_id, 'wc_braintree_gateway_transaction_id', true);
     $result = Braintree_Transaction::refund($transation_id, $amount);
     if ($result->success) {
         $this->add_log(print_r($result, true));
         $max_remaining_refund = wc_format_decimal($order->get_total() - $amount);
         if (!$max_remaining_refund > 0) {
             $order->update_status('refunded');
         }
         if (ob_get_length()) {
             ob_end_clean();
         }
         return true;
     } else {
         $wc_message = apply_filters('wc_braintree_refund_message', $result->message, $result);
         $this->add_log(print_r($result, true));
         return new WP_Error('wc_braintree_gateway_refund-error', $wc_message);
     }
 }
开发者ID:nishitlangaliya,项目名称:woo-braintree-payment-gateway,代码行数:26,代码来源:woo-braintree-payment-gateway.php

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

示例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");
     } */
 }
开发者ID:BersnardC,项目名称:DROPINN,代码行数:23,代码来源:payment.php

示例14: submitTransaction

 function submitTransaction($request)
 {
     return Braintree_Transaction::refund($request);
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:4,代码来源:braintree.php

示例15: refund

 /**
  * Refunds specified amount
  * 
  * @param Varien_Object $payment
  * @param decimal $amount
  * @return Braintree_Payments_Model_Paymentmethod
  */
 public function refund(Varien_Object $payment, $amount)
 {
     $transactionId = Mage::helper('braintree_payments')->clearTransactionId($payment->getRefundTransactionId());
     try {
         $transaction = Braintree_Transaction::find($transactionId);
         $this->_debug($payment->getCcTransId());
         $this->_debug($transaction);
         if ($transaction->status === Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT) {
             if ($transaction->amount != $amount) {
                 Mage::throwException(Mage::helper('braintree_payments')->__('This refund is for a partial amount but the Transaction has not settled. ' . 'Please wait 24 hours before trying to issue a partial refund.'));
             } else {
                 Mage::throwException(Mage::helper('braintree_payments')->__('The Transaction has not settled. ' . 'Please wait 24 hours before trying to issue a refund or use Void option.'));
             }
         }
         if ($transaction->status === Braintree_Transaction::SETTLED || $transaction->status === Braintree_Transaction::SETTLING) {
             $result = Braintree_Transaction::refund($transactionId, $amount);
         } else {
             $result = Braintree_Transaction::void($transactionId);
         }
         $this->_debug($result);
         if ($result->success) {
             $payment->setIsTransactionClosed(1);
         } else {
             Mage::throwException(Mage::helper('braintree_payments/error')->parseBraintreeError($result));
         }
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('braintree_payments')->__('There was an error refunding the transaction.') . ' ' . $e->getMessage());
     }
     return $this;
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:37,代码来源:Paymentmethod.php


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