Skip to content

Commit

Permalink
Merge pull request #131 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Changes from gocardless/gocardless-pro-java-template
  • Loading branch information
prolific117 authored Sep 24, 2024
2 parents f8a92a2 + b66c5dc commit e026a3b
Show file tree
Hide file tree
Showing 12 changed files with 572 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
jdk-version: [ 8, 9, 11 ]
jdk-version: [ 8, 11 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v2
Expand Down
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>5.27.0</version>
<version>6.0.0</version>
</dependency>
```

With Gradle:

```
implementation 'com.gocardless:gocardless-pro:5.27.0'
implementation 'com.gocardless:gocardless-pro:6.0.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 @@ -25,7 +25,7 @@ plugins {
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'com.gocardless'
version = '5.27.0'
version = '6.0.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/5.27.0 java/%s %s/%s %s/%s",
String.format("gocardless-pro-java/6.0.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", "5.27.0");
builder.put("GoCardless-Client-Version", "6.0.0");
HEADERS = builder.build();
}
private final OkHttpClient rawClient;
Expand Down
187 changes: 187 additions & 0 deletions src/main/java/com/gocardless/resources/BillingRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private BillingRequest() {
private PurposeCode purposeCode;
private Resources resources;
private Status status;
private SubscriptionRequest subscriptionRequest;

/**
* List of actions that can be performed before this billing request can be fulfilled.
Expand Down Expand Up @@ -119,6 +120,13 @@ public Status getStatus() {
return status;
}

/**
* Request for a subscription
*/
public SubscriptionRequest getSubscriptionRequest() {
return subscriptionRequest;
}

public enum PurposeCode {
@SerializedName("mortgage")
MORTGAGE, @SerializedName("utility")
Expand Down Expand Up @@ -383,6 +391,7 @@ private Links() {
private String paymentProvider;
private String paymentRequest;
private String paymentRequestPayment;
private String subscriptionRequest;

/**
* (Optional) ID of the [bank authorisation](#billing-requests-bank-authorisations) that was
Expand Down Expand Up @@ -464,6 +473,13 @@ public String getPaymentRequest() {
public String getPaymentRequestPayment() {
return paymentRequestPayment;
}

/**
* (Optional) ID of the associated subscription request
*/
public String getSubscriptionRequest() {
return subscriptionRequest;
}
}

/**
Expand All @@ -477,6 +493,7 @@ private MandateRequest() {
}

private AuthorisationSource authorisationSource;
private String consentType;
private Constraints constraints;
private String currency;
private String description;
Expand All @@ -500,6 +517,15 @@ 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.
*/
public String getConsentType() {
return consentType;
}

/**
* Constraints that will apply to the mandate_request. (Optional) Specifically for PayTo and
* VRP.
Expand Down Expand Up @@ -1002,6 +1028,7 @@ private CustomerBankAccount() {
private String accountHolderName;
private String accountNumberEnding;
private AccountType accountType;
private String bankAccountToken;
private String bankName;
private String countryCode;
private String createdAt;
Expand Down Expand Up @@ -1038,6 +1065,14 @@ 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.
*/
Expand Down Expand Up @@ -1249,4 +1284,156 @@ public String getSwedishIdentityNumber() {
}
}
}

