public IActionResult get_wx_order() { APIReturn apiReturn = null; WebParams ciac = new WebParams(Request); ciac.Add("action", "wxpayms_getordid"); CallResult cr = WebHttpClient.InvokeHttp("if2017", "dk", "wxpayms_getordid", HttpMethod.Get, ciac); if ((cr.Code != 0) || string.IsNullOrEmpty(cr.Message)) { return(this.FuncResult(new APIReturn(10000, cr.Message))); } string[] msgs = cr.Message.Split(','); if ((int.Parse(msgs[0]) != 0) || (msgs.Length != 9)) { return(this.FuncResult(new APIReturn(10000, string.Format($"{cr.Code}:{cr.Message}")))); } if (ciac["image"] == "image") { MemoryStream ms = new MemoryStream(); GetQRCode(msgs[8], ms); ArraySegment <byte> data = new ArraySegment <byte>(); ms.TryGetBuffer(out data); string str15 = Convert.ToBase64String(data.Array); msgs[8] = str15; } Hashtable ht = new Hashtable(); ht["orderid"] = msgs[1]; ht["code"] = msgs[8]; apiReturn = new APIReturn(0, "", ht); return(this.FuncResult(apiReturn)); }
public MondidoPage() { InitializeComponent(); WebParams data = new WebParams(); //Your account settings, fetch it from https://admin.mondido.com/en/settings#api var merchantId = "233"; var secret = "$2a$10$gU.z.9QNc8VSGYqcJSOhv."; ///Shh, should be stored in your backend! var paymentRef = Guid.NewGuid().ToString(); var customerRef = "123"; var amount = "10.00"; var currency = "eur"; //Find out what to send in the documentation //https://doc.mondido.com/hosted#outgoing data.Add("payment_ref", paymentRef); data.Add("customer_ref", customerRef); data.Add("amount", amount); data.Add("currency", currency); data.Add("merchant_id", merchantId); data.Add("success_url", "https://api.mondido.com/success"); // need to be a working URL for IOS data.Add("error_url", "https://api.mondido.com/fail"); // need to be a working URL for IOS data.Add("test", "true"); data.Add("authorize", "false"); data.Add("store_card", "false"); var device = @"{model: '" + CrossDeviceInfo.Current.Model + "', platform: '" + CrossDeviceInfo.Current.Platform + "', version: '" + CrossDeviceInfo.Current.Version + "', id: '" + CrossDeviceInfo.Current.Id + "'}"; string metadataStr = @"{ customer: {name: 'Tester', email: '*****@*****.**'}, device: " + device + "}"; var metadata = JObject.Parse(metadataStr); data.Add("metadata", System.Net.WebUtility.UrlEncode(metadata.ToString())); string itemsStr = "[{artno: '" + Guid.NewGuid().ToString() + "', description: 'An item', amount: '10.00', vat: '25.00', qty: '1' }]"; var items = JArray.Parse(itemsStr); data.Add("items", System.Net.WebUtility.UrlEncode(items.ToString())); // The hash *should* be generated in your backend for security reasons. // Recipe: MD5(merchant_id + payment_ref + customer_ref + amount + currency + test + secret) var hash = (merchantId + paymentRef + customerRef + amount + currency + "test" + secret); data.Add("hash", hash.ToMD5()); //Init the payment object payment = new Mondido.Base.Payment( browser, data, OnSuccess, OnFail ); //execute the payment payment.ExecuteHostedPayment(); }