diff --git a/GoCardless/GoCardless.csproj b/GoCardless/GoCardless.csproj index 892c356..659d43c 100644 --- a/GoCardless/GoCardless.csproj +++ b/GoCardless/GoCardless.csproj @@ -2,7 +2,7 @@ GoCardless - 4.2.0 + 4.3.0 GoCardless Ltd Client for the GoCardless API - a powerful, simple solution for the collection of recurring bank-to-bank payments false @@ -11,7 +11,7 @@ GoCardless Ltd gocardless payments rest api direct debit https://github.com/gocardless/gocardless-dotnet/blob/master/LICENSE.txt - https://github.com/gocardless/gocardless-dotnet/releases/tag/v4.2.0 + https://github.com/gocardless/gocardless-dotnet/releases/tag/v4.3.0 netstandard1.6;netstandard2.0;net46 True true diff --git a/GoCardless/GoCardlessClient.Generated.cs b/GoCardless/GoCardlessClient.Generated.cs index 03dc7a1..cef7e0d 100644 --- a/GoCardless/GoCardlessClient.Generated.cs +++ b/GoCardless/GoCardlessClient.Generated.cs @@ -103,5 +103,10 @@ public partial class GoCardlessClient /// public SubscriptionService Subscriptions => new SubscriptionService(this); + /// + ///A service for working with tax rate resources. + /// + public TaxRateService TaxRates => new TaxRateService(this); + } } diff --git a/GoCardless/GoCardlessClient.cs b/GoCardless/GoCardlessClient.cs index 33c5d8b..5ced718 100644 --- a/GoCardless/GoCardlessClient.cs +++ b/GoCardless/GoCardlessClient.cs @@ -252,9 +252,9 @@ private HttpRequestMessage BuildHttpRequestMessage(string method, string path var httpMethod = new HttpMethod(method); var requestMessage = new HttpRequestMessage(httpMethod, new Uri(_baseUrl, path)); - requestMessage.Headers.Add("User-Agent", "gocardless-dotnet/4.2.0"); + requestMessage.Headers.Add("User-Agent", "gocardless-dotnet/4.3.0"); requestMessage.Headers.Add("GoCardless-Version", "2015-07-06"); - requestMessage.Headers.Add("GoCardless-Client-Version", "4.2.0"); + requestMessage.Headers.Add("GoCardless-Client-Version", "4.3.0"); requestMessage.Headers.Add("GoCardless-Client-Library", "gocardless-dotnet"); requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _accessToken); diff --git a/GoCardless/Resources/Payment.cs b/GoCardless/Resources/Payment.cs index 98de66d..15ac649 100644 --- a/GoCardless/Resources/Payment.cs +++ b/GoCardless/Resources/Payment.cs @@ -103,7 +103,8 @@ public class Payment /// 30 characters
BECS NZ - 12 characters
/// Betalingsservice - 30 characters
/// PAD - 12 characters
SEPA - - /// 140 characters

