查询订单信息
@param string $out_trade_no 订单号
@return boolean|array
170734
public function getPayOrder($out_trade_no) {
		if (!$this->access_token && !$this->checkAuth()) return false;
		$sign = strtoupper(md5("out_trade_no=$out_trade_no&partner={$this->partnerid}&key={$this->partnerkey}"));
		$postdata = array(
				"appid"=>$this->appid,
				"appkey"=>$this->paysignkey,
				"package"=>"out_trade_no=$out_trade_no&partner={$this->partnerid}&sign=$sign",
				"timestamp"=>strval(time()),
		);
		$postdata['app_signature'] = $this->getSignature($postdata);
		$postdata['sign_method'] = 'sha1';
		unset($postdata['appkey']);
		$result = $this->http_post(self::API_BASE_URL_PREFIX.self::PAY_ORDERQUERY.'access_token='.$this->access_token,self::json_encode($postdata));
		if ($result)
		{
			$json = json_decode($result,true);
			if (!$json || !empty($json['errcode'])) {
				$this->errCode = $json['errcode'];
				$this->errMsg = $json['errmsg'].json_encode($postdata);
				return false;
			}
			return $json["order_info"];
		}
		return false;
	}
24738
def trades(opts = {})
      get('/api/1/BTCUSD/trades/fetch', opts).
        sort_by { |trade| trade['date'] }.collect do |trade|
        Trade.new(trade)
      end
    end
753133
public function sendPayDeliverNotify($openid,$transid,$out_trade_no,$status=1,$msg='ok'){
		if (!$this->access_token && !$this->checkAuth()) return false;
		$postdata = array(
				"appid"=>$this->appid,
				"appkey"=>$this->paysignkey,
				"openid"=>$openid,
				"transid"=>strval($transid),
				"out_trade_no"=>strval($out_trade_no),
				"deliver_timestamp"=>strval(time()),
				"deliver_status"=>strval($status),
				"deliver_msg"=>$msg,
		);
		$postdata['app_signature'] = $this->getSignature($postdata);
		$postdata['sign_method'] = 'sha1';
		unset($postdata['appkey']);
		$result = $this->http_post(self::API_BASE_URL_PREFIX.self::PAY_DELIVERNOTIFY.'access_token='.$this->access_token,self::json_encode($postdata));
		if ($result)
		{
			$json = json_decode($result,true);
			if (!$json || !empty($json['errcode'])) {
				$this->errCode = $json['errcode'];
				$this->errMsg = $json['errmsg'];
				return false;
			}
			return $json;
		}
		return false;
	}
1012518
def trade(self, trade_id, trade_price, trade_amount, trade_time):
        
        if self.status in [ORDER_STATUS.SUCCESS_PART, ORDER_STATUS.QUEUED]:
            trade_amount = int(trade_amount)
            trade_id = str(trade_id)

            if trade_amount < 1:

                self._status = ORDER_STATUS.NEXT
            else:
                if trade_id not in self.trade_id:
                    trade_price = float(trade_price)

                    trade_time = str(trade_time)

                    self.trade_id.append(trade_id)
                    self.trade_price = (
                        self.trade_price * self.trade_amount +
                        trade_price * trade_amount
                    ) / (
                        self.trade_amount + trade_amount
                    )
                    self.trade_amount += trade_amount
                    self.trade_time.append(trade_time)
                    self.callback(
                        self.code,
                        trade_id,
                        self.order_id,
                        self.realorder_id,
                        trade_price,
                        trade_amount,
                        self.towards,
                        trade_time
                    )
                else:
                    pass
        else:
            raise RuntimeError(
                'ORDER STATUS {} CANNNOT TRADE'.format(self.status)
            )
