diff --git a/README.md b/README.md
index 77c207b..47f9b2a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,14 @@
-ChargeOver C# API and Examples
+ChargeOver C# API and Examples (.NET 6)
==============================
+-----
+
+* Upgraded from .NET Framework to .NET 6.
+* Used .NET Upgrade Assistant to facilitate the process.
+* Replaced HttpWebRequest by HttpClient to comply with the new .NET 6 standards.
+
+-----
+
This is a C# .NET library for the [ChargeOver recurring billing platform](http://www.chargeover.com/). ChargeOver is a billing platform geared towards easy, automated, recurring invoicing.
diff --git a/src/ChargeOver.Wrapper.Examples/App.config b/src/ChargeOver.Wrapper.Examples/App.config
index 3dfb5ea..f17d704 100644
--- a/src/ChargeOver.Wrapper.Examples/App.config
+++ b/src/ChargeOver.Wrapper.Examples/App.config
@@ -1,4 +1,4 @@
-
+
@@ -7,6 +7,6 @@
-
+
diff --git a/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj b/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj
index d4c248c..8204e92 100644
--- a/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj
+++ b/src/ChargeOver.Wrapper.Examples/ChargeOver.Wrapper.Examples.csproj
@@ -1,73 +1,20 @@
-
-
-
+
- Debug
- AnyCPU
- {0CE183C5-CA80-4696-AE28-785455DB47DE}
+ net7.0
Exe
- Properties
- ChargeOver.Wrapper.Examples
- ChargeOver.Wrapper.Examples
- v4.6.1
- 512
- true
+ false
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+ all
+
-
- {03e09695-088d-4971-8888-eb16a8565eeb}
- ChargeOver.Wrapper
-
+
-
-
\ No newline at end of file
diff --git a/src/ChargeOver.Wrapper.Examples/Program.cs b/src/ChargeOver.Wrapper.Examples/Program.cs
index a89b9c3..95fd0be 100644
--- a/src/ChargeOver.Wrapper.Examples/Program.cs
+++ b/src/ChargeOver.Wrapper.Examples/Program.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System;
+using System.Linq;
using ChargeOver.Wrapper.Examples.Services;
namespace ChargeOver.Wrapper.Examples
@@ -9,15 +10,17 @@ static void Main()
{
var examples = new IServiceExample[]
{
- // CustomersServiceExample(),
+ new CustomersServiceExample(),
new InvoiceServiceExample(),
- //new SubscriptionServiceExample(),
+ new SubscriptionServiceExample(),
new TransactionsServiceExample(),
- //new CreditCardServiceExample(),
- //new ACHeCheckAccountsServiceExample()
+ new CreditCardServiceExample(),
+ new ACHeCheckAccountsServiceExample()
}.ToList();
examples.ForEach(e => e.Run());
+
+ Console.ReadLine();
}
}
}
diff --git a/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs
index 56ddfb5..9c4f61f 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/ACHeCheckAccountsServiceExample.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;
@@ -13,7 +14,7 @@ public ACHeCheckAccountsServiceExample()
_service = new ACHeCheckAccountsService();
}
- public void Run()
+ public async void Run()
{
var request = new StoreACHAccount
{
@@ -23,7 +24,7 @@ public void Run()
Routing = "072403004",
};
- var result = _service.StoreACHAccount(request);
+ var result = await _service.StoreACHAccount(request);
if (!result.IsSuccess()) throw new Exception("Store ACH failed.");
diff --git a/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs
index 40c30da..3b95a59 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/CreditCardServiceExample.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;
@@ -13,7 +14,7 @@ public CreditCardServiceExample()
_service = new CreditCardsService();
}
- public void Run()
+ public async void Run()
{
var request = new StoreCreditCard
{
@@ -29,7 +30,7 @@ public void Run()
Country = "United States",
};
- var result = _service.StoreCreditCard(request);
+ var result = await _service.StoreCreditCard(request);
if (!result.IsSuccess()) throw new Exception("Store credit card failed.");
diff --git a/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs
index 44b5604..cbfc3b7 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/CustomersServiceExample.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;
@@ -15,7 +16,7 @@ public CustomersServiceExample()
_service = new CustomersService();
}
- public void Run()
+ public async void Run()
{
var examples = new List
{
@@ -28,7 +29,7 @@ public void Run()
}
}
- private void CreateCustomer()
+ private async void CreateCustomer()
{
var customer = new Customer
{
@@ -40,23 +41,23 @@ private void CreateCustomer()
SuperUserEmail = "mail@mail.com"
};
- var result = _service.CreateCustomer(customer);
+ var result = await _service.CreateCustomer(customer);
if (!result.IsSuccess()) throw new Exception("Create customer failed.");
Console.WriteLine("Customer created with id: " + result.Id);
}
- private void QueryCustomerByName()
+ private async void QueryCustomerByName()
{
- var result = _service.QueryCustomers(new[] { "company:EQUALS:Name" });
+ var result = await _service.QueryCustomers(new[] { "company:EQUALS:Name" });
Console.WriteLine($"Customers found 'by name': {result.Response.Count()}");
}
- private void QueryCustomerByEmail()
+ private async void QueryCustomerByEmail()
{
- var result = _service.QueryCustomers(new[] { "superuser_email:EQUALS:mail@mail.com" });
+ var result = await _service.QueryCustomers(new[] { "superuser_email:EQUALS:mail@mail.com" });
Console.WriteLine($"Customers found 'by email': {result.Response.Count()}");
}
diff --git a/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs
index aa095e6..f1e8e4d 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/IServiceExample.cs
@@ -1,7 +1,10 @@
-namespace ChargeOver.Wrapper.Examples.Services
+using System.Threading.Tasks;
+
+namespace ChargeOver.Wrapper.Examples.Services
{
public interface IServiceExample
{
- void Run();
- }
+
+ void Run();
+ }
}
\ No newline at end of file
diff --git a/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs
index 364b6fa..4c2886a 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/InvoiceServiceExample.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;
@@ -18,7 +19,7 @@ public InvoiceServiceExample()
_customersService = new CustomersService();
}
- public void Run()
+ public async void Run()
{
var examples = new Action[] { CreateInvoice, QueryInvoiceByInvoiceId };
@@ -28,16 +29,16 @@ public void Run()
}
}
- private void CreateInvoice()
+ private async void CreateInvoice()
{
- var result = CreateNewInvoice();
+ var result = await CreateNewInvoice();
if (!result.IsSuccess()) throw new Exception("Create invoice failed.");
Console.WriteLine("Invoice created with id: " + result.Id);
}
- private IIdentityResponse CreateNewInvoice()
+ private async Task CreateNewInvoice()
{
var id = TakeItemId();
var customer = TakeCustomerId();
@@ -60,13 +61,13 @@ private IIdentityResponse CreateNewInvoice()
}
}
};
- var result = _service.CreateInvoice(request);
+ var result = await _service.CreateInvoice(request);
return result;
}
- private void QueryInvoiceByInvoiceId()
+ private async void QueryInvoiceByInvoiceId()
{
- var result = _service.QueryInvoices(new[] { "invoice_id:EQUALS:" + CreateNewInvoice().Id });
+ var result = await _service.QueryInvoices(new[] { "invoice_id:EQUALS:" + CreateNewInvoice().Id });
Console.WriteLine($"Invoices found by id: {result.Response.Count()}");
}
diff --git a/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs
index aa735a9..55e0faf 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/SubscriptionServiceExample.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;
@@ -26,22 +27,21 @@ public void Run()
}
}
- private void CreateSubscription()
+ private async void CreateSubscription()
{
- var result = CreateNewSubscription();
+ var result = await CreateNewSubscription();
if (!result.IsSuccess()) throw new Exception("Create subscription failed.");
Console.WriteLine("Subscription created with id: " + result.Id);
}
- private IIdentityResponse CreateNewSubscription()
+ private Task CreateNewSubscription()
{
var subscription = new Subscription
{
CustomerId = TakeCustomerId(),
- HoldUntilDatetime = DateTime.Parse("2018-10-01"),
- Coupon = 'The coupon code'
+ HoldUntilDatetime = DateTime.Parse("2018-10-01")
};
var line1 = new SubscriptionLineItem
@@ -81,10 +81,10 @@ private IIdentityResponse CreateNewSubscription()
return result;
}
- private void GetSubscriptionByPackageId()
+ private async void GetSubscriptionByPackageId()
{
var subscription = CreateNewSubscription();
- var result = _service.QuerySubscriptions(new[] { "package_id:EQUALS:" + subscription.Id });
+ var result = await _service.QuerySubscriptions(new[] { "package_id:EQUALS:" + subscription.Id });
Console.WriteLine($"Subscriptions found 'by id': {result.Response.Count()}");
}
diff --git a/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs b/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs
index bc2dbff..e2adbb1 100644
--- a/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs
+++ b/src/ChargeOver.Wrapper.Examples/Services/TransactionsServiceExample.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using ChargeOver.Wrapper.Services;
@@ -24,7 +25,7 @@ public TransactionsServiceExample()
_itemsService = new ItemsService();
}
- public void Run()
+ public async void Run()
{
this._customerId = AddCustomer();
@@ -36,9 +37,9 @@ public void Run()
}
}
- public void GetTransactionByTransactionId()
+ public async void GetTransactionByTransactionId()
{
- var result = _transactionsService.GetTransaction(this.AttemptPayment());
+ var result = await _transactionsService.GetTransaction(await this.AttemptPayment());
Console.WriteLine("Transaction ID we just got is: " + result.Response.TransactionId + " and is applied to " + result.Response.AppliedTo.Length + " invoices");
@@ -50,9 +51,9 @@ public void GetTransactionByTransactionId()
}
- public void QueryTransactionByTransactionId()
+ public async void QueryTransactionByTransactionId()
{
- var result = _transactionsService.QueryTransactions(new[] { "transaction_id:EQUALS:" + AttemptPayment() });
+ var result = await _transactionsService.QueryTransactions(new[] { "transaction_id:EQUALS:" + AttemptPayment() });
Console.WriteLine("Transactions found by id: " + result.Response.Count());
}
@@ -64,7 +65,7 @@ public void AttemptPaymentExample()
Console.WriteLine("Transaction ID for payment is: " + payment_id);
}
- public int AttemptPayment()
+ public async Task AttemptPayment()
{
var customerId = this._customerId;
int creditcardId = StoreCreditCard(customerId);
@@ -92,7 +93,7 @@ public int AttemptPayment()
try
{
- var result = _transactionsService.AttemptPayment(request);
+ var result = await _transactionsService.AttemptPayment(request);
if (!result.IsSuccess()) throw new Exception("Attempt payment failed.");
diff --git a/src/ChargeOver.Wrapper.Examples/appsettings.json b/src/ChargeOver.Wrapper.Examples/appsettings.json
new file mode 100644
index 0000000..b2bc73d
--- /dev/null
+++ b/src/ChargeOver.Wrapper.Examples/appsettings.json
@@ -0,0 +1,6 @@
+{
+ "ChargeOverAPIEndpoint": "",
+ "ChargeOverAPIUserName": "",
+ "ChargeOverAPIPassword": "",
+ "ChargeOverAPIAuth": "http-basic"
+}
\ No newline at end of file
diff --git a/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj b/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj
index 0aae5fe..b4ed4a1 100644
--- a/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj
+++ b/src/ChargeOver.Wrapper/ChargeOver.Wrapper.csproj
@@ -1,182 +1,18 @@
-
-
-
+
- Debug
- AnyCPU
- {03E09695-088D-4971-8888-EB16A8565EEB}
+ net6.0
Library
- Properties
- ChargeOver.Wrapper
- ChargeOver.Wrapper
- v4.5.2
- 512
+ false
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- ..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ all
+
-
+
-
-
\ No newline at end of file
diff --git a/src/ChargeOver.Wrapper/Models/Customer.cs b/src/ChargeOver.Wrapper/Models/Customer.cs
index 0406855..edffb17 100644
--- a/src/ChargeOver.Wrapper/Models/Customer.cs
+++ b/src/ChargeOver.Wrapper/Models/Customer.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
+using System.Collections.Generic;
namespace ChargeOver.Wrapper.Models
{
@@ -98,7 +99,7 @@ public sealed class Customer
/// Main contact phone number
///
[JsonProperty("superuser_phone")]
- public string SuperuserPhone { get; set; }
+ public string SuperUserPhone { get; set; }
///
/// Billing address line 1
///
@@ -214,5 +215,10 @@ public sealed class Customer
///
[JsonProperty("dunning_delivery")]
public string DunningDelivery { get; set; }
- }
+ ///
+ /// A list of tags
+ ///
+ [JsonProperty("tags")]
+ public HashSet Tags { get; set; }
+ }
}
diff --git a/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs b/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs
index f2ecfea..45f7398 100644
--- a/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs
+++ b/src/ChargeOver.Wrapper/Models/StoreCreditCard.cs
@@ -65,5 +65,15 @@ public sealed class StoreCreditCard
///
[JsonProperty("country")]
public string Country { get; set; }
- }
+ ///
+ /// Security Code
+ ///
+ [JsonProperty("cvv")]
+ public string SecurityCode { get; set; }
+ ///
+ /// The customer external key #
+ ///
+ [JsonProperty("customer_external_key")]
+ public int? CustomerExternalKey { get; set; }
+ }
}
diff --git a/src/ChargeOver.Wrapper/Models/StoringUsageData.cs b/src/ChargeOver.Wrapper/Models/StoringUsageData.cs
index 47dd333..030af9f 100644
--- a/src/ChargeOver.Wrapper/Models/StoringUsageData.cs
+++ b/src/ChargeOver.Wrapper/Models/StoringUsageData.cs
@@ -30,5 +30,10 @@ public sealed class StoringUsageData
///
[JsonProperty("external_key")]
public string ExternalKey { get; set; }
- }
+ ///
+ /// Line Item External key value
+ ///
+ [JsonProperty("line_item_external_key")]
+ public string LineItemExternalKey { get; set; }
+ }
}
diff --git a/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs b/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs
index 2f07daa..aa9273a 100644
--- a/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs
+++ b/src/ChargeOver.Wrapper/Models/SubscriptionLineItem.cs
@@ -47,5 +47,7 @@ public sealed class SubscriptionLineItem
public Tierset Tierset { get; set; }
[JsonProperty("line_quantity")]
public int LineQuantity { get; set; }
+ [JsonProperty("item_is_usage")]
+ public bool ItemIsUsage { get; set; }
}
}
\ No newline at end of file
diff --git a/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs b/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs
index 211bccf..1b5d9ea 100644
--- a/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs
+++ b/src/ChargeOver.Wrapper/Services/ACHeCheckAccountsService.cs
@@ -1,4 +1,5 @@
using ChargeOver.Wrapper.Models;
+using System.Threading.Tasks;
namespace ChargeOver.Wrapper.Services
{
@@ -16,18 +17,18 @@ public ACHeCheckAccountsService()
/// Store an ACH account
/// details: https://developer.chargeover.com/apidocs/rest/#create-ach
///
- public IIdentityResponse StoreACHAccount(StoreACHAccount request)
+ public async Task StoreACHAccount(StoreACHAccount request)
{
- return Create("ach", request);
+ return await Create("ach", request);
}
///
/// Delete an ACH account
/// details: https://developer.chargeover.com/apidocs/rest/#delete-an-ach
///
- public IResponse DeleteACHAccount(int id)
+ public async Task DeleteACHAccount(int id)
{
- return Delete("ach", id);
+ return await Delete("ach", id);
}
}
}
diff --git a/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs b/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs
index 6115ac6..90fbf18 100644
--- a/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs
+++ b/src/ChargeOver.Wrapper/Services/AdminWorkersService.cs
@@ -1,4 +1,5 @@
using ChargeOver.Wrapper.Models;
+using System.Threading.Tasks;
namespace ChargeOver.Wrapper.Services
{
@@ -16,27 +17,27 @@ public AdminWorkersService()
/// Get a list of admin workers
/// details: https://developer.chargeover.com/apidocs/rest/#list-admins
///
- public IResponse ListAdminWorkers()
+ public async Task> ListAdminWorkers()
{
- return GetList("admin");
+ return await GetList("admin");
}
///
/// Query for admin workers
/// details: https://developer.chargeover.com/apidocs/rest/#query-admins
///
- public IResponse QueryAdminWorkers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10)
+ public async Task> QueryAdminWorkers(string[] queries = null, string[] orders = null, int offset = 0, int limit = 10)
{
- return Query("admin", queries, orders, offset, limit);
+ return await Query("admin", queries, orders, offset, limit);
}
///
/// Get a specific admin worker
/// details: https://developer.chargeover.com/apidocs/rest/#get-admin
///
- public ICustomResponse GetAdminWorker(int id)
+ public async Task> GetAdminWorker(int id)
{
- return GetCustom("admin", id);
+ return await GetCustom("admin", id);
}
}
}
diff --git a/src/ChargeOver.Wrapper/Services/BaseService.cs b/src/ChargeOver.Wrapper/Services/BaseService.cs
index 62cc8e7..f0781cc 100644
--- a/src/ChargeOver.Wrapper/Services/BaseService.cs
+++ b/src/ChargeOver.Wrapper/Services/BaseService.cs
@@ -2,7 +2,11 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
using System.Text;
+using System.Threading.Tasks;
using ChargeOver.Wrapper.Models;
using Newtonsoft.Json;
@@ -23,37 +27,37 @@ protected BaseService(IChargeOverAPIConfiguration config)
protected BaseService() : this(new ConfigurationManagerChargeOverApiConfiguration()) { }
- protected IIdentityResponse Create(string endpoint, T request)
+ protected async Task Create(string endpoint, T request)
{
- return new IdentityResponse(Request(MethodType.POST, $"/{endpoint}", request));
+ return new IdentityResponse(await Request(MethodType.POST, $"/{endpoint}", request));
}
- protected IResponse Delete(string endpoint, int id)
+ protected async Task Delete(string endpoint, int id)
{
- return new Response(Request