企业付款
@param string $openid 红包接收者OPENID
@param int $amount 红包总金额
@param string $billno 商户订单号
@param string $desc 备注信息
@return bool|array
@link https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
500660
public function transfers($openid, $amount, $billno, $desc)
    {
        $data = array();
        $data['mchid'] = $this->mch_id;
        $data['mch_appid'] = $this->appid;
        $data['partner_trade_no'] = $billno;
        $data['openid'] = $openid;
        $data['amount'] = $amount;
        $data['check_name'] = 'NO_CHECK'; #不验证姓名
        $data['spbill_create_ip'] = Tools::getAddress(); //调用接口的机器Ip地址
        $data['desc'] = $desc; //备注信息
        $result = $this->postXmlSSL($data, self::MCH_BASE_URL . '/mmpaymkttransfers/promotion/transfers');
        $json = Tools::xml2arr($result);
        if (!empty($json) && false === $this->_parseResult($json)) {
            return false;
        }
        return $json;
    }
736861
public function deposit($amount, $desc='Deposit', $cat, $ref)
	{
		$amount = $this->_amountCheck($amount);

		if ($this->getError())
		{
			echo $this->getError();
			return;
		}

		$this->balance  += $amount;
		$this->earnings += $amount;

		if (!$this->_save('deposit', $amount, $desc, $cat, $ref))
		{
			echo $this->getError();
		}
	}
1224855
function RefundTransaction($oID, $txnID, $amount = 'Full', $note = '', $curCode = 'USD') {
    if ($this->_mode == 'payflow') {
      $values['ORIGID'] = $txnID;
      $values['TENDER'] = 'C';
      $values['TRXTYPE'] = 'C';
      $values['AMT'] = number_format((float)$amount, 2);
      if ($note != '') $values['COMMENT2'] = $note;
    } elseif ($this->_mode == 'nvp') {
      $values['TRANSACTIONID'] = $txnID;
      if ($amount != 'Full' && (float)$amount > 0) {
        $values['REFUNDTYPE'] = 'Partial';
        $values['CURRENCYCODE'] = $curCode;
        $values['AMT'] = number_format((float)$amount, 2);
      } else {
        $values['REFUNDTYPE'] = 'Full';
      }
      if ($note != '') $values['NOTE'] = $note;
    }
    return $this->_request($values, 'RefundTransaction');
  }
1100470
public function createRefundPaymentRequest($orderUuid, $amount = null)
    {
        $amountData = is_null($amount) ? [] : [
            'amount' => $amount,
        ];

        return $this->createRequest('POST', '/payment/refund', [
                'order_uuid' => $orderUuid,
            ] + $amountData);
    }
836183
public function DMSAuthorization($amount, $currency = 981, $description = '', $language = 'GE')
    {
        return $this->transaction('a', $amount, $currency, $description, $language, 'DMS');
    }
515472
public function authorize($payment, $amount)
        {
            $error = false;

            // check for payment
            if($amount > 0) {

                $payment->setAmount($amount);

                // Map magento keys to moneris way
                $transaction = $this->_build($payment, self::TRANSACTION_PREAUTH);
                $response = $this->_send($transaction);

                $payment->setCcApproval($response->getReceiptId())
                    ->setLastTransId($response->getReceiptId())
                    ->setCcTransId($response->getTxnNumber())
                    ->setCcAvsStatus($response->getAuthCode())
                    ->setCcCidStatus($response->getResponseCode());


                if($response->getResponseCode() > 0 && $response->getResponseCode() <= self::ERROR_CODE_LIMIT) {
                    $payment->setStatus(self::STATUS_APPROVED);
                } else if($response->getResponseCode() > self::ERROR_CODE_LIMIT && $response->getResponseCode() < self::ERROR_CODE_UPPER_LIMIT) {
                    $error = $this->_errors[$response->getResponseCode()];
                } else {
                    $error = 'Incomplete transaction.';
                }
            } else {
                $error = 'Invalid amount for authorization.';
            }

            // we've got something bad here.
            if ($error !== false) {
                $this->_log($error);
            }
            return $this;
        }
