diff --git a/Assemblies/BitPay.Net.Lib/BitPay.dll b/Assemblies/BitPay.Net.Lib/BitPay.dll
index b26df2a..cdd46bb 100644
Binary files a/Assemblies/BitPay.Net.Lib/BitPay.dll and b/Assemblies/BitPay.Net.Lib/BitPay.dll differ
diff --git a/Assemblies/BitPay.Net.Lib/BitPay.dll.config b/Assemblies/BitPay.Net.Lib/BitPay.dll.config
index 001905f..83bb33d 100644
--- a/Assemblies/BitPay.Net.Lib/BitPay.dll.config
+++ b/Assemblies/BitPay.Net.Lib/BitPay.dll.config
@@ -38,6 +38,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BitPay/BitPay.cs b/BitPay/BitPay.cs
index 2019286..0c8cf6b 100644
--- a/BitPay/BitPay.cs
+++ b/BitPay/BitPay.cs
@@ -11,14 +11,16 @@
using BitPayAPI.Models;
using BitPayAPI.Models.Invoice;
using BitPayAPI.Models.Ledger;
+using BitPayAPI.Models.Rate;
+using BitPayAPI.Models.Settlement;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Configuration;
/**
* @author Antonio Buedo
- * @date 4.15.2019
- * @version 2.0.1904
+ * @date 6.19.2019
+ * @version 2.1.1904
*
* See bitpay.com/api for more information.
*/
@@ -33,7 +35,7 @@ public class BitPay
private static string _configFilePath;
private const string BitpayApiVersion = "2.0.0";
- private const string BitpayPluginInfo = "BitPay_DotNet_Client_v2.0.1904";
+ private const string BitpayPluginInfo = "BitPay_DotNet_Client_v2.1.1906";
private string _baseUrl;
private string _clientName;
@@ -872,6 +874,7 @@ private void GetConfig()
{
try
{
+ string path = Directory.GetCurrentDirectory();
if (!File.Exists(_configFilePath))
{
throw new Exception("Configuration file not found");
diff --git a/BitPay/BitPay.csproj b/BitPay/BitPay.csproj
index ca68d16..3f110ad 100644
--- a/BitPay/BitPay.csproj
+++ b/BitPay/BitPay.csproj
@@ -11,7 +11,7 @@
Properties
BitPayAPI
BitPay
- v4.7.2
+ v4.5.2
512
@@ -80,6 +80,9 @@
..\packages\Multiformats.Base.1.0.8\lib\net45\Multiformats.Base.dll
+
+ ..\..\..\..\..\..\Library\Frameworks\Mono.framework\Versions\5.18.1\lib\mono\4.7.2-api\Facades\netstandard.dll
+
..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
@@ -282,7 +285,6 @@
-
@@ -307,15 +309,16 @@
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
diff --git a/BitPay/Models/Currency.cs b/BitPay/Models/Currency.cs
index 88d58c0..000166a 100644
--- a/BitPay/Models/Currency.cs
+++ b/BitPay/Models/Currency.cs
@@ -3,7 +3,7 @@
///
/// Model provided to avoid mistyping. Check the allowed currencies at: https://bitpay.com/currencies
///
- public static class Currency
+ public class Currency
{
// Crypto
public const string BCH = "BCH";
@@ -179,5 +179,10 @@ public static class Currency
public const string ZAR = "ZAR";
public const string ZMW = "ZMW";
public const string ZWL = "ZWL";
+
+ public static bool isValid(string value)
+ {
+ return typeof(Currency).GetMember(value).Length > 0;
+ }
}
}
\ No newline at end of file
diff --git a/BitPay/Models/Invoice/Invoice.cs b/BitPay/Models/Invoice/Invoice.cs
index 392afbe..0603bca 100644
--- a/BitPay/Models/Invoice/Invoice.cs
+++ b/BitPay/Models/Invoice/Invoice.cs
@@ -44,7 +44,7 @@ public string Currency
get => _currency;
set
{
- if (typeof(Currency).GetMember(value).Length == 0)
+ if (!Models.Currency.isValid(value))
throw new BitPayException("Error: currency code must be a type of BitPayAPI.Models.Currency");
_currency = value;
diff --git a/BitPay/Models/Rate.cs b/BitPay/Models/Rate/Rate.cs
similarity index 92%
rename from BitPay/Models/Rate.cs
rename to BitPay/Models/Rate/Rate.cs
index 61e0c29..7db0dfd 100644
--- a/BitPay/Models/Rate.cs
+++ b/BitPay/Models/Rate/Rate.cs
@@ -1,6 +1,6 @@
using Newtonsoft.Json;
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Rate
{
///
/// Provides an interface to a single exchange rate.
diff --git a/BitPay/Models/Rates.cs b/BitPay/Models/Rate/Rates.cs
similarity index 96%
rename from BitPay/Models/Rates.cs
rename to BitPay/Models/Rate/Rates.cs
index c98cee0..a4e1cbc 100644
--- a/BitPay/Models/Rates.cs
+++ b/BitPay/Models/Rate/Rates.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Rate
{
///
/// Provides an interface to the BitPay server to obtain exchange rate information.
diff --git a/BitPay/Models/InvoiceData.cs b/BitPay/Models/Settlement/InvoiceData.cs
similarity index 92%
rename from BitPay/Models/InvoiceData.cs
rename to BitPay/Models/Settlement/InvoiceData.cs
index 10278ea..ee3a534 100644
--- a/BitPay/Models/InvoiceData.cs
+++ b/BitPay/Models/Settlement/InvoiceData.cs
@@ -1,6 +1,6 @@
using System;
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Settlement
{
public class InvoiceData
{
diff --git a/BitPay/Models/RefundAmount.cs b/BitPay/Models/Settlement/RefundAmount.cs
similarity index 83%
rename from BitPay/Models/RefundAmount.cs
rename to BitPay/Models/Settlement/RefundAmount.cs
index 0bc524c..e2a2565 100644
--- a/BitPay/Models/RefundAmount.cs
+++ b/BitPay/Models/Settlement/RefundAmount.cs
@@ -1,4 +1,4 @@
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Settlement
{
public class RefundAmount
{
diff --git a/BitPay/Models/RefundInfo.cs b/BitPay/Models/Settlement/RefundInfo.cs
similarity index 82%
rename from BitPay/Models/RefundInfo.cs
rename to BitPay/Models/Settlement/RefundInfo.cs
index 3a18992..0896c71 100644
--- a/BitPay/Models/RefundInfo.cs
+++ b/BitPay/Models/Settlement/RefundInfo.cs
@@ -1,4 +1,4 @@
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Settlement
{
public class RefundInfo
{
diff --git a/BitPay/Models/Settlement.cs b/BitPay/Models/Settlement/Settlement.cs
similarity index 96%
rename from BitPay/Models/Settlement.cs
rename to BitPay/Models/Settlement/Settlement.cs
index 9eb3c46..9787ce7 100644
--- a/BitPay/Models/Settlement.cs
+++ b/BitPay/Models/Settlement/Settlement.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Settlement
{
public class Settlement
{
diff --git a/BitPay/Models/SettlementLedgerEntry.cs b/BitPay/Models/Settlement/SettlementLedgerEntry.cs
similarity index 91%
rename from BitPay/Models/SettlementLedgerEntry.cs
rename to BitPay/Models/Settlement/SettlementLedgerEntry.cs
index 6a96375..b8dc039 100644
--- a/BitPay/Models/SettlementLedgerEntry.cs
+++ b/BitPay/Models/Settlement/SettlementLedgerEntry.cs
@@ -1,6 +1,6 @@
using System;
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Settlement
{
public class SettlementLedgerEntry
{
diff --git a/BitPay/Models/WithHoldings.cs b/BitPay/Models/Settlement/WithHoldings.cs
similarity index 84%
rename from BitPay/Models/WithHoldings.cs
rename to BitPay/Models/Settlement/WithHoldings.cs
index 4286400..ca85cd7 100644
--- a/BitPay/Models/WithHoldings.cs
+++ b/BitPay/Models/Settlement/WithHoldings.cs
@@ -1,4 +1,4 @@
-namespace BitPayAPI.Models
+namespace BitPayAPI.Models.Settlement
{
public class WithHoldings
{
diff --git a/BitPay/Properties/AssemblyInfo.cs b/BitPay/Properties/AssemblyInfo.cs
index cf08b88..a1f7f6b 100644
--- a/BitPay/Properties/AssemblyInfo.cs
+++ b/BitPay/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.1904")]
-[assembly: AssemblyFileVersion("2.0.1904")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.1.1906")]
+[assembly: AssemblyFileVersion("2.1.1906")]
\ No newline at end of file
diff --git a/BitPaySetup/Properties/AssemblyInfo.cs b/BitPaySetup/Properties/AssemblyInfo.cs
index 2a87ea1..682218f 100644
--- a/BitPaySetup/Properties/AssemblyInfo.cs
+++ b/BitPaySetup/Properties/AssemblyInfo.cs
@@ -16,7 +16,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
-[assembly: AssemblyVersion("2.0.1904")]
+[assembly: AssemblyVersion("2.1.1906")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
diff --git a/BitPayUnitTest/BitPayTest.cs b/BitPayUnitTest/BitPayTest.cs
index 675cd57..6967f17 100644
--- a/BitPayUnitTest/BitPayTest.cs
+++ b/BitPayUnitTest/BitPayTest.cs
@@ -8,6 +8,7 @@
using BitPayAPI.Models;
using BitPayAPI.Models.Invoice;
using Microsoft.Extensions.Configuration;
+using Buyer = BitPayAPI.Models.Invoice.Buyer;
namespace BitPayUnitTest {
@@ -21,7 +22,7 @@ public class BitPayTest {
private static readonly string PairingCode = "GHXnenG";
// Your favourite client name
- private static readonly string ClientName = "BitPay .Net Client v2.0.1904 Tester on " + Environment.MachineName;
+ private static readonly string ClientName = "BitPay .Net Client v2.1.1906 Tester on " + Environment.MachineName;
// Define the date range for fetching results during the test
private static DateTime today = DateTime.Now;
@@ -147,7 +148,7 @@ public async Task TestShouldGetInvoiceNoSigned() {
// create an invoice without signature then retrieve it through the get method - they should match
var invoice = await _bitpay.CreateInvoice(new Invoice(100.0, Currency.EUR), signRequest: false);
var retrievedInvoice = await _bitpay.GetInvoice(invoice.Id, Facade.PointOfSale, false);
- Assert.Equal(invoice.Id, retrievedInvoice.Id);
+ Assert.AreEqual(invoice.Id, retrievedInvoice.Id);
}
[TestMethod]
@@ -170,21 +171,21 @@ public async Task TestShouldCreateInvoiceWithAdditionalParams() {
Buyer = buyerData,
PosData = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
PaymentCurrencies = new List {
- Invoice.PaymentCurrencyBtc,
- Invoice.PaymentCurrencyBch
+ Currency.BTC,
+ Currency.BCH
},
AcceptanceWindow = 480000,
FullNotifications = true,
// NotificationEmail = "",
-// NotificationUrl = "",
+ NotificationUrl = "https://hookb.in/03EBRQJrzasGmGkNPNw9",
OrderId = "1234",
Physical = true,
// RedirectUrl = "",
- TransactionSpeed = "medium",
+ TransactionSpeed = "high",
ItemCode = "bitcoindonation",
ItemDesc = "dhdhdfgh"
};
- invoice = await _bitpay.CreateInvoice(invoice);
+ invoice = await _bitpay.CreateInvoice(invoice, Facade.Merchant);
Assert.AreEqual(Status.New, invoice.Status, "Status is incorrect");
Assert.AreEqual("Satoshi", invoice.Buyer.Name, "BuyerName is incorrect");
Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", invoice.PosData, "PosData is incorrect");
@@ -326,5 +327,25 @@ so this test will always fail - since you can't approve the Payroll pairing code
}
+ [TestMethod]
+ public async Task TestGetSettlements() {
+
+ // make sure we get a ledger with a not null Entries property
+ var settlements = await _bitpay.GetSettlements(Currency.EUR, yesterday.AddMonths(-1).AddDays(3), tomorrow);
+ Assert.IsNotNull(settlements);
+
+ }
+
+ [TestMethod]
+ public async Task TestGetSettlement() {
+
+ // make sure we get a ledger with a not null Entries property
+ var settlements = await _bitpay.GetSettlements(Currency.EUR, yesterday.AddMonths(-1).AddDays(3), tomorrow);
+ var firstSettlement = settlements[0];
+ var settlement = await _bitpay.GetSettlement(firstSettlement.Id);
+ Assert.IsNotNull(settlement.Id);
+ Assert.AreEqual(firstSettlement.Id, settlement.Id);
+ }
+
}
}
diff --git a/BitPayXUnitTest/BitPayTests.cs b/BitPayXUnitTest/BitPayTests.cs
index 0b6037a..1cc8a83 100644
--- a/BitPayXUnitTest/BitPayTests.cs
+++ b/BitPayXUnitTest/BitPayTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Xunit;
using BitPayAPI;
using System.Collections.Generic;
@@ -22,7 +22,7 @@ public class Tests
private static readonly string PairingCode = "Bh3yy6r";
// Your favourite client name
- private static readonly string ClientName = "BitPay .Net Client v2.0.1904 Tester on " + Environment.MachineName;
+ private static readonly string ClientName = "BitPay .Net Client v2.1.1906 Tester on " + Environment.MachineName;
// Define the date range for fetching results during the test
private static DateTime today = DateTime.Now;
@@ -36,7 +36,7 @@ public Tests()
{
// JSON minified with the BitPay configuration as in the required configuration file
// and parsed into a IConfiguration object
- var json = "{\"BitPayConfiguration\":{\"Environment\":\"Test\",\"EnvConfig\":{\"Test\":{\"ClientDescription\":\"Net_test_140519\",\"ApiUrl\":\"https://test.bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"bitpay_private_test.key\",\"ApiTokens\":{\"pos\":\"GzkfCV5uiRPW6WE82iFWmGiVKSBw2Sjxe8pYq2DnD7Z7\",\"merchant\":\"NJ3nQUrmuH8RvBsKEGt7i1ocCFQfRo1qGSKUiUUPPbJ\",\"payroll\":\"8N17w4Aw3GXjykGyiqUzigswXf22MnfB7HP9vHqfDSHL\"}},\"Prod\":{\"ClientDescription\":\"\",\"ApiUrl\":\"https://bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"\",\"ApiTokens\":{\"pos\":\"\",\"merchant\":\"\",\"payroll\":\"\"}}}}}";
+ var json = "{\"BitPayConfiguration\":{\"Environment\":\"Test\",\"EnvConfig\":{\"Test\":{\"ClientDescription\":\"Net_test\",\"ApiUrl\":\"https://test.bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"bitpay_private_test.key\",\"ApiTokens\":{\"pos\":\"AvJdGrEqTW9HVsJit9zabAnrJabqaQDhWHRacHYgfgxK\",\"merchant\":\"CE2WRSEEt9FgXvXboxNFA4YdQyyDJmgVAo752TGA7eUj\",\"payroll\":\"9pJ7fzW1GGeuDQfj32aNATCDnyY6YAacVMcDrs7HHUNo\"}},\"Prod\":{\"ClientDescription\":\"\",\"ApiUrl\":\"https://bitpay.com/\",\"ApiVersion\":\"2.0.0\",\"PrivateKeyPath\":\"\",\"ApiTokens\":{\"pos\":\"\",\"merchant\":\"\",\"payroll\":\"\"}}}}}";
var memoryJsonFile = new MemoryFileInfo("config.json", Encoding.UTF8.GetBytes(json), DateTimeOffset.Now);
var memoryFileProvider = new MockFileProvider(memoryJsonFile);
@@ -86,7 +86,7 @@ again and they should pass.
public async Task TestShouldGetInvoiceId()
{
// create an invoice and make sure we receive an id - which means it has been successfully submitted
- var invoice = new Invoice(50.0, Currency.USD);
+ var invoice = new Invoice(30.0, Currency.EUR);
var basicInvoice = await _bitpay.CreateInvoice(invoice);
Assert.NotNull(basicInvoice.Id);
}
@@ -176,11 +176,11 @@ public async Task TestShouldCreateInvoiceWithAdditionalParams() {
AcceptanceWindow = 480000,
FullNotifications = true,
// NotificationEmail = "",
-// NotificationUrl = "",
+ NotificationUrl = "https://hookb.in/03EBRQJrzasGmGkNPNw9",
OrderId = "1234",
Physical = true,
// RedirectUrl = "",
- TransactionSpeed = "medium",
+ TransactionSpeed = "high",
ItemCode = "bitcoindonation",
ItemDesc = "dhdhdfgh"
};
@@ -318,5 +318,26 @@ so this test will always fail - since you can't approve the Payroll pairing code
await _bitpay.CancelPayoutBatch(batch0.Id);
}
+
+ [Fact]
+ public async Task TestGetSettlements() {
+
+ // make sure we get a ledger with a not null Entries property
+ var settlements = await _bitpay.GetSettlements(Currency.EUR, yesterday.AddMonths(-1).AddDays(3), tomorrow);
+ Assert.NotNull(settlements);
+
+ }
+
+ [Fact]
+ public async Task TestGetSettlement() {
+
+ // make sure we get a ledger with a not null Entries property
+ var settlements = await _bitpay.GetSettlements(Currency.EUR, yesterday.AddMonths(-1).AddDays(3), tomorrow);
+ var firstSettlement = settlements[0];
+ var settlement = await _bitpay.GetSettlement(firstSettlement.Id);
+ Assert.NotNull(settlement.Id);
+ Assert.Equal(firstSettlement.Id, settlement.Id);
+ }
+
}
}
\ No newline at end of file