Fee charged by PayU. In case of a refund,
this is the fee amount refunded to the original recipient of the payment.

@param string|double $fee

@return $this
177388
public function setFee($fee)
    {
        NumericValidator::validate($fee, "Fee");
        $fee = Formatter::formatToPrice($fee);
        $this->fee = $fee;
        return $this;
    }
756685
public function setPaymentExecutionDetail($value)
    {
        if (!$this->_isNumericArray($value)) {
            $value = array ($value);
        }
        $this->_fields['PaymentExecutionDetail']['FieldValue'] = $value;
        return $this;
    }
886662
public function subtract(MoneyContainer $money) : MoneyBag
    {
        foreach ($money->getAmounts() as $currencyCode => $amount) {
            $this->amounts[$currencyCode] = $this->getAmount($currencyCode)->minus($amount);
        }

        return $this;
    }
1179969
public function setCurrency($currency)
    {
        if ($currency) {
            $currency = strtoupper($currency);
            Currency::getNumericCode($currency); // ensure currency support
            $this->currency = $currency;
        } else {
            $this->currency = null;
        }

        return $this;
    }
1279946
final protected function _refund($a) {
		$ii = $this->ii(); /** @var OP $ii */
		/**
		 * 2016-03-17, 2017-11-11
		 * Despite of its name, @uses \Magento\Sales\Model\Order\Payment::getAuthorizationTransaction()
		 * simply returns the previous transaction,
		 * and it can be not only an `authorization` transaction,
		 * but a transaction of another type (e.g. `payment`) too.
		 *		public function getAuthorizationTransaction() {
		 *			return $this->transactionManager->getAuthorizationTransaction(
		 *				$this->getParentTransactionId(),
		 *				$this->getId(),
		 *				$this->getOrder()->getId()
		 *			);
		 *		}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment.php#L1242-#L1253
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment.php#L1316-L1327
		 * @see \Magento\Sales\Model\Order\Payment\Transaction\Manager::getAuthorizationTransaction()
		 *	public function getAuthorizationTransaction($parentTransactionId, $paymentId, $orderId) {
		 *		$transaction = false;
		 *		if ($parentTransactionId) {
		 *			$transaction = $this->transactionRepository->getByTransactionId(
		 *				$parentTransactionId,
		 *				$paymentId,
		 *				$orderId
		 *			);
		 *		}
		 *		return $transaction ?: $this->transactionRepository->getByTransactionType(
		 *			Transaction::TYPE_AUTH,
		 *			$paymentId,
		 *			$orderId
		 *		);
		 *	}
		 * The code is the same in Magento 2.0.0 - 2.2.1:
		 * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 * https://github.com/magento/magento2/blob/2.2.1/app/code/Magento/Sales/Model/Order/Payment/Transaction/Manager.php#L31-L47
		 * It is exactly what we need,
		 * because the module can be set up to capture payments without a preliminary authorization.
		 */
		if ($tPrev = $ii->getAuthorizationTransaction() /** @var T|false $tPrev */) {
			$id = $this->i2e($tPrev->getTxnId()); /** @var string $id */
			// 2016-03-24
			// Credit Memo и Invoice отсутствуют в сценарии Authorize / Capture
			// и присутствуют в сценарии Capture / Refund.
			$cm = $ii->getCreditmemo(); /** @var CM|null $cm */
			$fc = $this->fCharge(); /** @var fCharge $fc */
			$resp = $cm ? $fc->refund($id, $this->amountFormat($a)) : $fc->void($id); /** @var object $resp */
			$this->transInfo($resp);
			$ii->setTransactionId($this->e2i($id, $cm ? Ev::T_REFUND : 'void'));
			if ($cm) {
				/**
				 * 2017-01-19
				 * Записаваем идентификатор операции в БД,
				 * чтобы затем, при обработке оповещений от платёжной системы,
				 * проверять, не было ли это оповещение инициировано нашей же операцией,
				 * и если было, то не обрабатывать его повторно:
				 * @see \Df\Payment\W\Strategy\Refund::_handle()
				 * https://github.com/mage2pro/core/blob/1.12.16/StripeClone/WebhookStrategy/Charge/Refunded.php?ts=4#L21-L23
				 */
				dfp_container_add($this->ii(), self::II_TRANS, fRefund::s($this)->transId($resp));
			}
		}
	}
135773
public function refund($out_trade_no,$out_refund_no,$total_fee,$refund_fee,$op_user_id=1001){
        $wxpay = new PayLib\WxPayApi($this->type);

        //退款
        $input = new PayLib\WxPayRefund();
        $input->SetOut_trade_no($out_trade_no);
        $input->SetOut_refund_no($out_refund_no);
        $input->SetTotal_fee($total_fee);
        $input->SetRefund_fee($refund_fee);
        $input->SetOp_user_id($op_user_id);
        $input->SetTransaction_id('');
/*         var_dump($input);
        die; */
        return PayLib\WxPayApi::refund($input);
    }
255719
public function setPayment(Payment $payment)
    {
        $this->payment = $payment;

        if (!$payment->hasPaymentTransaction($this))
        {
            $payment->addPaymentTransaction($this);
        }

        return $this;
    }
