partial void btnPay_down(UIButton sender) { Boolean isTestNet = true; //const String KEY = "api_key_from_admin_portal"; //const String PASSWORD = "******"; String authorization = String.Format("{0}:{1}", Settings.Key, Settings.Password); String base64credentials = Convert.ToBase64String(new ASCIIEncoding().GetBytes(authorization)); //Note fields mandatory otherwise 500 error Int32 amountInCents = Convert.ToInt32(amount * 100); Models.BitPOS.OrderRequest request = new Models.BitPOS.OrderRequest() { amount = amountInCents, currency = "AUD", reference = "BitcoinBrisbane", description = "Test Ticket", failureURL = "https://www.bitcoinbrisbane.com.au/fail/1", successURL = "https://www.bitcoinbrisbane.com.au/greatsuccess/1" }; String json = JsonConvert.SerializeObject(request); WebClient webClient = new WebClient() { Credentials = new NetworkCredential(Settings.Key, Settings.Password) }; webClient.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", base64credentials); webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; if (isTestNet == true) { //Use this for test because of SSL issues //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; } String response = webClient.UploadString("https://rest.bitpos.me/services/webpay/order/create", json); Models.BitPOS.OrderResponse orderResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.BitPOS.OrderResponse>(response); // LoadingOverlay loadingOverlay = new LoadingOverlay(); // // // Determine the correct size to start the overlay (depending on device orientation) // var bounds = UIScreen.MainScreen.Bounds; // portrait bounds // if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight) { // bounds.Size = new CGSize(bounds.Size.Height, bounds.Size.Width); // } // // show the loading overlay on the UI thread using the correct orientation sizing // loadingOverlay = new LoadingOverlay (bounds); // this.View.Add ( loadingOverlay.loadPop ); UIAlertView alert = new UIAlertView("Send BTC", String.Format("Send {0:0.0000} to {1}", Decimal.Divide(orderResponse.satoshis, SATOSHI), orderResponse.bitcoinAddress), null, "Ok", null); alert.Show(); //ShowPopover(btn0, orderResponse.bitcoinAddress, String.Format("bitcoin:{0}", orderResponse.bitcoinAddress)); }
public Models.BitPOS.OrderResponse CreateOrder(Int32 amountInCents) { Boolean isTestNet = true; //const String KEY = "api_key_from_admin_portal"; //const String PASSWORD = "******"; String authorization = String.Format("{0}:{1}", _key, _password); String base64credentials = Convert.ToBase64String(new ASCIIEncoding().GetBytes(authorization)); //Note fields mandatory otherwise 500 error Models.BitPOS.OrderRequest request = new Models.BitPOS.OrderRequest() { amount = amountInCents, currency = "AUD", reference = "BitcoinBrisbane", description = "Test Ticket", failureURL = "https://www.bitcoinbrisbane.com.au/fail/1", successURL = "https://www.bitcoinbrisbane.com.au/greatsuccess/1" }; String json = JsonConvert.SerializeObject(request); WebClient webClient = new WebClient() { Credentials = new NetworkCredential(Settings.Key, Settings.Password) }; webClient.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", base64credentials); webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; if (isTestNet == true) { //Use this for test because of SSL issues //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; } String response = webClient.UploadString("https://rest.bitpos.me/services/webpay/order/create", json); Models.BitPOS.OrderResponse orderResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.BitPOS.OrderResponse>(response); return(orderResponse); }