/**
* Represents a subscription request resource returned from the API.
*
* Request for a subscription
*/
public static class SubscriptionRequest {
private SubscriptionRequest() {
// blank to prevent instantiation
}

private Integer amount;
private Integer appFee;
private Integer count;
private String currency;
private Integer dayOfMonth;
private Integer interval;
private IntervalUnit intervalUnit;
private Map<String, Object> metadata;
private Month month;
private String name;
private String paymentReference;
private String startDate;

/**
* Amount in the lowest denomination for the currency (e.g. pence in GBP, cents in EUR).
*/
public Integer getAmount() {
return amount;
}

/**
* The amount to be deducted from each payment as an app fee, to be paid to the partner
* integration which created the subscription, in the lowest denomination for the currency
* (e.g. pence in GBP, cents in EUR).
*/
public Integer getAppFee() {
return appFee;
}

/**
* The total number of payments that should be taken by this subscription.
*/
public Integer getCount() {
return count;
}

/**
* [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. Currently
* "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are supported.
*/
public String getCurrency() {
return currency;
}

/**
* As per RFC 2445. The day of the month to charge customers on. `1`-`28` or `-1` to
* indicate the last day of the month.
*/
public Integer getDayOfMonth() {
return dayOfMonth;
}

/**
* Number of `interval_units` between customer charge dates. Must be greater than or equal
* to `1`. Must result in at least one charge date per year. Defaults to `1`.
*/
public Integer getInterval() {
return interval;
}

/**
* The unit of time between customer charge dates. One of `weekly`, `monthly` or `yearly`.
*/
public IntervalUnit getIntervalUnit() {
return intervalUnit;
}

/**
* Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50
* characters and values up to 500 characters.
*/
public Map<String, Object> 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. <br />
* <p class="restricted-notice">
* <strong>Restricted</strong>: You need your own Service User Number to specify a payment
* reference for Bacs payments.
* </p>
*/
public String getPaymentReference() {
return paymentReference;
}

/**
* The date on which the first payment should be charged. Must be on or after the
* [mandate](#core-endpoints-mandates)'s `next_possible_charge_date`. When left blank and
* `month` or `day_of_month` are provided, this will be set to the date of the first
* payment. If created without `month` or `day_of_month` this will be set as the mandate's
* `next_possible_charge_date`
*/
public String getStartDate() {
return startDate;
}

public enum IntervalUnit {
@SerializedName("weekly")
WEEKLY, @SerializedName("monthly")
MONTHLY, @SerializedName("yearly")
YEARLY, @SerializedName("unknown")
UNKNOWN
}

public enum Month {
@SerializedName("january")
JANUARY, @SerializedName("february")
FEBRUARY, @SerializedName("march")
MARCH, @SerializedName("april")
APRIL, @SerializedName("may")
MAY, @SerializedName("june")
JUNE, @SerializedName("july")
JULY, @SerializedName("august")
AUGUST, @SerializedName("september")
SEPTEMBER, @SerializedName("october")
OCTOBER, @SerializedName("november")
NOVEMBER, @SerializedName("december")
DECEMBER, @SerializedName("unknown")
UNKNOWN
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private BillingRequestTemplate() {
private MandateRequestVerify mandateRequestVerify;
private Map<String, Object> metadata;
private String name;
private Integer paymentRequestAmount;
private String paymentRequestAmount;
private String paymentRequestCurrency;
private String paymentRequestDescription;
private Map<String, Object> paymentRequestMetadata;
Expand Down Expand Up @@ -141,9 +141,9 @@ public String getName() {
}

/**
* Amount in minor unit (e.g. pence in GBP, cents in EUR).
* Amount in full.
*/
public Integer getPaymentRequestAmount() {
public String getPaymentRequestAmount() {
return paymentRequestAmount;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private CustomerBankAccount() {
private String accountHolderName;
private String accountNumberEnding;
private AccountType accountType;
private String bankAccountToken;
private String bankName;
private String countryCode;
private String createdAt;
Expand Down Expand Up @@ -62,6 +63,14 @@ 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.
*/
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/gocardless/resources/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public enum ResourceType {
EXPORTS, @SerializedName("instalment_schedules")
INSTALMENT_SCHEDULES, @SerializedName("mandates")
MANDATES, @SerializedName("organisations")
ORGANISATIONS, @SerializedName("payer_authorisations")
ORGANISATIONS, @SerializedName("outbound_payments")
OUTBOUND_PAYMENTS, @SerializedName("payer_authorisations")
PAYER_AUTHORISATIONS, @SerializedName("payments")
PAYMENTS, @SerializedName("payouts")
PAYOUTS, @SerializedName("refunds")
Expand Down Expand Up @@ -175,6 +176,7 @@ private Details() {
private String cause;
private String currency;
private String description;
private Integer itemCount;
private String notRetriedReason;
private Origin origin;
private String property;
Expand Down Expand Up @@ -214,6 +216,13 @@ public String getDescription() {
return description;
}

/**
* Count of rows in the csv. This is sent for export events
*/
public Integer getItemCount() {
return itemCount;
}

/**
* When will_attempt_retry is set to false, this field will contain the reason the payment
* was not retried. This can be one of:
Expand Down
Loading

0 comments on commit e026a3b

Please sign in to comment.