From 9624ff1f3d299fdbd924ab662c6bda44a6879656 Mon Sep 17 00:00:00 2001 From: Sandilya Narahari Date: Tue, 7 Apr 2020 08:45:39 +0100 Subject: [PATCH 1/4] Increment the version (Patch version bump) --- GoCardless/GoCardless.csproj | 4 ++-- GoCardless/GoCardlessClient.cs | 4 ++-- README.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GoCardless/GoCardless.csproj b/GoCardless/GoCardless.csproj index 70760ee..45fec8a 100644 --- a/GoCardless/GoCardless.csproj +++ b/GoCardless/GoCardless.csproj @@ -2,7 +2,7 @@ GoCardless - 3.5.0 + 3.5.1 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.5.0 + https://github.com/gocardless/gocardless-dotnet/releases/tag/v3.5.1 netstandard1.6;netstandard2.0;net46 True true diff --git a/GoCardless/GoCardlessClient.cs b/GoCardless/GoCardlessClient.cs index e9f6039..c6d00a5 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.5.0"); + requestMessage.Headers.Add("User-Agent", "gocardless-dotnet/3.5.1"); requestMessage.Headers.Add("GoCardless-Version", "2015-07-06"); - requestMessage.Headers.Add("GoCardless-Client-Version", "3.5.0"); + requestMessage.Headers.Add("GoCardless-Client-Version", "3.5.1"); requestMessage.Headers.Add("GoCardless-Client-Library", "gocardless-dotnet"); requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _accessToken); diff --git a/README.md b/README.md index 55827f2..fce2d67 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.5.0` +`Install-Package GoCardless -Version 3.5.1` ## Usage From 1f0961e3e42df058601ab64aa20dae4ebb427942 Mon Sep 17 00:00:00 2001 From: Sandilya Narahari Date: Tue, 7 Apr 2020 08:52:55 +0100 Subject: [PATCH 2/4] Changes related to code comments --- GoCardless/Resources/BankDetailsLookup.cs | 9 ++- GoCardless/Resources/CreditorBankAccount.cs | 3 +- GoCardless/Resources/CustomerNotification.cs | 8 +- GoCardless/Resources/MandateImport.cs | 13 ++- GoCardless/Resources/MandateImportEntry.cs | 11 ++- GoCardless/Resources/PayoutItem.cs | 12 +-- GoCardless/Resources/Subscription.cs | 80 +++++++++++-------- .../Services/CreditorBankAccountService.cs | 3 +- .../Services/CustomerNotificationService.cs | 8 +- GoCardless/Services/CustomerService.cs | 6 +- .../Services/MandateImportEntryService.cs | 11 ++- GoCardless/Services/MandateImportService.cs | 13 ++- GoCardless/Services/MandateService.cs | 4 +- 13 files changed, 87 insertions(+), 94 deletions(-) diff --git a/GoCardless/Resources/BankDetailsLookup.cs b/GoCardless/Resources/BankDetailsLookup.cs index fb88abf..1e4dcac 100644 --- a/GoCardless/Resources/BankDetailsLookup.cs +++ b/GoCardless/Resources/BankDetailsLookup.cs @@ -29,10 +29,11 @@ public class BankDetailsLookup public string BankName { get; set; } /// - /// ISO 9362 SWIFT BIC of the bank with which the account is held.

Even if no BIC is returned for an account, GoCardless - /// may still be able to collect payments from it - you should refer to - /// the `available_debit_schemes` attribute to determine + /// ISO 9362 SWIFT BIC of the bank with which the account is held. + /// + ///

Even if no BIC is returned for an account, + /// GoCardless may still be able to collect payments from it - you + /// should refer to the `available_debit_schemes` attribute to determine /// reachability.

///
[JsonProperty("bic")] diff --git a/GoCardless/Resources/CreditorBankAccount.cs b/GoCardless/Resources/CreditorBankAccount.cs index 3ece3b1..85a4744 100644 --- a/GoCardless/Resources/CreditorBankAccount.cs +++ b/GoCardless/Resources/CreditorBankAccount.cs @@ -21,8 +21,7 @@ namespace GoCardless.Resources /// `links[creditor_bank_account]` in the error response. /// ///

