Example #1
0
        /// <summary>
        /// 条码支付
        /// </summary>
        /// <param name="tradepayModel">请求内容</param>
        /// <returns></returns>
        public static TradepayResponseModel TradePay(TradepayModel tradepayModel)
        {
            AlipayTradePayRequest payRequst = new AlipayTradePayRequest();

            payRequst.BizContent = JsonConvert.SerializeObject(tradepayModel);
            LogUtil.WriteAlipayLog("条码支付请求", "请求参数", payRequst.BizContent);
            Dictionary <string, string> paramsDict  = (Dictionary <string, string>)payRequst.GetParameters();
            AlipayTradePayResponse      payResponse = _client.Execute(payRequst);

            LogUtil.WriteAlipayLog("条码支付响应", "响应参数", payResponse.Body);
            return(new TradepayResponseModel
            {
                msg = payResponse.Msg,
                code = payResponse.Code,
                subcode = payResponse.SubCode,
                submsg = payResponse.SubMsg,
                buyer_logon_id = payResponse.BuyerLogonId,
                store_name = payResponse.StoreName,
                buyer_pay_amount = payResponse.BuyerPayAmount,
                buyer_user_id = payResponse.BuyerUserId,
                gmt_payment = payResponse.GmtPayment,
                out_trade_no = payResponse.OutTradeNo,
                point_amount = payResponse.PointAmount,
                invoice_amount = payResponse.InvoiceAmount,
                total_amount = payResponse.TotalAmount,
                trade_no = payResponse.TradeNo,
                receipt_amount = payResponse.ReceiptAmount
            });
        }
Example #2
0
        /// <summary>
        /// 条码支付
        /// </summary>
        /// <param name="tradepayModel">条码支付请求参数</param>
        /// <param name="payOverCallBack">支付结束回调函数</param>
        /// <param name="payStateChangeCallBack">支付状态改变回调函数</param>
        public void TradePay(TradepayModel tradepayModel, Action <bool, TradepayResponseModel> payOverCallBack, Action <bool, QueryResponseModel> payStateChangeCallBack)
        {
            TradepayResponseModel response = ServiceUtil.AliPayClient.TradePay(tradepayModel);

            ServiceUtil.AliPayClient.Close();
            #region 1.交易成功
            if (response.code == TradepayResultCode.TRADE_SUCCESS)
            {
                payOverCallBack(true, response);
                return;
            }
            #endregion
            #region 2.交易失败
            if (response.code == TradepayResultCode.TRADE_FAILURE)
            {
                payOverCallBack(false, response);
                return;
            }
            #endregion
            #region 3.交易结果未知
            if (response.code == TradepayResultCode.EXCEPTION || response.code == TradepayResultCode.PROCESSING)
            {
                string             out_trade_no  = response.out_trade_no;
                QueryResponseModel queryResponse = new QueryResponseModel();
                Task queryOrderTask = new Task(new Action(() =>
                {
                    queryResponse = Query(new QueryModel()
                    {
                        out_trade_no = out_trade_no
                    }, payStateChangeCallBack);
                }));
                queryOrderTask.Start();
            }
            #endregion
        }
Example #3
0
 public TradepayResponseModel TradePay(TradepayModel tradepayModel)
 {
     return(F2FPayUtil.TradePay(tradepayModel));
 }
Example #4
0
 public TradepayResponseModel TradePay(TradepayModel tradepayModel)
 {
     return(base.Channel.TradePay(tradepayModel));
 }