932498
public function actionAdopt()
    {
        $answerId = Yii::$app->request->post('answerId');
        $answer = $this->findModel($answerId);
        if (Yii::$app->user->id !== $answer->question->user_id) {
            Yii::$app->session->setFlash('danger', Yii::t('question', 'You can not take your own answer.'));
            return $this->redirect(['/question/question/view', 'id' => $answer->question_id]);
        }

        $transaction = Yii::$app->db->beginTransaction();
        try {
            $answer->adopted_at = time();
            $answer->save();
            $answer->question->status = Question::STATUS_END;
            $answer->question->save(false);

            if (isset(Yii::$app->user->identity->extend->adoptions)) {
                Yii::$app->user->identity->extend->updateCounters(['adoptions' => 1]);
            }
            if (function_exists('credit')) {
                /*悬赏处理*/
                if ($answer->question->price > 0) {
                    credit($answer->user_id, 'answer_adopted', $answer->question->price, $answer->question->id, $answer->question->title);
                }
            }

            $transaction->commit();
            Yii::$app->session->setFlash('success', Yii::t('question', 'Answer to adopt success.'));
            return $this->redirect(['/question/question/view', 'id' => $answer->question_id]);
        } catch (\Exception $e) {
            Yii::$app->session->setFlash('danger', Yii::t('question', 'Adopte failed. Please try again later.'));
            return $this->redirect(['/question/question/view', 'id' => $answer->question_id]);
        }
    }
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()
                    );
                }
            );
    }
331575
public function get_jssdk_parameters_current_wx_user(InterfacePay $interface,$redirect_uri = null){
        if (!$interface || !$redirect_uri) throw new \Exception('WeixinPayApi params exception');
        $config = $this->config;
        if (!isset($_GET['code'])) {
            /*获取订单号*/
            $out_trade_no=$_GET['out_trade_no'];
            if (!$out_trade_no) throw new \Exception('WeixinPayApi out_trade_no exception');
            /*校验订单是否能够支付*/
            $can_pay = $interface->check_can_pay();
            if (!$can_pay) {
                if ($this->business_interface) $this -> business_interface -> log("out_trade_no:$out_trade_no can not pay");
                return $can_pay;
            }

            $this->get_code($redirect_uri,$out_trade_no,'snsapi_base',self::PROCESS_REDIRECT);
        }else{
            /*如果有code参数；则表示获取到openid*/
            $code = $_GET['code'];

            /*校验订单是否能够支付*/
            $can_pay = $interface->check_can_pay();
            if (!$can_pay) {
                if ($this->business_interface) $this -> business_interface -> log("received wx_code out_trade_no:{$interface->get_out_trade_no()} can not pay");
                return $can_pay;
            }

            /*组合获取prepay_id的url*/
            $result = self::curl_auth_access_token($code);

            $openid = $result['openid'];

            /*封装统一下单数据*/
            $order = $interface -> create_unified_order_data($openid);

            /*统一下单 获取prepay_id*/
            $unified_order=$this->unified_order($order);

            /*组合jssdk需要用到的数据*/
            $time=time();
            $data = [
                'appId'=>$config['app_id'], /*appid*/
                'timeStamp'=>strval($time), /*时间戳*/
                'nonceStr'=>$unified_order['nonce_str'], /*随机字符串*/
                'package'=>'prepay_id='.$unified_order['prepay_id'],/* 预支付交易会话标识*/
                'signType'=>'MD5'//加密方式
            ];

            /*生成签名*/
            $data['paySign']=$this->make_sign($data);
            return $data;
        }
    }
1254925
public function get($send_to)
    {
        $res = static::check($send_to);
        if ($res['errcode']) {
            return $res;
        }
        
        $code = DataHelper::randomNumber(4);
        
        static::getCache()->set($send_to, [
            'send_to' => $send_to,
            'code'    => $code,
            'expire_time' => time() + $this->options['interval'],
        ]);
        
        return ErrorInfo::success(['code' => $code]);
    }
1097952
public function getItems($tradeOffer)
    {
        if (is_int($tradeOffer)) {
            $tradeOffer = $this->getTradeOfferViaAPI($tradeOffer);
        }

        if ($tradeOffer instanceof TradeOffer && $tradeId = $tradeOffer->getTradeId()) {
            $url = 'https://steamcommunity.com/trade/' . $tradeId . '/receipt/';
            $response = $this->steamCommunity->cURL($url);
            $pattern = '/oItem = ({.*});/';
            
            preg_match_all($pattern, $response, $matches);

            if ($matches[1]) {
                return array_map('json_decode', $matches[1]);
            }
        }

        return null;
    }