Restricted: This API is - /// not available for - /// partner integrations.

+ /// not available for partner integrations.

/// public class CreditorBankAccount { diff --git a/GoCardless/Resources/CustomerNotification.cs b/GoCardless/Resources/CustomerNotification.cs index 0d9a9d4..038071d 100644 --- a/GoCardless/Resources/CustomerNotification.cs +++ b/GoCardless/Resources/CustomerNotification.cs @@ -21,11 +21,9 @@ namespace GoCardless.Resources /// way, it is no longer visible using this API. /// ///

Restricted: This API is - /// currently - /// only available for approved integrators - please get - /// in touch if you would like to use this API.

- /// + /// currently only available for approved integrators - please get in touch if you would like to + /// use this API.

/// public class CustomerNotification { diff --git a/GoCardless/Resources/MandateImport.cs b/GoCardless/Resources/MandateImport.cs index ea94557..eec5d4f 100644 --- a/GoCardless/Resources/MandateImport.cs +++ b/GoCardless/Resources/MandateImport.cs @@ -45,16 +45,13 @@ namespace GoCardless.Resources /// system](#mandate-import-entries-list-all-mandate-import-entries). /// ///

Note that all Mandate Imports have an upper limit of - /// 30,000 entries, so - /// we recommend you split your import into several smaller imports if - /// you're planning to - /// exceed this threshold.

+ /// 30,000 entries, so we recommend you split your import into several + /// smaller imports if you're planning to exceed this threshold.

/// ///

Restricted: This API is - /// currently - /// only available for approved integrators - please get - /// in touch if you would like to use this API.

+ /// currently only available for approved integrators - please get in touch if you would like to + /// use this API.

/// public class MandateImport { diff --git a/GoCardless/Resources/MandateImportEntry.cs b/GoCardless/Resources/MandateImportEntry.cs index a64cf51..034e6c4 100644 --- a/GoCardless/Resources/MandateImportEntry.cs +++ b/GoCardless/Resources/MandateImportEntry.cs @@ -37,11 +37,9 @@ namespace GoCardless.Resources /// been imported. /// ///

Restricted: This API is - /// currently - /// only available for approved integrators - please get - /// in touch if you would like to use this API.

- /// + /// currently only available for approved integrators - please get in touch if you would like to + /// use this API.

/// public class MandateImportEntry { @@ -62,7 +60,8 @@ public class MandateImportEntry /// A unique identifier for this entry, which you can use (once the /// import has been /// processed by GoCardless) to identify the records that have been - /// created. + /// created. Limited + /// to 255 characters. /// /// [JsonProperty("record_identifier")] diff --git a/GoCardless/Resources/PayoutItem.cs b/GoCardless/Resources/PayoutItem.cs index 2ffdd5f..ee9dcde 100644 --- a/GoCardless/Resources/PayoutItem.cs +++ b/GoCardless/Resources/PayoutItem.cs @@ -38,15 +38,11 @@ public class PayoutItem /// the lowest denomination for the currency (e.g. pence in GBP, cents /// in EUR), to one decimal place. ///

For accuracy, we store some of our fees to greater - /// precision than - /// we can actually pay out (for example, a GoCardless fee we record - /// might come to 0.5 - /// pence, but it is not possible to send a payout via bank transfer - /// including a half - /// penny).

To calculate the final amount of the payout, we sum - /// all of the items + /// precision than we can actually pay out (for example, a GoCardless + /// fee we record might come to 0.5 pence, but it is not possible to + /// send a payout via bank transfer including a half penny).

To + /// calculate the final amount of the payout, we sum all of the items /// and then round to the nearest currency unit.

