public void testShouldGetInvoiceStatus()
 {
     try
     {
         basicInvoice = bitpay.createInvoice(new Invoice(50.0, "USD"));
         Assert.AreEqual(Invoice.STATUS_NEW, basicInvoice.Status, "Status is incorrect");
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
 public void testShouldGetInvoiceBTCPrice()
 {
     try
     {
         basicInvoice = bitpay.createInvoice(new Invoice(50.0, "USD"));
         Assert.IsNotNull(basicInvoice.BtcPrice, "Invoice created with btcPrice=NULL");
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
 public void testShouldGetInvoiceURL()
 {
     try
     {
         basicInvoice = bitpay.createInvoice(new Invoice(50.0m, "USD"));
         Assert.IsNotNull(basicInvoice.Url, "Invoice created with url=NULL");
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
 public void testShouldCreateInvoiceWithAdditionalParams()
 {
     try
     {
         Invoice invoice = new Invoice(100.0, "USD");
         invoice.BuyerName = "Satoshi";
         invoice.BuyerEmail = "*****@*****.**";
         invoice.FullNotifications = true;
         invoice.NotificationEmail = "*****@*****.**";
         invoice.PosData = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
         invoice = this.bitpay.createInvoice(invoice);
         Assert.AreEqual(Invoice.STATUS_NEW, invoice.Status, "Status is incorrect");
         Assert.AreEqual("Satoshi", invoice.BuyerName, "BuyerName is incorrect");
         Assert.AreEqual("*****@*****.**", invoice.BuyerEmail, "BuyerEmail is incorrect");
         Assert.AreEqual(true, invoice.FullNotifications, "FullNotifications is incorrect");
         Assert.AreEqual("*****@*****.**", invoice.NotificationEmail, "NotificationEmail is incorrect");
         Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", invoice.PosData, "PosData is incorrect");
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
 /// <summary>
 /// Create an invoice using the specified facade.
 /// </summary>
 /// <param name="invoice">An invoice request object.</param>
 /// <returns>A new invoice object returned from the server.</returns>
 public Invoice createInvoice(Invoice invoice, String facade = FACADE_POS)
 {
     invoice.Token = this.getAccessToken(facade);
     invoice.Guid = Guid.NewGuid().ToString();
     invoice.Nonce = NextNonce;
     String json = JsonConvert.SerializeObject(invoice);
     HttpResponseMessage response = this.postWithSignature("invoices", json);
     return JsonConvert.DeserializeObject<Invoice>(this.responseToJsonString(response));
 }
 public BitPayTest()
 {
     double price = 100.0;
     this.bitpay = new BitPay(API_KEY);
     basicInvoice = this.bitpay.createInvoice(price, "USD");
 }
 public void testShouldCreateInvoiceWithAdditionalParams()
 {
     try
     {
         Invoice invoice = new Invoice(100.0, "USD");
         invoice.BuyerName = "Satoshi";
         invoice.BuyerEmail = "*****@*****.**";
         invoice.FullNotifications = true;
         invoice.NotificationEmail = "*****@*****.**";
         invoice = this.bitpay.createInvoice(invoice);
         Assert.IsNotNull(invoice, "Invoice not created");
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
        /// <summary>
        /// Create an invoice using the specified facade.
        /// </summary>
        /// <param name="invoice">An invoice request object.</param>
        /// <returns>A new invoice object returned from the server.</returns>
        public Invoice createInvoice(Invoice invoice, String facade = FACADE_POS)
        {
            invoice.Token = this.getAccessToken(facade);
            invoice.Guid = Guid.NewGuid().ToString();
            String json = JsonConvert.SerializeObject(invoice);
            HttpResponseMessage response = this.postWithSignature("invoices", json);
            JsonConvert.PopulateObject(this.responseToJsonString(response), invoice);

            // Track the token for this invoice
            cacheToken(invoice.Id, invoice.Token);

            return invoice;
        }
 /// <summary>
 /// Create an invoice using the specified facade.
 /// </summary>
 /// <param name="invoice">An invoice request object.</param>
 /// <returns>A new invoice object returned from the server.</returns>
 public Invoice createInvoice(Invoice invoice, String facade = FACADE_POS)
 {
     Encoding ascii = Encoding.ASCII;
     Encoding unicode = Encoding.Unicode;
     invoice.Token = this.getAccessToken(facade);
     invoice.Guid = Guid.NewGuid().ToString();
     invoice.Nonce = NextNonce;
     String json = JsonConvert.SerializeObject(invoice);
     byte[] unicodeBytes = unicode.GetBytes(json);
     byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
     char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
     ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
     string asciiString = new string(asciiChars);
     HttpResponseMessage response = this.postWithSignature("invoices", asciiString);
     JsonConvert.PopulateObject(this.responseToJsonString(response), invoice);
     return invoice;
 }