1090366
function _GetTransactionDetails($oID) {
    if ($oID == '' || $oID < 1) return FALSE;
    global $db, $messageStack, $doPayPal;
    $doPayPal = $this->paypal_init();
    // look up history on this order from PayPal table
    $sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID order by last_modified DESC, date_added DESC, parent_txn_id DESC, paypal_ipn_id DESC LIMIT 2";
    $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
    $zc_ppHist = $db->Execute($sql);
    if ($zc_ppHist->RecordCount() == 0) return false;
    $txnID = $zc_ppHist->fields['txn_id'];
    if ($txnID == '' || $txnID === 0) return FALSE;
    /**
     * Read data from PayPal
     */
    $response = $doPayPal->GetTransactionDetails($txnID);
    if (isset($response['RESULT']) && $response['RESULT'] == '7' && $zc_ppHist->RecordCount() > 1) {
      $sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID and txn_id != :condition: order by last_modified ASC, date_added ASC, paypal_ipn_id ASC LIMIT 1";
      $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
      $sql = $db->bindVars($sql, ':condition:', $zc_ppHist->fields['txn_id'], 'integer');
      $zc_ppHist = $db->Execute($sql);
      if ($zc_ppHist->RecordCount() == 0) return false;
      $txnID = $zc_ppHist->fields['txn_id'];
      if ($txnID == '' || $txnID === 0) return FALSE;
      $response = $doPayPal->GetTransactionDetails($txnID);
    }

    $error = $this->_errorHandler($response, 'GetTransactionDetails', 10007);
    if ($error === true) {
      return false;
    } else {
      return $response;
    }
  }
477446
public function getNotify()
    {
        $data = Tools::xml2arr(file_get_contents("php://input"));
        if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS') {
            throw new InvalidResponseException('获取退款通知XML失败！');
        }
        if (!class_exists('Prpcrypt', false)) {
            include dirname(__DIR__) . '/WeChat/Contracts/Prpcrypt.php';
        }
        $pc = new \Prpcrypt(md5($this->config->get('mch_key')));
        $array = $pc->decrypt(base64_decode($data['req_info']));
        if (intval($array[0]) > 0) {
            throw new InvalidResponseException($array[1], $array[0]);
        }
        $data['decode'] = $array[1];
        return $data;
    }
1046696
def on_recv_rsp(self, rsp_pb):
        """"""
        ret_code, ret_data = UpdateOrderPush.unpack_rsp(rsp_pb)

        if ret_code != RET_OK:
            return ret_code, ret_data
        else:
            order_dict = ret_data
            col_list = ['trd_env', 'code', 'stock_name', 'dealt_avg_price', 'dealt_qty',
                        'qty', 'order_id', 'order_type', 'price', 'order_status',
                        'create_time', 'updated_time', 'trd_side', 'last_err_msg', 'trd_market',
                        ]

            trade_frame_table = pd.DataFrame([order_dict], columns=col_list)
            return RET_OK, trade_frame_table
129076
@RequestMapping("/submit")
    @ResponseBody
    public Boolean submit(
            @RequestParam("batchNo") String batchNo,
            @RequestParam("tradeNo") String tradeNo){
        RefundDetail detail = new RefundDetail();
        detail.setBatchNo(Dates.now("yyyyMMdd") + batchNo);
        RefundDetailData data = new RefundDetailData();
        data.setTradeNo(tradeNo);
        data.setFee("0.01");
        data.setReason("订单取消");
        detail.setDetailDatas(Arrays.asList(data));
        logger.info("refund submit: {}", detail);
        return alipayService.refund(detail);
    }