726804
public function hold($amount, $desc='Hold', $cat, $ref)
	{
		$amount = $this->_amountCheck($amount);

		if ($this->getError())
		{
			echo $this->getError();
			return;
		}

		// Current order processing workflow (which requires manual order fulfillment on the backend) prevents race
		// condition with the check and update below from corrupting user point balance, but if
		// but if workflow is ever changed, a table/row level lock would need to be added to this function
		// and error code added to deal with multiple orders with insufficient balances.
		//
		// See https://hubzero.org/support/ticket/234 for details

		if ($this->_creditCheck($amount))
		{
			$this->credit += $amount;

			if (!$this->_save('hold', $amount, $desc, $cat, $ref))
			{
				echo $this->getError();
			}
		}
		else
		{
			echo $this->getError();
		}
	}
259639
public function getBill($bill_date, $bill_type = 'ALL')
    {
        $data = array();
        $data['bill_date'] = $bill_date;
        $data['bill_type'] = $bill_type;
        $result = $this->postXml($data, self::MCH_BASE_URL . '/pay/downloadbill');
        $json = Tools::xml2arr($result);
        if (!empty($json) && false === $this->_parseResult($json)) {
            return false;
        }
        return $json;
    }
889327
public function transact($amount, $orderId, $invoiceNumber = null)
    {
        $this->transaction = [
            'amount' => $amount,
            'orderId' => $orderId,
            'invoiceNumber' => $invoiceNumber ?: $orderId,
        ];

        return $this->initiateTransaction();
    }
59185
public function executePayment($dAmount, & $oOrder)
    {
        /** @var oxUserPayment|OxpsPaymorrowOxUserPayment $oUserPayment */
        $oUserPayment = $this->_oPaymentInfo;

        if (is_object($oUserPayment) && $oUserPayment->isUserPaymentPaymorrowMethod()) {

            // Set real order ID (OXID field) to session to be used in order confirmation during payment.
            $oOrderId = $oOrder->getId();
            $oOrder->savePaymorrowTemporaryOrderIdToSession($oOrderId);

            /** @var OxpsPaymorrowModule $oModule */
            $oModule = oxRegistry::get('OxpsPaymorrowModule');

            /** @var OxpsPaymorrowRequestControllerProxy $oPmRequestControllerProxy */
            $oPmRequestControllerProxy = oxNew('OxpsPaymorrowRequestControllerProxy');
            $oPmRequestControllerProxy->confirmOrder($oModule->getPaymentMethodName(), $oOrderId);

            /** @var OxpsPaymorrowResponseHandler $oPmResponseHandler */
            $oPmResponseHandler = oxRegistry::get('OxpsPaymorrowResponseHandler');

            /**
             * If Order has an error after validation from Paymorrow services invalidate order and delete it
             * If Payment data save failed return an error
             */
            if ($oPmResponseHandler->hasErrors() or
                !$this->_savePaymorrowUserPaymentData($oOrder, $oPmResponseHandler)
            ) {
                $this->_handleOrderResponseErrors($oPmResponseHandler);

                return false;
            }
        }

        return $this->_OxpsPaymorrowOxPaymentGateway_executePayment_parent($dAmount, $oOrder);
    }
1125014
public function writeOff($amount,$userId)
    {
        if (!$this->canPay($amount, $userId)) {
            return false;

        }

        return $this->repository->create([
            'user_id' => $userId,
            'value' => $amount,
            'accepted' => 1,
            'hash' => uniqid('transaction_', true),
            'type' => BalanceTransaction::CONST_TYPE_PAYMENT,
        ]);

    }
