diff --git a/GoCardless/GoCardless.csproj b/GoCardless/GoCardless.csproj index 947b805..70760ee 100644 --- a/GoCardless/GoCardless.csproj +++ b/GoCardless/GoCardless.csproj @@ -2,7 +2,7 @@ GoCardless - 3.4.1 + 3.5.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/v3.4.1 + https://github.com/gocardless/gocardless-dotnet/releases/tag/v3.5.0 netstandard1.6;netstandard2.0;net46 True true diff --git a/GoCardless/GoCardlessClient.cs b/GoCardless/GoCardlessClient.cs index 95b6a2d..e9f6039 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/3.4.1"); + requestMessage.Headers.Add("User-Agent", "gocardless-dotnet/3.5.0"); requestMessage.Headers.Add("GoCardless-Version", "2015-07-06"); - requestMessage.Headers.Add("GoCardless-Client-Version", "3.4.1"); + requestMessage.Headers.Add("GoCardless-Client-Version", "3.5.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/Creditor.cs b/GoCardless/Resources/Creditor.cs index 9f9970b..28a6ea8 100644 --- a/GoCardless/Resources/Creditor.cs +++ b/GoCardless/Resources/Creditor.cs @@ -114,9 +114,9 @@ public class Creditor /// Boolean value indicating whether the organisation is responsible for /// sending all customer notifications (note this is separate from the /// functionality described - /// [here](https://developer.gocardless.com/getting-started/api/handling-customer-notifications/). - /// If you are a partner app, and this value is true, you should not - /// send notifications on behalf of this organisation. + /// [here](/getting-started/api/handling-customer-notifications/)). If + /// you are a partner app, and this value is true, you should not send + /// notifications on behalf of this organisation. /// [JsonProperty("merchant_responsible_for_notifications")] public bool? MerchantResponsibleForNotifications { get; set; } diff --git a/GoCardless/Resources/Event.cs b/GoCardless/Resources/Event.cs index 3a6db82..88f0a40 100644 --- a/GoCardless/Resources/Event.cs +++ b/GoCardless/Resources/Event.cs @@ -12,7 +12,8 @@ namespace GoCardless.Resources /// /// Events are stored for all webhooks. An event refers to a resource which /// has been updated, for example a payment which has been collected, or a - /// mandate which has been transferred. + /// mandate which has been transferred. See [here](#event-actions) for a + /// complete list of event types. /// public class Event { @@ -378,12 +379,18 @@ public class EventLinks [JsonConverter(typeof(StringEnumConverter))] public enum EventResourceType { - /// `resource_type` with a value of "payments" - [EnumMember(Value = "payments")] - Payments, + /// `resource_type` with a value of "creditors" + [EnumMember(Value = "creditors")] + Creditors, + /// `resource_type` with a value of "instalment_schedules" + [EnumMember(Value = "instalment_schedules")] + InstalmentSchedules, /// `resource_type` with a value of "mandates" [EnumMember(Value = "mandates")] Mandates, + /// `resource_type` with a value of "payments" + [EnumMember(Value = "payments")] + Payments, /// `resource_type` with a value of "payouts" [EnumMember(Value = "payouts")] Payouts, @@ -393,12 +400,9 @@ public enum EventResourceType { /// `resource_type` with a value of "subscriptions" [EnumMember(Value = "subscriptions")] Subscriptions, - /// `resource_type` with a value of "instalment_schedules" - [EnumMember(Value = "instalment_schedules")] - InstalmentSchedules, - /// `resource_type` with a value of "creditors" - [EnumMember(Value = "creditors")] - Creditors, + /// `resource_type` with a value of "organisations" + [EnumMember(Value = "organisations")] + Organisations, } } diff --git a/GoCardless/Resources/InstalmentSchedule.cs b/GoCardless/Resources/InstalmentSchedule.cs index 8e1d3a8..44ed857 100644 --- a/GoCardless/Resources/InstalmentSchedule.cs +++ b/GoCardless/Resources/InstalmentSchedule.cs @@ -69,7 +69,6 @@ public class InstalmentSchedule /// also be /// copied to the payments of the instalment schedule if you use /// schedule-based creation. - /// /// [JsonProperty("name")] public string Name { get; set; } @@ -104,10 +103,11 @@ public class InstalmentSchedule /// /// The total amount of the instalment schedule, defined as the sum of /// all individual - /// payments. If the requested payment amounts do not sum up correctly, - /// a validation - /// error will be returned. - /// + /// payments, in the lowest denomination for the currency (e.g. pence in + /// GBP, cents in + /// EUR). If the requested payment amounts do not sum up correctly, a + /// validation error + /// will be returned. /// [JsonProperty("total_amount")] public int? TotalAmount { get; set; } diff --git a/GoCardless/Resources/Subscription.cs b/GoCardless/Resources/Subscription.cs index ed2bc20..7110c7b 100644 --- a/GoCardless/Resources/Subscription.cs +++ b/GoCardless/Resources/Subscription.cs @@ -83,6 +83,13 @@ public class Subscription [JsonProperty("app_fee")] public int? AppFee { get; set; } + /// + /// The total number of payments that should be taken by this + /// subscription. + /// + [JsonProperty("count")] + public int? Count { get; set; } + /// /// Fixed [timestamp](#api-usage-time-zones--dates), recording when this /// resource was created. diff --git a/GoCardless/Services/EventService.cs b/GoCardless/Services/EventService.cs index 0df836a..4d0c282 100644 --- a/GoCardless/Services/EventService.cs +++ b/GoCardless/Services/EventService.cs @@ -18,7 +18,8 @@ namespace GoCardless.Services /// /// Events are stored for all webhooks. An event refers to a resource which /// has been updated, for example a payment which has been collected, or a - /// mandate which has been transferred. + /// mandate which has been transferred. See [here](#event-actions) for a + /// complete list of event types. /// public class EventService @@ -306,12 +307,18 @@ public enum EventInclude public enum EventResourceType { - /// `resource_type` with a value of "payments" - [EnumMember(Value = "payments")] - Payments, + /// `resource_type` with a value of "creditors" + [EnumMember(Value = "creditors")] + Creditors, + /// `resource_type` with a value of "instalment_schedules" + [EnumMember(Value = "instalment_schedules")] + InstalmentSchedules, /// `resource_type` with a value of "mandates" [EnumMember(Value = "mandates")] Mandates, + /// `resource_type` with a value of "payments" + [EnumMember(Value = "payments")] + Payments, /// `resource_type` with a value of "payouts" [EnumMember(Value = "payouts")] Payouts, @@ -321,12 +328,9 @@ public enum EventResourceType /// `resource_type` with a value of "subscriptions" [EnumMember(Value = "subscriptions")] Subscriptions, - /// `resource_type` with a value of "instalment_schedules" - [EnumMember(Value = "instalment_schedules")] - InstalmentSchedules, - /// `resource_type` with a value of "creditors" - [EnumMember(Value = "creditors")] - Creditors, + /// `resource_type` with a value of "organisations" + [EnumMember(Value = "organisations")] + Organisations, } /// diff --git a/GoCardless/Services/InstalmentScheduleService.cs b/GoCardless/Services/InstalmentScheduleService.cs index 3650185..ae88a85 100644 --- a/GoCardless/Services/InstalmentScheduleService.cs +++ b/GoCardless/Services/InstalmentScheduleService.cs @@ -50,13 +50,46 @@ public InstalmentScheduleService(GoCardlessClient goCardlessClient) /// /// Creates a new instalment schedule object, along with the associated - /// payments. + /// payments. This + /// API is recommended if you know the specific dates you wish to + /// charge. Otherwise, + /// please check out the [scheduling + /// version](#instalment-schedules-create-with-schedule). /// - /// The `instalments` property can either be an array of payment - /// properties (`amount` - /// and `charge_date`) or a schedule object with `interval`, - /// `interval_unit` and - /// `amounts`. + /// The `instalments` property is an array of payment properties + /// (`amount` and + /// `charge_date`). + /// + /// It can take quite a while to create the associated payments, so the + /// API will return + /// the status as `pending` initially. When processing has completed, a + /// subsequent GET + /// request for the instalment schedule will either have the status + /// `success` and link + /// to the created payments, or the status `error` and detailed + /// information about the + /// failures. + /// + /// An optional `InstalmentScheduleCreateWithDatesRequest` representing the body for this create_with_dates request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single instalment schedule resource + public Task CreateWithDatesAsync(InstalmentScheduleCreateWithDatesRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new InstalmentScheduleCreateWithDatesRequest(); + + var urlParams = new List> + {}; + + return _goCardlessClient.ExecuteAsync("POST", "/instalment_schedules", urlParams, request, id => GetAsync(id, null, customiseRequestMessage), "instalment_schedules", customiseRequestMessage); + } + + /// + /// Creates a new instalment schedule object, along with the associated + /// payments. This + /// API is recommended if you wish to use the GoCardless scheduling + /// logic. For finer + /// control over the individual dates, please check out the [alternative + /// version](#instalment-schedules-create-with-dates). /// /// It can take quite a while to create the associated payments, so the /// API will return @@ -68,12 +101,12 @@ public InstalmentScheduleService(GoCardlessClient goCardlessClient) /// about the /// failures. /// - /// An optional `InstalmentScheduleCreateRequest` representing the body for this create request. + /// An optional `InstalmentScheduleCreateWithScheduleRequest` representing the body for this create_with_schedule request. /// An optional `RequestSettings` allowing you to configure the request /// A single instalment schedule resource - public Task CreateAsync(InstalmentScheduleCreateRequest request = null, RequestSettings customiseRequestMessage = null) + public Task CreateWithScheduleAsync(InstalmentScheduleCreateWithScheduleRequest request = null, RequestSettings customiseRequestMessage = null) { - request = request ?? new InstalmentScheduleCreateRequest(); + request = request ?? new InstalmentScheduleCreateWithScheduleRequest(); var urlParams = new List> {}; @@ -184,13 +217,213 @@ public Task CancelAsync(string identity, InstalmentS /// /// Creates a new instalment schedule object, along with the associated - /// payments. + /// payments. This + /// API is recommended if you know the specific dates you wish to charge. + /// Otherwise, + /// please check out the [scheduling + /// version](#instalment-schedules-create-with-schedule). /// - /// The `instalments` property can either be an array of payment properties - /// (`amount` - /// and `charge_date`) or a schedule object with `interval`, `interval_unit` + /// The `instalments` property is an array of payment properties (`amount` /// and - /// `amounts`. + /// `charge_date`). + /// + /// It can take quite a while to create the associated payments, so the API + /// will return + /// the status as `pending` initially. When processing has completed, a + /// subsequent GET + /// request for the instalment schedule will either have the status + /// `success` and link + /// to the created payments, or the status `error` and detailed information + /// about the + /// failures. + /// + public class InstalmentScheduleCreateWithDatesRequest : IHasIdempotencyKey + { + + /// + /// The amount to be deducted from each payment as an app fee, to be + /// paid to the partner integration which created the subscription, in + /// the lowest denomination for the currency (e.g. pence in GBP, cents + /// in EUR). + /// + [JsonProperty("app_fee")] + public int? AppFee { 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 InstalmentScheduleCurrency? Currency { 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 InstalmentScheduleCurrency + { + + /// `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, + } + + /// + /// An explicit array of instalment payments, each specifying at least + /// an `amount` and `charge_date`. + /// + [JsonProperty("instalments")] + public InstalmentScheduleInstalments[] Instalments { get; set; } + /// + /// + /// + public class InstalmentScheduleInstalments + { + + /// + /// Amount, in the lowest denomination for the currency (e.g. pence + /// in GBP, cents in EUR). + /// + [JsonProperty("amount")] + public int? Amount { get; set; } + + /// + /// A future date on which the payment should be collected. If the + /// date + /// is before the next_possible_charge_date on the + /// [mandate](#core-endpoints-mandates), it will be automatically + /// rolled + /// forwards to that date. + /// + [JsonProperty("charge_date")] + public string ChargeDate { get; set; } + + /// + /// A human-readable description of the payment. This will be + /// included in the notification email GoCardless sends to your + /// customer if your organisation does not send its own + /// notifications (see [compliance + /// requirements](#appendix-compliance-requirements)). + /// + [JsonProperty("description")] + public string Description { get; set; } + } + + /// + /// Linked resources. + /// + [JsonProperty("links")] + public InstalmentScheduleLinks Links { get; set; } + /// + /// Linked resources for a InstalmentSchedule. + /// + public class InstalmentScheduleLinks + { + + /// + /// ID of the associated [mandate](#core-endpoints-mandates) which + /// the instalment schedule will create payments against. + /// + [JsonProperty("mandate")] + public string Mandate { get; set; } + } + + /// + /// Key-value store of custom data. Up to 3 keys are permitted, with key + /// names up to 50 characters and values up to 500 characters. + /// + [JsonProperty("metadata")] + public IDictionary Metadata { get; set; } + + /// + /// Name of the instalment schedule, up to 100 chars. This name will + /// also be + /// copied to the payments of the instalment schedule if you use + /// schedule-based creation. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// An optional reference that will appear on your customer's bank + /// statement. The character limit for this reference is dependent on + /// the scheme.
ACH - 10 characters
+ /// Autogiro - 11 characters
+ /// Bacs - 10 characters
BECS - + /// 30 characters
BECS NZ - 12 characters
+ /// Betalingsservice - 30 characters
+ /// PAD - 12 characters
SEPA - + /// 140 characters