516110
public function createMicroPay($auth_code, $out_trade_no, $total_fee, $body, $goods_tag = null)
    {
        $data = array(
            "appid"            => $this->appid,
            "mch_id"           => $this->mch_id,
            "body"             => $body,
            "out_trade_no"     => $out_trade_no,
            "total_fee"        => $total_fee,
            "auth_code"        => $auth_code,
            "spbill_create_ip" => Tools::getAddress(),
        );
        empty($goods_tag) || $data['goods_tag'] = $goods_tag;
        $json = Tools::xml2arr($this->postXml($data, self::MCH_BASE_URL . '/pay/micropay'));
        if (!empty($json) && false === $this->_parseResult($json)) {
            return false;
        }
        return $json;
    }
733182
public function verifyNotify(){
        if(empty($_POST)) {//判断POST来的数组是否为空
            return false;
        }
        else {
            //生成签名结果
            $isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);
            //获取支付宝远程服务器ATN结果（验证是否是支付宝发来的消息）
            $responseTxt = 'true';
            if (! empty($_POST["notify_id"])) {$responseTxt = $this->getResponse($_POST["notify_id"]);}

            //写日志记录
            //if ($isSign) {
            //	$isSignStr = 'true';
            //}
            //else {
            //	$isSignStr = 'false';
            //}
            //$log_text = "responseTxt=".$responseTxt."\n notify_url_log:isSign=".$isSignStr.",";
            //$log_text = $log_text.createLinkString($_POST);
            //logResult($log_text);

            //验证
            //$responsetTxt的结果不是true，与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
            //isSign的结果不是true，与安全校验码、请求时的参数格式（如：带自定义参数等）、编码格式有关
            if (preg_match("/true$/i",$responseTxt) && $isSign) {
                return true;
            } else {
                return false;
            }
        }
    }
1051921
public function fetchConfirmations()
    {
        $url = $this->generateConfirmationUrl();
        $confirmations = [];
        $response = '';
        try {
            $response = $this->mobileAuth->steamCommunity()->cURL($url);
        } catch (\Exception $ex) {
            return $confirmations;
        }
        if (strpos($response, '<div>Nothing to confirm</div>') === false) {
            $confIdRegex = '/data-confid="(\d+)"/';
            $confKeyRegex = '/data-key="(\d+)"/';
            $confOfferRegex = '/data-creator="(\d+)"/';
            $confDescRegex = '/<div>((Confirm|Trade with|Sell -) .+)<\/div>/';

            preg_match_all($confIdRegex, $response, $confIdMatches);
            preg_match_all($confKeyRegex, $response, $confKeyMatches);
            preg_match_all($confOfferRegex, $response, $confOfferMatches);
            preg_match_all($confDescRegex, $response, $confDescMatches);

            if (count($confIdMatches[1]) > 0 && count($confKeyMatches[1]) > 0 && count($confDescMatches) > 0 && count($confOfferMatches) > 0) {
                $checkedConfIds = [];

                for ($i = 0; $i < count($confIdMatches[1]); $i++) {
                    $confId = $confIdMatches[1][$i];

                    if (in_array($confId, $checkedConfIds)) {
                        continue;
                    }

                    $confKey = $confKeyMatches[1][$i];
                    $confOfferId = $confOfferMatches[1][$i];
                    $confDesc = $confDescMatches[1][$i];
                    $confirmations[] = new Confirmation($confId, $confKey, $confOfferId, $confDesc);

                    $checkedConfIds[] = $confId;
                }
            } else {
                throw new WgTokenInvalidException();
            }
        }
        return $confirmations;
    }
