diff --git a/src/main/java/com/gocardless/GoCardlessClient.java b/src/main/java/com/gocardless/GoCardlessClient.java
index c9bc75f5..4a54b034 100644
--- a/src/main/java/com/gocardless/GoCardlessClient.java
+++ b/src/main/java/com/gocardless/GoCardlessClient.java
@@ -21,6 +21,7 @@ public class GoCardlessClient {
private final BillingRequestService billingRequests;
private final BillingRequestFlowService billingRequestFlows;
private final BillingRequestTemplateService billingRequestTemplates;
+ private final BillingRequestWithActionService billingRequestWithActions;
private final BlockService blocks;
private final CreditorService creditors;
private final CreditorBankAccountService creditorBankAccounts;
@@ -181,6 +182,7 @@ private GoCardlessClient(HttpClient httpClient) {
this.billingRequests = new BillingRequestService(httpClient);
this.billingRequestFlows = new BillingRequestFlowService(httpClient);
this.billingRequestTemplates = new BillingRequestTemplateService(httpClient);
+ this.billingRequestWithActions = new BillingRequestWithActionService(httpClient);
this.blocks = new BlockService(httpClient);
this.creditors = new CreditorService(httpClient);
this.creditorBankAccounts = new CreditorBankAccountService(httpClient);
@@ -264,6 +266,13 @@ public BillingRequestTemplateService billingRequestTemplates() {
return billingRequestTemplates;
}
+ /**
+ * A service class for working with billing request with action resources.
+ */
+ public BillingRequestWithActionService billingRequestWithActions() {
+ return billingRequestWithActions;
+ }
+
/**
* A service class for working with block resources.
*/
diff --git a/src/main/java/com/gocardless/resources/BillingRequestWithAction.java b/src/main/java/com/gocardless/resources/BillingRequestWithAction.java
new file mode 100644
index 00000000..3f6f6961
--- /dev/null
+++ b/src/main/java/com/gocardless/resources/BillingRequestWithAction.java
@@ -0,0 +1,1980 @@
+package com.gocardless.resources;
+
+import com.google.gson.annotations.SerializedName;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a billing request with action resource returned from the API.
+ *
+ * Billing Requests help create resources that require input or action from a customer. An example
+ * of required input might be additional customer billing details, while an action would be asking a
+ * customer to authorise a payment using their mobile banking app.
+ *
+ * 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 BillingRequestWithAction {
+ private BillingRequestWithAction() {
+ // blank to prevent instantiation
+ }
+
+ private BankAuthorisations bankAuthorisations;
+ private BillingRequests billingRequests;
+
+ /**
+ * Bank Authorisations can be used to authorise Billing Requests. Authorisations are created
+ * against a specific bank, usually the bank that provides the payer's account.
+ *
+ * Creation of Bank Authorisations is only permitted from GoCardless hosted UIs (see Billing
+ * Request Flows) to ensure we meet regulatory requirements for checkout flows.
+ */
+ public BankAuthorisations getBankAuthorisations() {
+ return bankAuthorisations;
+ }
+
+ /**
+ * Billing Requests help create resources that require input or action from a customer. An
+ * example of required input might be additional customer billing details, while an action would
+ * be asking a customer to authorise a payment using their mobile banking app.
+ *
+ * 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 BillingRequests getBillingRequests() {
+ return billingRequests;
+ }
+
+ /**
+ * Represents a bank authorisation resource returned from the API.
+ *
+ * Bank Authorisations can be used to authorise Billing Requests. Authorisations are created
+ * against a specific bank, usually the bank that provides the payer's account.
+ *
+ * Creation of Bank Authorisations is only permitted from GoCardless hosted UIs (see Billing
+ * Request Flows) to ensure we meet regulatory requirements for checkout flows.
+ */
+ public static class BankAuthorisations {
+ private BankAuthorisations() {
+ // blank to prevent instantiation
+ }
+
+ private AuthorisationType authorisationType;
+ private String authorisedAt;
+ private String createdAt;
+ private String expiresAt;
+ private String id;
+ private String lastVisitedAt;
+ private Links links;
+ private String qrCodeUrl;
+ private String redirectUri;
+ private String url;
+
+ /**
+ * Type of authorisation, can be either 'mandate' or 'payment'.
+ */
+ public AuthorisationType getAuthorisationType() {
+ return authorisationType;
+ }
+
+ /**
+ * Fixed [timestamp](#api-usage-dates-and-times), recording when the user has been
+ * authorised.
+ */
+ public String getAuthorisedAt() {
+ return authorisedAt;
+ }
+
+ /**
+ * Timestamp when the flow was created
+ */
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ /**
+ * Timestamp when the url will expire. Each authorisation url currently lasts for 15
+ * minutes, but this can vary by bank.
+ */
+ public String getExpiresAt() {
+ return expiresAt;
+ }
+
+ /**
+ * Unique identifier, beginning with "BAU".
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Fixed [timestamp](#api-usage-dates-and-times), recording when the authorisation URL has
+ * been visited.
+ */
+ public String getLastVisitedAt() {
+ return lastVisitedAt;
+ }
+
+ public Links getLinks() {
+ return links;
+ }
+
+ /**
+ * URL to a QR code PNG image of the bank authorisation url. This QR code can be used as an
+ * alternative to providing the `url` to the payer to allow them to authorise with their
+ * mobile devices.
+ */
+ public String getQrCodeUrl() {
+ return qrCodeUrl;
+ }
+
+ /**
+ * URL that the payer can be redirected to after authorising the payment.
+ *
+ * On completion of bank authorisation, the query parameter of either `outcome=success` or
+ * `outcome=failure` will be appended to the `redirect_uri` to indicate the result of the
+ * bank authorisation. If the bank authorisation is expired, the query parameter
+ * `outcome=timeout` will be appended to the `redirect_uri`, in which case you should prompt
+ * the user to try the bank authorisation step again.
+ *
+ * Please note: bank authorisations can still fail despite an `outcome=success` on the
+ * `redirect_uri`. It is therefore recommended to wait for the relevant bank authorisation
+ * event, such as
+ * [`BANK_AUTHORISATION_AUTHORISED`](#billing-request-bankauthorisationauthorised),
+ * [`BANK_AUTHORISATION_DENIED`](#billing-request-bankauthorisationdenied), or
+ * [`BANK_AUTHORISATION_FAILED`](#billing-request-bankauthorisationfailed) in order to show
+ * the correct outcome to the user.
+ *
+ * The BillingRequestFlow ID will also be appended to the `redirect_uri` as query parameter
+ * `id=BRF123`.
+ *
+ * Defaults to `https://pay.gocardless.com/billing/static/thankyou`.
+ */
+ public String getRedirectUri() {
+ return redirectUri;
+ }
+
+ /**
+ * URL for an oauth flow that will allow the user to authorise the payment
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ public enum AuthorisationType {
+ @SerializedName("mandate")
+ MANDATE, @SerializedName("payment")
+ PAYMENT, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public static class Links {
+ private Links() {
+ // blank to prevent instantiation
+ }
+
+ private String billingRequest;
+ private String institution;
+
+ /**
+ * ID of the [billing request](#billing-requests-billing-requests) against which this
+ * authorisation was created.
+ */
+ public String getBillingRequest() {
+ return billingRequest;
+ }
+
+ /**
+ * ID of the [institution](#billing-requests-institutions) against which this
+ * authorisation was created.
+ */
+ public String getInstitution() {
+ return institution;
+ }
+ }
+ }
+
+ /**
+ * Represents a billing request resource returned from the API.
+ *
+ * Billing Requests help create resources that require input or action from a customer. An
+ * example of required input might be additional customer billing details, while an action would
+ * be asking a customer to authorise a payment using their mobile banking app.
+ *
+ * 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 static class BillingRequests {
+ private BillingRequests() {
+ // blank to prevent instantiation
+ }
+
+ private List actions;
+ private String createdAt;
+ private Boolean fallbackEnabled;
+ private Boolean fallbackOccurred;
+ private String id;
+ private InstalmentScheduleRequest instalmentScheduleRequest;
+ private Links links;
+ private MandateRequest mandateRequest;
+ private Map metadata;
+ private PaymentRequest paymentRequest;
+ 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.
+ */
+ public List getActions() {
+ return actions;
+ }
+
+ /**
+ * Fixed [timestamp](#api-usage-dates-and-times), recording when this resource was created.
+ */
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ /**
+ * (Optional) If true, this billing request can fallback from instant payment to direct
+ * debit. Should not be set if GoCardless payment intelligence feature is used.
+ *
+ * See [Billing Requests: Retain customers with
+ * Fallbacks](https://developer.gocardless.com/billing-requests/retain-customers-with-fallbacks/)
+ * for more information.
+ */
+ 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".
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Request for an instalment schedule. Has to contain either `instalments_with_schedule`
+ * object or an array of `instalments_with_dates` objects
+ */
+ public InstalmentScheduleRequest getInstalmentScheduleRequest() {
+ return instalmentScheduleRequest;
+ }
+
+ public Links getLinks() {
+ return links;
+ }
+
+ /**
+ * Request for a mandate
+ */
+ public MandateRequest getMandateRequest() {
+ return mandateRequest;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Request for a one-off strongly authorised payment
+ */
+ public PaymentRequest getPaymentRequest() {
+ return paymentRequest;
+ }
+
+ /**
+ * Specifies the high-level purpose of a mandate and/or payment using a set of pre-defined
+ * categories. Required for the PayTo scheme, optional for all others. Currently `mortgage`,
+ * `utility`, `loan`, `dependant_support`, `gambling`, `retail`, `salary`, `personal`,
+ * `government`, `pension`, `tax` and `other` are supported.
+ */
+ public PurposeCode getPurposeCode() {
+ return purposeCode;
+ }
+
+ public Resources getResources() {
+ return resources;
+ }
+
+ /**
+ * One of:
+ *
+ * - `pending`: the billing request is pending and can be used
+ * - `ready_to_fulfil`: the billing request is ready to fulfil
+ * - `fulfilling`: the billing request is currently undergoing fulfilment
+ * - `fulfilled`: the billing request has been fulfilled and a payment created
+ * - `cancelled`: the billing request has been cancelled and cannot be used
+ *
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * Request for a subscription
+ */
+ public SubscriptionRequest getSubscriptionRequest() {
+ return subscriptionRequest;
+ }
+
+ public enum PurposeCode {
+ @SerializedName("mortgage")
+ MORTGAGE, @SerializedName("utility")
+ UTILITY, @SerializedName("loan")
+ LOAN, @SerializedName("dependant_support")
+ DEPENDANT_SUPPORT, @SerializedName("gambling")
+ GAMBLING, @SerializedName("retail")
+ RETAIL, @SerializedName("salary")
+ SALARY, @SerializedName("personal")
+ PERSONAL, @SerializedName("government")
+ GOVERNMENT, @SerializedName("pension")
+ PENSION, @SerializedName("tax")
+ TAX, @SerializedName("other")
+ OTHER, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public enum Status {
+ @SerializedName("pending")
+ PENDING, @SerializedName("ready_to_fulfil")
+ READY_TO_FULFIL, @SerializedName("fulfilling")
+ FULFILLING, @SerializedName("fulfilled")
+ FULFILLED, @SerializedName("cancelled")
+ CANCELLED, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public static class Action {
+ private Action() {
+ // blank to prevent instantiation
+ }
+
+ private List availableCurrencies;
+ private BankAuthorisation bankAuthorisation;
+ private CollectCustomerDetails collectCustomerDetails;
+ private List completesActions;
+ private InstitutionGuessStatus institutionGuessStatus;
+ private Boolean required;
+ private List requiresActions;
+ private Status status;
+ private Type type;
+
+ /**
+ * List of currencies the current mandate supports
+ */
+ public List getAvailableCurrencies() {
+ return availableCurrencies;
+ }
+
+ /**
+ * Describes the behaviour of bank authorisations, for the bank_authorisation action
+ */
+ public BankAuthorisation getBankAuthorisation() {
+ return bankAuthorisation;
+ }
+
+ /**
+ * Additional parameters to help complete the collect_customer_details action
+ */
+ public CollectCustomerDetails getCollectCustomerDetails() {
+ return collectCustomerDetails;
+ }
+
+ /**
+ * Which other action types this action can complete.
+ */
+ public List getCompletesActions() {
+ return completesActions;
+ }
+
+ /**
+ * Describes whether we inferred the institution from the provided bank account details.
+ * One of: - `not_needed`: we won't attempt to infer the institution as it is not
+ * needed. Either because it was manually selected or the billing request does not
+ * support this feature - `pending`: we are waiting on the bank details in order to
+ * infer the institution - `failed`: we weren't able to infer the institution -
+ * `success`: we inferred the institution and added it to the resources of a Billing
+ * Request
+ *
+ */
+ public InstitutionGuessStatus getInstitutionGuessStatus() {
+ return institutionGuessStatus;
+ }
+
+ /**
+ * Informs you whether the action is required to fulfil the billing request or not.
+ */
+ public Boolean getRequired() {
+ return required;
+ }
+
+ /**
+ * Requires completing these actions before this action can be completed.
+ */
+ public List getRequiresActions() {
+ return requiresActions;
+ }
+
+ /**
+ * Status of the action
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * Unique identifier for the action.
+ */
+ public Type getType() {
+ return type;
+ }
+
+ public enum InstitutionGuessStatus {
+ @SerializedName("not_needed")
+ NOT_NEEDED, @SerializedName("pending")
+ PENDING, @SerializedName("failed")
+ FAILED, @SerializedName("success")
+ SUCCESS, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public enum Status {
+ @SerializedName("pending")
+ PENDING, @SerializedName("completed")
+ COMPLETED, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public enum Type {
+ @SerializedName("choose_currency")
+ CHOOSE_CURRENCY, @SerializedName("collect_amount")
+ COLLECT_AMOUNT, @SerializedName("collect_customer_details")
+ COLLECT_CUSTOMER_DETAILS, @SerializedName("collect_bank_account")
+ COLLECT_BANK_ACCOUNT, @SerializedName("bank_authorisation")
+ BANK_AUTHORISATION, @SerializedName("confirm_payer_details")
+ CONFIRM_PAYER_DETAILS, @SerializedName("select_institution")
+ SELECT_INSTITUTION, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ /**
+ * Represents a available currency resource returned from the API.
+ *
+ * List of currencies the current mandate supports
+ */
+ public static class AvailableCurrencies {
+ private AvailableCurrencies() {
+ // blank to prevent instantiation
+ }
+
+ private String currency;
+
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code.
+ */
+ public String getCurrency() {
+ return currency;
+ }
+ }
+
+ /**
+ * Represents a bank authorisation resource returned from the API.
+ *
+ * Describes the behaviour of bank authorisations, for the bank_authorisation action
+ */
+ public static class BankAuthorisation {
+ private BankAuthorisation() {
+ // blank to prevent instantiation
+ }
+
+ private Adapter adapter;
+ private AuthorisationType authorisationType;
+
+ /**
+ * Which authorisation adapter will be used to power these authorisations
+ * (GoCardless internal use only)
+ */
+ public Adapter getAdapter() {
+ return adapter;
+ }
+
+ /**
+ * What type of bank authorisations are supported on this billing request
+ */
+ public AuthorisationType getAuthorisationType() {
+ return authorisationType;
+ }
+
+ public enum Adapter {
+ @SerializedName("open_banking_gateway_pis")
+ OPEN_BANKING_GATEWAY_PIS, @SerializedName("plaid_ais")
+ PLAID_AIS, @SerializedName("open_banking_gateway_ais")
+ OPEN_BANKING_GATEWAY_AIS, @SerializedName("bankid_ais")
+ BANKID_AIS, @SerializedName("bank_pay_recurring")
+ BANK_PAY_RECURRING, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public enum AuthorisationType {
+ @SerializedName("payment")
+ PAYMENT, @SerializedName("mandate")
+ MANDATE, @SerializedName("unknown")
+ UNKNOWN
+ }
+ }
+
+ /**
+ * Represents a collect customer detail resource returned from the API.
+ *
+ * Additional parameters to help complete the collect_customer_details action
+ */
+ public static class CollectCustomerDetails {
+ private CollectCustomerDetails() {
+ // blank to prevent instantiation
+ }
+
+ private String defaultCountryCode;
+ private IncompleteFields incompleteFields;
+
+ /**
+ * Default customer country code, as determined by scheme and payer location
+ */
+ public String getDefaultCountryCode() {
+ return defaultCountryCode;
+ }
+
+ public IncompleteFields getIncompleteFields() {
+ return incompleteFields;
+ }
+
+ public static class IncompleteFields {
+ private IncompleteFields() {
+ // blank to prevent instantiation
+ }
+
+ private List customer;
+ private List customerBillingDetail;
+
+ public List getCustomer() {
+ return customer;
+ }
+
+ public List getCustomerBillingDetail() {
+ return customerBillingDetail;
+ }
+ }
+ }
+ }
+
+ /**
+ * Represents a instalment schedule request resource returned from the API.
+ *
+ * Request for an instalment schedule. Has to contain either `instalments_with_schedule`
+ * object or an array of `instalments_with_dates` objects
+ */
+ public static class InstalmentScheduleRequest {
+ private InstalmentScheduleRequest() {
+ // blank to prevent instantiation
+ }
+
+ private Integer appFee;
+ private String currency;
+ private List instalmentsWithDates;
+ private InstalmentsWithSchedule instalmentsWithSchedule;
+ 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 "USD" and "CAD" are supported.
+ */
+ public String getCurrency() {
+ return currency;
+ }
+
+ /**
+ * An explicit array of instalment payments, each specifying at least an `amount` and
+ * `charge_date`. See [create (with dates)](#instalment-schedules-create-with-dates)
+ */
+ public List getInstalmentsWithDates() {
+ return instalmentsWithDates;
+ }
+
+ /**
+ * Frequency of the payments you want to create, together with an array of payment
+ * amounts to be collected, with a specified start date for the first payment. See
+ * [create (with schedule)](#instalment-schedules-create-with-schedule)
+ *
+ */
+ public InstalmentsWithSchedule getInstalmentsWithSchedule() {
+ return instalmentsWithSchedule;
+ }
+
+ 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 static class InstalmentsWithDate {
+ private InstalmentsWithDate() {
+ // blank to prevent instantiation
+ }
+
+ private Integer amount;
+ private String chargeDate;
+ private String description;
+
+ /**
+ * Amount, in the lowest denomination for the currency (e.g. pence in GBP, cents in
+ * EUR).
+ */
+ public Integer getAmount() {
+ return amount;
+ }
+
+ /**
+ * A future date on which the payment should be collected. If the date is before the
+ * next_possible_charge_date on the [mandate](#core-endpoints-mandates), it will be
+ * automatically rolled forwards to that date.
+ */
+ public String getChargeDate() {
+ return chargeDate;
+ }
+
+ /**
+ * A human-readable description of the payment. This will be included in the
+ * notification email GoCardless sends to your customer if your organisation does
+ * not send its own notifications (see [compliance
+ * requirements](#appendix-compliance-requirements)).
+ */
+ public String getDescription() {
+ return description;
+ }
+ }
+
+ /**
+ * Represents a instalments with schedule resource returned from the API.
+ *
+ * Frequency of the payments you want to create, together with an array of payment
+ * amounts to be collected, with a specified start date for the first payment. See
+ * [create (with schedule)](#instalment-schedules-create-with-schedule)
+ *
+ */
+ public static class InstalmentsWithSchedule {
+ private InstalmentsWithSchedule() {
+ // blank to prevent instantiation
+ }
+
+ private List amounts;
+ private Integer interval;
+ private IntervalUnit intervalUnit;
+ private String startDate;
+
+ /**
+ * List of amounts of each instalment, in the lowest denomination for the currency
+ * (e.g. cents in USD).
+ *
+ */
+ public List getAmounts() {
+ return amounts;
+ }
+
+ /**
+ * Number of `interval_units` between charge dates. Must be greater than or equal 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;
+ }
+
+ /**
+ * 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 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
+ }
+
+ private String bankAuthorisation;
+ private String creditor;
+ 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 used to verify this request.
+ */
+ public String getBankAuthorisation() {
+ return bankAuthorisation;
+ }
+
+ /**
+ * ID of the associated [creditor](#core-endpoints-creditors).
+ */
+ public String getCreditor() {
+ return creditor;
+ }
+
+ /**
+ * ID of the [customer](#core-endpoints-customers) that will be used for this request
+ */
+ public String getCustomer() {
+ return customer;
+ }
+
+ /**
+ * (Optional) ID of the [customer_bank_account](#core-endpoints-customer-bank-accounts)
+ * that will be used for this request
+ */
+ public String getCustomerBankAccount() {
+ return customerBankAccount;
+ }
+
+ /**
+ * ID of the customer billing detail that will be used for this request
+ */
+ 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
+ */
+ public String getMandateRequest() {
+ return mandateRequest;
+ }
+
+ /**
+ * (Optional) ID of the [mandate](#core-endpoints-mandates) that was created from this
+ * mandate request. this mandate request.
+ */
+ public String getMandateRequestMandate() {
+ return mandateRequestMandate;
+ }
+
+ /**
+ * ID of the associated organisation.
+ */
+ public String getOrganisation() {
+ return organisation;
+ }
+
+ /**
+ * (Optional) ID of the associated payment provider
+ */
+ public String getPaymentProvider() {
+ return paymentProvider;
+ }
+
+ /**
+ * (Optional) ID of the associated payment request
+ */
+ public String getPaymentRequest() {
+ return paymentRequest;
+ }
+
+ /**
+ * (Optional) ID of the [payment](#core-endpoints-payments) that was created from this
+ * payment request.
+ */
+ 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;
+ }
+ }
+
+ /**
+ * Represents a mandate request resource returned from the API.
+ *
+ * Request for a mandate
+ */
+ public static class MandateRequest {
+ private MandateRequest() {
+ // blank to prevent instantiation
+ }
+
+ private AuthorisationSource authorisationSource;
+ private String consentType;
+ private Constraints constraints;
+ private String currency;
+ private String description;
+ private Links links;
+ private Map metadata;
+ private Boolean payerRequestedDualSignature;
+ private String scheme;
+ private Boolean sweeping;
+ private Verify verify;
+
+ /**
+ * This field is ACH specific, sometimes referred to as [SEC
+ * code](https://www.moderntreasury.com/learn/sec-codes).
+ *
+ * This is the way that the payer gives authorisation to the merchant. web:
+ * Authorisation is Internet Initiated or via Mobile Entry (maps to SEC code: WEB)
+ * telephone: Authorisation is provided orally over telephone (maps to SEC code: TEL)
+ * paper: Authorisation is provided in writing and signed, or similarly authenticated
+ * (maps to SEC code: PPD)
+ *
+ */
+ public AuthorisationSource getAuthorisationSource() {
+ return authorisationSource;
+ }
+
+ /**
+ * 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. _Note:_ This is only supported for ACH and
+ * PAD schemes.
+ *
+ */
+ public String getConsentType() {
+ return consentType;
+ }
+
+ /**
+ * Constraints that will apply to the mandate_request. (Optional) Specifically for PayTo
+ * and VRP.
+ */
+ public Constraints getConstraints() {
+ return constraints;
+ }
+
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code.
+ */
+ public String getCurrency() {
+ return currency;
+ }
+
+ /**
+ * A human-readable description of the payment and/or mandate. This will be displayed to
+ * the payer when authorising the billing request.
+ *
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ 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;
+ }
+
+ /**
+ * This attribute can be set to true if the payer has indicated that multiple signatures
+ * are required for the mandate. As long as every other Billing Request actions have
+ * been completed, the payer will receive an email notification containing instructions
+ * on how to complete the additional signature. The dual signature flow can only be
+ * completed using GoCardless branded pages.
+ */
+ public Boolean getPayerRequestedDualSignature() {
+ return payerRequestedDualSignature;
+ }
+
+ /**
+ * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz",
+ * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported.
+ * Optional for mandate only requests - if left blank, the payer will be able to select
+ * the currency/scheme to pay with from a list of your available schemes.
+ */
+ public String getScheme() {
+ return scheme;
+ }
+
+ /**
+ * If true, this billing request would be used to set up a mandate solely for moving (or
+ * sweeping) money from one account owned by the payer to another account that the payer
+ * also owns. This is required for Faster Payments
+ */
+ public Boolean getSweeping() {
+ return sweeping;
+ }
+
+ /**
+ * Verification preference for the mandate. One of:
+ *
+ * - `minimum`: only verify if absolutely required, such as when part of scheme
+ * rules
+ * - `recommended`: in addition to `minimum`, use the GoCardless payment intelligence
+ * solution to decide if a payer should be verified
+ * - `when_available`: if verification mechanisms are available, use them
+ * - `always`: as `when_available`, but fail to create the Billing Request if a
+ * mechanism isn't available
+ *
+ *
+ * By default, all Billing Requests use the `recommended` verification preference. It
+ * uses GoCardless payment intelligence solution to determine if a payer is fraudulent
+ * or not. The verification mechanism is based on the response and the payer may be
+ * asked to verify themselves. If the feature is not available, `recommended` behaves
+ * like `minimum`.
+ *
+ * If you never wish to take advantage of our reduced risk products and Verified
+ * Mandates as they are released in new schemes, please use the `minimum` verification
+ * preference.
+ *
+ * See [Billing Requests: Creating Verified
+ * Mandates](https://developer.gocardless.com/getting-started/billing-requests/verified-mandates/)
+ * for more information.
+ */
+ public Verify getVerify() {
+ return verify;
+ }
+
+ public enum AuthorisationSource {
+ @SerializedName("web")
+ WEB, @SerializedName("telephone")
+ TELEPHONE, @SerializedName("paper")
+ PAPER, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public enum Verify {
+ @SerializedName("minimum")
+ MINIMUM, @SerializedName("recommended")
+ RECOMMENDED, @SerializedName("when_available")
+ WHEN_AVAILABLE, @SerializedName("always")
+ ALWAYS, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ /**
+ * Represents a constraint resource returned from the API.
+ *
+ * Constraints that will apply to the mandate_request. (Optional) Specifically for PayTo
+ * and VRP.
+ */
+ public static class Constraints {
+ private Constraints() {
+ // blank to prevent instantiation
+ }
+
+ private String endDate;
+ private Integer maxAmountPerPayment;
+ private String paymentMethod;
+ private List periodicLimits;
+ private String startDate;
+
+ /**
+ * The latest date at which payments can be taken, must occur after start_date if
+ * present
+ *
+ * This is an optional field and if it is not supplied the agreement will be
+ * considered open and will not have an end date. Keep in mind the end date must
+ * take into account how long it will take the user to set up this agreement via the
+ * Billing Request.
+ *
+ */
+ public String getEndDate() {
+ return endDate;
+ }
+
+ /**
+ * The maximum amount that can be charged for a single payment. Required for VRP.
+ */
+ 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
+ */
+ public List getPeriodicLimits() {
+ return periodicLimits;
+ }
+
+ /**
+ * The date from which payments can be taken.
+ *
+ * This is an optional field and if it is not supplied the start date will be set to
+ * the day authorisation happens.
+ *
+ */
+ public String getStartDate() {
+ return startDate;
+ }
+
+ public static class PeriodicLimit {
+ private PeriodicLimit() {
+ // blank to prevent instantiation
+ }
+
+ private Alignment alignment;
+ private Integer maxPayments;
+ private Integer maxTotalAmount;
+ private Period period;
+
+ /**
+ * The alignment of the period.
+ *
+ * `calendar` - this will finish on the end of the current period. For example
+ * this will expire on the Monday for the current week or the January for the
+ * next year.
+ *
+ * `creation_date` - this will finish on the next instance of the current
+ * period. For example Monthly it will expire on the same day of the next month,
+ * or yearly the same day of the next year.
+ *
+ */
+ public Alignment getAlignment() {
+ return alignment;
+ }
+
+ /**
+ * (Optional) The maximum number of payments that can be collected in this
+ * periodic limit.
+ */
+ public Integer getMaxPayments() {
+ return maxPayments;
+ }
+
+ /**
+ * The maximum total amount that can be charged for all payments in this
+ * periodic limit. Required for VRP.
+ *
+ */
+ public Integer getMaxTotalAmount() {
+ return maxTotalAmount;
+ }
+
+ /**
+ * The repeating period for this mandate
+ */
+ public Period getPeriod() {
+ return period;
+ }
+
+ public enum Alignment {
+ @SerializedName("calendar")
+ CALENDAR, @SerializedName("creation_date")
+ CREATION_DATE, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public enum Period {
+ @SerializedName("day")
+ DAY, @SerializedName("week")
+ WEEK, @SerializedName("month")
+ MONTH, @SerializedName("year")
+ YEAR, @SerializedName("flexible")
+ FLEXIBLE, @SerializedName("unknown")
+ UNKNOWN
+ }
+ }
+ }
+
+ public static class Links {
+ private Links() {
+ // blank to prevent instantiation
+ }
+
+ private String mandate;
+
+ /**
+ * (Optional) ID of the [mandate](#core-endpoints-mandates) that was created from
+ * this mandate request. this mandate request.
+ *
+ */
+ public String getMandate() {
+ return mandate;
+ }
+ }
+ }
+
+ /**
+ * Represents a payment request resource returned from the API.
+ *
+ * Request for a one-off strongly authorised payment
+ */
+ public static class PaymentRequest {
+ private PaymentRequest() {
+ // blank to prevent instantiation
+ }
+
+ private Integer amount;
+ private Integer appFee;
+ private String currency;
+ private String description;
+ private FundsSettlement fundsSettlement;
+ private Links links;
+ private Map metadata;
+ private String reference;
+ private String scheme;
+
+ /**
+ * Amount in minor unit (e.g. pence in GBP, cents in EUR).
+ */
+ public Integer getAmount() {
+ return amount;
+ }
+
+ /**
+ * The amount to be deducted from the payment as an app fee, to be paid to the partner
+ * integration which created the billing request, 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. `GBP`
+ * and `EUR` supported; `GBP` with your customers in the UK and for `EUR` with your
+ * customers in supported Eurozone countries only.
+ */
+ public String getCurrency() {
+ return currency;
+ }
+
+ /**
+ * A human-readable description of the payment and/or mandate. This will be displayed to
+ * the payer when authorising the billing request.
+ *
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * This field will decide how GoCardless handles settlement of funds from the customer.
+ *
+ * - `managed` will be moved through GoCardless' account, batched, and payed out. -
+ * `direct` will be a direct transfer from the payer's account to the merchant where
+ * invoicing will be handled separately.
+ *
+ */
+ public FundsSettlement getFundsSettlement() {
+ return fundsSettlement;
+ }
+
+ 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;
+ }
+
+ /**
+ * A custom payment reference defined by the merchant. It is only available for payments
+ * using the Direct Funds settlement model on the Faster Payments scheme.
+ *
+ */
+ public String getReference() {
+ return reference;
+ }
+
+ /**
+ * (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` are supported in supported Eurozone countries (EUR).
+ * For Eurozone countries, `sepa_credit_transfer` is used as the default. Please be
+ * aware that `sepa_instant_credit_transfer` may incur an additional fee for your
+ * customer.
+ */
+ public String getScheme() {
+ return scheme;
+ }
+
+ public enum FundsSettlement {
+ @SerializedName("managed")
+ MANAGED, @SerializedName("direct")
+ DIRECT, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public static class Links {
+ private Links() {
+ // blank to prevent instantiation
+ }
+
+ private String payment;
+
+ /**
+ * (Optional) ID of the [payment](#core-endpoints-payments) that was created from
+ * this payment request.
+ */
+ public String getPayment() {
+ return payment;
+ }
+ }
+ }
+
+ public static class Resources {
+ private Resources() {
+ // blank to prevent instantiation
+ }
+
+ private Customer customer;
+ private CustomerBankAccount customerBankAccount;
+ private CustomerBillingDetail customerBillingDetail;
+
+ /**
+ * Embedded customer
+ */
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ /**
+ * Embedded customer bank account, only if a bank account is linked
+ */
+ public CustomerBankAccount getCustomerBankAccount() {
+ return customerBankAccount;
+ }
+
+ /**
+ * Embedded customer billing detail
+ */
+ public CustomerBillingDetail getCustomerBillingDetail() {
+ return customerBillingDetail;
+ }
+
+ /**
+ * Represents a customer resource returned from the API.
+ *
+ * Embedded customer
+ */
+ public static class Customer {
+ private Customer() {
+ // blank to prevent instantiation
+ }
+
+ private String companyName;
+ private String createdAt;
+ private String email;
+ private String familyName;
+ private String givenName;
+ private String id;
+ private String language;
+ private Map metadata;
+ private String phoneNumber;
+
+ /**
+ * Customer's company name. Required unless a `given_name` and `family_name` are
+ * provided. For Canadian customers, the use of a `company_name` value will mean
+ * that any mandate created from this customer will be considered to be a "Business
+ * PAD" (otherwise, any mandate will be considered to be a "Personal PAD").
+ */
+ public String getCompanyName() {
+ return companyName;
+ }
+
+ /**
+ * Fixed [timestamp](#api-usage-dates-and-times), recording when this resource was
+ * created.
+ */
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ /**
+ * Customer's email address. Required in most cases, as this allows GoCardless to
+ * send notifications to this customer.
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * Customer's surname. Required unless a `company_name` is provided.
+ */
+ public String getFamilyName() {
+ return familyName;
+ }
+
+ /**
+ * Customer's first name. Required unless a `company_name` is provided.
+ */
+ public String getGivenName() {
+ return givenName;
+ }
+
+ /**
+ * Unique identifier, beginning with "CU".
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code. Used as
+ * the language for notification emails sent by GoCardless if your organisation does
+ * not send its own (see [compliance
+ * requirements](#appendix-compliance-requirements)). Currently only "en", "fr",
+ * "de", "pt", "es", "it", "nl", "da", "nb", "sl", "sv" are supported. If this is
+ * not provided, the language will be chosen based on the `country_code` (if
+ * supplied) or default to "en".
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number,
+ * including country code.
+ */
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+ }
+
+ /**
+ * Represents a customer bank account resource returned from the API.
+ *
+ * Embedded customer bank account, only if a bank account is linked
+ */
+ public static class CustomerBankAccount {
+ private CustomerBankAccount() {
+ // blank to prevent instantiation
+ }
+
+ private String accountHolderName;
+ private String accountNumberEnding;
+ private AccountType accountType;
+ private String bankAccountToken;
+ private String bankName;
+ private String countryCode;
+ private String createdAt;
+ private String currency;
+ private Boolean enabled;
+ private String id;
+ private Links links;
+ private Map metadata;
+
+ /**
+ * Name of the account holder, as known by the bank. This field will be
+ * transliterated, upcased and truncated to 18 characters. This field is required
+ * unless the request includes a [customer bank account
+ * token](#javascript-flow-customer-bank-account-tokens).
+ */
+ public String getAccountHolderName() {
+ return accountHolderName;
+ }
+
+ /**
+ * The last few digits of the account number. Currently 4 digits for NZD bank
+ * accounts and 2 digits for other currencies.
+ */
+ public String getAccountNumberEnding() {
+ return accountNumberEnding;
+ }
+
+ /**
+ * Bank account type. Required for USD-denominated bank accounts. Must not be
+ * provided for bank accounts in other currencies. See [local
+ * details](#local-bank-details-united-states) for more information.
+ */
+ public AccountType getAccountType() {
+ return accountType;
+ }
+
+ /**
+ * A token to uniquely refer to a set of bank account details. This feature is still
+ * in early access and is only available for certain organisations.
+ */
+ public String getBankAccountToken() {
+ return bankAccountToken;
+ }
+
+ /**
+ * Name of bank, taken from the bank details.
+ */
+ public String getBankName() {
+ return bankName;
+ }
+
+ /**
+ * [ISO 3166-1 alpha-2
+ * code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
+ * Defaults to the country code of the `iban` if supplied, otherwise is required.
+ */
+ public String getCountryCode() {
+ return countryCode;
+ }
+
+ /**
+ * Fixed [timestamp](#api-usage-dates-and-times), recording when this resource was
+ * created.
+ */
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ /**
+ * [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;
+ }
+
+ /**
+ * Boolean value showing whether the bank account is enabled or disabled.
+ */
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Unique identifier, beginning with "BA".
+ */
+ public String getId() {
+ return id;
+ }
+
+ 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;
+ }
+
+ public enum AccountType {
+ @SerializedName("savings")
+ SAVINGS, @SerializedName("checking")
+ CHECKING, @SerializedName("unknown")
+ UNKNOWN
+ }
+
+ public static class Links {
+ private Links() {
+ // blank to prevent instantiation
+ }
+
+ private String customer;
+
+ /**
+ * ID of the [customer](#core-endpoints-customers) that owns this bank account.
+ */
+ public String getCustomer() {
+ return customer;
+ }
+ }
+ }
+
+ /**
+ * Represents a customer billing detail resource returned from the API.
+ *
+ * Embedded customer billing detail
+ */
+ public static class CustomerBillingDetail {
+ private CustomerBillingDetail() {
+ // blank to prevent instantiation
+ }
+
+ private String addressLine1;
+ private String addressLine2;
+ private String addressLine3;
+ private String city;
+ private String countryCode;
+ private String createdAt;
+ private String danishIdentityNumber;
+ private String id;
+ private String ipAddress;
+ private String postalCode;
+ private String region;
+ private List schemes;
+ private String swedishIdentityNumber;
+
+ /**
+ * The first line of the customer's address.
+ */
+ public String getAddressLine1() {
+ return addressLine1;
+ }
+
+ /**
+ * The second line of the customer's address.
+ */
+ public String getAddressLine2() {
+ return addressLine2;
+ }
+
+ /**
+ * The third line of the customer's address.
+ */
+ public String getAddressLine3() {
+ return addressLine3;
+ }
+
+ /**
+ * The city of the customer's address.
+ */
+ public String getCity() {
+ return city;
+ }
+
+ /**
+ * [ISO 3166-1 alpha-2
+ * code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
+ */
+ public String getCountryCode() {
+ return countryCode;
+ }
+
+ /**
+ * Fixed [timestamp](#api-usage-dates-and-times), recording when this resource was
+ * created.
+ */
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ /**
+ * For Danish customers only. The civic/company number (CPR or CVR) of the customer.
+ * Must be supplied if the customer's bank account is denominated in Danish krone
+ * (DKK).
+ */
+ public String getDanishIdentityNumber() {
+ return danishIdentityNumber;
+ }
+
+ /**
+ * Unique identifier, beginning with "CU".
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * For ACH customers only. Required for ACH customers. A string containing the IP
+ * address of the payer to whom the mandate belongs (i.e. as a result of their
+ * completion of a mandate setup flow in their browser).
+ *
+ * Not required for creating offline mandates where `authorisation_source` is set to
+ * telephone or paper.
+ *
+ */
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ /**
+ * The customer's postal code.
+ */
+ public String getPostalCode() {
+ return postalCode;
+ }
+
+ /**
+ * The customer's address region, county or department. For US customers a 2 letter
+ * [ISO3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) state code is
+ * required (e.g. `CA` for California).
+ */
+ public String getRegion() {
+ return region;
+ }
+
+ /**
+ * The schemes associated with this customer billing detail
+ */
+ public List getSchemes() {
+ return schemes;
+ }
+
+ /**
+ * For Swedish customers only. The civic/company number (personnummer,
+ * samordningsnummer, or organisationsnummer) of the customer. Must be supplied if
+ * the customer's bank account is denominated in Swedish krona (SEK). This field
+ * cannot be changed once it has been set.
+ */
+ public String getSwedishIdentityNumber() {
+ return swedishIdentityNumber;
+ }
+ }
+ }
+
+ /**
+ * 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 "USD" and "CAD" 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/resources/OutboundPayment.java b/src/main/java/com/gocardless/resources/OutboundPayment.java
index 3ba6c627..c75f2e0f 100644
--- a/src/main/java/com/gocardless/resources/OutboundPayment.java
+++ b/src/main/java/com/gocardless/resources/OutboundPayment.java
@@ -25,6 +25,7 @@ private OutboundPayment() {
private Integer amount;
private String createdAt;
+ private Currency currency;
private String description;
private String executionDate;
private String id;
@@ -51,6 +52,14 @@ public String getCreatedAt() {
return createdAt;
}
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency. Currently only "GBP"
+ * is supported.
+ */
+ public Currency getCurrency() {
+ return currency;
+ }
+
/**
* A human-readable description of the outbound payment
*/
@@ -141,6 +150,12 @@ public Verifications getVerifications() {
return verifications;
}
+ public enum Currency {
+ @SerializedName("GBP")
+ GBP, @SerializedName("unknown")
+ UNKNOWN
+ }
+
public enum Status {
@SerializedName("verifying")
VERIFYING, @SerializedName("pending_approval")
diff --git a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java
new file mode 100644
index 00000000..71c21d3a
--- /dev/null
+++ b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java
@@ -0,0 +1,1977 @@
+package com.gocardless.services;
+
+import com.gocardless.http.*;
+import com.gocardless.resources.BillingRequestWithAction;
+import com.google.common.collect.ImmutableMap;
+import com.google.gson.annotations.SerializedName;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Service class for working with billing request with action resources.
+ *
+ * Billing Requests help create resources that require input or action from a customer. An example
+ * of required input might be additional customer billing details, while an action would be asking a
+ * customer to authorise a payment using their mobile banking app.
+ *
+ * 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 BillingRequestWithActionService {
+ private final HttpClient httpClient;
+
+ /**
+ * Constructor. Users of this library should have no need to call this - an instance of this
+ * class can be obtained by calling
+ * {@link com.gocardless.GoCardlessClient#billingRequestWithActions() }.
+ */
+ public BillingRequestWithActionService(HttpClient httpClient) {
+ this.httpClient = httpClient;
+ }
+
+ /**
+ * Creates a billing request and completes any specified actions in a single request. This
+ * endpoint allows you to create a billing request and immediately complete actions such as
+ * collecting customer details, bank account details, or other required actions.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest createWithActions() {
+ return new BillingRequestWithActionCreateWithActionsRequest(httpClient);
+ }
+
+ /**
+ * Request class for {@link BillingRequestWithActionService#createWithActions }.
+ *
+ * Creates a billing request and completes any specified actions in a single request. This
+ * endpoint allows you to create a billing request and immediately complete actions such as
+ * collecting customer details, bank account details, or other required actions.
+ */
+ public static final class BillingRequestWithActionCreateWithActionsRequest
+ extends PostRequest {
+ private Actions actions;
+ private Boolean fallbackEnabled;
+ private Links links;
+ private MandateRequest mandateRequest;
+ private Map metadata;
+ private PaymentRequest paymentRequest;
+ private PurposeCode purposeCode;
+ private SubscriptionRequest subscriptionRequest;
+
+ /**
+ * Action payloads
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withActions(Actions actions) {
+ this.actions = actions;
+ return this;
+ }
+
+ /**
+ * URL for an oauth flow that will allow the user to authorise the payment
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withActionsBankAuthorisationRedirectUri(
+ String bankAuthorisationRedirectUri) {
+ if (actions == null) {
+ actions = new Actions();
+ }
+ actions.withBankAuthorisationRedirectUri(bankAuthorisationRedirectUri);
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withActionsCollectBankAccount(
+ CollectBankAccount collectBankAccount) {
+ if (actions == null) {
+ actions = new Actions();
+ }
+ actions.withCollectBankAccount(collectBankAccount);
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withActionsCollectCustomerDetails(
+ CollectCustomerDetails collectCustomerDetails) {
+ if (actions == null) {
+ actions = new Actions();
+ }
+ actions.withCollectCustomerDetails(collectCustomerDetails);
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withActionsConfirmPayerDetails(
+ ConfirmPayerDetails confirmPayerDetails) {
+ if (actions == null) {
+ actions = new Actions();
+ }
+ actions.withConfirmPayerDetails(confirmPayerDetails);
+ return this;
+ }
+
+ /**
+ * Create a bank authorisation object as part of this request
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withActionsCreateBankAuthorisation(
+ Boolean createBankAuthorisation) {
+ if (actions == null) {
+ actions = new Actions();
+ }
+ actions.withCreateBankAuthorisation(createBankAuthorisation);
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withActionsSelectInstitution(
+ SelectInstitution selectInstitution) {
+ if (actions == null) {
+ actions = new Actions();
+ }
+ actions.withSelectInstitution(selectInstitution);
+ return this;
+ }
+
+ /**
+ * (Optional) If true, this billing request can fallback from instant payment to direct
+ * debit. Should not be set if GoCardless payment intelligence feature is used.
+ *
+ * See [Billing Requests: Retain customers with
+ * Fallbacks](https://developer.gocardless.com/billing-requests/retain-customers-with-fallbacks/)
+ * for more information.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withFallbackEnabled(
+ Boolean fallbackEnabled) {
+ this.fallbackEnabled = fallbackEnabled;
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withLinks(Links links) {
+ this.links = links;
+ return this;
+ }
+
+ /**
+ * ID of the associated [creditor](#core-endpoints-creditors). Only required if your account
+ * manages multiple creditors.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withLinksCreditor(String creditor) {
+ if (links == null) {
+ links = new Links();
+ }
+ links.withCreditor(creditor);
+ return this;
+ }
+
+ /**
+ * ID of the [customer](#core-endpoints-customers) against which this request should be
+ * made.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withLinksCustomer(String customer) {
+ if (links == null) {
+ links = new Links();
+ }
+ links.withCustomer(customer);
+ return this;
+ }
+
+ /**
+ * (Optional) ID of the [customer_bank_account](#core-endpoints-customer-bank-accounts)
+ * against which this request should be made.
+ *
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withLinksCustomerBankAccount(
+ String customerBankAccount) {
+ if (links == null) {
+ links = new Links();
+ }
+ links.withCustomerBankAccount(customerBankAccount);
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequest(
+ MandateRequest mandateRequest) {
+ this.mandateRequest = mandateRequest;
+ return this;
+ }
+
+ /**
+ * This field is ACH specific, sometimes referred to as [SEC
+ * code](https://www.moderntreasury.com/learn/sec-codes).
+ *
+ * This is the way that the payer gives authorisation to the merchant. web: Authorisation is
+ * Internet Initiated or via Mobile Entry (maps to SEC code: WEB) telephone: Authorisation
+ * is provided orally over telephone (maps to SEC code: TEL) paper: Authorisation is
+ * provided in writing and signed, or similarly authenticated (maps to SEC code: PPD)
+ *
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestAuthorisationSource(
+ MandateRequest.AuthorisationSource authorisationSource) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withAuthorisationSource(authorisationSource);
+ return this;
+ }
+
+ /**
+ * Constraints that will apply to the mandate_request. (Optional) Specifically for PayTo and
+ * VRP.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestConstraints(
+ Constraints constraints) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withConstraints(constraints);
+ return this;
+ }
+
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestCurrency(
+ String currency) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withCurrency(currency);
+ return this;
+ }
+
+ /**
+ * A human-readable description of the payment and/or mandate. This will be displayed to the
+ * payer when authorising the billing request.
+ *
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestDescription(
+ String description) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withDescription(description);
+ 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 BillingRequestWithActionCreateWithActionsRequest withMandateRequestMetadata(
+ Map metadata) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withMetadata(metadata);
+ return this;
+ }
+
+ /**
+ * Unique reference. Different schemes have different length and [character
+ * set](#appendix-character-sets) requirements. GoCardless will generate a unique reference
+ * satisfying the different scheme requirements if this field is left blank.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestReference(
+ String reference) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withReference(reference);
+ return this;
+ }
+
+ /**
+ * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz",
+ * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported.
+ * Optional for mandate only requests - if left blank, the payer will be able to select the
+ * currency/scheme to pay with from a list of your available schemes.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestScheme(
+ String scheme) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withScheme(scheme);
+ return this;
+ }
+
+ /**
+ * If true, this billing request would be used to set up a mandate solely for moving (or
+ * sweeping) money from one account owned by the payer to another account that the payer
+ * also owns. This is required for Faster Payments
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestSweeping(
+ Boolean sweeping) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withSweeping(sweeping);
+ return this;
+ }
+
+ /**
+ * Verification preference for the mandate. One of:
+ *
+ * - `minimum`: only verify if absolutely required, such as when part of scheme rules
+ * - `recommended`: in addition to `minimum`, use the GoCardless payment intelligence
+ * solution to decide if a payer should be verified
+ * - `when_available`: if verification mechanisms are available, use them
+ * - `always`: as `when_available`, but fail to create the Billing Request if a mechanism
+ * isn't available
+ *
+ *
+ * By default, all Billing Requests use the `recommended` verification preference. It uses
+ * GoCardless payment intelligence solution to determine if a payer is fraudulent or not.
+ * The verification mechanism is based on the response and the payer may be asked to verify
+ * themselves. If the feature is not available, `recommended` behaves like `minimum`.
+ *
+ * If you never wish to take advantage of our reduced risk products and Verified Mandates as
+ * they are released in new schemes, please use the `minimum` verification preference.
+ *
+ * See [Billing Requests: Creating Verified
+ * Mandates](https://developer.gocardless.com/getting-started/billing-requests/verified-mandates/)
+ * for more information.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withMandateRequestVerify(
+ MandateRequest.Verify verify) {
+ if (mandateRequest == null) {
+ mandateRequest = new MandateRequest();
+ }
+ mandateRequest.withVerify(verify);
+ 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 BillingRequestWithActionCreateWithActionsRequest withMetadata(
+ Map metadata) {
+ this.metadata = metadata;
+ 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 BillingRequestWithActionCreateWithActionsRequest withMetadata(String key,
+ String value) {
+ if (metadata == null) {
+ metadata = new HashMap<>();
+ }
+ metadata.put(key, value);
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequest(
+ PaymentRequest paymentRequest) {
+ this.paymentRequest = paymentRequest;
+ return this;
+ }
+
+ /**
+ * Amount in minor unit (e.g. pence in GBP, cents in EUR).
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestAmount(
+ Integer amount) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withAmount(amount);
+ return this;
+ }
+
+ /**
+ * The amount to be deducted from the payment as an app fee, to be paid to the partner
+ * integration which created the billing request, in the lowest denomination for the
+ * currency (e.g. pence in GBP, cents in EUR).
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestAppFee(
+ Integer appFee) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withAppFee(appFee);
+ return this;
+ }
+
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. `GBP` and
+ * `EUR` supported; `GBP` with your customers in the UK and for `EUR` with your customers in
+ * supported Eurozone countries only.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestCurrency(
+ String currency) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withCurrency(currency);
+ return this;
+ }
+
+ /**
+ * A human-readable description of the payment and/or mandate. This will be displayed to the
+ * payer when authorising the billing request.
+ *
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestDescription(
+ String description) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withDescription(description);
+ return this;
+ }
+
+ /**
+ * This field will decide how GoCardless handles settlement of funds from the customer.
+ *
+ * - `managed` will be moved through GoCardless' account, batched, and payed out. - `direct`
+ * will be a direct transfer from the payer's account to the merchant where invoicing will
+ * be handled separately.
+ *
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestFundsSettlement(
+ PaymentRequest.FundsSettlement fundsSettlement) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withFundsSettlement(fundsSettlement);
+ 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 BillingRequestWithActionCreateWithActionsRequest withPaymentRequestMetadata(
+ Map metadata) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withMetadata(metadata);
+ return this;
+ }
+
+ /**
+ * A custom payment reference defined by the merchant. It is only available for payments
+ * using the Direct Funds settlement model on the Faster Payments scheme.
+ *
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestReference(
+ String reference) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withReference(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 BillingRequestWithActionCreateWithActionsRequest 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`
+ * are supported in supported Eurozone countries (EUR). For Eurozone countries,
+ * `sepa_credit_transfer` is used as the default. Please be aware that
+ * `sepa_instant_credit_transfer` may incur an additional fee for your customer.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestScheme(
+ String scheme) {
+ if (paymentRequest == null) {
+ paymentRequest = new PaymentRequest();
+ }
+ paymentRequest.withScheme(scheme);
+ return this;
+ }
+
+ /**
+ * Specifies the high-level purpose of a mandate and/or payment using a set of pre-defined
+ * categories. Required for the PayTo scheme, optional for all others. Currently `mortgage`,
+ * `utility`, `loan`, `dependant_support`, `gambling`, `retail`, `salary`, `personal`,
+ * `government`, `pension`, `tax` and `other` are supported.
+ */
+ public BillingRequestWithActionCreateWithActionsRequest withPurposeCode(
+ PurposeCode purposeCode) {
+ this.purposeCode = purposeCode;
+ return this;
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest 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 BillingRequestWithActionCreateWithActionsRequest withSubscriptionRequestStartDate(
+ String startDate) {
+ if (subscriptionRequest == null) {
+ subscriptionRequest = new SubscriptionRequest();
+ }
+ subscriptionRequest.withStartDate(startDate);
+ return this;
+ }
+
+ private BillingRequestWithActionCreateWithActionsRequest(HttpClient httpClient) {
+ super(httpClient);
+ }
+
+ public BillingRequestWithActionCreateWithActionsRequest withHeader(String headerName,
+ String headerValue) {
+ this.addHeader(headerName, headerValue);
+ return this;
+ }
+
+ @Override
+ protected String getPathTemplate() {
+ return "billing_requests/create_with_actions";
+ }
+
+ @Override
+ protected String getEnvelope() {
+ return "billing_requests";
+ }
+
+ @Override
+ protected Class getResponseClass() {
+ return BillingRequestWithAction.class;
+ }
+
+ @Override
+ protected boolean hasBody() {
+ return true;
+ }
+
+ public enum PurposeCode {
+ @SerializedName("mortgage")
+ MORTGAGE, @SerializedName("utility")
+ UTILITY, @SerializedName("loan")
+ LOAN, @SerializedName("dependant_support")
+ DEPENDANT_SUPPORT, @SerializedName("gambling")
+ GAMBLING, @SerializedName("retail")
+ RETAIL, @SerializedName("salary")
+ SALARY, @SerializedName("personal")
+ PERSONAL, @SerializedName("government")
+ GOVERNMENT, @SerializedName("pension")
+ PENSION, @SerializedName("tax")
+ TAX, @SerializedName("other")
+ OTHER, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+
+ public static class CollectBankAccount {
+ private String accountHolderName;
+ private String accountNumber;
+ private String accountNumberSuffix;
+ private AccountType accountType;
+ private String bankCode;
+ private String branchCode;
+ private String countryCode;
+ private String currency;
+ private String iban;
+ private Map metadata;
+ private String payId;
+
+ /**
+ * Name of the account holder, as known by the bank. This field will be transliterated,
+ * upcased and truncated to 18 characters. This field is required unless the request
+ * includes a [customer bank account
+ * token](#javascript-flow-customer-bank-account-tokens).
+ */
+ public CollectBankAccount withAccountHolderName(String accountHolderName) {
+ this.accountHolderName = accountHolderName;
+ return this;
+ }
+
+ /**
+ * Bank account number - see [local details](#appendix-local-bank-details) for more
+ * information. Alternatively you can provide an `iban`.
+ */
+ public CollectBankAccount withAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ return this;
+ }
+
+ /**
+ * Account number suffix (only for bank accounts denominated in NZD) - see [local
+ * details](#local-bank-details-new-zealand) for more information.
+ */
+ public CollectBankAccount withAccountNumberSuffix(String accountNumberSuffix) {
+ this.accountNumberSuffix = accountNumberSuffix;
+ return this;
+ }
+
+ /**
+ * Bank account type. Required for USD-denominated bank accounts. Must not be provided
+ * for bank accounts in other currencies. See [local
+ * details](#local-bank-details-united-states) for more information.
+ */
+ public CollectBankAccount withAccountType(AccountType accountType) {
+ this.accountType = accountType;
+ return this;
+ }
+
+ /**
+ * Bank code - see [local details](#appendix-local-bank-details) for more information.
+ * Alternatively you can provide an `iban`.
+ */
+ public CollectBankAccount withBankCode(String bankCode) {
+ this.bankCode = bankCode;
+ return this;
+ }
+
+ /**
+ * Branch code - see [local details](#appendix-local-bank-details) for more information.
+ * Alternatively you can provide an `iban`.
+ */
+ public CollectBankAccount withBranchCode(String branchCode) {
+ this.branchCode = branchCode;
+ return this;
+ }
+
+ /**
+ * [ISO 3166-1 alpha-2
+ * code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
+ * Defaults to the country code of the `iban` if supplied, otherwise is required.
+ */
+ public CollectBankAccount withCountryCode(String countryCode) {
+ this.countryCode = countryCode;
+ 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 CollectBankAccount withCurrency(String currency) {
+ this.currency = currency;
+ return this;
+ }
+
+ /**
+ * International Bank Account Number. Alternatively you can provide [local
+ * details](#appendix-local-bank-details). IBANs are not accepted for Swedish bank
+ * accounts denominated in SEK - you must supply [local
+ * details](#local-bank-details-sweden).
+ */
+ public CollectBankAccount withIban(String iban) {
+ this.iban = iban;
+ 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 CollectBankAccount withMetadata(Map metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * A unique record such as an email address, mobile number or company number, that can
+ * be used to make and accept payments.
+ */
+ public CollectBankAccount withPayId(String payId) {
+ this.payId = payId;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (accountHolderName != null) {
+ params.put("collect_bank_account[account_holder_name]", accountHolderName);
+ }
+ if (accountNumber != null) {
+ params.put("collect_bank_account[account_number]", accountNumber);
+ }
+ if (accountNumberSuffix != null) {
+ params.put("collect_bank_account[account_number_suffix]", accountNumberSuffix);
+ }
+ if (accountType != null) {
+ params.put("collect_bank_account[account_type]", accountType);
+ }
+ if (bankCode != null) {
+ params.put("collect_bank_account[bank_code]", bankCode);
+ }
+ if (branchCode != null) {
+ params.put("collect_bank_account[branch_code]", branchCode);
+ }
+ if (countryCode != null) {
+ params.put("collect_bank_account[country_code]", countryCode);
+ }
+ if (currency != null) {
+ params.put("collect_bank_account[currency]", currency);
+ }
+ if (iban != null) {
+ params.put("collect_bank_account[iban]", iban);
+ }
+ if (metadata != null) {
+ params.put("collect_bank_account[metadata]", metadata);
+ }
+ if (payId != null) {
+ params.put("collect_bank_account[pay_id]", payId);
+ }
+ return params.build();
+ }
+
+ public enum AccountType {
+ @SerializedName("savings")
+ SAVINGS, @SerializedName("checking")
+ CHECKING, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+ }
+
+ public static class Customer {
+ private String companyName;
+ private String email;
+ private String familyName;
+ private String givenName;
+ private String language;
+ private Map metadata;
+ private String phoneNumber;
+
+ /**
+ * Customer's company name. Required unless a `given_name` and `family_name` are
+ * provided. For Canadian customers, the use of a `company_name` value will mean that
+ * any mandate created from this customer will be considered to be a "Business PAD"
+ * (otherwise, any mandate will be considered to be a "Personal PAD").
+ */
+ public Customer withCompanyName(String companyName) {
+ this.companyName = companyName;
+ return this;
+ }
+
+ /**
+ * Customer's email address. Required in most cases, as this allows GoCardless to send
+ * notifications to this customer.
+ */
+ public Customer withEmail(String email) {
+ this.email = email;
+ return this;
+ }
+
+ /**
+ * Customer's surname. Required unless a `company_name` is provided.
+ */
+ public Customer withFamilyName(String familyName) {
+ this.familyName = familyName;
+ return this;
+ }
+
+ /**
+ * Customer's first name. Required unless a `company_name` is provided.
+ */
+ public Customer withGivenName(String givenName) {
+ this.givenName = givenName;
+ return this;
+ }
+
+ /**
+ * [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) code. Used as the
+ * language for notification emails sent by GoCardless if your organisation does not
+ * send its own (see [compliance requirements](#appendix-compliance-requirements)).
+ * Currently only "en", "fr", "de", "pt", "es", "it", "nl", "da", "nb", "sl", "sv" are
+ * supported. If this is not provided and a customer was linked during billing request
+ * creation, the linked customer language will be used. Otherwise, the language is
+ * default to "en".
+ */
+ public Customer withLanguage(String language) {
+ this.language = language;
+ 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 Customer withMetadata(Map metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including
+ * country code.
+ */
+ public Customer withPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (companyName != null) {
+ params.put("customer[company_name]", companyName);
+ }
+ if (email != null) {
+ params.put("customer[email]", email);
+ }
+ if (familyName != null) {
+ params.put("customer[family_name]", familyName);
+ }
+ if (givenName != null) {
+ params.put("customer[given_name]", givenName);
+ }
+ if (language != null) {
+ params.put("customer[language]", language);
+ }
+ if (metadata != null) {
+ params.put("customer[metadata]", metadata);
+ }
+ if (phoneNumber != null) {
+ params.put("customer[phone_number]", phoneNumber);
+ }
+ return params.build();
+ }
+ }
+
+ public static class CustomerBillingDetail {
+ private String addressLine1;
+ private String addressLine2;
+ private String addressLine3;
+ private String city;
+ private String countryCode;
+ private String danishIdentityNumber;
+ private String ipAddress;
+ private String postalCode;
+ private String region;
+ private String swedishIdentityNumber;
+
+ /**
+ * The first line of the customer's address.
+ */
+ public CustomerBillingDetail withAddressLine1(String addressLine1) {
+ this.addressLine1 = addressLine1;
+ return this;
+ }
+
+ /**
+ * The second line of the customer's address.
+ */
+ public CustomerBillingDetail withAddressLine2(String addressLine2) {
+ this.addressLine2 = addressLine2;
+ return this;
+ }
+
+ /**
+ * The third line of the customer's address.
+ */
+ public CustomerBillingDetail withAddressLine3(String addressLine3) {
+ this.addressLine3 = addressLine3;
+ return this;
+ }
+
+ /**
+ * The city of the customer's address.
+ */
+ public CustomerBillingDetail withCity(String city) {
+ this.city = city;
+ return this;
+ }
+
+ /**
+ * [ISO 3166-1 alpha-2
+ * code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
+ */
+ public CustomerBillingDetail withCountryCode(String countryCode) {
+ this.countryCode = countryCode;
+ return this;
+ }
+
+ /**
+ * For Danish customers only. The civic/company number (CPR or CVR) of the customer.
+ * Must be supplied if the customer's bank account is denominated in Danish krone (DKK).
+ */
+ public CustomerBillingDetail withDanishIdentityNumber(String danishIdentityNumber) {
+ this.danishIdentityNumber = danishIdentityNumber;
+ return this;
+ }
+
+ /**
+ * For ACH customers only. Required for ACH customers. A string containing the IP
+ * address of the payer to whom the mandate belongs (i.e. as a result of their
+ * completion of a mandate setup flow in their browser).
+ *
+ * Not required for creating offline mandates where `authorisation_source` is set to
+ * telephone or paper.
+ *
+ */
+ public CustomerBillingDetail withIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ return this;
+ }
+
+ /**
+ * The customer's postal code.
+ */
+ public CustomerBillingDetail withPostalCode(String postalCode) {
+ this.postalCode = postalCode;
+ return this;
+ }
+
+ /**
+ * The customer's address region, county or department. For US customers a 2 letter
+ * [ISO3166-2:US](https://en.wikipedia.org/wiki/ISO_3166-2:US) state code is required
+ * (e.g. `CA` for California).
+ */
+ public CustomerBillingDetail withRegion(String region) {
+ this.region = region;
+ return this;
+ }
+
+ /**
+ * For Swedish customers only. The civic/company number (personnummer,
+ * samordningsnummer, or organisationsnummer) of the customer. Must be supplied if the
+ * customer's bank account is denominated in Swedish krona (SEK). This field cannot be
+ * changed once it has been set.
+ */
+ public CustomerBillingDetail withSwedishIdentityNumber(String swedishIdentityNumber) {
+ this.swedishIdentityNumber = swedishIdentityNumber;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (addressLine1 != null) {
+ params.put("customer_billing_detail[address_line1]", addressLine1);
+ }
+ if (addressLine2 != null) {
+ params.put("customer_billing_detail[address_line2]", addressLine2);
+ }
+ if (addressLine3 != null) {
+ params.put("customer_billing_detail[address_line3]", addressLine3);
+ }
+ if (city != null) {
+ params.put("customer_billing_detail[city]", city);
+ }
+ if (countryCode != null) {
+ params.put("customer_billing_detail[country_code]", countryCode);
+ }
+ if (danishIdentityNumber != null) {
+ params.put("customer_billing_detail[danish_identity_number]",
+ danishIdentityNumber);
+ }
+ if (ipAddress != null) {
+ params.put("customer_billing_detail[ip_address]", ipAddress);
+ }
+ if (postalCode != null) {
+ params.put("customer_billing_detail[postal_code]", postalCode);
+ }
+ if (region != null) {
+ params.put("customer_billing_detail[region]", region);
+ }
+ if (swedishIdentityNumber != null) {
+ params.put("customer_billing_detail[swedish_identity_number]",
+ swedishIdentityNumber);
+ }
+ return params.build();
+ }
+ }
+
+ public static class CollectCustomerDetails {
+ private Customer customer;
+ private CustomerBillingDetail customerBillingDetail;
+
+ public CollectCustomerDetails withCustomer(Customer customer) {
+ this.customer = customer;
+ return this;
+ }
+
+ public CollectCustomerDetails withCustomerBillingDetail(
+ CustomerBillingDetail customerBillingDetail) {
+ this.customerBillingDetail = customerBillingDetail;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (customer != null) {
+ params.put("collect_customer_details[customer]", customer);
+ }
+ if (customerBillingDetail != null) {
+ params.put("collect_customer_details[customer_billing_detail]",
+ customerBillingDetail);
+ }
+ return params.build();
+ }
+ }
+
+ public static class ConfirmPayerDetails {
+ private Map metadata;
+ private Boolean payerRequestedDualSignature;
+
+ /**
+ * 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 ConfirmPayerDetails withMetadata(Map metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * This attribute can be set to true if the payer has indicated that multiple signatures
+ * are required for the mandate. As long as every other Billing Request actions have
+ * been completed, the payer will receive an email notification containing instructions
+ * on how to complete the additional signature. The dual signature flow can only be
+ * completed using GoCardless branded pages.
+ */
+ public ConfirmPayerDetails withPayerRequestedDualSignature(
+ Boolean payerRequestedDualSignature) {
+ this.payerRequestedDualSignature = payerRequestedDualSignature;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (metadata != null) {
+ params.put("confirm_payer_details[metadata]", metadata);
+ }
+ if (payerRequestedDualSignature != null) {
+ params.put("confirm_payer_details[payer_requested_dual_signature]",
+ payerRequestedDualSignature);
+ }
+ return params.build();
+ }
+ }
+
+ public static class SelectInstitution {
+ private String countryCode;
+ private String institution;
+
+ /**
+ * [ISO
+ * 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
+ * alpha-2 code. The country code of the institution. If nothing is provided,
+ * institutions with the country code 'GB' are returned by default.
+ */
+ public SelectInstitution withCountryCode(String countryCode) {
+ this.countryCode = countryCode;
+ return this;
+ }
+
+ /**
+ * The unique identifier for this institution
+ */
+ public SelectInstitution withInstitution(String institution) {
+ this.institution = institution;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (countryCode != null) {
+ params.put("select_institution[country_code]", countryCode);
+ }
+ if (institution != null) {
+ params.put("select_institution[institution]", institution);
+ }
+ return params.build();
+ }
+ }
+
+ public static class Actions {
+ private String bankAuthorisationRedirectUri;
+ private CollectBankAccount collectBankAccount;
+ private CollectCustomerDetails collectCustomerDetails;
+ private ConfirmPayerDetails confirmPayerDetails;
+ private Boolean createBankAuthorisation;
+ private SelectInstitution selectInstitution;
+
+ /**
+ * URL for an oauth flow that will allow the user to authorise the payment
+ */
+ public Actions withBankAuthorisationRedirectUri(String bankAuthorisationRedirectUri) {
+ this.bankAuthorisationRedirectUri = bankAuthorisationRedirectUri;
+ return this;
+ }
+
+ public Actions withCollectBankAccount(CollectBankAccount collectBankAccount) {
+ this.collectBankAccount = collectBankAccount;
+ return this;
+ }
+
+ public Actions withCollectCustomerDetails(
+ CollectCustomerDetails collectCustomerDetails) {
+ this.collectCustomerDetails = collectCustomerDetails;
+ return this;
+ }
+
+ public Actions withConfirmPayerDetails(ConfirmPayerDetails confirmPayerDetails) {
+ this.confirmPayerDetails = confirmPayerDetails;
+ return this;
+ }
+
+ /**
+ * Create a bank authorisation object as part of this request
+ */
+ public Actions withCreateBankAuthorisation(Boolean createBankAuthorisation) {
+ this.createBankAuthorisation = createBankAuthorisation;
+ return this;
+ }
+
+ public Actions withSelectInstitution(SelectInstitution selectInstitution) {
+ this.selectInstitution = selectInstitution;
+ return this;
+ }
+ }
+
+ public static class Links {
+ private String creditor;
+ private String customer;
+ private String customerBankAccount;
+
+ /**
+ * ID of the associated [creditor](#core-endpoints-creditors). Only required if your
+ * account manages multiple creditors.
+ */
+ public Links withCreditor(String creditor) {
+ this.creditor = creditor;
+ return this;
+ }
+
+ /**
+ * ID of the [customer](#core-endpoints-customers) against which this request should be
+ * made.
+ */
+ public Links withCustomer(String customer) {
+ this.customer = customer;
+ return this;
+ }
+
+ /**
+ * (Optional) ID of the [customer_bank_account](#core-endpoints-customer-bank-accounts)
+ * against which this request should be made.
+ *
+ */
+ public Links withCustomerBankAccount(String customerBankAccount) {
+ this.customerBankAccount = customerBankAccount;
+ return this;
+ }
+ }
+
+ public static class PeriodicLimits {
+ private Alignment alignment;
+ private Integer maxPayments;
+ private Integer maxTotalAmount;
+ private Period period;
+
+ /**
+ * The alignment of the period.
+ *
+ * `calendar` - this will finish on the end of the current period. For example this will
+ * expire on the Monday for the current week or the January for the next year.
+ *
+ * `creation_date` - this will finish on the next instance of the current period. For
+ * example Monthly it will expire on the same day of the next month, or yearly the same
+ * day of the next year.
+ *
+ */
+ public PeriodicLimits withAlignment(Alignment alignment) {
+ this.alignment = alignment;
+ return this;
+ }
+
+ /**
+ * (Optional) The maximum number of payments that can be collected in this periodic
+ * limit.
+ */
+ public PeriodicLimits withMaxPayments(Integer maxPayments) {
+ this.maxPayments = maxPayments;
+ return this;
+ }
+
+ /**
+ * The maximum total amount that can be charged for all payments in this periodic limit.
+ * Required for VRP.
+ *
+ */
+ public PeriodicLimits withMaxTotalAmount(Integer maxTotalAmount) {
+ this.maxTotalAmount = maxTotalAmount;
+ return this;
+ }
+
+ /**
+ * The repeating period for this mandate
+ */
+ public PeriodicLimits withPeriod(Period period) {
+ this.period = period;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (alignment != null) {
+ params.put("periodic_limits[alignment]", alignment);
+ }
+ if (maxPayments != null) {
+ params.put("periodic_limits[max_payments]", maxPayments);
+ }
+ if (maxTotalAmount != null) {
+ params.put("periodic_limits[max_total_amount]", maxTotalAmount);
+ }
+ if (period != null) {
+ params.put("periodic_limits[period]", period);
+ }
+ return params.build();
+ }
+
+ public enum Alignment {
+ @SerializedName("calendar")
+ CALENDAR, @SerializedName("creation_date")
+ CREATION_DATE, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+
+ public enum Period {
+ @SerializedName("day")
+ DAY, @SerializedName("week")
+ WEEK, @SerializedName("month")
+ MONTH, @SerializedName("year")
+ YEAR, @SerializedName("flexible")
+ FLEXIBLE, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+ }
+
+ public static class Constraints {
+ private String endDate;
+ private Integer maxAmountPerPayment;
+ private String paymentMethod;
+ private List periodicLimits;
+ private String startDate;
+
+ /**
+ * The latest date at which payments can be taken, must occur after start_date if
+ * present
+ *
+ * This is an optional field and if it is not supplied the agreement will be considered
+ * open and will not have an end date. Keep in mind the end date must take into account
+ * how long it will take the user to set up this agreement via the Billing Request.
+ *
+ */
+ public Constraints withEndDate(String endDate) {
+ this.endDate = endDate;
+ return this;
+ }
+
+ /**
+ * The maximum amount that can be charged for a single payment. Required for VRP.
+ */
+ public Constraints withMaxAmountPerPayment(Integer maxAmountPerPayment) {
+ this.maxAmountPerPayment = 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
+ */
+ public Constraints withPeriodicLimits(List periodicLimits) {
+ this.periodicLimits = periodicLimits;
+ return this;
+ }
+
+ /**
+ * The date from which payments can be taken.
+ *
+ * This is an optional field and if it is not supplied the start date will be set to the
+ * day authorisation happens.
+ *
+ */
+ public Constraints withStartDate(String startDate) {
+ this.startDate = startDate;
+ return this;
+ }
+
+ public Map getQueryParams() {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ if (endDate != null) {
+ params.put("constraints[end_date]", endDate);
+ }
+ 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);
+ }
+ if (startDate != null) {
+ params.put("constraints[start_date]", startDate);
+ }
+ return params.build();
+ }
+ }
+
+ public static class MandateRequest {
+ private AuthorisationSource authorisationSource;
+ private Constraints constraints;
+ private String currency;
+ private String description;
+ private Map metadata;
+ private String reference;
+ private String scheme;
+ private Boolean sweeping;
+ private Verify verify;
+
+ /**
+ * This field is ACH specific, sometimes referred to as [SEC
+ * code](https://www.moderntreasury.com/learn/sec-codes).
+ *
+ * This is the way that the payer gives authorisation to the merchant. web:
+ * Authorisation is Internet Initiated or via Mobile Entry (maps to SEC code: WEB)
+ * telephone: Authorisation is provided orally over telephone (maps to SEC code: TEL)
+ * paper: Authorisation is provided in writing and signed, or similarly authenticated
+ * (maps to SEC code: PPD)
+ *
+ */
+ public MandateRequest withAuthorisationSource(AuthorisationSource authorisationSource) {
+ this.authorisationSource = authorisationSource;
+ return this;
+ }
+
+ /**
+ * Constraints that will apply to the mandate_request. (Optional) Specifically for PayTo
+ * and VRP.
+ */
+ public MandateRequest withConstraints(Constraints constraints) {
+ this.constraints = constraints;
+ return this;
+ }
+
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code.
+ */
+ public MandateRequest withCurrency(String currency) {
+ this.currency = currency;
+ return this;
+ }
+
+ /**
+ * A human-readable description of the payment and/or mandate. This will be displayed to
+ * the payer when authorising the billing request.
+ *
+ */
+ public MandateRequest withDescription(String description) {
+ this.description = description;
+ 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 MandateRequest withMetadata(Map metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * Unique reference. Different schemes have different length and [character
+ * set](#appendix-character-sets) requirements. GoCardless will generate a unique
+ * reference satisfying the different scheme requirements if this field is left blank.
+ */
+ public MandateRequest withReference(String reference) {
+ this.reference = reference;
+ return this;
+ }
+
+ /**
+ * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz",
+ * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported.
+ * Optional for mandate only requests - if left blank, the payer will be able to select
+ * the currency/scheme to pay with from a list of your available schemes.
+ */
+ public MandateRequest withScheme(String scheme) {
+ this.scheme = scheme;
+ return this;
+ }
+
+ /**
+ * If true, this billing request would be used to set up a mandate solely for moving (or
+ * sweeping) money from one account owned by the payer to another account that the payer
+ * also owns. This is required for Faster Payments
+ */
+ public MandateRequest withSweeping(Boolean sweeping) {
+ this.sweeping = sweeping;
+ return this;
+ }
+
+ /**
+ * Verification preference for the mandate. One of:
+ *
+ * - `minimum`: only verify if absolutely required, such as when part of scheme
+ * rules
+ * - `recommended`: in addition to `minimum`, use the GoCardless payment intelligence
+ * solution to decide if a payer should be verified
+ * - `when_available`: if verification mechanisms are available, use them
+ * - `always`: as `when_available`, but fail to create the Billing Request if a
+ * mechanism isn't available
+ *
+ *
+ * By default, all Billing Requests use the `recommended` verification preference. It
+ * uses GoCardless payment intelligence solution to determine if a payer is fraudulent
+ * or not. The verification mechanism is based on the response and the payer may be
+ * asked to verify themselves. If the feature is not available, `recommended` behaves
+ * like `minimum`.
+ *
+ * If you never wish to take advantage of our reduced risk products and Verified
+ * Mandates as they are released in new schemes, please use the `minimum` verification
+ * preference.
+ *
+ * See [Billing Requests: Creating Verified
+ * Mandates](https://developer.gocardless.com/getting-started/billing-requests/verified-mandates/)
+ * for more information.
+ */
+ public MandateRequest withVerify(Verify verify) {
+ this.verify = verify;
+ return this;
+ }
+
+ public enum AuthorisationSource {
+ @SerializedName("web")
+ WEB, @SerializedName("telephone")
+ TELEPHONE, @SerializedName("paper")
+ PAPER, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+
+ public enum Verify {
+ @SerializedName("minimum")
+ MINIMUM, @SerializedName("recommended")
+ RECOMMENDED, @SerializedName("when_available")
+ WHEN_AVAILABLE, @SerializedName("always")
+ ALWAYS, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+ }
+
+ public static class PaymentRequest {
+ private Integer amount;
+ private Integer appFee;
+ private String currency;
+ private String description;
+ private FundsSettlement fundsSettlement;
+ private Map metadata;
+ private String reference;
+ private Boolean retryIfPossible;
+ private String scheme;
+
+ /**
+ * Amount in minor unit (e.g. pence in GBP, cents in EUR).
+ */
+ public PaymentRequest withAmount(Integer amount) {
+ this.amount = amount;
+ return this;
+ }
+
+ /**
+ * The amount to be deducted from the payment as an app fee, to be paid to the partner
+ * integration which created the billing request, in the lowest denomination for the
+ * currency (e.g. pence in GBP, cents in EUR).
+ */
+ public PaymentRequest withAppFee(Integer appFee) {
+ this.appFee = appFee;
+ return this;
+ }
+
+ /**
+ * [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. `GBP`
+ * and `EUR` supported; `GBP` with your customers in the UK and for `EUR` with your
+ * customers in supported Eurozone countries only.
+ */
+ public PaymentRequest withCurrency(String currency) {
+ this.currency = currency;
+ return this;
+ }
+
+ /**
+ * A human-readable description of the payment and/or mandate. This will be displayed to
+ * the payer when authorising the billing request.
+ *
+ */
+ public PaymentRequest withDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * This field will decide how GoCardless handles settlement of funds from the customer.
+ *
+ * - `managed` will be moved through GoCardless' account, batched, and payed out. -
+ * `direct` will be a direct transfer from the payer's account to the merchant where
+ * invoicing will be handled separately.
+ *
+ */
+ public PaymentRequest withFundsSettlement(FundsSettlement fundsSettlement) {
+ this.fundsSettlement = fundsSettlement;
+ 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 PaymentRequest withMetadata(Map metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * A custom payment reference defined by the merchant. It is only available for payments
+ * using the Direct Funds settlement model on the Faster Payments scheme.
+ *
+ */
+ public PaymentRequest withReference(String reference) {
+ this.reference = 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
+ * `sepa_instant_credit_transfer` are supported in supported Eurozone countries (EUR).
+ * For Eurozone countries, `sepa_credit_transfer` is used as the default. Please be
+ * aware that `sepa_instant_credit_transfer` may incur an additional fee for your
+ * customer.
+ */
+ public PaymentRequest withScheme(String scheme) {
+ this.scheme = scheme;
+ return this;
+ }
+
+ public enum FundsSettlement {
+ @SerializedName("managed")
+ MANAGED, @SerializedName("direct")
+ DIRECT, @SerializedName("unknown")
+ UNKNOWN;
+
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+ }
+ }
+
+ 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();
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/gocardless/services/RefundService.java b/src/main/java/com/gocardless/services/RefundService.java
index 78ecf121..6f0c2efe 100644
--- a/src/main/java/com/gocardless/services/RefundService.java
+++ b/src/main/java/com/gocardless/services/RefundService.java
@@ -39,9 +39,6 @@ public RefundService(HttpClient httpClient) {
* amount refunded for the payment. This safeguard is there to prevent two processes from
* creating refunds without awareness of each other.
*
- * - `number_of_refunds_exceeded` if twenty five or more refunds have already been created
- * against the payment.
- *
* - `available_refund_amount_insufficient` if the creditor does not have sufficient balance for
* refunds available to cover the cost of the requested refund.
*
@@ -87,9 +84,6 @@ public RefundUpdateRequest update(String identity) {
* amount refunded for the payment. This safeguard is there to prevent two processes from
* creating refunds without awareness of each other.
*
- * - `number_of_refunds_exceeded` if twenty five or more refunds have already been created
- * against the payment.
- *
* - `available_refund_amount_insufficient` if the creditor does not have sufficient balance for
* refunds available to cover the cost of the requested refund.
*