Note that this reference must be unique (for + /// each merchant) for the BECS scheme as it is a scheme requirement.

Restricted: You can only /// specify a payment reference for Bacs payments (that is, when /// collecting from the UK) if you're on the /// Fees that have already been deducted from the payout amount in minor - /// unit (e.g. pence in GBP, cents in EUR). + /// unit (e.g. pence in GBP, cents in EUR), inclusive of tax if + /// applicable. /// /// For each `late_failure_settled` or `chargeback_settled` action, we /// refund the transaction fees in a payout. This means that a payout @@ -120,6 +121,16 @@ public class Payout /// [JsonProperty("status")] public PayoutStatus? Status { get; set; } + + ///

+ /// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) code + /// for the currency in which tax is paid out to the tax authorities of + /// your tax jurisdiction. Currently “EUR”, “GBP”, for French or British + /// merchants, this will be `null` if tax is not applicable + /// beta + /// + [JsonProperty("tax_currency")] + public string TaxCurrency { get; set; } } /// diff --git a/GoCardless/Resources/PayoutItem.cs b/GoCardless/Resources/PayoutItem.cs index ee9dcde..c5ea380 100644 --- a/GoCardless/Resources/PayoutItem.cs +++ b/GoCardless/Resources/PayoutItem.cs @@ -53,9 +53,20 @@ public class PayoutItem [JsonProperty("links")] public PayoutItemLinks Links { get; set; } + /// + /// An array of tax items beta + /// + /// Note: VAT applies to transaction and surcharge fees for merchants + /// operating in the UK and France. + /// + [JsonProperty("taxes")] + public List Taxes { get; set; } + /// /// The type of the credit (positive) or debit (negative) item in the - /// payout. One of: + /// payout (inclusive of VAT if applicable). One of: ///
    ///
  • `payment_paid_out` (credit)
  • ///
  • `payment_failed` (debit): The payment failed to be @@ -70,7 +81,8 @@ public class PayoutItem /// to the customer, and the funds have been returned to you.
  • ///
  • `gocardless_fee` (credit/debit): The fees that GoCardless /// charged for a payment. In the case of a payment failure or - /// chargeback, these will appear as credits.
  • + /// chargeback, these will appear as credits. Will include taxes if + /// applicable for merchants. ///
  • `app_fee` (credit/debit): The optional fees that a partner may /// have taken for a payment. In the case of a payment failure or /// chargeback, these will appear as credits.
  • @@ -81,7 +93,8 @@ public class PayoutItem /// credits. ///
  • `surcharge_fee` (credit/debit): GoCardless deducted a surcharge /// fee as the payment failed or was charged back, or refunded a - /// surcharge fee as the bank or customer cancelled the chargeback.
  • + /// surcharge fee as the bank or customer cancelled the chargeback. Will + /// include taxes if applicable for merchants. ///
/// ///
@@ -109,7 +122,109 @@ public class PayoutItemLinks } /// - /// The type of the credit (positive) or debit (negative) item in the payout. One of: + /// An array of tax items beta + /// + /// Note: VAT applies to transaction and surcharge fees for merchants + /// operating in the UK + /// and France. + /// + public class PayoutItemTaxis + { + /// + /// The amount of tax applied to a fee in fractional currency; the + /// lowest denomination for the currency (e.g. pence in GBP, cents in + /// EUR), to one decimal place. + /// + [JsonProperty("amount")] + public string Amount { get; set; } + + /// + /// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) + /// currency code. Currently "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", + /// "SEK" and "USD" are supported. + /// + [JsonProperty("currency")] + public PayoutItemTaxisCurrency? Currency { get; set; } + + /// + /// The amount of tax to be paid out to the tax authorities in + /// fractional currency; the lowest denomination for the currency (e.g. + /// pence in GBP, cents in EUR), to one decimal place. + /// + /// When `currency` and `destination_currency` don't match this will be + /// `null` until the `exchange_rate` has been finalised. + /// + [JsonProperty("destination_amount")] + public string DestinationAmount { get; set; } + + /// + /// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) code + /// for the currency in which tax is paid out to the tax authorities of + /// your tax jurisdiction. Currently “EUR” for French merchants and + /// “GBP” for British merchants. + /// + [JsonProperty("destination_currency")] + public string DestinationCurrency { get; set; } + + /// + /// The exchange rate for the tax from the currency into the destination + /// currency. + /// + /// Present only if the currency and the destination currency don't + /// match and the exchange rate has been finalised. + /// + /// You can listen for the payout's [`tax_exchange_rates_confirmed` + /// webhook](https://developer.gocardless.com/api-reference/#event-actions-payout) + /// to know when the exchange rate has been finalised for all fees in + /// the payout. + /// + [JsonProperty("exchange_rate")] + public string ExchangeRate { get; set; } + + /// + /// The unique identifier created by the jurisdiction, tax type and + /// version + /// + [JsonProperty("tax_rate_id")] + public string TaxRateId { get; set; } + } + + /// + /// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently + /// "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum PayoutItemTaxisCurrency { + + /// `currency` with a value of "AUD" + [EnumMember(Value = "AUD")] + AUD, + /// `currency` with a value of "CAD" + [EnumMember(Value = "CAD")] + CAD, + /// `currency` with a value of "DKK" + [EnumMember(Value = "DKK")] + DKK, + /// `currency` with a value of "EUR" + [EnumMember(Value = "EUR")] + EUR, + /// `currency` with a value of "GBP" + [EnumMember(Value = "GBP")] + GBP, + /// `currency` with a value of "NZD" + [EnumMember(Value = "NZD")] + NZD, + /// `currency` with a value of "SEK" + [EnumMember(Value = "SEK")] + SEK, + /// `currency` with a value of "USD" + [EnumMember(Value = "USD")] + USD, + } + + /// + /// The type of the credit (positive) or debit (negative) item in the payout (inclusive of VAT + /// if applicable). One of: ///
    ///
  • `payment_paid_out` (credit)
  • ///
  • `payment_failed` (debit): The payment failed to be processed.
  • @@ -120,7 +235,8 @@ public class PayoutItemLinks ///
  • `refund_funds_returned` (credit): The refund could not be sent to the customer, and the /// funds have been returned to you.
  • ///
  • `gocardless_fee` (credit/debit): The fees that GoCardless charged for a payment. In the - /// case of a payment failure or chargeback, these will appear as credits.
  • + /// case of a payment failure or chargeback, these will appear as credits. Will include taxes if + /// applicable for merchants. ///
  • `app_fee` (credit/debit): The optional fees that a partner may have taken for a payment. /// In the case of a payment failure or chargeback, these will appear as credits.
  • ///
  • `revenue_share` (credit/debit): A share of the fees that GoCardless collected which some @@ -128,7 +244,7 @@ public class PayoutItemLinks /// In the case of a payment failure or chargeback, these will appear as credits.
  • ///
  • `surcharge_fee` (credit/debit): GoCardless deducted a surcharge fee as the payment /// failed or was charged back, or refunded a surcharge fee as the bank or customer cancelled - /// the chargeback.
  • + /// the chargeback. Will include taxes if applicable for merchants. ///
