Used to submit a refund for a given transaction.
972985
function _doRefund($oID, $amount = 0) {
    global $db, $messageStack;
    $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_ECHECK_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $proceedToRefund = true;
    $refundNote = strip_tags(zen_db_input($_POST['refnote']));
    if (isset($_POST['refconfirm']) && $_POST['refconfirm'] != 'on') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_REFUND_CONFIRM_ERROR, 'error');
      $proceedToRefund = false;
    }
    if (isset($_POST['buttonrefund']) && $_POST['buttonrefund'] == MODULE_PAYMENT_AUTHORIZENET_ECHECK_ENTRY_REFUND_BUTTON_TEXT) {
      $refundAmt = (float)$_POST['refamt'];
      $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_ECHECK_REFUNDED_ORDER_STATUS_ID;
      if ($refundAmt == 0) {
        $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_INVALID_REFUND_AMOUNT, 'error');
        $proceedToRefund = false;
      }
    }
    if (isset($_POST['cc_number']) && trim($_POST['cc_number']) == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_CC_NUM_REQUIRED_ERROR, 'error');
    }
    if (isset($_POST['trans_id']) && trim($_POST['trans_id']) == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToRefund = false;
    }

    /**
     * Submit refund request to gateway
     */
    if ($proceedToRefund) {
      $submit_data = array('x_type' => 'CREDIT',
                           'x_card_num' => trim($_POST['cc_number']),
                           'x_amount' => number_format($refundAmt, 2),
                           'x_trans_id' => trim($_POST['trans_id'])
                           );
      unset($response);
      $response = $this->_sendRequest($submit_data);
      $response_code = $response[0];
      $response_text = $response[3];
      $response_alert = $response_text . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $refundNote;
      $this->_debugActions($response);

      if ($response_code != '1') {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $sql_data_array = array('orders_id' => $oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'REFUND INITIATED. Trans ID:' . $response[6] . ' ' . $response[4]. "\n" . ' Gross Refund Amt: ' . $response[9] . "\n" . $refundNote,
                                'customer_notified' => 0
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        $db->Execute("update " . TABLE_ORDERS  . "
                      set orders_status = '" . (int)$new_order_status . "'
                      where orders_id = '" . (int)$oID . "'");
        $messageStack->add_session(sprintf(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_REFUND_INITIATED, $response[9], $response[6]), 'success');
        return true;
      }
    }
    return false;
  }
1159941
def refund_order(self, order_id, **params):
        """"""
        for required in ['currency']:
            if required not in params:
                raise ValueError("Missing required parameter: %s" % required)
        response = self._post('v2', 'orders', order_id, 'refund', data=params)
        return self._make_api_object(response, Order)
751711
public RefundQueryResponse queryByTransactionId(String transactionId){
        Map<String, String> queryParams = buildQueryParams(WepayField.TRANSACTION_ID, transactionId);
        Map<String, Object> respData = doPost(QUERY, queryParams);
        return renderQueryResp(respData);
    }
224107
async function refund(ctx) {
  let order = ctx.state.order;
  let body = ctx.state.body || ctx.request.body;
  let orderId = body.order || ctx.request.body.order;
  let reason = body.reason || ctx.request.body.reason;
  let amount = body.amount || ctx.request.body.amount;
  if (!orderId && !order || ctx.method !== 'POST') _2.default.error(400);
  if (!ctx.user) _2.default.error(403);
  if (!reason) _2.default.error('Invalid refund reason');
  if (!order) {
    // $Flow
    let orderTmp = await _Order2.default.findById(orderId).where('user', ctx.user._id);
    order = orderTmp;
    if (!order) _2.default.error('Order not found');
    if (order.state !== 400 && order.state !== 500) _2.default.error('Order state error');
  }
  if (!amount) {
    amount = order.payed;
  }
  if (amount > order.payed) _2.default.error('Invalid refund amount');
  await _2.default.run('Refund', {
    ctx, order, reason, amount
  });
  ctx.body = order.data();
}
1165543
public function refundTransaction($transaction, $amount = 0.00)
    {
        $this->setRequestData([
            'TRANSACTIONID' => $transaction,
        ]);

        if ($amount > 0) {
            $this->post = $this->post->merge([
                'REFUNDTYPE' => 'Partial',
                'AMT'        => $amount,
            ]);
        }

        return $this->doPayPalRequest('RefundTransaction');
    }
895875
public function refund($oOrder = null, $fPrice, $aRequestParameters = array())
    {
        //Refund ID
        if ($oOrder !== null) {
            $aRequestParameters['refund_amount'] = $fPrice;
            $this->_mapOrderToRequestParameters(
                $oOrder,
                $aRequestParameters,
                array('amazon_capture_id', 'currency_code', 'refund_reference_id', 'seller_refund_note')
            );
        }

        //Make request
        $this->_addSandboxSimulationParams('refund', $aRequestParameters);
        $oData = $this->_convertResponse($this->_getAmazonClient()->refund($aRequestParameters));

        //Update/Insert Refund info
        if ($oData && $oOrder !== null) {
            $sError = '';
            $sAmazonRefundId = '';

            if (isset($oData->Error)) {
                $sState = 'Error';
                $sError = $oData->Error->Message;
            } else {
                $sState = $oData->RefundResult->RefundDetails->RefundStatus->State;
                $sAmazonRefundId = $oData->RefundResult->RefundDetails->AmazonRefundId;
            }

            $sId = $oOrder->getFieldData('bestitamazonorderreferenceid').'_'.$this->getUtilsDate()->getTime();

            $sQuery = "
                INSERT bestitamazonrefunds SET 
                  ID = {$this->getDatabase()->quote($sId)},
                  OXORDERID = {$this->getDatabase()->quote($oOrder->getId())},
                  BESTITAMAZONREFUNDID = {$this->getDatabase()->quote($sAmazonRefundId)},
                  AMOUNT = {$fPrice},
                  STATE = {$this->getDatabase()->quote($sState)},
                  ERROR = {$this->getDatabase()->quote($sError)},
                  TIMESTAMP = NOW()";

            $this->getDatabase()->execute($sQuery);
        }

        return $oData;
    }
1282608
def settle(self, reserveTransactionId, transactionAmount=None):
        
        params = {}
        params['ReserveTransactionId'] = reserveTransactionId
        if(transactionAmount != None):
            params['TransactionAmount'] = transactionAmount
        
        response = self.make_request("Settle", params)
        body = response.read()
        if(response.status == 200):
            rs = ResultSet()
            h = handler.XmlHandler(rs, self)
            xml.sax.parseString(body, h)
            return rs
        else:
            raise FPSResponseError(response.status, response.reason, body)
413709
public function refund(array $params)
    {
        // transaction identifier must be set
        if(!isset($params['identifier']))
        {
            throw new MonetivoException('$transaction["identifier"] is not set');
        }
        // other parameters like 'amount' and 'description' are optional

        return $this->merchantApi->call('post', 'transactions/' . $params['identifier'] . '/refund', [
            'form_params' => $params
        ])->toArray();
    }
842696
def clean_total_refund_amount(self):
        '''
        
        '''
        initial = self.cleaned_data.get('initial_refund_amount', 0)
        total = self.cleaned_data['total_refund_amount']
        summed_refunds = sum([v for k,v in self.cleaned_data.items() if k.startswith('item_refundamount_')])

        if not self.cleaned_data.get('id'):
            raise ValidationError('ID not in cleaned data')

        if summed_refunds != total:
            raise ValidationError(_('Passed value does not match sum of allocated refunds.'))
        elif summed_refunds > self.cleaned_data['id'].amountPaid + self.cleaned_data['id'].refunds:
            raise ValidationError(_('Total refunds allocated exceed revenue received.'))
        elif total < initial:
            raise ValidationError(_('Cannot reduce the total amount of the refund.'))
        return total
1295395
public static void rollback()
   {
      try {
         if (userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION) {
            userTransaction.rollback();
         }
         else {
            LOGGER.warn("Request to rollback transaction when none was in started.");
         }
      }
      catch (Exception e) {
         LOGGER.warn("Transaction rollback failed.", e);
      }
   }
461578
public function create($orderId, Refund &$refund)
    {
        $data = $refund->exportData();
        $endpoint = '/admin/orders/'.$orderId.'/refunds.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'refund' => $data
            )
        );
        $refund->setData($response['refund']);
    }
