예제 #1
0
        public NativeResponseMessage native(NativeRequestMessage nativeRequestMessage)
        {
            Dictionary <string, string> param = new Dictionary <string, string>();

            param["total_fee"]    = nativeRequestMessage.total_fee.ToString();
            param["out_trade_no"] = nativeRequestMessage.out_trade_no.ToString();;
            param["body"]         = nativeRequestMessage.body;
            param["attch"]        = nativeRequestMessage.attch;
            //可选项目
            if (!String.IsNullOrEmpty(nativeRequestMessage.notify_url))
            {
                param["notify_url"] = nativeRequestMessage.notify_url;
            }
            if (!String.IsNullOrEmpty(nativeRequestMessage.type))
            {
                param["type"] = nativeRequestMessage.notify_url;
            }
            string url  = this.apiUrl[MethodBase.GetCurrentMethod().Name];
            String json = this.post(url, param);
            NativeResponseMessage message = JsonSerializer.Deserialize <NativeResponseMessage>(json, MyJsonConvert.GetOptions());

            return(message);
        }
예제 #2
0
        public IActionResult NativePay()
        {
            long?id = idGenerator.NextId();
            var  nativeRequestMessage = new NativeRequestMessage()
            {
                total_fee    = 1,
                out_trade_no = id.ToString(),
                body         = "test",
                attch        = "userid",
                notify_url   = webSiteConfig.Payjs.Notify_Url
            };

            var responseMessage = pay.native(nativeRequestMessage);

            ViewBag.msg = responseMessage;
            CommodityOrder goodOrder = new CommodityOrder()
            {
                CommodityOrderId      = id,
                mchid                 = webSiteConfig.Payjs.PayJS_MCHID,
                total_fee             = nativeRequestMessage.total_fee,
                out_trade_no          = id.ToString(),
                body                  = nativeRequestMessage.body,
                attch                 = nativeRequestMessage.attch,
                notify_url            = nativeRequestMessage.notify_url,
                type                  = nativeRequestMessage.type,
                payjs_order_id        = responseMessage.payjs_order_id,
                NativeRequestMessage  = nativeRequestMessage.ToJsonString(),
                NativeResponseMessage = responseMessage.ToJsonString()
            };

            var orderObj = dataContext.GoodOrder.Add(goodOrder);

            dataContext.SaveChanges();


            return(View());
        }