/// ///
diff --git a/GoCardless/Resources/Refund.cs b/GoCardless/Resources/Refund.cs index 69041e3..b815e61 100644 --- a/GoCardless/Resources/Refund.cs +++ b/GoCardless/Resources/Refund.cs @@ -75,7 +75,8 @@ public class Refund /// 30 characters
BECS NZ - 12 characters
/// Betalingsservice - 30 characters
/// PAD - 12 characters
SEPA - - /// 140 characters

Note that this reference must be unique (for + /// each merchant) for the BECS scheme as it is a scheme requirement.

Restricted: You can only /// specify a payment reference for Bacs payments (that is, when /// collecting from the UK) if you're on the + /// Represents a tax rate resource. + /// + /// Tax rates from tax authority. + ///

+ public class TaxRate + { + /// + /// Date at which GoCardless stopped applying the tax rate for the + /// jurisdiction. + /// + [JsonProperty("end_date")] + public string EndDate { get; set; } + + /// + /// The unique identifier created by the jurisdiction, tax type and + /// version + /// + [JsonProperty("id")] + public string Id { get; set; } + + /// + /// The jurisdiction this tax rate applies to + /// + [JsonProperty("jurisdiction")] + public string Jurisdiction { get; set; } + + /// + /// The percentage of tax that is applied onto of GoCardless fees + /// + [JsonProperty("percentage")] + public string Percentage { get; set; } + + /// + /// Date at which GoCardless started applying the tax rate in the + /// jurisdiction. + /// + [JsonProperty("start_date")] + public string StartDate { get; set; } + + /// + /// The type of tax applied by this rate + /// + [JsonProperty("type")] + public string Type { get; set; } + } + +} diff --git a/GoCardless/Services/InstalmentScheduleService.cs b/GoCardless/Services/InstalmentScheduleService.cs index ad3544b..2f711d3 100644 --- a/GoCardless/Services/InstalmentScheduleService.cs +++ b/GoCardless/Services/InstalmentScheduleService.cs @@ -398,7 +398,8 @@ public class InstalmentScheduleLinks /// 30 characters
BECS NZ - 12 characters
/// Betalingsservice - 30 characters
/// PAD - 12 characters
SEPA - - /// 140 characters

Note that this reference must be unique (for + /// each merchant) for the BECS scheme as it is a scheme requirement.

Restricted: You can only /// specify a payment reference for Bacs payments (that is, when /// collecting from the UK) if you're on the BECS NZ - 12 characters
/// Betalingsservice - 30 characters
/// PAD - 12 characters
SEPA - - /// 140 characters

Note that this reference must be unique (for + /// each merchant) for the BECS scheme as it is a scheme requirement.

Restricted: You can only /// specify a payment reference for Bacs payments (that is, when /// collecting from the UK) if you're on the BECS NZ - 12 characters
/// Betalingsservice - 30 characters
/// PAD - 12 characters
SEPA - - /// 140 characters

Note that this reference must be unique (for + /// each merchant) for the BECS scheme as it is a scheme requirement.

Restricted: You can only /// specify a payment reference for Bacs payments (that is, when /// collecting from the UK) if you're on the BECS NZ - 12 characters
/// Betalingsservice - 30 characters
/// PAD - 12 characters
SEPA - - /// 140 characters

Note that this reference must be unique (for + /// each merchant) for the BECS scheme as it is a scheme requirement.

Restricted: You can only /// specify a payment reference for Bacs payments (that is, when /// collecting from the UK) if you're on the + /// Service class for working with tax rate resources. + /// + /// Tax rates from tax authority. + /// + + public class TaxRateService + { + private readonly GoCardlessClient _goCardlessClient; + + ///

+ /// Constructor. Users of this library should not call this. An instance of this + /// class can be accessed through an initialised GoCardlessClient. + /// + public TaxRateService(GoCardlessClient goCardlessClient) + { + _goCardlessClient = goCardlessClient; + } + + /// + /// Returns a [cursor-paginated](#api-usage-cursor-pagination) list of + /// all tax rates. + /// + /// An optional `TaxRateListRequest` representing the query parameters for this list request. + /// An optional `RequestSettings` allowing you to configure the request + /// A set of tax rate resources + public Task ListAsync(TaxRateListRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new TaxRateListRequest(); + + var urlParams = new List> + {}; + + return _goCardlessClient.ExecuteAsync("GET", "/tax_rates", urlParams, request, null, null, customiseRequestMessage); + } + + /// + /// Get a lazily enumerated list of tax rates. + /// This acts like the #list method, but paginates for you automatically. + /// + public IEnumerable All(TaxRateListRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new TaxRateListRequest(); + + string cursor = null; + do + { + request.After = cursor; + + var result = Task.Run(() => ListAsync(request, customiseRequestMessage)).Result; + foreach (var item in result.TaxRates) + { + yield return item; + } + cursor = result.Meta?.Cursors?.After; + } while (cursor != null); + } + + /// + /// Get a lazily enumerated list of tax rates. + /// This acts like the #list method, but paginates for you automatically. + /// + public IEnumerable>> AllAsync(TaxRateListRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new TaxRateListRequest(); + + return new TaskEnumerable, string>(async after => + { + request.After = after; + var list = await this.ListAsync(request, customiseRequestMessage); + return Tuple.Create(list.TaxRates, list.Meta?.Cursors?.After); + }); + } + + /// + /// Retrieves the details of a tax rate. + /// + /// The unique identifier created by the jurisdiction, tax type and version + /// An optional `TaxRateGetRequest` representing the query parameters for this get request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single tax rate resource + public Task GetAsync(string identity, TaxRateGetRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new TaxRateGetRequest(); + if (identity == null) throw new ArgumentException(nameof(identity)); + + var urlParams = new List> + { + new KeyValuePair("identity", identity), + }; + + return _goCardlessClient.ExecuteAsync("GET", "/tax_rates/:identity", urlParams, request, null, null, customiseRequestMessage); + } + } + + + /// + /// Returns a [cursor-paginated](#api-usage-cursor-pagination) list of all + /// tax rates. + /// + public class TaxRateListRequest + { + + /// + /// Cursor pointing to the start of the desired set. + /// + [JsonProperty("after")] + public string After { get; set; } + + /// + /// Cursor pointing to the end of the desired set. + /// + [JsonProperty("before")] + public string Before { get; set; } + + /// + /// The jurisdiction this tax rate applies to + /// + [JsonProperty("jurisdiction")] + public string Jurisdiction { get; set; } + } + + + /// + /// Retrieves the details of a tax rate. + /// + public class TaxRateGetRequest + { + } + + /// + /// An API response for a request returning a single tax rate. + /// + public class TaxRateResponse : ApiResponse + { + /// + /// The tax rate from the response. + /// + [JsonProperty("tax_rates")] + public TaxRate TaxRate { get; private set; } + } + + /// + /// An API response for a request returning a list of tax rates. + /// + public class TaxRateListResponse : ApiResponse + { + /// + /// The list of tax rates from the response. + /// + [JsonProperty("tax_rates")] + public IReadOnlyList TaxRates { get; private set; } + + /// + /// Response metadata (e.g. pagination cursors) + /// + public Meta Meta { get; private set; } + } +} diff --git a/README.md b/README.md index fcf8f83..24c93fc 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ For full details of the GoCardless API, see the [API docs](https://developer.goc To install `GoCardless`, run the following command in the [Package Manager Console](https://docs.microsoft.com/en-us/nuget/tools/package-manager-console) -`Install-Package GoCardless -Version 4.2.0` +`Install-Package GoCardless -Version 4.3.0` ## Usage