Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ With Maven:
<dependency>
<groupId>com.gocardless</groupId>
<artifactId>gocardless-pro</artifactId>
<version>8.2.0</version>
<version>8.5.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:8.2.0'
implementation 'com.gocardless:gocardless-pro:8.5.0'
```

## Initializing the client
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gocardless/http/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gocardless/resources/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/gocardless/resources/Mandate.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private Mandate() {
private FundsSettlement fundsSettlement;
private String id;
private Links links;
private MandateType mandateType;
private Map<String, String> metadata;
private String nextPossibleChargeDate;
private String nextPossibleStandardAchChargeDate;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/gocardless/resources/Payment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -695,7 +695,7 @@ public BillingRequestCreateRequest withPaymentRequestReference(String reference)
* enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus).
* </p>
* <p class="notice">
* <strong>Important</strong>: This is not applicable to IBP and VRP payments.
* <strong>Important</strong>: This is not applicable to Pay by Bank and VRP payments.
* </p>
*/
public BillingRequestCreateRequest withPaymentRequestRetryIfPossible(
Expand Down Expand Up @@ -1759,7 +1759,7 @@ public PaymentRequest withReference(String reference) {
* be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus).
* </p>
* <p class="notice">
* <strong>Important</strong>: This is not applicable to IBP and VRP payments.
* <strong>Important</strong>: This is not applicable to Pay by Bank and VRP payments.
* </p>
*/
public PaymentRequest withRetryIfPossible(Boolean retryIfPossible) {
Expand Down Expand Up @@ -3063,7 +3063,7 @@ protected Class<BillingRequest> 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<BillingRequest> {
@PathParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestRefere
* enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus).
* </p>
* <p class="notice">
* <strong>Important</strong>: This is not applicable to IBP and VRP payments.
* <strong>Important</strong>: This is not applicable to Pay by Bank and VRP payments.
* </p>
*/
public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestRetryIfPossible(
Expand Down Expand Up @@ -1711,7 +1711,7 @@ public PaymentRequest withReference(String reference) {
* be enabled in [GoCardless dashboard](https://manage.gocardless.com/success-plus).
* </p>
* <p class="notice">
* <strong>Important</strong>: This is not applicable to IBP and VRP payments.
* <strong>Important</strong>: This is not applicable to Pay by Bank and VRP payments.
* </p>
*/
public PaymentRequest withRetryIfPossible(Boolean retryIfPossible) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/gocardless/services/PaymentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ public PaymentListRequest<S> 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<S> withScheme(String scheme) {
this.scheme = scheme;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
}