931157
public function refund($amount, $reference, array $options = [])
    {
        $params = [];

        if ($amount !== null) {
            $params['amount'] = $this->gateway->amount($amount);
        }

        if (array_key_exists('reason', $options)) {
            $params['reason'] = $options['reason'];
        }

        $url = sprintf($this->gateway->buildUrlFromString('orders').'/%s/refund', $reference);

        return $this->gateway->commit('post', $url, $params);
    }
1342017
def refund(amount = nil)
      warn "[DEPRECATED] refund as an instance method is deprecated. Please use Transaction.refund"
      result = @gateway.transaction.refund(id, amount)

      if result.success?
        SuccessfulResult.new(:new_transaction => result.transaction)
      else
        result
      end
    end
11933
@Deprecated
	public static String refund(Map<String, String> reqData) {
		return HttpUtils.post(SDKConfig.getConfig().getBackRequestUrl(), reqData);
	}
230673
function(transaction, _callback) {
      try {
        transaction.secret(secret);
      } catch (exception) {
        return _callback(exception);
      }

      transaction.once('error', _callback);

      transaction.once('submitted', function(message) {
        if (message.result.slice(0, 3) === 'tec'
            && options.validated !== true) {
          return formatTransactionResponseWrapper(transaction, message,
            _callback);
        }

        // Handle erred transactions that should not make it into ledger (all
        // errors that aren't tec-class). This function is called before the
        // transaction `error` listener.
        switch (message.engine_result) {
          case 'terNO_ACCOUNT':
          case 'terNO_AUTH':
          case 'terNO_LINE':
          case 'terINSUF_FEE_B':
            // The transaction needs to be aborted. Preserve the original ter-
            // class error for presentation to the client
            transaction.removeListener('error', _callback);
            transaction.once('error', function() {
              _callback(message);
            });
            transaction.abort();
            break;
        }
      });

      transaction.once('proposed', function(message) {
        if (options.validated !== true) {
          formatTransactionResponseWrapper(transaction, message, _callback);
        }
      });

      transaction.once('success', function(message) {
        if (options.validated === true) {
          formatTransactionResponseWrapper(transaction, message, _callback);
        }
      });

      if (options.saveTransaction === true) {
        transaction.on('state', function() {
          var transactionSummary = transaction.summary();
          if (transactionSummary.submitIndex !== undefined) {
            api.db.saveTransaction(transactionSummary);
          }
        });

        transaction.on('postsubmit', function() {
          api.db.saveTransaction(transaction.summary());
        });
      }

      transaction.submit();
    }
649144
def register
      response_request = Request.post("transactions/cancels", api_version, params)
      Response.new(response_request, self).serialize
    end
608786
def return_action(self, return_action):
        
        allowed_values = ["refund", "storeCredit"]  # noqa: E501
        if return_action is not None and return_action not in allowed_values:
            raise ValueError(
                "Invalid value for `return_action` ({0}), must be one of {1}"  # noqa: E501
                .format(return_action, allowed_values)
            )

        self._return_action = return_action