Refund for complete or sale payments

@param array $params

@return boolean
511096
public function refund($params)
	{
		$requestParams = $this->initRequestParams('refund', $params);
		$this->request('refund', $requestParams);

		return empty($this->error);
	}
710842
public function refund(Array $params)
    {
        $refundRequest = $this->getRequestParam('RefundRequestParam', $params, $this->config, $this->sign);

        $requestResult = $this->executeCurlRequest($refundRequest);

        $requestResult = (array)simplexml_load_string($requestResult, 'SimpleXMLElement', LIBXML_NOCDATA);

        if ($requestResult['is_success'] == 'T') {
            return $this->success('退款成功！', $requestResult);
        }

        return $this->error($this->getErrorMessage('refund', $requestResult['error']), $requestResult);
    }
732900
public function refunds()
    {
        if (!isset($this->refunds)) {
            $this->refunds = new Services\RefundsService($this->api_client);
        }

        return $this->refunds;
    }
1217726
public function refund($params = null, $opts = null)
    {
        $this->refunds->create($params, $opts);
        $this->refresh();
        return $this;
    }
1305396
public function complete($params)
	{
		$requestParams = $this->initRequestParams('complete', $params);
		$this->request('complete', $requestParams);

		return empty($this->error);
	}
895999
public function all(array $params = array())
    {
        $data = $this->request('/admin/checkouts.json', 'GET', $params);
        return $this->createCollection(AbandonedCheckout::class, $data['checkouts']);
    }
689366
public function refundTransaction($request)
    {
        $caller = $this->getCaller();
        $caller->setRequest($request);

        $response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoRefund::class);
        $response->setData($caller->call('RefundTransaction'));

        return $response;
    }
599819
public function refund($params, $opts = null)
    {
        $url = self::classUrl() . '/' . $this->instanceId() . "/refund";
        list($resp, $usedOpts) = self::request(self::METHOD_POST, $url, $params, $opts);
        $this->install($resp, $usedOpts);
        return $this;
    }
1061654
public function all(array $params = array())
    {
        $data = $this->request('/admin/application_credits.json', 'GET', $params);
        return $this->createCollection(ApplicationCredit::class, $data['application_credits']);
    }
1262332
public function getResult(...$params)
    {
        try {
            $result = $this->connection->recv();
            App::debug('service result =' . json_encode($result));
            $packer = service_packer();
            $result = $packer->unpack($result);
            $data   = $packer->checkData($result);
        } catch (\Throwable $throwable) {
            if (empty($this->fallbackData)) {
                throw $throwable;
            }
            $data = $this->fallbackData;
        } finally {
            $this->release();
        }

        return $data;
    }
164941
public function completePurchase(array $parameters = [])
    {
        if ($this->isOldApi()) {
            $requestClass = OldCompletePurchaseRequest::class;
        } else {
            $requestClass = CompletePurchaseRequest::class;
        }

        return $this->createRequest($requestClass, $parameters);
    }
360311
public function cancelTransaction($params)
    {
        $this->sdk->ServiceURL = $this->getApiEndpoint('DoAction');
        $this->sdk->Action = array_replace(
            $this->sdk->Action,
            array_intersect_key($params, $this->sdk->Action)
        );

        return $this->sdk->DoAction();
    }
699399
def admin_refund
      return if !user_is_allowed('orders', 'edit')
    
      response = Caboose::StdClass.new({
        'refresh' => nil,
        'error' => nil,
        'success' => nil
      })
    
      order = Order.find(params[:id])
    
      if order.financial_status != 'captured'
        response.error = "This order hasn't been captured yet, you will need to void instead"
      else
        if PaymentProcessor.refund(order)
          order.update_attributes(
            :financial_status => 'refunded',
            :status => 'cancelled'
          )
          
          response.success = 'Order refunded successfully'
        else
          response.error = 'Error refunding order'
        end
        
        #if order.calculate_net < (order.amount_discounted || 0) || PaymentProcessor.refund(order)
        #  order.financial_status = 'refunded'
        #  order.status = 'refunded'
        #  order.save
        #  
        #  if order.discounts.any?
        #    discount = order.discounts.first
        #    amount_to_refund = order.calculate_net < order.amount_discounted ? order.calculate_net : order.amount_discounted
        #    discount.update_attribute(:amount_current, amount_to_refund + discount.amount_current)
        #  end
        #  
        #  response.success = "Order refunded successfully"
        #else
        #  response.error = "Error refunding order."
        #end
      end
    
      render json: response
      
      # return if !user_is_allowed('orders', 'edit')
      #     
      # response = Caboose::StdClass.new({
      #   'refresh' => nil,
      #   'error' => nil,
      #   'success' => nil
      # })
      #     
      # order = Order.find(params[:id])
      #     
      # if order.financial_status != 'captured'
      #   response.error = "This order hasn't been captured yet, you will need to void instead"
      # else
      #   if PaymentProcessor.refund(order)
      #     order.financial_status = 'refunded'
      #     order.status = 'refunded'
      #     order.save
      #     
      #     # Add the variant quantities ordered back
      #     order.cancel
      #     
      #     response.success = "Order refunded successfully"
      #   else
      #     response.error = "Error refunding order."
      #   end
      # end
      #     
      # render :json => response
    end
1252276
public function refund()
    {
        if (!userHasPermission('admin:invoice:payment:refund')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        $oUri          = Factory::service('Uri');
        $oInput        = Factory::service('Input');
        $oPaymentModel = Factory::model('Payment', 'nails/module-invoice');
        $iPaymentId    = $oUri->segment(5);
        $sAmount       = $oInput->post('amount') ?: null;
        $sReason       = $oInput->post('reason') ?: null;
        $sRedirect     = urldecode($oInput->post('return_to')) ?: 'invoice/payment/view/' . $iPaymentId;

        try {

            $oPayment = $oPaymentModel->getById($iPaymentId);
            if (empty($oPaymentModel)) {
                throw new NailsException('Invalid payment ID.');
            }

            // --------------------------------------------------------------------------

            //  Convert the amount to its smallest unit
            $iAmount = intval($sAmount * pow(10, $oPayment->currency->decimal_precision));

            // --------------------------------------------------------------------------

            if (!$oPaymentModel->refund($iPaymentId, $iAmount, $sReason)) {
                throw new NailsException('Failed to refund payment. ' . $oPaymentModel->lastError(), 1);
            }

            $sStatus  = 'success';
            $sMessage = 'Payment refunded successfully.';

        } catch (NailsException $e) {
            $sStatus  = 'error';
            $sMessage = $e->getMessage();
        }

        $oSession = Factory::service('Session', 'nails/module-auth');
        $oSession->setFlashData($sStatus, $sMessage);
        redirect($sRedirect);
    }
794323
public function transactionData($params)
    {
        Util::verifyKeys(
                self::$_transactionSignature,
                $params
                );
        $params["kind"] = TransparentRedirect::CREATE_TRANSACTION;
        $transactionType = isset($params['transaction']['type']) ?
            $params['transaction']['type'] :
            null;
        if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) {
           throw new InvalidArgumentException(
                   'expected transaction[type] of sale or credit, was: ' .
                   $transactionType
                   );
        }

        return $this->_data($params);
    }
742542
public function pay(array $params)
    {
        $params['appid'] = $this->app['config']->app_id;

        return $this->request($this->wrap('pay/micropay'), $params);
    }
642050
public function markOrderAsFinished(array $params)
    {
        $params['appid'] = $this->app['config']->app_id;
        $params['sub_appid'] = null;

        return $this->safeRequest(
            'secapi/pay/profitsharingfinish', $params
        );
    }