1321133
private static function _handleTypeOutput($data, $hasType = true, $mark = true, $outString = '')
    {
        # 常规打印，不含有类型
        if (!$hasType) {
            return self::_handleNormalOutput($data);
        }

        $jsClass = self::$controlClass;
        $html = 'htmlspecialchars';
        $ucfirst = 'ucfirst';
        static $i = 1;
        $usualString = "<dt><div class=\"array-value\">\n%s</div></dt>\n";
        $outString .= '<dl>' . PHP_EOL;
        $dataType = gettype($data);

        // if (is_object($data)) $data = (array)$data;
        # 含类型打印
        if (is_array($data)) {
            $count = 'count';
            $mark && $outString .= "<dt>\n<span class=\"print-icon icon-hide\"></span><div class=\"{$jsClass}\" style=\"width:98%\">" .
                "<strong class=\"general-print-color-dg\">{$ucfirst($dataType)}</strong>(size:<strong>{$count($data)}</strong>)<strong>(</strong></div>\n</dt>\n";
            $outString .= '<!-- .general-print-ar-content -->' . PHP_EOL . '<dd class="general-print-ar-content">';
            $tab = self::_getTab($i);

            foreach ($data as $k => $v) {
                $vType = gettype($v);
                $k = is_int($k) ? $k : "'{$html($k,ENT_QUOTES)}'";
                $outString .= "\n<dl>\n<dt><div class=\"array-key\">$tab$k</div>";

                if (is_array($v) || is_object($v) || is_resource($data)) {//
                    $outString .= "<div class=\"array-value {$jsClass}\"> &rArr; <strong class=\"general-print-color-dg\">{$ucfirst($vType)}</strong>(size:";

                    if (empty($v)) {
                        $outString .= '0)<strong>()</strong> </div><span class="print-icon icon-hide"></span></dt>';
                        continue;
                    }
                    $i++;

                    $outString .= "<strong>{$count((array)$v)}</strong>)<strong>(</strong></div>\n<span class=\"print-icon icon-hide\"></span></dt>\n";
                    $outString .= ltrim(self::_handleTypeOutput($v, true, false), '<dl>');
                } else {
                    $length_html = '';

                    if ($v === null) {
                        $v = '(null)';
                    } else if ($v === false) {
                        $v = '(false)';
                    } else if ($v === true) {
                        $v = '(true)';
                    } else {
                        $length = PrintHelper::strLength($v);
                        $length_html = "(<span class=\"general-print-color-g\">length:</span>{$length})";
                        $vType === 'string' && $v = "\"{$html($v,ENT_QUOTES)}\"";
                    }

                    $outString .= "<div class=\"array-value\"> &rArr; {$vType} <span class=\"general-print-color-r\">{$v}</span> {$length_html} </div></dt>" . PHP_EOL . "</dl>";
                }
            }//--endforeach--

            $endTab = substr($tab, 0, -($i - 1));
            $outString .= "\n</dd><!-- /.general-print-ar-content -->\n</dl>\n<dl><dt><strong>$endTab)</strong></dt>";
        } else if (is_object($data)) {
            // $outString .= PrintHelper::getSystemPrintData($data);
            $outString .= '<!-- .general-print-ar-content -->' . PHP_EOL . '<dd class="general-print-ar-content">';
            $outString .= PrintHelper::getSystemPrintData($data);
            $outString .= "\n</dd><!-- /.general-print-ar-content -->\n</dl>\n<dl><dt><strong>  )</strong></dt>";
        } else if (is_resource($data)) {
            if (($dataType = get_resource_type($data)) === 'stream' and $meta = stream_get_meta_data($data)) {

                if (isset($meta['uri'])) {
                    $file = $meta['uri'];
                    $resourceString = "Resource ({$dataType}) {$html( $file, ENT_QUOTES)}";
                } else {
                    $resourceString = "Resource ({$dataType})";
                }

            } else {
                $resourceString = "Resource ({$dataType})";
            }

            $outString .= sprintf($usualString, $resourceString);
        } else {
            $length = null;

            if ($data === false) $data = 'false';
            else if ($data === true) $data = 'true';
            else if ($data === null) $data = 'null';
            else $length = PrintHelper::strLength($data);// float integer string

            $dataType === 'string' && $data = "\"{$html($data,ENT_QUOTES)}\"";

            if ($length === null)
                $lengthString = '';
            else
                $lengthString = "(<span class=\"general-print-color-g\">length:</span>{$length})";

            $outString .= sprintf($usualString, "{$dataType} <span class=\"general-print-color-r\">{$data}</span> {$lengthString}");
        }

        return $outString . '</dl>' . PHP_EOL;
    }