关闭订单
@param string $out_trade_no 商户订单号
@return array
@throws Exceptions\LocalCacheException
@throws InvalidResponseException
961962
public function closeOrder($out_trade_no)
    {
        $pay = new Order($this->config->get());
        return $pay->close($out_trade_no);
    }
47225
public function queryTransfers($partner_trade_no)
    {
        $pay = new Transfers($this->config->get());
        return $pay->query($partner_trade_no);
    }
434757
public function reply($msg = array(), $return = false)
    {
        if (empty($msg)) {
            if (empty($this->_msg)) {   //防止不先设置回复内容，直接调用reply方法导致异常
                return false;
            }
            $msg = $this->_msg;
        }
        $xmldata = Tools::arr2xml($msg);
        if ($this->encrypt_type == 'aes') { //如果来源消息为加密方式
            !class_exists('Prpcrypt', false) && require __DIR__ . '/Lib/Prpcrypt.php';
            $pc = new Prpcrypt($this->encodingAesKey);
            // 如果是第三方平台，加密得使用 component_appid
            $array = $pc->encrypt($xmldata, empty($this->config['component_appid']) ? $this->appid : $this->config['component_appid']);
            $ret = $array[0];
            if ($ret != 0) {
                Tools::log('Encrypt Error!', "ERR - {$this->appid}");
                return false;
            }
            $timestamp = time();
            $nonce = rand(77, 999) * rand(605, 888) * rand(11, 99);
            $encrypt = $array[1];
            $tmpArr = array($this->token, $timestamp, $nonce, $encrypt);
            sort($tmpArr, SORT_STRING);
            $signature = sha1(implode($tmpArr));
            $format = "<xml><Encrypt><![CDATA[%s]]></Encrypt><MsgSignature><![CDATA[%s]]></MsgSignature><TimeStamp>%s</TimeStamp><Nonce><![CDATA[%s]]></Nonce></xml>";
            $xmldata = sprintf($format, $encrypt, $signature, $timestamp, $nonce);
        }
        if ($return) {
            return $xmldata;
        }
        echo $xmldata;
    }
190014
public function queryTransFresBank($partner_trade_no)
    {
        $pay = new TransfersBank($this->config->get());
        return $pay->query($partner_trade_no);
    }