Restricted: You can only + /// specify a payment reference for Bacs payments (that is, when + /// collecting from the UK) if you're on the GoCardless Plus, Pro or + /// Enterprise packages.

+ ///
+ [JsonProperty("payment_reference")] + public string PaymentReference { get; set; } + + /// + /// On failure, automatically retry payments using [Optimise Smart + /// Payment + /// Retries](#optimise-smart-payment-retries). Default is `false`. + /// + [JsonProperty("retry_if_possible")] + public bool? RetryIfPossible { get; set; } + + /// + /// The total amount of the instalment schedule, defined as the sum of + /// all individual + /// payments, in the lowest denomination for the currency (e.g. pence in + /// GBP, cents in + /// EUR). If the requested payment amounts do not sum up correctly, a + /// validation error + /// will be returned. + /// + [JsonProperty("total_amount")] + public int? TotalAmount { get; set; } + + /// + /// A unique key to ensure that this request only succeeds once, allowing you to safely retry request errors such as network failures. + /// Any requests, where supported, to create a resource with a key that has previously been used will not succeed. + /// See: https://developer.gocardless.com/api-reference/#making-requests-idempotency-keys + /// + [JsonIgnore] + public string IdempotencyKey { get; set; } + } + + + /// + /// Creates a new instalment schedule object, along with the associated + /// payments. This + /// API is recommended if you wish to use the GoCardless scheduling logic. + /// For finer + /// control over the individual dates, please check out the [alternative + /// version](#instalment-schedules-create-with-dates). /// /// It can take quite a while to create the associated payments, so the API /// will return @@ -202,7 +435,7 @@ public Task CancelAsync(string identity, InstalmentS /// about the /// failures. /// - public class InstalmentScheduleCreateRequest : IHasIdempotencyKey + public class InstalmentScheduleCreateWithScheduleRequest : IHasIdempotencyKey { /// @@ -257,8 +490,77 @@ public enum InstalmentScheduleCurrency USD, } + /// + /// Frequency of the payments you want to create, together with an array + /// of payment + /// amounts to be collected, with a specified start date for the first + /// payment. + /// + /// [JsonProperty("instalments")] - public IDictionary Instalments { get; set; } + public InstalmentScheduleInstalments Instalments { get; set; } + /// + /// Frequency of the payments you want to create, together with an array + /// of payment + /// amounts to be collected, with a specified start date for the first + /// payment. + /// + /// + public class InstalmentScheduleInstalments + { + + /// + /// List of amounts of each instalment, in the lowest denomination + /// for the + /// currency (e.g. pence in GBP, cents in EUR). + /// + /// + [JsonProperty("amounts")] + public int?[] Amounts { get; set; } + + /// + /// Number of `interval_units` between charge dates. Must be greater + /// than or + /// equal to `1`. + /// + /// + [JsonProperty("interval")] + public int? Interval { get; set; } + + /// + /// The unit of time between customer charge dates. One of `weekly`, + /// `monthly` or `yearly`. + /// + [JsonProperty("interval_unit")] + public InstalmentScheduleIntervalUnit? IntervalUnit { get; set; } + /// + /// The unit of time between customer charge dates. One of `weekly`, + /// `monthly` or `yearly`. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum InstalmentScheduleIntervalUnit + { + + /// `interval_unit` with a value of "weekly" + [EnumMember(Value = "weekly")] + Weekly, + /// `interval_unit` with a value of "monthly" + [EnumMember(Value = "monthly")] + Monthly, + /// `interval_unit` with a value of "yearly" + [EnumMember(Value = "yearly")] + Yearly, + } + + /// + /// The date on which the first payment should be charged. Must be + /// on or after the [mandate](#core-endpoints-mandates)'s + /// `next_possible_charge_date`. When blank, this will be set as the + /// mandate's `next_possible_charge_date`. + /// + [JsonProperty("start_date")] + public string StartDate { get; set; } + } /// /// Linked resources. @@ -291,7 +593,6 @@ public class InstalmentScheduleLinks /// also be /// copied to the payments of the instalment schedule if you use /// schedule-based creation. - /// /// [JsonProperty("name")] public string Name { get; set; } @@ -317,8 +618,8 @@ public class InstalmentScheduleLinks /// /// On failure, automatically retry payments using [Optimise Smart - /// Payment Retries](#optimise-smart-payment-retries). Default is - /// `false`. + /// Payment + /// Retries](#optimise-smart-payment-retries). Default is `false`. /// [JsonProperty("retry_if_possible")] public bool? RetryIfPossible { get; set; } @@ -326,10 +627,11 @@ public class InstalmentScheduleLinks /// /// The total amount of the instalment schedule, defined as the sum of /// all individual - /// payments. If the requested payment amounts do not sum up correctly, - /// a validation - /// error will be returned. - /// + /// payments, in the lowest denomination for the currency (e.g. pence in + /// GBP, cents in + /// EUR). If the requested payment amounts do not sum up correctly, a + /// validation error + /// will be returned. /// [JsonProperty("total_amount")] public int? TotalAmount { get; set; } diff --git a/GoCardless/Services/SubscriptionService.cs b/GoCardless/Services/SubscriptionService.cs index 532e310..a3d202e 100644 --- a/GoCardless/Services/SubscriptionService.cs +++ b/GoCardless/Services/SubscriptionService.cs @@ -545,7 +545,7 @@ public class CreatedAtParam /// At most four valid status values /// [JsonProperty("status")] - public SubscriptionStatus[] Status { get; set; } + public string[] Status { get; set; } /// /// One of: ///
    diff --git a/README.md b/README.md index 10c5f2a..55827f2 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 3.4.1` +`Install-Package GoCardless -Version 3.5.0` ## Usage