diff --git a/README.md b/README.md index 0ae15581..7daaec76 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ With Maven: com.gocardless gocardless-pro - 7.2.0 + 7.4.0 ``` With Gradle: ``` -implementation 'com.gocardless:gocardless-pro:7.2.0' +implementation 'com.gocardless:gocardless-pro:7.4.0' ``` ## Initializing the client diff --git a/build.gradle b/build.gradle index eefaa549..e1ae65dd 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ plugins { sourceCompatibility = 1.8 targetCompatibility = 1.8 group = 'com.gocardless' -version = '7.2.0' +version = '7.4.0' apply plugin: 'ch.raffael.pegdown-doclet' diff --git a/src/main/java/com/gocardless/http/HttpClient.java b/src/main/java/com/gocardless/http/HttpClient.java index b9db1b66..2d07e6c1 100644 --- a/src/main/java/com/gocardless/http/HttpClient.java +++ b/src/main/java/com/gocardless/http/HttpClient.java @@ -35,7 +35,7 @@ public class HttpClient { private static final String DISALLOWED_USER_AGENT_CHARACTERS = "[^\\w!#$%&'\\*\\+\\-\\.\\^`\\|~]"; private static final String USER_AGENT = - String.format("gocardless-pro-java/7.2.0 java/%s %s/%s %s/%s", + String.format("gocardless-pro-java/7.4.0 java/%s %s/%s %s/%s", cleanUserAgentToken(System.getProperty("java.vm.specification.version")), cleanUserAgentToken(System.getProperty("java.vm.name")), cleanUserAgentToken(System.getProperty("java.version")), @@ -49,7 +49,7 @@ public class HttpClient { builder.put("GoCardless-Version", "2015-07-06"); builder.put("Accept", "application/json"); builder.put("GoCardless-Client-Library", "gocardless-pro-java"); - builder.put("GoCardless-Client-Version", "7.2.0"); + builder.put("GoCardless-Client-Version", "7.4.0"); HEADERS = builder.build(); } private final OkHttpClient rawClient; diff --git a/src/main/java/com/gocardless/http/ListResponse.java b/src/main/java/com/gocardless/http/ListResponse.java index 3ceb00ef..3e41594d 100644 --- a/src/main/java/com/gocardless/http/ListResponse.java +++ b/src/main/java/com/gocardless/http/ListResponse.java @@ -1,5 +1,6 @@ package com.gocardless.http; +import com.gocardless.resources.*; import java.util.List; /** @@ -10,10 +11,12 @@ public class ListResponse { private final List items; private final Meta meta; + private final Linked linked; - ListResponse(List items, Meta meta) { + ListResponse(List items, Meta meta, Linked linked) { this.items = items; this.meta = meta; + this.linked = linked; } /** @@ -81,4 +84,98 @@ private String getAfter() { } } } + + static class Linked { + private final List billingRequests; + + public List getBillingRequests() { + return billingRequests; + } + + private final List creditors; + + public List getCreditors() { + return creditors; + } + + private final List customers; + + public List getCustomers() { + return customers; + } + + private final List instalmentSchedules; + + public List getInstalmentSchedules() { + return instalmentSchedules; + } + + private final List mandates; + + public List getMandates() { + return mandates; + } + + private final List outboundPayments; + + public List getOutboundPayments() { + return outboundPayments; + } + + private final List payerAuthorisations; + + public List getPayerAuthorisations() { + return payerAuthorisations; + } + + private final List payments; + + public List getPayments() { + return payments; + } + + private final List payouts; + + public List getPayouts() { + return payouts; + } + + private final List refunds; + + public List getRefunds() { + return refunds; + } + + private final List schemeIdentifiers; + + public List getSchemeIdentifiers() { + return schemeIdentifiers; + } + + private final List subscriptions; + + public List getSubscriptions() { + return subscriptions; + } + + Linked(List payouts, List customers, List creditors, + List instalmentSchedules, + List outboundPayments, List billingRequests, + List schemeIdentifiers, List payments, + List subscriptions, List mandates, + List payerAuthorisations, List refunds) { + this.billingRequests = billingRequests; + this.creditors = creditors; + this.customers = customers; + this.instalmentSchedules = instalmentSchedules; + this.mandates = mandates; + this.outboundPayments = outboundPayments; + this.payerAuthorisations = payerAuthorisations; + this.payments = payments; + this.payouts = payouts; + this.refunds = refunds; + this.schemeIdentifiers = schemeIdentifiers; + this.subscriptions = subscriptions; + } + } } diff --git a/src/main/java/com/gocardless/http/ResponseParser.java b/src/main/java/com/gocardless/http/ResponseParser.java index e394db67..504a56ec 100644 --- a/src/main/java/com/gocardless/http/ResponseParser.java +++ b/src/main/java/com/gocardless/http/ResponseParser.java @@ -46,7 +46,9 @@ ListResponse parsePage(String responseBody, String envelope, TypeToken
  • items = parseMultiple(json, envelope, clazz); JsonObject metaJson = json.getAsJsonObject("meta"); ListResponse.Meta meta = gson.fromJson(metaJson, ListResponse.Meta.class); - return new ListResponse<>(ImmutableList.copyOf(items), meta); + JsonObject linkedJson = json.getAsJsonObject("linked"); + ListResponse.Linked linked = gson.fromJson(linkedJson, ListResponse.Linked.class); + return new ListResponse<>(ImmutableList.copyOf(items), meta, linked); } GoCardlessApiException parseError(String responseBody) { diff --git a/src/main/java/com/gocardless/resources/BillingRequest.java b/src/main/java/com/gocardless/resources/BillingRequest.java index 9e536da4..0e63cfc0 100644 --- a/src/main/java/com/gocardless/resources/BillingRequest.java +++ b/src/main/java/com/gocardless/resources/BillingRequest.java @@ -161,7 +161,11 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("unknown") + OTHER, @SerializedName("Epayment") + EPAYMENT, @SerializedName("Commercial") + COMMERCIAL, @SerializedName("OtherPayment") + OTHERPAYMENT, @SerializedName("Trade") + TRADE, @SerializedName("unknown") UNKNOWN } diff --git a/src/main/java/com/gocardless/resources/BillingRequestWithAction.java b/src/main/java/com/gocardless/resources/BillingRequestWithAction.java index 2d6549d1..17366a44 100644 --- a/src/main/java/com/gocardless/resources/BillingRequestWithAction.java +++ b/src/main/java/com/gocardless/resources/BillingRequestWithAction.java @@ -357,7 +357,11 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("unknown") + OTHER, @SerializedName("Epayment") + EPAYMENT, @SerializedName("Commercial") + COMMERCIAL, @SerializedName("OtherPayment") + OTHERPAYMENT, @SerializedName("Trade") + TRADE, @SerializedName("unknown") UNKNOWN } diff --git a/src/main/java/com/gocardless/resources/Event.java b/src/main/java/com/gocardless/resources/Event.java index a33b16d2..cc62ee6a 100644 --- a/src/main/java/com/gocardless/resources/Event.java +++ b/src/main/java/com/gocardless/resources/Event.java @@ -324,6 +324,7 @@ private Links() { private String customerBankAccount; private String instalmentSchedule; private String mandate; + private String mandateRequest; private String mandateRequestMandate; private String newCustomerBankAccount; private String newMandate; @@ -397,6 +398,13 @@ public String getMandate() { return mandate; } + /** + * This is the id of the mandate request associated to this event + */ + public String getMandateRequest() { + return mandateRequest; + } + /** * If `resource_type` is `billing_requests`, this is the ID of the * [mandate](#core-endpoints-mandates) which has been created. diff --git a/src/main/java/com/gocardless/resources/Mandate.java b/src/main/java/com/gocardless/resources/Mandate.java index cefb1188..2934507c 100644 --- a/src/main/java/com/gocardless/resources/Mandate.java +++ b/src/main/java/com/gocardless/resources/Mandate.java @@ -1,7 +1,6 @@ package com.gocardless.resources; import com.google.gson.annotations.SerializedName; -import java.util.List; import java.util.Map; /** @@ -227,7 +226,9 @@ private ConsentParameters() { private String endDate; private Integer maxAmountPerPayment; - private List periods; + private Integer maxAmountPerPeriod; + private Integer maxPaymentsPerPeriod; + private Period period; private String startDate; /** @@ -245,10 +246,24 @@ public Integer getMaxAmountPerPayment() { } /** - * Frequency configuration + * The maximum total amount that can be charged for all payments in this period */ - public List getPeriods() { - return periods; + public Integer getMaxAmountPerPeriod() { + return maxAmountPerPeriod; + } + + /** + * The maximum number of payments that can be collected in this period + */ + public Integer getMaxPaymentsPerPeriod() { + return maxPaymentsPerPeriod; + } + + /** + * The repeating period for this mandate + */ + public Period getPeriod() { + return period; } /** @@ -258,45 +273,14 @@ public String getStartDate() { return startDate; } - public static class Period { - private Period() { - // blank to prevent instantiation - } - - private Integer maxAmountPerPeriod; - private Integer maxPaymentsPerPeriod; - private PeriodPeriod period; - - /** - * The maximum total amount that can be charged for all payments in this period - */ - public Integer getMaxAmountPerPeriod() { - return maxAmountPerPeriod; - } - - /** - * The maximum number of payments that can be collected in this period - */ - public Integer getMaxPaymentsPerPeriod() { - return maxPaymentsPerPeriod; - } - - /** - * The repeating period for this mandate - */ - public PeriodPeriod getPeriod() { - return period; - } - - public enum PeriodPeriod { - @SerializedName("day") - DAY, @SerializedName("week") - WEEK, @SerializedName("month") - MONTH, @SerializedName("year") - YEAR, @SerializedName("flexible") - FLEXIBLE, @SerializedName("unknown") - UNKNOWN - } + public enum Period { + @SerializedName("day") + DAY, @SerializedName("week") + WEEK, @SerializedName("month") + MONTH, @SerializedName("year") + YEAR, @SerializedName("flexible") + FLEXIBLE, @SerializedName("unknown") + UNKNOWN } } diff --git a/src/main/java/com/gocardless/resources/OutboundPayment.java b/src/main/java/com/gocardless/resources/OutboundPayment.java index c75f2e0f..5a6d0bf7 100644 --- a/src/main/java/com/gocardless/resources/OutboundPayment.java +++ b/src/main/java/com/gocardless/resources/OutboundPayment.java @@ -33,7 +33,7 @@ private OutboundPayment() { private Links links; private Map metadata; private String reference; - private String scheme; + private Scheme scheme; private Status status; private Verifications verifications; @@ -103,7 +103,10 @@ public Map getMetadata() { } /** - * An auto-generated reference that will appear on your receiver's bank statement. + * An optional reference that will appear on your customer's bank statement. The character limit + * for this reference is dependent on the scheme.
    + * Faster Payments - 18 characters, including: + * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 &-./"
    */ public String getReference() { return reference; @@ -113,7 +116,7 @@ public String getReference() { * Bank payment scheme to process the outbound payment. Currently only "faster_payments" (GBP) * is supported. */ - public String getScheme() { + public Scheme getScheme() { return scheme; } @@ -156,6 +159,12 @@ public enum Currency { UNKNOWN } + public enum Scheme { + @SerializedName("faster_payments") + FASTER_PAYMENTS, @SerializedName("unknown") + UNKNOWN + } + public enum Status { @SerializedName("verifying") VERIFYING, @SerializedName("pending_approval") @@ -233,8 +242,8 @@ private RecipientBankAccountHolderVerification() { private Type type; /** - * -| The actual account name returned by the recipient's bank, populated only in the - * case of a partial match. + * The actual account name returned by the recipient's bank, populated only in the case + * of a partial match. */ public String getActualAccountName() { return actualAccountName; diff --git a/src/main/java/com/gocardless/resources/Payment.java b/src/main/java/com/gocardless/resources/Payment.java index 38321bfc..30e59391 100644 --- a/src/main/java/com/gocardless/resources/Payment.java +++ b/src/main/java/com/gocardless/resources/Payment.java @@ -31,6 +31,7 @@ private Payment() { private Map metadata; private String reference; private Boolean retryIfPossible; + private String scheme; private Status status; /** @@ -154,6 +155,14 @@ public Boolean getRetryIfPossible() { return retryIfPossible; } + /** + * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz", + * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported. + */ + public String getScheme() { + return scheme; + } + /** * One of: *
      diff --git a/src/main/java/com/gocardless/resources/ScenarioSimulator.java b/src/main/java/com/gocardless/resources/ScenarioSimulator.java index 36abced2..81f200e0 100644 --- a/src/main/java/com/gocardless/resources/ScenarioSimulator.java +++ b/src/main/java/com/gocardless/resources/ScenarioSimulator.java @@ -109,6 +109,11 @@ private ScenarioSimulator() { * it, and moves the associated payment to `failed`. The billing request must be in the * `pending` state, with all actions completed except for `bank_authorisation`. Only billing * requests with a `payment_request` are supported. + *
    • `billing_request_fulfilled_and_payment_confirmed_to_failed`: Authorises the billing + * request, fulfils it, moves the associated payment to `confirmed` and then moves it to + * `failed`. The billing request must be in the `pending` state, with all actions completed + * except for `bank_authorisation`. Only billing requests with a `payment_request` are + * supported.
    • *
    • `billing_request_fulfilled_and_payment_paid_out`: Authorises the billing request, fulfils * it, and moves the associated payment to `paid_out`. The billing request must be in the * `pending` state, with all actions completed except for `bank_authorisation`. Only billing diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index 4be888fa..3e25bb91 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -921,7 +921,11 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("unknown") + OTHER, @SerializedName("Epayment") + EPAYMENT, @SerializedName("Commercial") + COMMERCIAL, @SerializedName("OtherPayment") + OTHERPAYMENT, @SerializedName("Trade") + TRADE, @SerializedName("unknown") UNKNOWN; @Override diff --git a/src/main/java/com/gocardless/services/BillingRequestTemplateService.java b/src/main/java/com/gocardless/services/BillingRequestTemplateService.java index 16ea5a36..53261738 100644 --- a/src/main/java/com/gocardless/services/BillingRequestTemplateService.java +++ b/src/main/java/com/gocardless/services/BillingRequestTemplateService.java @@ -79,6 +79,8 @@ public BillingRequestTemplateUpdateRequest update(String identity) { */ public static final class BillingRequestTemplateListRequest extends ListRequest { + private String paymentRequestScheme; + /** * Cursor pointing to the start of the desired set. */ @@ -103,6 +105,19 @@ public BillingRequestTemplateListRequest withLimit(Integer limit) { 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 BillingRequestTemplateListRequest withPaymentRequestScheme( + String paymentRequestScheme) { + this.paymentRequestScheme = paymentRequestScheme; + return this; + } + private BillingRequestTemplateListRequest(HttpClient httpClient, ListRequestExecutor executor) { super(httpClient, executor); @@ -118,6 +133,9 @@ public BillingRequestTemplateListRequest withHeader(String headerName, protected Map getQueryParams() { ImmutableMap.Builder params = ImmutableMap.builder(); params.putAll(super.getQueryParams()); + if (paymentRequestScheme != null) { + params.put("payment_request_scheme", paymentRequestScheme); + } return params.build(); } diff --git a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java index 77ab8402..a8996381 100644 --- a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java +++ b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java @@ -553,7 +553,11 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("unknown") + OTHER, @SerializedName("Epayment") + EPAYMENT, @SerializedName("Commercial") + COMMERCIAL, @SerializedName("OtherPayment") + OTHERPAYMENT, @SerializedName("Trade") + TRADE, @SerializedName("unknown") UNKNOWN; @Override diff --git a/src/main/java/com/gocardless/services/OutboundPaymentService.java b/src/main/java/com/gocardless/services/OutboundPaymentService.java index 64e61177..d8257bf1 100644 --- a/src/main/java/com/gocardless/services/OutboundPaymentService.java +++ b/src/main/java/com/gocardless/services/OutboundPaymentService.java @@ -105,7 +105,8 @@ public static final class OutboundPaymentCreateRequest private String executionDate; private Links links; private Map metadata; - private String scheme; + private String reference; + private Scheme scheme; /** * Amount, in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). @@ -181,11 +182,22 @@ public OutboundPaymentCreateRequest withMetadata(String key, String value) { return this; } + /** + * An optional reference that will appear on your customer's bank statement. The character + * limit for this reference is dependent on the scheme.
      + * Faster Payments - 18 characters, including: + * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 &-./"
      + */ + public OutboundPaymentCreateRequest withReference(String reference) { + this.reference = reference; + return this; + } + /** * Bank payment scheme to process the outbound payment. Currently only "faster_payments" * (GBP) is supported. */ - public OutboundPaymentCreateRequest withScheme(String scheme) { + public OutboundPaymentCreateRequest withScheme(Scheme scheme) { this.scheme = scheme; return this; } @@ -233,6 +245,17 @@ protected boolean hasBody() { return true; } + public enum Scheme { + @SerializedName("faster_payments") + FASTER_PAYMENTS, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + public static class Links { private String creditor; private String recipientBankAccount; @@ -266,7 +289,8 @@ public static final class OutboundPaymentWithdrawRequest extends PostRequest metadata; - private String scheme; + private String reference; + private Scheme scheme; /** * Amount, in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR). @@ -330,11 +354,22 @@ public OutboundPaymentWithdrawRequest withMetadata(String key, String value) { return this; } + /** + * An optional reference that will appear on your customer's bank statement. The character + * limit for this reference is dependent on the scheme.
      + * Faster Payments - 18 characters, including: + * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 &-./"
      + */ + public OutboundPaymentWithdrawRequest withReference(String reference) { + this.reference = reference; + return this; + } + /** * Bank payment scheme to process the outbound payment. Currently only "faster_payments" * (GBP) is supported. */ - public OutboundPaymentWithdrawRequest withScheme(String scheme) { + public OutboundPaymentWithdrawRequest withScheme(Scheme scheme) { this.scheme = scheme; return this; } @@ -373,6 +408,17 @@ protected String getRequestEnvelope() { return "data"; } + public enum Scheme { + @SerializedName("faster_payments") + FASTER_PAYMENTS, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + public static class Links { private String creditor;