Пример #1
0
        /// <summary>
        /// 构造支付请求数据
        /// </summary>
        /// <param name="aoM">支付宝支付订单对象</param>
        /// <returns>请求数据集</returns>
        private AlipayTradePrecreateContentBuilder BuildPrecreateContent(AlipayOrderModel aoM)
        {
            //线上联调时,请输入真实的外部订单号。
            string out_trade_no = aoM.ID;//订单号
            AlipayTradePrecreateContentBuilder builder = new AlipayTradePrecreateContentBuilder
            {
                //收款账号
                seller_id = _config.PID,
                //订单编号
                out_trade_no = out_trade_no,
                //订单总金额
                total_amount = aoM.TotalPrice.ToString(),
                //参与优惠计算的金额
                discountable_amount = aoM.DiscounPrice.ToString(),
                //不参与优惠计算的金额
                undiscountable_amount = aoM.UnDiscounPrice.ToString(),
                //订单名称
                subject = aoM.Name,
                //自定义超时时间
                timeout_express = "5m",
                //订单描述
                body = aoM.Description,
                //门店编号,很重要的参数,可以用作之后的营销
                store_id = aoM.StoreID,
                //操作员编号,很重要的参数,可以用作之后的营销
                operator_id = aoM.OperatorId
            };
            //传入商品信息详情
            List <GoodsInfo> gList = new List <GoodsInfo>();
            GoodsInfo        goods;

            foreach (AlipayProductModel item in aoM.Items)
            {
                goods = new GoodsInfo
                {
                    goods_id   = item.ID,
                    goods_name = item.Name,
                    price      = item.Price.ToString(),
                    quantity   = item.Nubmer.ToString()
                };
                gList.Add(goods);
            }
            builder.goods_detail = gList;
            //系统商接入可以填此参数用作返佣
            ExtendParams exParam = new ExtendParams
            {
                sys_service_provider_id = aoM.NotifyParams
            };

            builder.extend_params = exParam;
            return(builder);
        }
        private static AlipayTradeCreateRequest getTradeCreateRequest()
        {
            AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
            AlipayTradeCreateModel   model   = new AlipayTradeCreateModel();

            model.OutTradeNo  = "20200320010101006";
            model.TotalAmount = "88.88";
            model.Subject     = "Iphone6 16G";
            model.BuyerId     = "2088102177846880";
            ExtendParams extendParams = new ExtendParams();

            extendParams.HbFqNum           = "3";
            extendParams.HbFqSellerPercent = "100";
            model.ExtendParams             = extendParams;
            request.SetBizModel(model);
            return(request);
        }