938105
public function subtract(Money $other): Money
    {
        $this->guardCurrency($other);

        $amount = $this->amount - $other->amount;

        $this->guardAmountInBounds($amount);

        return $this->withAmount($amount);
    }
569539
public function transaction() {

		if(null === $this -> connection) {
			$this -> connect();
		}

		$this -> connection -> autocommit(false);
		$this -> connection -> begin_transaction(MYSQLI_TRANS_START_READ_WRITE);

		return $this;
	}
169862
public function subtract(Money $subtrahend)
    {
        $this->assertSameCurrency($subtrahend);

        return new Money(bcsub($this->amount, $subtrahend->getAmountString(), self::GAAP_PRECISION), $this->currency);
    }
892661
public function refundToBuyer($refundAmount, $refundCurrency)
    {
        $refund = new OffAmazonPaymentsService_Model_Price();
        $refund->setCurrencyCode($refundCurrency);
        $refund->setAmount($refundAmount);
        
        $refundRequest = new OffAmazonPaymentsService_Model_RefundRequest();
        $refundRequest->setSellerId($this->_sellerId);
        $refundRequest->setAmazonCaptureId($this->_amazonCaptureId);
        $refundRequest->setRefundReferenceId($this->_refundReferenceId);
        $refundRequest->setRefundAmount($refund);
        
        return $this->_service->refund($refundRequest);
    }
705282
public function setTotal($total)
    {
        NumericValidator::validate($total, "Total");
        $total = Formatter::formatToPrice($total, $this->getCurrency());
        $this->total = $total;
        return $this;
    }
382727
private function _convertRefund($request) {
        
        $parameters = array();
        $parameters['Action'] = 'Refund';
        if ($request->isSetSellerId()) {
            $parameters['SellerId'] =  $request->getSellerId();
        }
        if ($request->isSetAmazonCaptureId()) {
            $parameters['AmazonCaptureId'] =  $request->getAmazonCaptureId();
        }
        if ($request->isSetRefundReferenceId()) {
            $parameters['RefundReferenceId'] =  $request->getRefundReferenceId();
        }
        if ($request->isSetRefundAmount()) {
            $refundAmount = $request->getRefundAmount();
            if ($refundAmount->isSetAmount()) {
                $parameters['RefundAmount' . '.' . 'Amount'] =  $refundAmount->getAmount();
            }
            if ($refundAmount->isSetCurrencyCode()) {
                $parameters['RefundAmount' . '.' . 'CurrencyCode'] =  $refundAmount->getCurrencyCode();
            }
        }
        if ($request->isSetSellerRefundNote()) {
            $parameters['SellerRefundNote'] =  $request->getSellerRefundNote();
        }
        if ($request->isSetSoftDescriptor()) {
            $parameters['SoftDescriptor'] =  $request->getSoftDescriptor();
        }

        return $parameters;
    }
1203848
public function charge(Request $request)
    {
        $payment = $this->paymentService->getFromSession('stripe');
        if ($payment instanceof Payment) {
            //Creates the charge on Stripe's servers - This will charge user's card
            $orderId = $this->paymentService->charge('stripe', $payment);

            if (false !== $orderId) {
                //Redirects to returnRoute, if defined, with orderId
                if (null !== $payment->getReturnRoute()) {
                    return $this->redirectToRoute($payment->getReturnRoute(), array('orderId' => $orderId));
                }

                //Redirects to payment
                return $this->redirectToRoute('payment_display', array('orderId' => $orderId));
            }

            //Redirects to payment
            return $this->redirectToRoute('payment_display', array('orderId' => $payment->getOrderId()));
        }

        //Not found
        throw $this->createNotFoundException();
    }
457814
public function refund($amount, $originalTransactionReference, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL)
	{
		$request = Request::createFromClient($this);

		$request->setTransactionType(Request::TRANSACTION_TYPE_REFUND)
		        ->setTotalAmount($amount)
		        ->setOriginalTransactionReference($originalTransactionReference)
		        ->setClientReference($clientReference)
		        ->setComment($comment)
		        ->setMerchantDescription($description)
		        ->setMerchantCardHolderName($cardHolderName)
		        ->setTaxAmount($taxAmount);

		return $request;
	}
191863
private function refundByTransaction(
        $tranId,
        \Magento\Sales\Model\Order $sale
    ) {
        $saleId = $sale->getId();
        $saleIncId = $sale->getIncrementId();
        /** @var ETrans $transaction */
        $transaction = $this->daoTrans->getById($tranId);
        $accIdCust = $transaction->getDebitAccId();
        $accIdSys = $transaction->getCreditAccId();
        $amount = $transaction->getValue();
        $note = "Refund for sale #$saleIncId";
        $operId = $this->createOperation($accIdSys, $accIdCust, $amount, $note);
        $this->logger->info("Refund operation #$operId is created for sale #$saleIncId/$saleId");
    }
112102
public function filterByCurrency($currency) {
        foreach ($this->_paymentMethod as $name => $class) {
            if (!in_array($currency, $class->getSupportedCurrency()) && !in_array('00', $class->getSupportedCurrency()))
                unset($this->paymentMethods[$name]);
        }
        return $this;
    }