- /// /// [JsonProperty("amount")] public string Amount { get; set; } diff --git a/GoCardless/Resources/Subscription.cs b/GoCardless/Resources/Subscription.cs index 7110c7b..ca6d95e 100644 --- a/GoCardless/Resources/Subscription.cs +++ b/GoCardless/Resources/Subscription.cs @@ -18,40 +18,46 @@ namespace GoCardless.Resources /// The following rules apply when specifying recurrence: /// /// - The first payment must be charged within 1 year. - /// - When neither `month` nor `day_of_month` are present, the subscription - /// will recur from the `start_date` based on the `interval_unit`. - /// - If `month` or `day_of_month` are present, the recurrence rules will be - /// applied from the `start_date`, and the following validations apply: + /// - If `day_of_month` and `start_date` are not provided `start_date` will + /// be the [mandate](#core-endpoints-mandates)'s `next_possible_charge_date` + /// and the subscription will then recur based on the `interval` & + /// `interval_unit` + /// - If `month` or `day_of_month` are present the following validations + /// apply: /// - /// | interval_unit | month | - /// day_of_month | - /// | :-------------- | :--------------------------------------------- | - /// :-------------------------------------- | - /// | yearly | optional (required if `day_of_month` provided) | - /// optional (required if `month` provided) | - /// | monthly | invalid | - /// required | - /// | weekly | invalid | - /// invalid | + /// | __interval_unit__ | __month__ | + /// __day_of_month__ | + /// | :---------------- | :--------------------------------------------- | + /// :----------------------------------------- | + /// | yearly | optional (required if `day_of_month` provided) | + /// optional (invalid if `month` not provided) | + /// | monthly | invalid | + /// optional | + /// | weekly | invalid | + /// invalid | /// /// Examples: /// - /// | interval_unit | interval | month | day_of_month | valid? - /// | - /// | :-------------- | :--------- | :------ | :------------- | + /// | __interval_unit__ | __interval__ | __month__ | __day_of_month__ | + /// valid? | + /// | :---------------- | :----------- | :-------- | :--------------- | /// :------------------------------------------------- | - /// | yearly | 1 | january | -1 | valid - /// | - /// | yearly | 1 | march | | invalid - - /// missing `day_of_month` | - /// | monthly | 6 | | 12 | valid - /// | - /// | monthly | 6 | august | 12 | invalid - - /// `month` must be blank | - /// | weekly | 2 | | | valid - /// | - /// | weekly | 2 | october | 10 | invalid - - /// `month` and `day_of_month` must be blank | + /// | yearly | 1 | january | -1 | + /// valid | + /// | monthly | 6 | | | + /// valid | + /// | monthly | 6 | | 12 | + /// valid | + /// | weekly | 2 | | | + /// valid | + /// | yearly | 1 | march | | + /// invalid - missing `day_of_month` | + /// | yearly | 1 | | 2 | + /// invalid - missing `month` | + /// | monthly | 6 | august | 12 | + /// invalid - `month` must be blank | + /// | weekly | 2 | october | 10 | + /// invalid - `month` and `day_of_month` must be blank | /// /// ### Rolling dates /// @@ -175,11 +181,14 @@ public class Subscription /// /// An optional payment reference. This will be set as the reference on - /// each payment created and will appear on your customer's bank - /// statement. See the documentation for the [create payment - /// endpoint](#payments-create-a-payment) for more details.

Restricted: You need your - /// own Service User Number to specify a payment reference for Bacs + /// each payment + /// created and will appear on your customer's bank statement. See the + /// documentation for + /// the [create payment endpoint](#payments-create-a-payment) for more + /// details. + /// + ///

Restricted: You need + /// your own Service User Number to specify a payment reference for Bacs /// payments.

