public bool SetBillInfo(string _title, string _subTitle, double _totalPrice, string _billid, string _info) { if (!isInit) { return(false); } body.totalPrice = _totalPrice; body.title = _title; body.subTitle = _subTitle; body.noat = (_totalPrice * 0.1).ToString(); body.nhat = "0"; body.ddtd = "0"; body.ttd = "0"; body.lotteryID = "0"; body.billType = "Huvi"; body.billID = _billid; body.billQRCode = "0"; Console.WriteLine("[" + DateTime.Now.ToString("hh:mm:ss.fff") + "] totalPrice: " + body.totalPrice + ",noat: " + body.noat); if (_info == null) { body.products = null; } else { ArrayList products = new ArrayList(); string[] infoList = _info.Split('|'); for (int i = 0; i < infoList.Length; i++) { string tmp = infoList[i]; string[] tmpList = tmp.Split(';'); if (tmpList.Length == 3) { MChatProduct product = new MChatProduct(); product.name = tmpList[0]; product.quantity = int.Parse(tmpList[1]); product.unitPrice = double.Parse(tmpList[2]); Console.WriteLine("[" + DateTime.Now.ToString("hh:mm:ss.fff") + "] product:name:" + product.name + ",quantity:" + product.quantity + ",unitPrice:" + product.unitPrice); products.Add(product); } } body.products = products; } Console.WriteLine("[" + DateTime.Now.ToString("hh:mm:ss.fff") + "] products count:" + body.products.Count); return(true); }
static void Main(string[] args) { //ConfigBuilder configBuilder = new ConfigBuilder(); //configBuilder.url = "18.144.43.141"; //configBuilder.port = 8790; //MChatBusinessNotificationService mchatservice = configBuilder.build(); //mchatservice.connect("Test"); var t = Task.Run(async() => { MChatScanPaymentBuilder paymentBuilder = new MChatScanPaymentBuilder(); paymentBuilder.domain = "developer.mongolchat.com"; paymentBuilder.apiKey = ""; paymentBuilder.workerKey = ""; MChatScanPayment payment = paymentBuilder.Build(); MChatGenerateQRCodeRequestBody body = new MChatGenerateQRCodeRequestBody(); body.totalPrice = 7; body.title = "Laviva"; body.subTitle = "Welcome to Laviva"; body.noat = "200"; body.nhat = "0"; body.ttd = "ttd"; ArrayList products = new ArrayList(); MChatProduct product = new MChatProduct(); product.name = "Coca Cola"; product.quantity = 1; product.unitPrice = 2000; products.Add(product); body.products = products; MChatResponseGenerateQRCode response = await payment.GenerateNewCodeAsync(body, (MChatScanPayment scanPayment, BNSState state, String generatedQRCode, MChatResponse res) => { if (state == BNSState.Ready) { // Succesfully connected and ready to receive notification from notification service Console.WriteLine("Ready to display QRCode: " + generatedQRCode); } else if (state == BNSState.Connected) { // Successfully connected to notification service Console.WriteLine("Connected: " + res); } else if (state == BNSState.Disconnected) { // Disconnected from notification service Console.WriteLine("Disconnected: " + res); } else if (state == BNSState.PaymentSuccessful) { // Got response from payment notification service Console.WriteLine("PaymentSuccesfull: " + generatedQRCode + "\n" + res); var t2 = Task.Run(async() => { MChatResponseCheckState responseStateSuccesfull = await payment.CheckQRCodePaymentState(generatedQRCode); Console.WriteLine(responseStateSuccesfull.ToString()); }); } else if (state == BNSState.ErrorOccured) { // Error Occured when connection notification service Console.WriteLine("ErrorOccured: " + res); } if (res != null) { Console.WriteLine(res.ToString()); } }); Console.WriteLine(response.ToString()); MChatResponseCheckState responseState = await payment.CheckQRCodePaymentState("pay://71698b23f949e980fdc842e84879a68a59e5970047f3feb9720eb81894a9646b"); Console.WriteLine(responseState.ToString()); }); try { t.Wait(); } catch (Exception e) { Console.WriteLine(e.ToString()); } //Console.WriteLine("Start"); var t1 = Task.Run(async() => { await Task.Delay(1200000); }); t1.Wait(); }