示例#1
0
        /// <summary>
        /// 请求手机网页即时到账授权接口
        /// </summary>
        /// <param name="subject">用户购买的商品名称,不可空</param>
        /// <param name="out_trade_no">支付宝合作商户网站唯一订单号。不可空</param>
        /// <param name="total_fee">该笔订单的资金总额,单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。不可空</param>
        /// <param name="seller_account_name">卖家的支付宝账号。交易成功后,买家资金会转移到该账户中。不可空</param>
        /// <param name="call_back_url">支付成功后的跳转页面链接。支付成功才会跳转。不可空</param>
        /// <param name="notify_url">支付宝服务器主动通知商户网站里指定的页面http路径。可为空</param>
        /// <param name="out_user">买家在商户系统的唯一标识。当该买家支付成功一次后,再次支付金额在30元内时,不需要再次输入密码,可为空</param>
        /// <param name="merchant_url">用户付款中途退出返回商户的地址。可为空</param>
        /// <param name="pay_expire">交易自动关闭时间,单位为分钟。默认值21600(即15天)。可为空</param>
        /// <returns></returns>
        public static string RequestTradeCreateDirect(string subject, string out_trade_no, string total_fee,
                                                      string seller_account_name, string call_back_url, string notify_url, string out_user,
                                                      string merchant_url, string pay_expire)
        {
            Dictionary <string, string> sParaTempToken = CreateDefaultParamsDict("alipay.wap.trade.create.direct");

            sParaTempToken.Add("req_data", BuildReqData(subject, out_trade_no, total_fee,
                                                        seller_account_name, call_back_url, notify_url, out_user,
                                                        merchant_url, pay_expire));
            string sHtmlTextToken = AlipaySubmit.BuildRequest(GATEWAY_NEW, sParaTempToken);
            //URLDECODE返回的信息
            Encoding code = Encoding.GetEncoding(AlipayConfig.Input_charset);

            sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code);
            return(sHtmlTextToken);
        }
示例#2
0
        /// <summary>
        /// 生成手机网页即时到账支付表单
        /// </summary>
        /// <param name="subject">用户购买的商品名称,不可空</param>
        /// <param name="out_trade_no">支付宝合作商户网站唯一订单号。不可空</param>
        /// <param name="total_fee">该笔订单的资金总额,单位为RMB-Yuan。取值范围为[0.01,100000000.00],精确到小数点后两位。不可空</param>
        /// <param name="out_user">买家在商户系统的唯一标识。当该买家支付成功一次后,再次支付金额在30元内时,不需要再次输入密码,可为空</param>
        public static string BuildRequest(string subject, string out_trade_no, string total_fee,
                                          string out_user)
        {
            ////////////////////////////////////////////调用授权接口alipay.wap.trade.create.direct获取授权码token////////////////////////////////////////////
            string sHtmlTextToken = RequestTradeCreateDirect(subject, out_trade_no, total_fee, out_user);
            //解析远程模拟提交后返回的信息
            Dictionary <string, string> dicHtmlTextToken = AlipaySubmit.ParseResponse(sHtmlTextToken);
            //获取token
            string request_token = dicHtmlTextToken["request_token"];

            ////////////////////////////////////////////根据授权码token调用交易接口alipay.wap.auth.authAndExecute////////////////////////////////////////////
            //业务详细
            string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>";
            //必填
            //把请求参数打包成数组
            Dictionary <string, string> sParaTemp = CreateDefaultParamsDict("alipay.wap.auth.authAndExecute");

            sParaTemp.Add("req_data", req_data);

            //建立请求
            string sHtmlText = AlipaySubmit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认");

            return(sHtmlText);
        }