From 16f04b82d599004383f097fa4c0d3080165bbe75 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:00:04 +0000 Subject: [PATCH 1/6] Changes generated by 27bb168a71a1451a60141a047064ef0d9856112d This commit was automatically created from gocardless/gocardless-pro-java-template@27bb168a71a1451a60141a047064ef0d9856112d by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-java-template/actions/runs/11038495118 --- .../gocardless/resources/BillingRequest.java | 168 --------- .../services/BillingRequestService.java | 328 ------------------ 2 files changed, 496 deletions(-) diff --git a/src/main/java/com/gocardless/resources/BillingRequest.java b/src/main/java/com/gocardless/resources/BillingRequest.java index e5d66982..9ba90610 100644 --- a/src/main/java/com/gocardless/resources/BillingRequest.java +++ b/src/main/java/com/gocardless/resources/BillingRequest.java @@ -31,7 +31,6 @@ private BillingRequest() { private PurposeCode purposeCode; private Resources resources; private Status status; - private SubscriptionRequest subscriptionRequest; /** * List of actions that can be performed before this billing request can be fulfilled. @@ -120,13 +119,6 @@ public Status getStatus() { return status; } - /** - * Request for a subscription - */ - public SubscriptionRequest getSubscriptionRequest() { - return subscriptionRequest; - } - public enum PurposeCode { @SerializedName("mortgage") MORTGAGE, @SerializedName("utility") @@ -391,7 +383,6 @@ private Links() { private String paymentProvider; private String paymentRequest; private String paymentRequestPayment; - private String subscriptionRequest; /** * (Optional) ID of the [bank authorisation](#billing-requests-bank-authorisations) that was @@ -473,13 +464,6 @@ public String getPaymentRequest() { public String getPaymentRequestPayment() { return paymentRequestPayment; } - - /** - * (Optional) ID of the associated subscription request - */ - public String getSubscriptionRequest() { - return subscriptionRequest; - } } /** @@ -1284,156 +1268,4 @@ public String getSwedishIdentityNumber() { } } } - - /** - * Represents a subscription request resource returned from the API. - * - * Request for a subscription - */ - public static class SubscriptionRequest { - private SubscriptionRequest() { - // blank to prevent instantiation - } - - private Integer amount; - private Integer appFee; - private Integer count; - private String currency; - private Integer dayOfMonth; - private Integer interval; - private IntervalUnit intervalUnit; - private Map metadata; - private Month month; - private String name; - private String paymentReference; - private String startDate; - - /** - * Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). - */ - public Integer getAmount() { - return amount; - } - - /** - * 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). - */ - public Integer getAppFee() { - return appFee; - } - - /** - * The total number of payments that should be taken by this subscription. - */ - public Integer getCount() { - return count; - } - - /** - * [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. - */ - public String getCurrency() { - return currency; - } - - /** - * As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to - * indicate the last day of the month. - */ - public Integer getDayOfMonth() { - return dayOfMonth; - } - - /** - * Number of `interval_units` between customer charge dates. Must be greater than or equal - * to `1`. Must result in at least one charge date per year. Defaults to `1`. - */ - public Integer getInterval() { - return interval; - } - - /** - * The unit of time between customer charge dates. One of `weekly`, `monthly` or `yearly`. - */ - public IntervalUnit getIntervalUnit() { - return intervalUnit; - } - - /** - * 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. - */ - public Map getMetadata() { - return metadata; - } - - /** - * Name of the month on which to charge a customer. Must be lowercase. Only applies when the - * interval_unit is `yearly`. - * - */ - public Month getMonth() { - return month; - } - - /** - * Optional name for the subscription. This will be set as the description on each payment - * created. Must not exceed 255 characters. - */ - public String getName() { - return name; - } - - /** - * 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 payments. - *

- */ - public String getPaymentReference() { - return paymentReference; - } - - /** - * 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 left blank and - * `month` or `day_of_month` are provided, this will be set to the date of the first - * payment. If created without `month` or `day_of_month` this will be set as the mandate's - * `next_possible_charge_date` - */ - public String getStartDate() { - return startDate; - } - - public enum IntervalUnit { - @SerializedName("weekly") - WEEKLY, @SerializedName("monthly") - MONTHLY, @SerializedName("yearly") - YEARLY, @SerializedName("unknown") - UNKNOWN - } - - public enum Month { - @SerializedName("january") - JANUARY, @SerializedName("february") - FEBRUARY, @SerializedName("march") - MARCH, @SerializedName("april") - APRIL, @SerializedName("may") - MAY, @SerializedName("june") - JUNE, @SerializedName("july") - JULY, @SerializedName("august") - AUGUST, @SerializedName("september") - SEPTEMBER, @SerializedName("october") - OCTOBER, @SerializedName("november") - NOVEMBER, @SerializedName("december") - DECEMBER, @SerializedName("unknown") - UNKNOWN - } - } } diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index 0ca322c6..3dc82c6a 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -167,7 +167,6 @@ public static final class BillingRequestCreateRequest private Map metadata; private PaymentRequest paymentRequest; private PurposeCode purposeCode; - private SubscriptionRequest subscriptionRequest; /** * (Optional) If true, this billing request can fallback from instant payment to direct @@ -501,167 +500,6 @@ public BillingRequestCreateRequest withPurposeCode(PurposeCode purposeCode) { return this; } - public BillingRequestCreateRequest withSubscriptionRequest( - SubscriptionRequest subscriptionRequest) { - this.subscriptionRequest = subscriptionRequest; - return this; - } - - /** - * Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). - */ - public BillingRequestCreateRequest withSubscriptionRequestAmount(Integer amount) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withAmount(amount); - return this; - } - - /** - * 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). - */ - public BillingRequestCreateRequest withSubscriptionRequestAppFee(Integer appFee) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withAppFee(appFee); - return this; - } - - /** - * The total number of payments that should be taken by this subscription. - */ - public BillingRequestCreateRequest withSubscriptionRequestCount(Integer count) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withCount(count); - return this; - } - - /** - * [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. - */ - public BillingRequestCreateRequest withSubscriptionRequestCurrency(String currency) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withCurrency(currency); - return this; - } - - /** - * As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to - * indicate the last day of the month. - */ - public BillingRequestCreateRequest withSubscriptionRequestDayOfMonth(Integer dayOfMonth) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withDayOfMonth(dayOfMonth); - return this; - } - - /** - * Number of `interval_units` between customer charge dates. Must be greater than or equal - * to `1`. Must result in at least one charge date per year. Defaults to `1`. - */ - public BillingRequestCreateRequest withSubscriptionRequestInterval(Integer interval) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withInterval(interval); - return this; - } - - /** - * The unit of time between customer charge dates. One of `weekly`, `monthly` or `yearly`. - */ - public BillingRequestCreateRequest withSubscriptionRequestIntervalUnit( - SubscriptionRequest.IntervalUnit intervalUnit) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withIntervalUnit(intervalUnit); - return this; - } - - /** - * 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. - */ - public BillingRequestCreateRequest withSubscriptionRequestMetadata( - Map metadata) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withMetadata(metadata); - return this; - } - - /** - * Name of the month on which to charge a customer. Must be lowercase. Only applies when the - * interval_unit is `yearly`. - * - */ - public BillingRequestCreateRequest withSubscriptionRequestMonth( - SubscriptionRequest.Month month) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withMonth(month); - return this; - } - - /** - * Optional name for the subscription. This will be set as the description on each payment - * created. Must not exceed 255 characters. - */ - public BillingRequestCreateRequest withSubscriptionRequestName(String name) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withName(name); - return this; - } - - /** - * 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 payments. - *

- */ - public BillingRequestCreateRequest withSubscriptionRequestPaymentReference( - String paymentReference) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withPaymentReference(paymentReference); - return this; - } - - /** - * 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 left blank and - * `month` or `day_of_month` are provided, this will be set to the date of the first - * payment. If created without `month` or `day_of_month` this will be set as the mandate's - * `next_possible_charge_date` - */ - public BillingRequestCreateRequest withSubscriptionRequestStartDate(String startDate) { - if (subscriptionRequest == null) { - subscriptionRequest = new SubscriptionRequest(); - } - subscriptionRequest.withStartDate(startDate); - return this; - } - public BillingRequestCreateRequest withIdempotencyKey(String idempotencyKey) { super.setIdempotencyKey(idempotencyKey); return this; @@ -1168,172 +1006,6 @@ public String toString() { } } } - - public static class SubscriptionRequest { - private Integer amount; - private Integer appFee; - private Integer count; - private String currency; - private Integer dayOfMonth; - private Integer interval; - private IntervalUnit intervalUnit; - private Map metadata; - private Month month; - private String name; - private String paymentReference; - private String startDate; - - /** - * Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). - */ - public SubscriptionRequest withAmount(Integer amount) { - this.amount = amount; - return this; - } - - /** - * 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). - */ - public SubscriptionRequest withAppFee(Integer appFee) { - this.appFee = appFee; - return this; - } - - /** - * The total number of payments that should be taken by this subscription. - */ - public SubscriptionRequest withCount(Integer count) { - this.count = count; - return this; - } - - /** - * [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. - */ - public SubscriptionRequest withCurrency(String currency) { - this.currency = currency; - return this; - } - - /** - * As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to - * indicate the last day of the month. - */ - public SubscriptionRequest withDayOfMonth(Integer dayOfMonth) { - this.dayOfMonth = dayOfMonth; - return this; - } - - /** - * Number of `interval_units` between customer charge dates. Must be greater than or - * equal to `1`. Must result in at least one charge date per year. Defaults to `1`. - */ - public SubscriptionRequest withInterval(Integer interval) { - this.interval = interval; - return this; - } - - /** - * The unit of time between customer charge dates. One of `weekly`, `monthly` or - * `yearly`. - */ - public SubscriptionRequest withIntervalUnit(IntervalUnit intervalUnit) { - this.intervalUnit = intervalUnit; - return this; - } - - /** - * 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. - */ - public SubscriptionRequest withMetadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Name of the month on which to charge a customer. Must be lowercase. Only applies when - * the interval_unit is `yearly`. - * - */ - public SubscriptionRequest withMonth(Month month) { - this.month = month; - return this; - } - - /** - * Optional name for the subscription. This will be set as the description on each - * payment created. Must not exceed 255 characters. - */ - public SubscriptionRequest withName(String name) { - this.name = name; - return this; - } - - /** - * 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 payments. - *

- */ - public SubscriptionRequest withPaymentReference(String paymentReference) { - this.paymentReference = paymentReference; - return this; - } - - /** - * 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 left blank - * and `month` or `day_of_month` are provided, this will be set to the date of the first - * payment. If created without `month` or `day_of_month` this will be set as the - * mandate's `next_possible_charge_date` - */ - public SubscriptionRequest withStartDate(String startDate) { - this.startDate = startDate; - return this; - } - - public enum IntervalUnit { - @SerializedName("weekly") - WEEKLY, @SerializedName("monthly") - MONTHLY, @SerializedName("yearly") - YEARLY, @SerializedName("unknown") - UNKNOWN; - - @Override - public String toString() { - return name().toLowerCase(); - } - } - - public enum Month { - @SerializedName("january") - JANUARY, @SerializedName("february") - FEBRUARY, @SerializedName("march") - MARCH, @SerializedName("april") - APRIL, @SerializedName("may") - MAY, @SerializedName("june") - JUNE, @SerializedName("july") - JULY, @SerializedName("august") - AUGUST, @SerializedName("september") - SEPTEMBER, @SerializedName("october") - OCTOBER, @SerializedName("november") - NOVEMBER, @SerializedName("december") - DECEMBER, @SerializedName("unknown") - UNKNOWN; - - @Override - public String toString() { - return name().toLowerCase(); - } - } - } } /** From 771110da541c09ffac3e2cc49cb12bba815afb94 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 13:13:04 +0000 Subject: [PATCH 2/6] Changes generated by c8939115bd6320568f3249ee7926eee8aface132 This commit was automatically created from gocardless/gocardless-pro-java-template@c8939115bd6320568f3249ee7926eee8aface132 by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-java-template/actions/runs/11292980537 --- .../services/BillingRequestService.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index 3dc82c6a..a9788e25 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -474,6 +474,26 @@ public BillingRequestCreateRequest withPaymentRequestReference(String reference) return this; } + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to be + * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ *

+ * Important: This is not applicable to IBP and VRP payments. + *

+ */ + public BillingRequestCreateRequest withPaymentRequestRetryIfPossible( + Boolean retryIfPossible) { + if (paymentRequest == null) { + paymentRequest = new PaymentRequest(); + } + paymentRequest.withRetryIfPossible(retryIfPossible); + return this; + } + /** * (Optional) A scheme used for Open Banking payments. Currently `faster_payments` is * supported in the UK (GBP) and `sepa_credit_transfer` and `sepa_instant_credit_transfer` @@ -909,6 +929,7 @@ public static class PaymentRequest { private FundsSettlement fundsSettlement; private Map metadata; private String reference; + private Boolean retryIfPossible; private String scheme; /** @@ -981,6 +1002,22 @@ public PaymentRequest withReference(String reference) { return this; } + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to + * be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ *

+ * Important: This is not applicable to IBP and VRP payments. + *

+ */ + public PaymentRequest withRetryIfPossible(Boolean retryIfPossible) { + this.retryIfPossible = retryIfPossible; + return this; + } + /** * (Optional) A scheme used for Open Banking payments. Currently `faster_payments` is * supported in the UK (GBP) and `sepa_credit_transfer` and From c553274d25b5d48f21a0f9ecaef769da3af98405 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:18:42 +0000 Subject: [PATCH 3/6] Changes generated by 72694f31f3c3b26443159a02f2c6e830e8ae4730 This commit was automatically created from gocardless/gocardless-pro-java-template@72694f31f3c3b26443159a02f2c6e830e8ae4730 by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-java-template/actions/runs/11347987613 --- .../com/gocardless/resources/BillingRequestFlow.java | 9 +++++++++ .../gocardless/services/BillingRequestFlowService.java | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/com/gocardless/resources/BillingRequestFlow.java b/src/main/java/com/gocardless/resources/BillingRequestFlow.java index fea439d3..1e96834c 100644 --- a/src/main/java/com/gocardless/resources/BillingRequestFlow.java +++ b/src/main/java/com/gocardless/resources/BillingRequestFlow.java @@ -31,6 +31,7 @@ private BillingRequestFlow() { private String sessionToken; private Boolean showRedirectButtons; private Boolean showSuccessRedirectButton; + private Boolean skipSuccessScreen; /** * URL for a GC-controlled flow which will allow the payer to fulfil the billing request @@ -182,6 +183,14 @@ public Boolean getShowSuccessRedirectButton() { return showSuccessRedirectButton; } + /** + * If true, the payer will not be redirected to the success screen after completing the flow. A + * redirect_uri needs to be provided for this parameter to be taken into account. + */ + public Boolean getSkipSuccessScreen() { + return skipSuccessScreen; + } + public static class Links { private Links() { // blank to prevent instantiation diff --git a/src/main/java/com/gocardless/services/BillingRequestFlowService.java b/src/main/java/com/gocardless/services/BillingRequestFlowService.java index 399d234c..4eeddcec 100644 --- a/src/main/java/com/gocardless/services/BillingRequestFlowService.java +++ b/src/main/java/com/gocardless/services/BillingRequestFlowService.java @@ -59,6 +59,7 @@ public static final class BillingRequestFlowCreateRequest private String redirectUri; private Boolean showRedirectButtons; private Boolean showSuccessRedirectButton; + private Boolean skipSuccessScreen; /** * (Experimental feature) Fulfil the Billing Request on completion of the flow (true by @@ -373,6 +374,15 @@ public BillingRequestFlowCreateRequest withShowSuccessRedirectButton( return this; } + /** + * If true, the payer will not be redirected to the success screen after completing the + * flow. A redirect_uri needs to be provided for this parameter to be taken into account. + */ + public BillingRequestFlowCreateRequest withSkipSuccessScreen(Boolean skipSuccessScreen) { + this.skipSuccessScreen = skipSuccessScreen; + return this; + } + private BillingRequestFlowCreateRequest(HttpClient httpClient) { super(httpClient); } From d79f63200c22db54140456eb17013df10e544802 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:05:58 +0000 Subject: [PATCH 4/6] Changes generated by a0104762f99f4015350335655b84ee6bd162586e This commit was automatically created from gocardless/gocardless-pro-java-template@a0104762f99f4015350335655b84ee6bd162586e by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-java-template/actions/runs/11681827105 --- .../java/com/gocardless/resources/BillingRequest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/gocardless/resources/BillingRequest.java b/src/main/java/com/gocardless/resources/BillingRequest.java index 9ba90610..8a7c93ab 100644 --- a/src/main/java/com/gocardless/resources/BillingRequest.java +++ b/src/main/java/com/gocardless/resources/BillingRequest.java @@ -23,6 +23,7 @@ private BillingRequest() { private List actions; private String createdAt; private Boolean fallbackEnabled; + private Boolean fallbackOccurred; private String id; private Links links; private MandateRequest mandateRequest; @@ -58,6 +59,13 @@ public Boolean getFallbackEnabled() { return fallbackEnabled; } + /** + * True if the billing request was completed with direct debit. + */ + public Boolean getFallbackOccurred() { + return fallbackOccurred; + } + /** * Unique identifier, beginning with "BRQ". */ From 3a1b7597ec3593b74119b11e5c903328307daed1 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:16:12 +0000 Subject: [PATCH 5/6] Changes generated by 851cb46811f8b7e3d0057a0c31e11e412a6b1594 This commit was automatically created from gocardless/gocardless-pro-java-template@851cb46811f8b7e3d0057a0c31e11e412a6b1594 by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-java-template/actions/runs/12123374750 --- .../gocardless/resources/BillingRequest.java | 382 ++++++++++- .../services/BillingRequestService.java | 611 +++++++++++++++++- 2 files changed, 989 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gocardless/resources/BillingRequest.java b/src/main/java/com/gocardless/resources/BillingRequest.java index 8a7c93ab..de4bf608 100644 --- a/src/main/java/com/gocardless/resources/BillingRequest.java +++ b/src/main/java/com/gocardless/resources/BillingRequest.java @@ -14,6 +14,10 @@ * See [Billing Requests: * Overview](https://developer.gocardless.com/getting-started/billing-requests/overview/) for * how-to's, explanations and tutorials. + *

+ * Important: All properties associated with `subscription_request` and + * `instalment_schedule_request` are only supported for ACH and PAD schemes. + *

*/ public class BillingRequest { private BillingRequest() { @@ -25,6 +29,7 @@ private BillingRequest() { private Boolean fallbackEnabled; private Boolean fallbackOccurred; private String id; + private InstalmentScheduleRequest instalmentScheduleRequest; private Links links; private MandateRequest mandateRequest; private Map metadata; @@ -32,6 +37,7 @@ private BillingRequest() { private PurposeCode purposeCode; private Resources resources; private Status status; + private SubscriptionRequest subscriptionRequest; /** * List of actions that can be performed before this billing request can be fulfilled. @@ -73,6 +79,13 @@ public String getId() { return id; } + /** + * Request for an instalment schedule + */ + public InstalmentScheduleRequest getInstalmentScheduleRequest() { + return instalmentScheduleRequest; + } + public Links getLinks() { return links; } @@ -127,6 +140,13 @@ public Status getStatus() { return status; } + /** + * Request for a subscription + */ + public SubscriptionRequest getSubscriptionRequest() { + return subscriptionRequest; + } + public enum PurposeCode { @SerializedName("mortgage") MORTGAGE, @SerializedName("utility") @@ -375,6 +395,135 @@ public List getCustomerBillingDetail() { } } + /** + * Represents a instalment schedule request resource returned from the API. + * + * Request for an instalment schedule + */ + public static class InstalmentScheduleRequest { + private InstalmentScheduleRequest() { + // blank to prevent instantiation + } + + private Integer appFee; + private Currency currency; + private List instalments; + private Links links; + private Map metadata; + private String name; + private String paymentReference; + private Boolean retryIfPossible; + private Integer totalAmount; + + /** + * 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). + */ + public Integer getAppFee() { + return appFee; + } + + /** + * [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. + */ + public Currency getCurrency() { + return currency; + } + + /** + * instalments to be created. See [create (with + * dates)](#instalment-schedules-create-with-dates) and [create (with + * schedule)](#instalment-schedules-create-with-schedule) for more information on how to + * specify instalments. + */ + public List getInstalments() { + return instalments; + } + + public Links getLinks() { + return links; + } + + /** + * 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. + */ + public Map getMetadata() { + return metadata; + } + + /** + * 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. + */ + public String getName() { + return name; + } + + /** + * 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.
+ */ + public String getPaymentReference() { + return paymentReference; + } + + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to be + * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ */ + public Boolean getRetryIfPossible() { + return retryIfPossible; + } + + /** + * 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. + */ + public Integer getTotalAmount() { + return totalAmount; + } + + public enum Currency { + @SerializedName("AUD") + AUD, @SerializedName("CAD") + CAD, @SerializedName("DKK") + DKK, @SerializedName("EUR") + EUR, @SerializedName("GBP") + GBP, @SerializedName("NZD") + NZD, @SerializedName("SEK") + SEK, @SerializedName("USD") + USD, @SerializedName("unknown") + UNKNOWN + } + + public static class Links { + private Links() { + // blank to prevent instantiation + } + + private String instalmentSchedule; + + /** + * (Optional) ID of the [instalment_schedule](#core-endpoints-instalment-schedules) that + * was created from this instalment schedule request. + * + */ + public String getInstalmentSchedule() { + return instalmentSchedule; + } + } + } + public static class Links { private Links() { // blank to prevent instantiation @@ -385,12 +534,16 @@ private Links() { private String customer; private String customerBankAccount; private String customerBillingDetail; + private String instalmentScheduleRequest; + private String instalmentScheduleRequestInstalmentSchedule; private String mandateRequest; private String mandateRequestMandate; private String organisation; private String paymentProvider; private String paymentRequest; private String paymentRequestPayment; + private String subscriptionRequest; + private String subscriptionRequestSubscription; /** * (Optional) ID of the [bank authorisation](#billing-requests-bank-authorisations) that was @@ -429,6 +582,21 @@ public String getCustomerBillingDetail() { return customerBillingDetail; } + /** + * (Optional) ID of the associated instalment schedule request + */ + public String getInstalmentScheduleRequest() { + return instalmentScheduleRequest; + } + + /** + * (Optional) ID of the [instalment_schedule](#core-endpoints-instalment-schedules) that was + * created from this instalment schedule request. + */ + public String getInstalmentScheduleRequestInstalmentSchedule() { + return instalmentScheduleRequestInstalmentSchedule; + } + /** * (Optional) ID of the associated mandate request */ @@ -472,6 +640,21 @@ public String getPaymentRequest() { public String getPaymentRequestPayment() { return paymentRequestPayment; } + + /** + * (Optional) ID of the associated subscription request + */ + public String getSubscriptionRequest() { + return subscriptionRequest; + } + + /** + * (Optional) ID of the [subscription](#core-endpoints-subscriptions) that was created from + * this subscription request. + */ + public String getSubscriptionRequestSubscription() { + return subscriptionRequestSubscription; + } } /** @@ -511,8 +694,9 @@ public AuthorisationSource getAuthorisationSource() { /** * This attribute represents the authorisation type between the payer and merchant. It can - * be set to one-off, recurring or standing for ACH scheme. And single, recurring and - * sporadic for PAD scheme. + * be set to `one_off`, `recurring` or `standing` for ACH scheme. And `single`, `recurring` + * and `sporadic` for PAD scheme. _Note:_ This is only supported for ACH and PAD schemes. + * */ public String getConsentType() { return consentType; @@ -632,6 +816,7 @@ private Constraints() { private String endDate; private Integer maxAmountPerPayment; + private String paymentMethod; private List periodicLimits; private String startDate; @@ -655,6 +840,15 @@ public Integer getMaxAmountPerPayment() { return maxAmountPerPayment; } + /** + * A constraint where you can specify info (free text string) about how payments are + * calculated. _Note:_ This is only supported for ACH and PAD schemes. + * + */ + public String getPaymentMethod() { + return paymentMethod; + } + /** * List of periodic limits and constraints which apply to them */ @@ -1276,4 +1470,188 @@ public String getSwedishIdentityNumber() { } } } + + /** + * Represents a subscription request resource returned from the API. + * + * Request for a subscription + */ + public static class SubscriptionRequest { + private SubscriptionRequest() { + // blank to prevent instantiation + } + + private Integer amount; + private Integer appFee; + private Integer count; + private String currency; + private Integer dayOfMonth; + private Integer interval; + private IntervalUnit intervalUnit; + private Links links; + private Map metadata; + private Month month; + private String name; + private String paymentReference; + private Boolean retryIfPossible; + private String startDate; + + /** + * Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). + */ + public Integer getAmount() { + return amount; + } + + /** + * 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). + */ + public Integer getAppFee() { + return appFee; + } + + /** + * The total number of payments that should be taken by this subscription. + */ + public Integer getCount() { + return count; + } + + /** + * [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. + */ + public String getCurrency() { + return currency; + } + + /** + * As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to + * indicate the last day of the month. + */ + public Integer getDayOfMonth() { + return dayOfMonth; + } + + /** + * Number of `interval_units` between customer charge dates. Must be greater than or equal + * to `1`. Must result in at least one charge date per year. Defaults to `1`. + */ + public Integer getInterval() { + return interval; + } + + /** + * The unit of time between customer charge dates. One of `weekly`, `monthly` or `yearly`. + */ + public IntervalUnit getIntervalUnit() { + return intervalUnit; + } + + public Links getLinks() { + return links; + } + + /** + * 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. + */ + public Map getMetadata() { + return metadata; + } + + /** + * Name of the month on which to charge a customer. Must be lowercase. Only applies when the + * interval_unit is `yearly`. + * + */ + public Month getMonth() { + return month; + } + + /** + * Optional name for the subscription. This will be set as the description on each payment + * created. Must not exceed 255 characters. + */ + public String getName() { + return name; + } + + /** + * 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.
+ */ + public String getPaymentReference() { + return paymentReference; + } + + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to be + * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ */ + public Boolean getRetryIfPossible() { + return retryIfPossible; + } + + /** + * The date on which the first payment should be charged. If fulfilled after this date, this + * will be set as the mandate's `next_possible_charge_date`. When left blank and `month` or + * `day_of_month` are provided, this will be set to the date of the first payment. If + * created without `month` or `day_of_month` this will be set as the mandate's + * `next_possible_charge_date`. + * + */ + public String getStartDate() { + return startDate; + } + + public enum IntervalUnit { + @SerializedName("weekly") + WEEKLY, @SerializedName("monthly") + MONTHLY, @SerializedName("yearly") + YEARLY, @SerializedName("unknown") + UNKNOWN + } + + public enum Month { + @SerializedName("january") + JANUARY, @SerializedName("february") + FEBRUARY, @SerializedName("march") + MARCH, @SerializedName("april") + APRIL, @SerializedName("may") + MAY, @SerializedName("june") + JUNE, @SerializedName("july") + JULY, @SerializedName("august") + AUGUST, @SerializedName("september") + SEPTEMBER, @SerializedName("october") + OCTOBER, @SerializedName("november") + NOVEMBER, @SerializedName("december") + DECEMBER, @SerializedName("unknown") + UNKNOWN + } + + public static class Links { + private Links() { + // blank to prevent instantiation + } + + private String subscription; + + /** + * (Optional) ID of the [subscription](#core-endpoints-subscriptions) that was created + * from this subscription request. + * + */ + public String getSubscription() { + return subscription; + } + } + } } diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index a9788e25..9ffc7059 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -19,6 +19,10 @@ * See [Billing Requests: * Overview](https://developer.gocardless.com/getting-started/billing-requests/overview/) for * how-to's, explanations and tutorials. + *

+ * Important: All properties associated with `subscription_request` and + * `instalment_schedule_request` are only supported for ACH and PAD schemes. + *

*/ public class BillingRequestService { private final HttpClient httpClient; @@ -32,7 +36,10 @@ public BillingRequestService(HttpClient httpClient) { } /** - * + *

+ * Important: All properties associated with `subscription_request` and + * `instalment_schedule_request` are only supported for ACH and PAD schemes. + *

*/ public BillingRequestCreateRequest create() { return new BillingRequestCreateRequest(httpClient); @@ -157,16 +164,21 @@ public BillingRequestSelectInstitutionRequest selectInstitution(String identity) /** * Request class for {@link BillingRequestService#create }. * - * + *

+ * Important: All properties associated with `subscription_request` and + * `instalment_schedule_request` are only supported for ACH and PAD schemes. + *

*/ public static final class BillingRequestCreateRequest extends IdempotentPostRequest { private Boolean fallbackEnabled; + private InstalmentScheduleRequest instalmentScheduleRequest; private Links links; private MandateRequest mandateRequest; private Map metadata; private PaymentRequest paymentRequest; private PurposeCode purposeCode; + private SubscriptionRequest subscriptionRequest; /** * (Optional) If true, this billing request can fallback from instant payment to direct @@ -181,6 +193,124 @@ public BillingRequestCreateRequest withFallbackEnabled(Boolean fallbackEnabled) return this; } + public BillingRequestCreateRequest withInstalmentScheduleRequest( + InstalmentScheduleRequest instalmentScheduleRequest) { + this.instalmentScheduleRequest = instalmentScheduleRequest; + return this; + } + + /** + * 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). + */ + public BillingRequestCreateRequest withInstalmentScheduleRequestAppFee(Integer appFee) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withAppFee(appFee); + return this; + } + + /** + * [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. + */ + public BillingRequestCreateRequest withInstalmentScheduleRequestCurrency( + InstalmentScheduleRequest.Currency currency) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withCurrency(currency); + return this; + } + + /** + * instalments to be created. See [create (with + * dates)](#instalment-schedules-create-with-dates) and [create (with + * schedule)](#instalment-schedules-create-with-schedule) for more information on how to + * specify instalments. + */ + public BillingRequestCreateRequest withInstalmentScheduleRequestInstalments( + List instalments) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withInstalments(instalments); + return this; + } + + /** + * 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. + */ + public BillingRequestCreateRequest withInstalmentScheduleRequestMetadata( + Map metadata) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withMetadata(metadata); + return this; + } + + /** + * 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. + */ + public BillingRequestCreateRequest withInstalmentScheduleRequestName(String name) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withName(name); + return this; + } + + /** + * 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.
+ */ + public BillingRequestCreateRequest withInstalmentScheduleRequestPaymentReference( + String paymentReference) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withPaymentReference(paymentReference); + return this; + } + + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to be + * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ */ + public BillingRequestCreateRequest withInstalmentScheduleRequestRetryIfPossible( + Boolean retryIfPossible) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withRetryIfPossible(retryIfPossible); + return this; + } + + /** + * 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. + */ + public BillingRequestCreateRequest withInstalmentScheduleRequestTotalAmount( + Integer totalAmount) { + if (instalmentScheduleRequest == null) { + instalmentScheduleRequest = new InstalmentScheduleRequest(); + } + instalmentScheduleRequest.withTotalAmount(totalAmount); + return this; + } + public BillingRequestCreateRequest withLinks(Links links) { this.links = links; return this; @@ -520,6 +650,181 @@ public BillingRequestCreateRequest withPurposeCode(PurposeCode purposeCode) { return this; } + public BillingRequestCreateRequest withSubscriptionRequest( + SubscriptionRequest subscriptionRequest) { + this.subscriptionRequest = subscriptionRequest; + return this; + } + + /** + * Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). + */ + public BillingRequestCreateRequest withSubscriptionRequestAmount(Integer amount) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withAmount(amount); + return this; + } + + /** + * 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). + */ + public BillingRequestCreateRequest withSubscriptionRequestAppFee(Integer appFee) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withAppFee(appFee); + return this; + } + + /** + * The total number of payments that should be taken by this subscription. + */ + public BillingRequestCreateRequest withSubscriptionRequestCount(Integer count) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withCount(count); + return this; + } + + /** + * [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. + */ + public BillingRequestCreateRequest withSubscriptionRequestCurrency(String currency) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withCurrency(currency); + return this; + } + + /** + * As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to + * indicate the last day of the month. + */ + public BillingRequestCreateRequest withSubscriptionRequestDayOfMonth(Integer dayOfMonth) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withDayOfMonth(dayOfMonth); + return this; + } + + /** + * Number of `interval_units` between customer charge dates. Must be greater than or equal + * to `1`. Must result in at least one charge date per year. Defaults to `1`. + */ + public BillingRequestCreateRequest withSubscriptionRequestInterval(Integer interval) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withInterval(interval); + return this; + } + + /** + * The unit of time between customer charge dates. One of `weekly`, `monthly` or `yearly`. + */ + public BillingRequestCreateRequest withSubscriptionRequestIntervalUnit( + SubscriptionRequest.IntervalUnit intervalUnit) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withIntervalUnit(intervalUnit); + return this; + } + + /** + * 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. + */ + public BillingRequestCreateRequest withSubscriptionRequestMetadata( + Map metadata) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withMetadata(metadata); + return this; + } + + /** + * Name of the month on which to charge a customer. Must be lowercase. Only applies when the + * interval_unit is `yearly`. + * + */ + public BillingRequestCreateRequest withSubscriptionRequestMonth( + SubscriptionRequest.Month month) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withMonth(month); + return this; + } + + /** + * Optional name for the subscription. This will be set as the description on each payment + * created. Must not exceed 255 characters. + */ + public BillingRequestCreateRequest withSubscriptionRequestName(String name) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withName(name); + return this; + } + + /** + * 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.
+ */ + public BillingRequestCreateRequest withSubscriptionRequestPaymentReference( + String paymentReference) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withPaymentReference(paymentReference); + return this; + } + + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to be + * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ */ + public BillingRequestCreateRequest withSubscriptionRequestRetryIfPossible( + Boolean retryIfPossible) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withRetryIfPossible(retryIfPossible); + return this; + } + + /** + * The date on which the first payment should be charged. If fulfilled after this date, this + * will be set as the mandate's `next_possible_charge_date`. When left blank and `month` or + * `day_of_month` are provided, this will be set to the date of the first payment. If + * created without `month` or `day_of_month` this will be set as the mandate's + * `next_possible_charge_date`. + * + */ + public BillingRequestCreateRequest withSubscriptionRequestStartDate(String startDate) { + if (subscriptionRequest == null) { + subscriptionRequest = new SubscriptionRequest(); + } + subscriptionRequest.withStartDate(startDate); + return this; + } + public BillingRequestCreateRequest withIdempotencyKey(String idempotencyKey) { super.setIdempotencyKey(idempotencyKey); return this; @@ -585,6 +890,117 @@ public String toString() { } } + public static class InstalmentScheduleRequest { + private Integer appFee; + private Currency currency; + private List instalments; + private Map metadata; + private String name; + private String paymentReference; + private Boolean retryIfPossible; + private Integer totalAmount; + + /** + * 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). + */ + public InstalmentScheduleRequest withAppFee(Integer appFee) { + this.appFee = appFee; + return this; + } + + /** + * [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. + */ + public InstalmentScheduleRequest withCurrency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * instalments to be created. See [create (with + * dates)](#instalment-schedules-create-with-dates) and [create (with + * schedule)](#instalment-schedules-create-with-schedule) for more information on how to + * specify instalments. + */ + public InstalmentScheduleRequest withInstalments(List instalments) { + this.instalments = instalments; + return this; + } + + /** + * 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. + */ + public InstalmentScheduleRequest withMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * 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. + */ + public InstalmentScheduleRequest withName(String name) { + this.name = name; + return this; + } + + /** + * 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.
+ */ + public InstalmentScheduleRequest withPaymentReference(String paymentReference) { + this.paymentReference = paymentReference; + return this; + } + + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to + * be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ */ + public InstalmentScheduleRequest withRetryIfPossible(Boolean retryIfPossible) { + this.retryIfPossible = retryIfPossible; + return this; + } + + /** + * 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. + */ + public InstalmentScheduleRequest withTotalAmount(Integer totalAmount) { + this.totalAmount = totalAmount; + return this; + } + + public enum Currency { + @SerializedName("AUD") + AUD, @SerializedName("CAD") + CAD, @SerializedName("DKK") + DKK, @SerializedName("EUR") + EUR, @SerializedName("GBP") + GBP, @SerializedName("NZD") + NZD, @SerializedName("SEK") + SEK, @SerializedName("USD") + USD, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name(); + } + } + } + public static class Links { private String creditor; private String customer; @@ -716,6 +1132,7 @@ public String toString() { public static class Constraints { private String endDate; private Integer maxAmountPerPayment; + private String paymentMethod; private List periodicLimits; private String startDate; @@ -741,6 +1158,16 @@ public Constraints withMaxAmountPerPayment(Integer maxAmountPerPayment) { return this; } + /** + * A constraint where you can specify info (free text string) about how payments are + * calculated. _Note:_ This is only supported for ACH and PAD schemes. + * + */ + public Constraints withPaymentMethod(String paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + /** * List of periodic limits and constraints which apply to them */ @@ -769,6 +1196,9 @@ public Map getQueryParams() { if (maxAmountPerPayment != null) { params.put("constraints[max_amount_per_payment]", maxAmountPerPayment); } + if (paymentMethod != null) { + params.put("constraints[payment_method]", paymentMethod); + } if (periodicLimits != null) { params.put("constraints[periodic_limits]", periodicLimits); } @@ -1043,6 +1473,183 @@ public String toString() { } } } + + public static class SubscriptionRequest { + private Integer amount; + private Integer appFee; + private Integer count; + private String currency; + private Integer dayOfMonth; + private Integer interval; + private IntervalUnit intervalUnit; + private Map metadata; + private Month month; + private String name; + private String paymentReference; + private Boolean retryIfPossible; + private String startDate; + + /** + * Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). + */ + public SubscriptionRequest withAmount(Integer amount) { + this.amount = amount; + return this; + } + + /** + * 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). + */ + public SubscriptionRequest withAppFee(Integer appFee) { + this.appFee = appFee; + return this; + } + + /** + * The total number of payments that should be taken by this subscription. + */ + public SubscriptionRequest withCount(Integer count) { + this.count = count; + return this; + } + + /** + * [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. + */ + public SubscriptionRequest withCurrency(String currency) { + this.currency = currency; + return this; + } + + /** + * As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to + * indicate the last day of the month. + */ + public SubscriptionRequest withDayOfMonth(Integer dayOfMonth) { + this.dayOfMonth = dayOfMonth; + return this; + } + + /** + * Number of `interval_units` between customer charge dates. Must be greater than or + * equal to `1`. Must result in at least one charge date per year. Defaults to `1`. + */ + public SubscriptionRequest withInterval(Integer interval) { + this.interval = interval; + return this; + } + + /** + * The unit of time between customer charge dates. One of `weekly`, `monthly` or + * `yearly`. + */ + public SubscriptionRequest withIntervalUnit(IntervalUnit intervalUnit) { + this.intervalUnit = intervalUnit; + return this; + } + + /** + * 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. + */ + public SubscriptionRequest withMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Name of the month on which to charge a customer. Must be lowercase. Only applies when + * the interval_unit is `yearly`. + * + */ + public SubscriptionRequest withMonth(Month month) { + this.month = month; + return this; + } + + /** + * Optional name for the subscription. This will be set as the description on each + * payment created. Must not exceed 255 characters. + */ + public SubscriptionRequest withName(String name) { + this.name = name; + return this; + } + + /** + * 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.
+ */ + public SubscriptionRequest withPaymentReference(String paymentReference) { + this.paymentReference = paymentReference; + return this; + } + + /** + * On failure, automatically retry payments using [intelligent + * retries](#success-intelligent-retries). Default is `false`. + *

+ * Important: To be able to use intelligent retries, Success+ needs to + * be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). + *

+ */ + public SubscriptionRequest withRetryIfPossible(Boolean retryIfPossible) { + this.retryIfPossible = retryIfPossible; + return this; + } + + /** + * The date on which the first payment should be charged. If fulfilled after this date, + * this will be set as the mandate's `next_possible_charge_date`. When left blank and + * `month` or `day_of_month` are provided, this will be set to the date of the first + * payment. If created without `month` or `day_of_month` this will be set as the + * mandate's `next_possible_charge_date`. + * + */ + public SubscriptionRequest withStartDate(String startDate) { + this.startDate = startDate; + return this; + } + + public enum IntervalUnit { + @SerializedName("weekly") + WEEKLY, @SerializedName("monthly") + MONTHLY, @SerializedName("yearly") + YEARLY, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + + public enum Month { + @SerializedName("january") + JANUARY, @SerializedName("february") + FEBRUARY, @SerializedName("march") + MARCH, @SerializedName("april") + APRIL, @SerializedName("may") + MAY, @SerializedName("june") + JUNE, @SerializedName("july") + JULY, @SerializedName("august") + AUGUST, @SerializedName("september") + SEPTEMBER, @SerializedName("october") + OCTOBER, @SerializedName("november") + NOVEMBER, @SerializedName("december") + DECEMBER, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + } } /** From c2795d907f881c3df88909dc0c051e0ad962ee10 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:43:14 +0000 Subject: [PATCH 6/6] Changes generated by b24c038da677f67706f77745f899ac26cc72a8d4 This commit was automatically created from gocardless/gocardless-pro-java-template@b24c038da677f67706f77745f899ac26cc72a8d4 by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-pro-java-template/actions/runs/12123878341 --- README.md | 4 ++-- build.gradle | 2 +- src/main/java/com/gocardless/http/HttpClient.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1438e0f7..7be53b2c 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ With Maven: com.gocardless gocardless-pro - 6.0.0 + 6.1.0 ``` With Gradle: ``` -implementation 'com.gocardless:gocardless-pro:6.0.0' +implementation 'com.gocardless:gocardless-pro:6.1.0' ``` ## Initializing the client diff --git a/build.gradle b/build.gradle index 785f1dd0..b1d67a39 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ plugins { sourceCompatibility = 1.8 targetCompatibility = 1.8 group = 'com.gocardless' -version = '6.0.0' +version = '6.1.0' apply plugin: 'ch.raffael.pegdown-doclet' diff --git a/src/main/java/com/gocardless/http/HttpClient.java b/src/main/java/com/gocardless/http/HttpClient.java index faf8ea0a..1240e82e 100644 --- a/src/main/java/com/gocardless/http/HttpClient.java +++ b/src/main/java/com/gocardless/http/HttpClient.java @@ -35,7 +35,7 @@ public class HttpClient { private static final String DISALLOWED_USER_AGENT_CHARACTERS = "[^\\w!#$%&'\\*\\+\\-\\.\\^`\\|~]"; private static final String USER_AGENT = - String.format("gocardless-pro-java/6.0.0 java/%s %s/%s %s/%s", + String.format("gocardless-pro-java/6.1.0 java/%s %s/%s %s/%s", cleanUserAgentToken(System.getProperty("java.vm.specification.version")), cleanUserAgentToken(System.getProperty("java.vm.name")), cleanUserAgentToken(System.getProperty("java.version")), @@ -49,7 +49,7 @@ public class HttpClient { builder.put("GoCardless-Version", "2015-07-06"); builder.put("Accept", "application/json"); builder.put("GoCardless-Client-Library", "gocardless-pro-java"); - builder.put("GoCardless-Client-Version", "6.0.0"); + builder.put("GoCardless-Client-Version", "6.1.0"); HEADERS = builder.build(); } private final OkHttpClient rawClient;