///
[JsonProperty("payment_reference")] @@ -215,6 +224,8 @@ public class Subscription /// this subscription have been created ///
  • `cancelled`: the subscription has been cancelled and will no /// longer create payments
  • + ///
  • `paused`: the subscription has been paused and will not create + /// payments
  • /// /// [JsonProperty("status")] @@ -313,6 +324,7 @@ public enum SubscriptionMonth { ///
  • `finished`: all of the payments scheduled for creation under this subscription have been /// created
  • ///
  • `cancelled`: the subscription has been cancelled and will no longer create payments
  • + ///
  • `paused`: the subscription has been paused and will not create payments
  • /// /// [JsonConverter(typeof(StringEnumConverter))] diff --git a/GoCardless/Services/CreditorBankAccountService.cs b/GoCardless/Services/CreditorBankAccountService.cs index ba693f2..e1ad54d 100644 --- a/GoCardless/Services/CreditorBankAccountService.cs +++ b/GoCardless/Services/CreditorBankAccountService.cs @@ -27,8 +27,7 @@ namespace GoCardless.Services /// `links[creditor_bank_account]` in the error response. /// ///

    Restricted: This API is - /// not available for - /// partner integrations.

    + /// not available for partner integrations.

    /// public class CreditorBankAccountService diff --git a/GoCardless/Services/CustomerNotificationService.cs b/GoCardless/Services/CustomerNotificationService.cs index e7b86ac..af66a26 100644 --- a/GoCardless/Services/CustomerNotificationService.cs +++ b/GoCardless/Services/CustomerNotificationService.cs @@ -27,11 +27,9 @@ namespace GoCardless.Services /// way, it is no longer visible using this API. /// ///

    Restricted: This API is - /// currently - /// only available for approved integrators - please get - /// in touch if you would like to use this API.

    - /// + /// currently only available for approved integrators - please get in touch if you would like to + /// use this API.

    /// public class CustomerNotificationService diff --git a/GoCardless/Services/CustomerService.cs b/GoCardless/Services/CustomerService.cs index 8a55337..bb97a21 100644 --- a/GoCardless/Services/CustomerService.cs +++ b/GoCardless/Services/CustomerService.cs @@ -155,8 +155,7 @@ public Task UpdateAsync(string identity, CustomerUpdateRequest /// ID. /// ///

    The action of removing a - /// customer cannot be - /// reversed, so please use with care.

    + /// customer cannot be reversed, so please use with care.

    /// /// Unique identifier, beginning with "CU". /// An optional `CustomerRemoveRequest` representing the body for this remove request. @@ -562,8 +561,7 @@ public class CustomerUpdateRequest /// ID. /// ///

    The action of removing a customer - /// cannot be - /// reversed, so please use with care.

    + /// cannot be reversed, so please use with care.

    /// public class CustomerRemoveRequest { diff --git a/GoCardless/Services/MandateImportEntryService.cs b/GoCardless/Services/MandateImportEntryService.cs index f9a9f05..36d486e 100644 --- a/GoCardless/Services/MandateImportEntryService.cs +++ b/GoCardless/Services/MandateImportEntryService.cs @@ -43,11 +43,9 @@ namespace GoCardless.Services /// been imported. /// ///

    Restricted: This API is - /// currently - /// only available for approved integrators - please get - /// in touch if you would like to use this API.

    - /// + /// currently only available for approved integrators - please get in touch if you would like to + /// use this API.

    /// public class MandateImportEntryService @@ -405,7 +403,8 @@ public class MandateImportEntryLinks /// A unique identifier for this entry, which you can use (once the /// import has been /// processed by GoCardless) to identify the records that have been - /// created. + /// created. Limited + /// to 255 characters. /// /// [JsonProperty("record_identifier")] diff --git a/GoCardless/Services/MandateImportService.cs b/GoCardless/Services/MandateImportService.cs index db04842..651b0c1 100644 --- a/GoCardless/Services/MandateImportService.cs +++ b/GoCardless/Services/MandateImportService.cs @@ -51,16 +51,13 @@ namespace GoCardless.Services /// system](#mandate-import-entries-list-all-mandate-import-entries). /// ///

    Note that all Mandate Imports have an upper limit of - /// 30,000 entries, so - /// we recommend you split your import into several smaller imports if - /// you're planning to - /// exceed this threshold.

    + /// 30,000 entries, so we recommend you split your import into several + /// smaller imports if you're planning to exceed this threshold.

    /// ///

    Restricted: This API is - /// currently - /// only available for approved integrators - please get - /// in touch if you would like to use this API.

    + /// currently only available for approved integrators - please get in touch if you would like to + /// use this API.

    /// public class MandateImportService diff --git a/GoCardless/Services/MandateService.cs b/GoCardless/Services/MandateService.cs index d9bd92d..7904b18 100644 --- a/GoCardless/Services/MandateService.cs +++ b/GoCardless/Services/MandateService.cs @@ -184,7 +184,7 @@ public Task CancelAsync(string identity, MandateCancelRequest r /// This will fail with a `mandate_not_inactive` error if the mandate is /// already being submitted, or is active. /// - /// Mandates can be resubmitted up to 3 times. + /// Mandates can be resubmitted up to 10 times. /// /// Unique identifier, beginning with "MD". Note that this prefix may not apply to mandates created before 2016. /// An optional `MandateReinstateRequest` representing the body for this reinstate request. @@ -481,7 +481,7 @@ public class MandateCancelRequest /// This will fail with a `mandate_not_inactive` error if the mandate is /// already being submitted, or is active. /// - /// Mandates can be resubmitted up to 3 times. + /// Mandates can be resubmitted up to 10 times. /// public class MandateReinstateRequest { From 2a3a1cf2f8b846ba3c70a8648c4cc240d45a88f0 Mon Sep 17 00:00:00 2001 From: Sandilya Narahari Date: Tue, 7 Apr 2020 08:53:23 +0100 Subject: [PATCH 3/4] Add metadata param to redirect flow creation endpoint --- GoCardless/Resources/RedirectFlow.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/GoCardless/Resources/RedirectFlow.cs b/GoCardless/Resources/RedirectFlow.cs index 260e320..76f1ec2 100644 --- a/GoCardless/Resources/RedirectFlow.cs +++ b/GoCardless/Resources/RedirectFlow.cs @@ -85,6 +85,13 @@ public class RedirectFlow [JsonProperty("links")] public RedirectFlowLinks Links { 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; } + /// /// The URL of the hosted payment pages for this redirect flow. This is /// the URL you should redirect your customer to. From e52a0bdd5972d5e81cc9c5caf1ad26436fcab8d6 Mon Sep 17 00:00:00 2001 From: Sandilya Narahari Date: Tue, 7 Apr 2020 08:53:53 +0100 Subject: [PATCH 4/4] Add the ability to pause and resume a subscription. Modify earliest charge date for paused subscriptions --- GoCardless/Resources/Subscription.cs | 24 +- GoCardless/Services/RedirectFlowService.cs | 7 + GoCardless/Services/SubscriptionService.cs | 293 +++++++++++++++++---- 3 files changed, 274 insertions(+), 50 deletions(-) diff --git a/GoCardless/Resources/Subscription.cs b/GoCardless/Resources/Subscription.cs index ca6d95e..1b9a733 100644 --- a/GoCardless/Resources/Subscription.cs +++ b/GoCardless/Resources/Subscription.cs @@ -119,12 +119,23 @@ public class Subscription public int? DayOfMonth { get; set; } /// - /// Date on or after which no further payments should be created. If - /// this field is blank and `count` is not specified, the subscription - /// will continue forever.

    Deprecated: This field + /// The earliest date that will be used as a `charge_date` on payments + /// created for this subscription if it is resumed. Only present for + /// `paused` subscriptions. + /// This value will change over time. + ///

    + [JsonProperty("earliest_charge_date_after_resume")] + public string EarliestChargeDateAfterResume { get; set; } + + /// + /// Date on or after which no further payments should be created. + /// + /// If this field is blank and `count` is not specified, the + /// subscription will continue forever. + /// + ///

    Deprecated: This field /// will be removed in a future API version. Use `count` to specify a - /// number of payments instead.

    + /// number of payments instead.

    ///
    [JsonProperty("end_date")] public string EndDate { get; set; } @@ -345,6 +356,9 @@ public enum SubscriptionStatus { /// `status` with a value of "cancelled" [EnumMember(Value = "cancelled")] Cancelled, + /// `status` with a value of "paused" + [EnumMember(Value = "paused")] + Paused, } /// diff --git a/GoCardless/Services/RedirectFlowService.cs b/GoCardless/Services/RedirectFlowService.cs index 6ebbc44..2abd6c9 100644 --- a/GoCardless/Services/RedirectFlowService.cs +++ b/GoCardless/Services/RedirectFlowService.cs @@ -167,6 +167,13 @@ public class RedirectFlowLinks public string Creditor { 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; } + /// /// Information used to prefill the payment page so your customer /// doesn't have to re-type details you already hold about them. It will diff --git a/GoCardless/Services/SubscriptionService.cs b/GoCardless/Services/SubscriptionService.cs index a3d202e..766122f 100644 --- a/GoCardless/Services/SubscriptionService.cs +++ b/GoCardless/Services/SubscriptionService.cs @@ -24,40 +24,46 @@ namespace GoCardless.Services /// The following rules apply when specifying recurrence: /// /// - The first payment must be charged within 1 year. - /// - When neither `month` nor `day_of_month` are present, the subscription - /// will recur from the `start_date` based on the `interval_unit`. - /// - If `month` or `day_of_month` are present, the recurrence rules will be - /// applied from the `start_date`, and the following validations apply: - /// - /// | interval_unit | month | - /// day_of_month | - /// | :-------------- | :--------------------------------------------- | - /// :-------------------------------------- | - /// | yearly | optional (required if `day_of_month` provided) | - /// optional (required if `month` provided) | - /// | monthly | invalid | - /// required | - /// | weekly | invalid | - /// invalid | + /// - If `day_of_month` and `start_date` are not provided `start_date` will + /// be the [mandate](#core-endpoints-mandates)'s `next_possible_charge_date` + /// and the subscription will then recur based on the `interval` & + /// `interval_unit` + /// - If `month` or `day_of_month` are present the following validations + /// apply: + /// + /// | __interval_unit__ | __month__ | + /// __day_of_month__ | + /// | :---------------- | :--------------------------------------------- | + /// :----------------------------------------- | + /// | yearly | optional (required if `day_of_month` provided) | + /// optional (invalid if `month` not provided) | + /// | monthly | invalid | + /// optional | + /// | weekly | invalid | + /// invalid | /// /// Examples: /// - /// | interval_unit | interval | month | day_of_month | valid? - /// | - /// | :-------------- | :--------- | :------ | :------------- | + /// | __interval_unit__ | __interval__ | __month__ | __day_of_month__ | + /// valid? | + /// | :---------------- | :----------- | :-------- | :--------------- | /// :------------------------------------------------- | - /// | yearly | 1 | january | -1 | valid - /// | - /// | yearly | 1 | march | | invalid - - /// missing `day_of_month` | - /// | monthly | 6 | | 12 | valid - /// | - /// | monthly | 6 | august | 12 | invalid - - /// `month` must be blank | - /// | weekly | 2 | | | valid - /// | - /// | weekly | 2 | october | 10 | invalid - - /// `month` and `day_of_month` must be blank | + /// | yearly | 1 | january | -1 | + /// valid | + /// | monthly | 6 | | | + /// valid | + /// | monthly | 6 | | 12 | + /// valid | + /// | weekly | 2 | | | + /// valid | + /// | yearly | 1 | march | | + /// invalid - missing `day_of_month` | + /// | yearly | 1 | | 2 | + /// invalid - missing `month` | + /// | monthly | 6 | august | 12 | + /// invalid - `month` must be blank | + /// | weekly | 2 | october | 10 | + /// invalid - `month` and `day_of_month` must be blank | /// /// ### Rolling dates /// @@ -222,6 +228,100 @@ public Task UpdateAsync(string identity, SubscriptionUpdat return _goCardlessClient.ExecuteAsync("PUT", "/subscriptions/:identity", urlParams, request, null, "subscriptions", customiseRequestMessage); } + /// + /// Pause a subscription object. + /// No payments will be created until it is resumed. + /// + /// This can only be used when a subscription collecting a fixed number + /// of payments (created using `count`) + /// or when they continue forever (created without `count` or + /// `end_date`) + /// + /// When `pause_cycles` is omitted the subscription is paused until the + /// [resume endpoint](#subscriptions-resume-a-subscription) is called. + /// If the subscription is collecting a fixed number of payments, + /// `end_date` will be set to `nil`. + /// When paused indefinitely, `upcoming_payments` will be empty. + /// + /// When `pause_cycles` is provided the subscription will be paused for + /// the number of cycles requested. + /// If the subscription is collecting a fixed number of payments, + /// `end_date` will be set to a new value. + /// When paused for a number of cycles, `upcoming_payments` will still + /// contain the upcoming charge dates. + /// + /// This fails with: + /// + /// - `forbidden` if the subscription was created by an app and you are + /// not authenticated as that app, or if the subscription was not + /// created by an app and you are authenticated as an app + /// + /// - `validation_failed` if invalid data is provided when attempting to + /// pause a subscription. + /// + /// - `subscription_not_active` if the subscription is no longer active. + /// + /// - `subscription_already_ended` if the subscription has taken all + /// payments. + /// + /// - `pause_cycles_must_be_greater_than_or_equal_to` if the provided + /// value for `pause_cycles` cannot be satisfied. + /// + /// + /// Unique identifier, beginning with "SB". + /// An optional `SubscriptionPauseRequest` representing the body for this pause request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single subscription resource + public Task PauseAsync(string identity, SubscriptionPauseRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SubscriptionPauseRequest(); + if (identity == null) throw new ArgumentException(nameof(identity)); + + var urlParams = new List> + { + new KeyValuePair("identity", identity), + }; + + return _goCardlessClient.ExecuteAsync("POST", "/subscriptions/:identity/actions/pause", urlParams, request, null, "data", customiseRequestMessage); + } + + /// + /// Resume a subscription object. + /// Payments will start to be created again based on the subscriptions + /// recurrence rules. + /// + /// This fails with: + /// + /// - `forbidden` if the subscription was created by an app and you are + /// not authenticated as that app, or if the subscription was not + /// created by an app and you are authenticated as an app + /// + /// - `validation_failed` if invalid data is provided when attempting to + /// resume a subscription. + /// + /// - `subscription_not_paused` if the subscription is not paused. + /// + /// - `subscription_already_scheduled_to_resume` if a subscription + /// already has a scheduled resume date. + /// + /// + /// Unique identifier, beginning with "SB". + /// An optional `SubscriptionResumeRequest` representing the body for this resume request. + /// An optional `RequestSettings` allowing you to configure the request + /// A single subscription resource + public Task ResumeAsync(string identity, SubscriptionResumeRequest request = null, RequestSettings customiseRequestMessage = null) + { + request = request ?? new SubscriptionResumeRequest(); + if (identity == null) throw new ArgumentException(nameof(identity)); + + var urlParams = new List> + { + new KeyValuePair("identity", identity), + }; + + return _goCardlessClient.ExecuteAsync("POST", "/subscriptions/:identity/actions/resume", urlParams, request, null, "data", customiseRequestMessage); + } + /// /// Immediately cancels a subscription; no more payments will be created /// under it. Any metadata supplied to this endpoint will be stored on @@ -294,12 +394,14 @@ public class SubscriptionCreateRequest : IHasIdempotencyKey public int? DayOfMonth { get; set; } /// - /// Date on or after which no further payments should be created. If - /// this field is blank and `count` is not specified, the subscription - /// will continue forever.

    Deprecated: This field + /// Date on or after which no further payments should be created. + /// + /// If this field is blank and `count` is not specified, the + /// subscription will continue forever. + /// + ///

    Deprecated: This field /// will be removed in a future API version. Use `count` to specify a - /// number of payments instead.

    + /// number of payments instead.

    ///
    [JsonProperty("end_date")] public string EndDate { get; set; } @@ -430,11 +532,14 @@ public enum SubscriptionMonth /// /// An optional payment reference. This will be set as the reference on - /// each payment created and will appear on your customer's bank - /// statement. See the documentation for the [create payment - /// endpoint](#payments-create-a-payment) for more details.

    Restricted: You need your - /// own Service User Number to specify a payment reference for Bacs + /// each payment + /// created and will appear on your customer's bank statement. See the + /// documentation for + /// the [create payment endpoint](#payments-create-a-payment) for more + /// details. + /// + ///

    Restricted: You need + /// your own Service User Number to specify a payment reference for Bacs /// payments.

    ///
    [JsonProperty("payment_reference")] @@ -559,6 +664,8 @@ public class CreatedAtParam /// this subscription have been created ///
  • `cancelled`: the subscription has been cancelled and will no /// longer create payments
  • + ///
  • `paused`: the subscription has been paused and will not create + /// payments
  • /// ///
    [JsonConverter(typeof(StringEnumConverter))] @@ -580,6 +687,9 @@ public enum SubscriptionStatus /// `status` with a value of "cancelled" [EnumMember(Value = "cancelled")] Cancelled, + /// `status` with a value of "paused" + [EnumMember(Value = "paused")] + Paused, } } @@ -656,11 +766,14 @@ public class SubscriptionUpdateRequest /// /// An optional payment reference. This will be set as the reference on - /// each payment created and will appear on your customer's bank - /// statement. See the documentation for the [create payment - /// endpoint](#payments-create-a-payment) for more details.

    Restricted: You need your - /// own Service User Number to specify a payment reference for Bacs + /// each payment + /// created and will appear on your customer's bank statement. See the + /// documentation for + /// the [create payment endpoint](#payments-create-a-payment) for more + /// details. + /// + ///

    Restricted: You need + /// your own Service User Number to specify a payment reference for Bacs /// payments.

    ///
    [JsonProperty("payment_reference")] @@ -668,6 +781,96 @@ public class SubscriptionUpdateRequest } + /// + /// Pause a subscription object. + /// No payments will be created until it is resumed. + /// + /// This can only be used when a subscription collecting a fixed number of + /// payments (created using `count`) + /// or when they continue forever (created without `count` or `end_date`) + /// + /// When `pause_cycles` is omitted the subscription is paused until the + /// [resume endpoint](#subscriptions-resume-a-subscription) is called. + /// If the subscription is collecting a fixed number of payments, `end_date` + /// will be set to `nil`. + /// When paused indefinitely, `upcoming_payments` will be empty. + /// + /// When `pause_cycles` is provided the subscription will be paused for the + /// number of cycles requested. + /// If the subscription is collecting a fixed number of payments, `end_date` + /// will be set to a new value. + /// When paused for a number of cycles, `upcoming_payments` will still + /// contain the upcoming charge dates. + /// + /// This fails with: + /// + /// - `forbidden` if the subscription was created by an app and you are not + /// authenticated as that app, or if the subscription was not created by an + /// app and you are authenticated as an app + /// + /// - `validation_failed` if invalid data is provided when attempting to + /// pause a subscription. + /// + /// - `subscription_not_active` if the subscription is no longer active. + /// + /// - `subscription_already_ended` if the subscription has taken all + /// payments. + /// + /// - `pause_cycles_must_be_greater_than_or_equal_to` if the provided value + /// for `pause_cycles` cannot be satisfied. + /// + /// + public class SubscriptionPauseRequest + { + + /// + /// 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; } + + /// + /// The number of cycles to pause a subscription for. A cycle is one + /// duration of `interval` and `interval_unit`. + /// + [JsonProperty("pause_cycles")] + public int? PauseCycles { get; set; } + } + + + /// + /// Resume a subscription object. + /// Payments will start to be created again based on the subscriptions + /// recurrence rules. + /// + /// This fails with: + /// + /// - `forbidden` if the subscription was created by an app and you are not + /// authenticated as that app, or if the subscription was not created by an + /// app and you are authenticated as an app + /// + /// - `validation_failed` if invalid data is provided when attempting to + /// resume a subscription. + /// + /// - `subscription_not_paused` if the subscription is not paused. + /// + /// - `subscription_already_scheduled_to_resume` if a subscription already + /// has a scheduled resume date. + /// + /// + public class SubscriptionResumeRequest + { + + /// + /// 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; } + } + + /// /// Immediately cancels a subscription; no more payments will be created /// under it. Any metadata supplied to this endpoint will be stored on the