diff --git a/README.md b/README.md index 086e4aee..0a59ac61 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ With Maven: com.gocardless gocardless-pro - 8.2.0 + 8.5.0 ``` With Gradle: ``` -implementation 'com.gocardless:gocardless-pro:8.2.0' +implementation 'com.gocardless:gocardless-pro:8.5.0' ``` ## Initializing the client diff --git a/build.gradle b/build.gradle index 4dee109d..0719c7f5 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ plugins { sourceCompatibility = 1.8 targetCompatibility = 1.8 group = 'com.gocardless' -version = '8.2.0' +version = '8.5.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 5ba4265d..9c51e2c7 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/8.2.0 java/%s %s/%s %s/%s", + String.format("gocardless-pro-java/8.5.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", "8.2.0"); + builder.put("GoCardless-Client-Version", "8.5.0"); HEADERS = builder.build(); } private final OkHttpClient rawClient; diff --git a/src/main/java/com/gocardless/resources/Event.java b/src/main/java/com/gocardless/resources/Event.java index 1f1328d1..bba52e8f 100644 --- a/src/main/java/com/gocardless/resources/Event.java +++ b/src/main/java/com/gocardless/resources/Event.java @@ -508,7 +508,7 @@ public String getPaymentAccountTransaction() { /** * If `resource_type` is `billing_requests`, this is the ID of the - * [payment](#core-endpoints-payments) which has been created for Instant Bank Payment. + * [payment](#core-endpoints-payments) which has been created for Pay by Bank. */ public String getPaymentRequestPayment() { return paymentRequestPayment; diff --git a/src/main/java/com/gocardless/resources/Mandate.java b/src/main/java/com/gocardless/resources/Mandate.java index f87eaab2..8f53c0cd 100644 --- a/src/main/java/com/gocardless/resources/Mandate.java +++ b/src/main/java/com/gocardless/resources/Mandate.java @@ -23,6 +23,7 @@ private Mandate() { private FundsSettlement fundsSettlement; private String id; private Links links; + private MandateType mandateType; private Map metadata; private String nextPossibleChargeDate; private String nextPossibleStandardAchChargeDate; @@ -92,6 +93,13 @@ public Links getLinks() { return links; } + /** + * Mandate type + */ + public MandateType getMandateType() { + return mandateType; + } + /** * 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. @@ -199,6 +207,16 @@ public enum FundsSettlement { UNKNOWN } + public enum MandateType { + @SerializedName("bank_debit") + BANK_DEBIT, @SerializedName("instant") + INSTANT, @SerializedName("recurring") + RECURRING, @SerializedName("vrp_commercial") + VRP_COMMERCIAL, @SerializedName("vrp_sweeping") + VRP_SWEEPING, @SerializedName("unknown") + UNKNOWN + } + public enum Status { @SerializedName("pending_customer_approval") PENDING_CUSTOMER_APPROVAL, @SerializedName("pending_submission") diff --git a/src/main/java/com/gocardless/resources/Payment.java b/src/main/java/com/gocardless/resources/Payment.java index 712ba7d0..dc9ea978 100644 --- a/src/main/java/com/gocardless/resources/Payment.java +++ b/src/main/java/com/gocardless/resources/Payment.java @@ -157,7 +157,8 @@ public Boolean getRetryIfPossible() { /** * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz", - * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported. + * "betalingsservice", "faster_payments", "pad", "pay_to", "sepa_core", "sepa_credit_transfer" + * and "sepa_instant_credit_transfer" are supported. */ public String getScheme() { return scheme; diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index a63deae4..c3ae4839 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -130,7 +130,7 @@ public BillingRequestGetRequest get(String identity) { * Notifies the customer linked to the billing request, asking them to authorise it. Currently, * the customer can only be notified by email. * - * This endpoint is currently supported only for Instant Bank Pay Billing Requests. + * This endpoint is currently supported only for Pay by Bank Billing Requests. */ public BillingRequestNotifyRequest notify(String identity) { return new BillingRequestNotifyRequest(httpClient, identity); @@ -695,7 +695,7 @@ public BillingRequestCreateRequest withPaymentRequestReference(String reference) * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). *

*

- * Important: This is not applicable to IBP and VRP payments. + * Important: This is not applicable to Pay by Bank and VRP payments. *

*/ public BillingRequestCreateRequest withPaymentRequestRetryIfPossible( @@ -1759,7 +1759,7 @@ public PaymentRequest withReference(String reference) { * be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). *

*

- * Important: This is not applicable to IBP and VRP payments. + * Important: This is not applicable to Pay by Bank and VRP payments. *

*/ public PaymentRequest withRetryIfPossible(Boolean retryIfPossible) { @@ -3063,7 +3063,7 @@ protected Class getResponseClass() { * Notifies the customer linked to the billing request, asking them to authorise it. Currently, * the customer can only be notified by email. * - * This endpoint is currently supported only for Instant Bank Pay Billing Requests. + * This endpoint is currently supported only for Pay by Bank Billing Requests. */ public static final class BillingRequestNotifyRequest extends PostRequest { @PathParam diff --git a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java index 700711b1..dee9a2d7 100644 --- a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java +++ b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java @@ -514,7 +514,7 @@ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestRefere * enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). *

*

- * Important: This is not applicable to IBP and VRP payments. + * Important: This is not applicable to Pay by Bank and VRP payments. *

*/ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestRetryIfPossible( @@ -1711,7 +1711,7 @@ public PaymentRequest withReference(String reference) { * be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus). *

*

- * Important: This is not applicable to IBP and VRP payments. + * Important: This is not applicable to Pay by Bank and VRP payments. *

*/ public PaymentRequest withRetryIfPossible(Boolean retryIfPossible) { diff --git a/src/main/java/com/gocardless/services/PaymentService.java b/src/main/java/com/gocardless/services/PaymentService.java index 692efae4..7c841939 100644 --- a/src/main/java/com/gocardless/services/PaymentService.java +++ b/src/main/java/com/gocardless/services/PaymentService.java @@ -538,7 +538,8 @@ public PaymentListRequest withMandate(String mandate) { /** * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz", - * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported. + * "betalingsservice", "faster_payments", "pad", "pay_to", "sepa_core", + * "sepa_credit_transfer" and "sepa_instant_credit_transfer" are supported. */ public PaymentListRequest withScheme(String scheme) { this.scheme = scheme; diff --git a/src/test/java/com/gocardless/code_samples/BillingRequestsChooseCurrencyCodeSampleTest.java b/src/test/java/com/gocardless/code_samples/BillingRequestsChooseCurrencyCodeSampleTest.java new file mode 100644 index 00000000..6d8cd948 --- /dev/null +++ b/src/test/java/com/gocardless/code_samples/BillingRequestsChooseCurrencyCodeSampleTest.java @@ -0,0 +1,53 @@ +package com.gocardless.code_samples; + +// Code Sample Test +// This test verifies that a documentation code sample is syntactically valid +// and can execute against a mocked API without errors. +// +// IMPORTANT: This test does NOT verify business logic - it only verifies that +// the code sample compiles and executes without syntax errors. +import com.gocardless.GoCardlessClient; +import com.gocardless.resources.*; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class BillingRequestsChooseCurrencyCodeSampleTest { + private static final String ACCESS_TOKEN = "SECRET_TOKEN"; + private GoCardlessClient client; + private MockWebServer server; + + @Before + public void setUp() throws Exception { + server = new MockWebServer(); + server.start(); + client = GoCardlessClient.newBuilder(ACCESS_TOKEN) + .withBaseUrl(String.format("http://localhost:%d", server.getPort())).build(); + } + + @After + public void tearDown() throws Exception { + server.shutdown(); + } + + @Test + public void testChooseCurrencyCodeSample() throws Exception { + // Mock response - enqueue multiple times to handle code samples with multiple API calls + String responseBody = "{ \"billing_requests\": {} }"; + for (int i = 0; i < 5; i++) { + server.enqueue(new MockResponse().setBody(responseBody).setResponseCode(200)); + } + // Suppress stdout from code samples + PrintStream originalOut = System.out; + System.setOut(new PrintStream(new ByteArrayOutputStream())); + try { + client.billingRequests().chooseCurrency("BR123").withCurrency("GBP").execute(); + } finally { + System.setOut(originalOut); + } + } +} diff --git a/src/test/java/com/gocardless/code_samples/BillingRequestsFallbackCodeSampleTest.java b/src/test/java/com/gocardless/code_samples/BillingRequestsFallbackCodeSampleTest.java new file mode 100644 index 00000000..e63110c1 --- /dev/null +++ b/src/test/java/com/gocardless/code_samples/BillingRequestsFallbackCodeSampleTest.java @@ -0,0 +1,53 @@ +package com.gocardless.code_samples; + +// Code Sample Test +// This test verifies that a documentation code sample is syntactically valid +// and can execute against a mocked API without errors. +// +// IMPORTANT: This test does NOT verify business logic - it only verifies that +// the code sample compiles and executes without syntax errors. +import com.gocardless.GoCardlessClient; +import com.gocardless.resources.*; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class BillingRequestsFallbackCodeSampleTest { + private static final String ACCESS_TOKEN = "SECRET_TOKEN"; + private GoCardlessClient client; + private MockWebServer server; + + @Before + public void setUp() throws Exception { + server = new MockWebServer(); + server.start(); + client = GoCardlessClient.newBuilder(ACCESS_TOKEN) + .withBaseUrl(String.format("http://localhost:%d", server.getPort())).build(); + } + + @After + public void tearDown() throws Exception { + server.shutdown(); + } + + @Test + public void testFallbackCodeSample() throws Exception { + // Mock response - enqueue multiple times to handle code samples with multiple API calls + String responseBody = "{ \"billing_requests\": {} }"; + for (int i = 0; i < 5; i++) { + server.enqueue(new MockResponse().setBody(responseBody).setResponseCode(200)); + } + // Suppress stdout from code samples + PrintStream originalOut = System.out; + System.setOut(new PrintStream(new ByteArrayOutputStream())); + try { + client.billingRequests().fallback("BR123").execute(); + } finally { + System.setOut(originalOut); + } + } +}