1356075
public function registerTransaction($amount, $localTrxID) {
		$token = $this->authenticate();
		
		// paypal like the amount as string, to prevent floating point errors
		if (!is_string($amount))
			$amount = sprintf("%0.2f", $amount);
		
		$a = (object)[
			"amount" => (object)[
				"total" => $amount,
				"currency" => $this->currency,
			]
		];	
		
		$route = Route::get('paypal_response');
		$base = URL::base(true);
		$payment_data = (object)[
			'intent' => "sale",
			'redirect_urls' => (object)[
				'return_url' => $base . $route->uri([
						'action' => 'complete', 'trxid' => $localTrxID]),
				'cancel_url' => $base . $route->uri([
						'action' => 'cancel', 'trxid' => $localTrxID]),
			],
			'payer' => (object)[ 'payment_method' => 'paypal', ],
    		"transactions" => [ $a ],
        ];
		
		$request = $this->genRequest('payments/payment', $payment_data, $token);
		return $this->call($request);
	}
1339746
private function createOrderInvoice($order, $transactionId, $amount)
    {
        if ($order->getTotalInvoiced() + $amount == $order->getGrandTotal()) {
            $invoice = $this->invoiceService->prepareInvoice($order);
        } else {
            $invoice = $this->invoiceService->prepareInvoiceWithoutItems($order, $amount);
        }

        $invoice->setRequestedCaptureCase(Invoice::CAPTURE_OFFLINE);
        $invoice->setTransactionId($transactionId);
        $invoice->setBaseGrandTotal($amount);
        $invoice->setGrandTotal($amount);
        $invoice->register();
        $invoice->save();

        $order->addRelatedObject($invoice);

        if (!$invoice->getEmailSent()) {
            $this->invoiceSender->send($invoice);
        }

        //Add notification comment to order
        $order->addStatusHistoryComment(
            __('Invoice #%1 is created. Notification email is sent to customer.', $invoice->getId())
        )->setIsCustomerNotified(true)->save();

        return $invoice;
    }
1350004
public static function NewBill($data)
	{
		$bill = new Bill;
		$merchantData = Headers::GetMerchant();
		$bill->merchant_id = $merchantData['login'];
		$bill->bill_id = $data['bill_id'];
		$bill->user = $data['user'];
		$bill->amount = $data['amount'];
		$bill->ccy = $data['ccy'];
		$bill->comment = isset($data['comment']) ? $data['comment'] : null;
		$bill->lifetime = isset($data['lifetime']) ? $data['lifetime'] : 0;
		$bill->pay_source = isset($data['pay_source']) ? $data['pay_source'] : null;
		$bill->prv_name = isset($data['prv_name']) ? $data['prv_name'] : null;
		$bill->status = Bill::C_STATUS_WAITING;
		$bill->save();

		return $bill;

	}
227234
public static function setPayStatus($paymentId, $status, $params)
    {
        if (($payment = static::findOne(['id' => $paymentId])) == null) {
            return false;
        }
        if (static::STATE_SUCCESS == $payment->trade_state) {
            return true;
        }
        if ($status == true) {
            $payment->updateAttributes([
                'pay_id' => $params['pay_id'],
                'trade_state' => static::STATE_SUCCESS,
                'note' => $params['message']
            ]);//标记支付已经完成
            /** @var \yuncms\payment\OrderInterface $orderModel */
            $orderModel = $payment->model;
            if (!empty($payment->model_id) && !empty($orderModel)) {
                $orderModel::setPayStatus($payment->model_id, $paymentId, $status, $params);
            }
            return true;
        }
        return false;
    }
905156
public OvhBill bill_billId_GET(String billId) throws IOException {
		String qPath = "/me/bill/{billId}";
		StringBuilder sb = path(qPath, billId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhBill.class);
	}
335677
public function queryRedPack($billno)
    {
        $data['mch_billno'] = $billno;
        $data['bill_type'] = 'MCHT';
        $result = $this->postXmlSSL($data, self::MCH_BASE_URL . '/mmpaymkttransfers/gethbinfo');
        $json = Tools::xml2arr($result);
        if (!empty($json) && false === $this->_parseResult($json)) {
            return false;
        }
        return $json;
    }