1210331
public function sendFaxAsyncWithHttpInfo($payload_outbox)
    {
        $returnType = '';
        $request = $this->sendFaxRequest($payload_outbox);

        return $this->client
            ->sendAsync($request, $this->createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }
722694
protected function getResult($options)
    {
        $this->applyData($options);
        $method = str_replace('.', '_', $this->options['method']) . '_response';
        $data = json_decode(Tools::get($this->gateway, $this->options->get()), true);
        if (!isset($data[$method]['code']) || $data[$method]['code'] !== '10000') {
            throw new InvalidResponseException(
                "Error: " .
                (empty($data[$method]['code']) ? '' : "{$data[$method]['msg']} [{$data[$method]['code']}]\r\n") .
                (empty($data[$method]['sub_code']) ? '' : "{$data[$method]['sub_msg']} [{$data[$method]['sub_code']}]\r\n"),
                $data[$method]['code'], $data
            );
        }
        return $data[$method];
        // 去除返回结果签名检查
        // return $this->verify($data[$method], $data['sign']);
    }
1005106
BitcointoyouPublicTrade[] getBitcointoyouPublicTrades(
      CurrencyPair currencyPair, Long tradeTimestamp, Long minTradeId) throws IOException {

    String currency = currencyPair.base.toString();

    try {
      return bitcointoyou.getTrades(currency, tradeTimestamp, minTradeId);
    } catch (BitcointoyouException e) {
      throw new ExchangeException(e.getError());
    }
  }
432738
def query_bankcard(self, out_trade_no):
        
        data = {
            'mch_id': self.mch_id,
            'partner_trade_no': out_trade_no,
        }
        return self._post('mmpaysptrans/query_bank', data=data)
46127
public function getAccessToken()
    {
        $param = [
            'grant_type' => 'client_credentials',
            'client_id' => $this->apiKey,
            'client_secret' => $this->secretKey
        ];
        $result = $this->client->post($this->accessTokenUrl(), $param);

        if (!is_array($result)) {
            throw new Exception('请求access token失败');
        }

        $content = json_decode($result['content'], true);
        $this->accessToken = $content['access_token'];
    }
778874
public function getSHA1($token, $timestamp, $nonce, $encrypt_msg)
	{
		//排序
		try {
			$array = array($encrypt_msg, $token, $timestamp, $nonce);
			sort($array, SORT_STRING);
			$str = implode($array);
			return array(ErrorCode::$OK, sha1($str));
		} catch (Exception $e) {
			//print $e . "\n";
			return array(ErrorCode::$ComputeSignatureError, null);
		}
	}
888735
def get_best_ip_by_real_data_fetch(_type='stock'):
    
    from QUANTAXIS.QAUtil.QADate import QA_util_today_str
    import time
    
    #找到前两天的有效交易日期
    pre_trade_date=QA_util_get_real_date(QA_util_today_str())
    pre_trade_date=QA_util_get_real_date(pre_trade_date)
    
    # 某个函数获取的耗时测试
    def get_stock_data_by_ip(ips):
        start=time.time()
        try:
            QA_fetch_get_stock_transaction('000001',pre_trade_date,pre_trade_date,2,ips['ip'],ips['port'])
            end=time.time()
            return end-start
        except:
            return 9999

    def get_future_data_by_ip(ips):
        start=time.time()
        try:
            QA_fetch_get_future_transaction('RBL8',pre_trade_date,pre_trade_date,2,ips['ip'],ips['port'])
            end=time.time()
            return end-start
        except:
            return 9999

    func,ip_list=0,0
    if _type=='stock':
        func,ip_list=get_stock_data_by_ip,stock_ip_list
    else:
        func,ip_list=get_future_data_by_ip,future_ip_list  
    from pathos.multiprocessing import Pool
    def multiMap(func,sequence):
        res=[]
        pool=Pool(4)
        for i in sequence:
            res.append(pool.apply_async(func,(i,)))
        pool.close()
        pool.join()
        return list(map(lambda x:x.get(),res))
   
    res=multiMap(func,ip_list)
    index=res.index(min(res))
    return ip_list[index]
47942
def pay_order_query(self, out_trade_no):
        

        package = {
            'partner': self.pay_partner_id,
            'out_trade_no': out_trade_no,
        }

        _package = package.items()
        _package.sort()

        s = '&'.join(
            [
                "%s=%s" % (p[0], str(p[1]))
                for p in (_package + [('key', self.pay_partner_key)])
            ]
        )
        package['sign'] = md5(s).hexdigest().upper()

        package = '&'.join(["%s=%s" % (p[0], p[1]) for p in package.items()])

        params, sign, _ = self._pay_sign_dict(
            add_noncestr=False, package=package
        )

        params['app_signature'] = sign
        params['sign_method'] = 'sha1'

        return self.post(
            url="https://api.weixin.qq.com/pay/orderquery", data=params
        )
1084827
private function tradesData(array $trades)
    {
        $output = [];
        foreach ($trades as $trade) {
            $price = $trade['p'];
            $quantity = $trade['q'];
            $timestamp = $trade['T'];
            $maker = $trade['m'] ? 'true' : 'false';
            $output[] = [
                "price" => $price,
                "quantity" => $quantity,
                "timestamp" => $timestamp,
                "maker" => $maker,
            ];
        }
        return $output;
    }
1297599
public function QPayRefund($params = array()){
        /*  入参
            $params = array();
            $params["out_trade_no"] = "20160512161914_BBC";
            $params["sub_mch_id"] = "1900005911";
            $params["out_refund_no"] = "20160512161914_BBC_out_refund_1";
            $params["refund_fee"] = "99999";
            $params["op_user_id"] = "1900005911";
            $params["op_user_passwd"] = "";*/
        if (empty($params["out_trade_no"])){
            throw new Exception('商户订单号参数不能缺少' ,'OUT_TRADE_NO_MUST_INPUT');
        }
//        if (empty($params["sub_mch_id"])){
//            throw new Exception('货币类型不能缺少' ,'FEE_TYPE');
//        }
        if (empty($params["op_user_id"])){
            throw new Exception('订单金额不能缺少' ,'TOTAL_FEE');
        }
        if (empty($params["op_user_passwd"])){
            throw new Exception('终端IP不能缺少' ,'SPBILL_CREATE_IP');
        }
        if (empty($params["out_refund_no"])){
            throw new Exception('退款单号能缺少' ,'SPBILL_CREATE_IP');
        }
        if (empty($params["refund_fee"])){
            throw new Exception('退款金额不能缺少' ,'SPBILL_CREATE_IP');
        }
        //api调用
        $qpayApi = new QpayMchAPI('https://api.qpay.qq.com/cgi-bin/pay/qpay_refund.cgi', true, 10);
        $qpayApi->setMchId($params['mchId']);
        $qpayApi->setMchKey('8525638f86969d1de5c51ad0494f4f13');
        $qpayApi->setIsSSL(true);
        $qpayApi->setCertFilePath('/Users/aji/documents/Project/sicmouse-api/app/apiclient_cert.pem');
        $qpayApi->setKeyFilePath('/Users/aji/documents/Project/sicmouse-api/app/apiclient_key.pem');
        $ret = $qpayApi->reqQpay($params);
        return QpayMchUtil::xmlToArray($ret);
    }
570134
def reverse(self, transaction_id=None, out_trade_no=None):
        
        data = {
            'appid': self.appid,
            'transaction_id': transaction_id,
            'out_trade_no': out_trade_no,
        }
        return self._post('secapi/pay/reverse', data=data)
911857
function callBack($from,$to,$customerSerNum,$fromSerNum,$promptTone)
	  {
        //子帐号鉴权信息验证，对必选参数进行判空。
        $auth=$this->subAuth();
        if($auth!=""){
            return $auth;
        }
        // 拼接请求包体
        if($this->BodyType=="json"){
           $body= "{'from':'$from','to':'$to','customerSerNum':'$customerSerNum','fromSerNum':'$fromSerNum','promptTone':'$promptTone'}";
        }else{
           $body= "<CallBack>
                     <from>$from</from>
                     <to>$to</to>
                     <customerSerNum>$customerSerNum</customerSerNum>
                     <fromSerNum>$fromSerNum</fromSerNum>
                     <promptTone>$promptTone</promptTone>
                   </CallBack>";
        }
        $this->showlog("request body = ".$body);
        // 大写的sig参数
        $sig =  strtoupper(md5($this->SubAccountSid . $this->SubAccountToken . $this->Batch));
        // 生成请求URL
        $url="https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/SubAccounts/$this->SubAccountSid/Calls/Callback?sig=$sig";
        $this->showlog("request url = ".$url);
        // 生成授权：子帐号Id + 英文冒号 + 时间戳
        $authen=base64_encode($this->SubAccountSid . ":" . $this->Batch);
        // 生成包头
        $header = array("Accept:application/$this->BodyType","Content-Type:application/$this->BodyType;charset=utf-8","Authorization:$authen");
        // 发请求
        $result = $this->curl_post($url,$body,$header);
        $this->showlog("response body = ".$result);
        if($this->BodyType=="json"){//JSON格式
           $datas=json_decode($result);
        }else{ //xml格式
           $datas = simplexml_load_string(trim($result," \t\n\r"));
        }
      //  if($datas == FALSE){
//            $datas = new stdClass();
//            $datas->statusCode = '172003';
//            $datas->statusMsg = '返回包体错误'; 
//        }
        return $datas;
	}
113014
public function trade($market, $amount, $type, $rate=false) {



        $data = [
            'Market' => $market,
            'Type' => $type,
            'Amount' => $amount,
            'Rate' => $rate
        ];

        $b = $this->privateRequest("SubmitTrade", $data, "POST");
    
        return $b;

    }