Пример #1
0
        public string passdata(int memberId, int price)
        {
            var post = new WebClient();

            post.Encoding = System.Text.Encoding.UTF8;
            //var data = new System.Net.WebHeaderCollection();
            LinePay  linePay  = new LinePay();
            Linedata linedata = linePay.PaymentInfo(memberId, price);

            post.Headers.Add("X-LINE-ChannelId", "1653696494");
            post.Headers.Add("X-LINE-ChannelSecret", "86ba3a2c73531c34810b6617047ef6a8");
            post.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            string json = JsonConvert.SerializeObject(linedata);

            //var bResult = post.UploadString("https://api-pay.line.me/v2/payments/request", json);
            var bResult = post.UploadString("https://sandbox-api-pay.line.me/v2/payments/request", json);

            return(bResult);
        }
Пример #2
0
        public Linedata PaymentInfo(int memberId, int price)
        {
            OrderDetailRepository orderDetail = new OrderDetailRepository();
            var          productInfo          = orderDetail.GetAllCart(memberId).FirstOrDefault();
            CartServices cartServices         = new CartServices();
            //數量
            int quantity            = cartServices.GetCarQuantity(memberId).CountAmount;
            JavaScriptSerializer js = new JavaScriptSerializer();
            JsonURL url             = js.Deserialize <JsonURL>(productInfo.PicUrl);

            LinePay  line     = new LinePay();
            Linedata linedata = new Linedata()
            {
                productName     = line.ProductName(quantity, productInfo.ProductName),
                currency        = "TWD",
                orderId         = productInfo.OrderID.ToString(),
                productImageUrl = url.Url1,
                amount          = price,
                confirmUrl      = Url + "Checkout"
            };

            return(linedata);
        }