diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2801c23..b1f26a49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,70 +1,44 @@ -name: gocardless/gocardless-pro-java/build -on: push +name: build & test + +on: + push: + branches: [master] + pull_request: + types: [opened, reopened, synchronize] jobs: - test_library_jdk8: - runs-on: ubuntu-latest - container: - image: openjdk:8 - steps: - - uses: actions/checkout@v2 - - name: Test - run: |- - export TERM=${TERM:-dumb} - ./install_crypto_deps.sh - ./gradlew test - - name: Save test results - run: |- - mkdir -p ~/junit - find . -type f -regex "$OUT_DIR/build/test-results/test/.*xml" -exec cp {} ~/junit/ \; - if: always() - - uses: actions/upload-artifact@v2 - with: - path: "~/junit" - - uses: actions/upload-artifact@v2 - with: - path: "~/junit" - test_library_jdk9: - runs-on: ubuntu-latest - container: - image: openjdk:9 - steps: - - uses: actions/checkout@v2 - - name: Test - run: |- - export TERM=${TERM:-dumb} - ./install_crypto_deps.sh - ./gradlew test --debug - - name: Save test results - run: |- - mkdir -p ~/junit - find . -type f -regex "$OUT_DIR/build/test-results/test/.*xml" -exec cp {} ~/junit/ \; - if: always() - - uses: actions/upload-artifact@v2 - with: - path: "~/junit" - - uses: actions/upload-artifact@v2 - with: - path: "~/junit" - test_library_jdk11: + test: runs-on: ubuntu-latest - container: - image: openjdk:11 + strategy: + fail-fast: false + matrix: + jdk-version: [ 8, 9, 11 ] steps: - - uses: actions/checkout@v2 - - name: Test - run: |- - export TERM=${TERM:-dumb} - ./install_crypto_deps.sh - ./gradlew test - - name: Save test results - run: |- - mkdir -p ~/junit - find . -type f -regex "$OUT_DIR/build/test-results/test/.*xml" -exec cp {} ~/junit/ \; - if: always() - - uses: actions/upload-artifact@v2 - with: - path: "~/junit" - - uses: actions/upload-artifact@v2 - with: - path: "~/junit" + - uses: actions/checkout@v4 + - uses: actions/setup-java@v2 + with: + java-version: "${{ matrix.jdk-version }}" + distribution: adopt + - name: Verify java installed properly + run: java -version + - name: Grant execute permission for gradlew + run: chmod +x gradlew + # test + - name: Test + run: |- + export TERM=${TERM:-dumb} + ./gradlew test --debug + # test build + - name: Build with Gradle + run: ./gradlew build + - name: Save test results + if: always() + run: |- + mkdir -p ~/junit + find . -type f -regex "./build/test-results/test/.*xml" -exec cp {} ~/junit/ \; + - uses: actions/upload-artifact@v4 + if: always() + with: + name: test_library_jdk${{ matrix.jdk-version }}_junit + path: "~/junit" + retention-days: 7 diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index c552613f..89d600c1 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -31,5 +31,5 @@ jobs: - name: Publish package run: ./gradlew publishToSonatype closeAndReleaseStagingRepository -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_KEY_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg) -Dorg.gradle.internal.http.socketTimeout=300000 --stacktrace env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + MAVEN_USERNAME: ${{ secrets.OSSRH_ACCESS_TOKEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_ACCESS_TOKEN_PASSWORD }} diff --git a/.gitignore b/.gitignore index 6266b006..e134aac3 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,6 @@ out/ ############################## ## Visual Studio Code ############################## -.vscode/ \ No newline at end of file +.vscode/ + +tmp-push-files-checkout/ diff --git a/README.md b/README.md index bf80ae2d..f03ea69f 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ With Maven: com.gocardless gocardless-pro - 5.14.2 + 5.26.1 ``` With Gradle: ``` -implementation 'com.gocardless:gocardless-pro:5.14.2' +implementation 'com.gocardless:gocardless-pro:5.26.1' ``` ## Initializing the client diff --git a/build.gradle b/build.gradle index 78ab4f66..633e9aeb 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,11 @@ buildscript { repositories { mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } + jcenter() + google() + maven { + url 'https://maven.google.com' + } } dependencies { @@ -20,12 +25,18 @@ plugins { sourceCompatibility = 1.8 targetCompatibility = 1.8 group = 'com.gocardless' -version = '5.14.2' +version = '5.26.1' apply plugin: 'ch.raffael.pegdown-doclet' repositories { mavenCentral() + maven { url 'https://plugins.gradle.org/m2/' } + jcenter() + google() + maven { + url 'https://maven.google.com' + } } dependencies { diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 index cccdd3d5..a956838e --- a/gradlew +++ b/gradlew @@ -1,4 +1,5 @@ #!/usr/bin/env sh +set -x ############################################################################## ## diff --git a/src/main/java/com/gocardless/GoCardlessClient.java b/src/main/java/com/gocardless/GoCardlessClient.java index 2b8aa595..11a66816 100644 --- a/src/main/java/com/gocardless/GoCardlessClient.java +++ b/src/main/java/com/gocardless/GoCardlessClient.java @@ -29,11 +29,14 @@ public class GoCardlessClient { private final EventService events; private final InstalmentScheduleService instalmentSchedules; private final InstitutionService institutions; + private final LogoService logos; private final MandateService mandates; private final MandateImportService mandateImports; private final MandateImportEntryService mandateImportEntries; private final MandatePdfService mandatePdfs; + private final NegativeBalanceLimitService negativeBalanceLimits; private final PayerAuthorisationService payerAuthorisations; + private final PayerThemeService payerThemes; private final PaymentService payments; private final PayoutService payouts; private final PayoutItemService payoutItems; @@ -43,6 +46,7 @@ public class GoCardlessClient { private final SchemeIdentifierService schemeIdentifiers; private final SubscriptionService subscriptions; private final TaxRateService taxRates; + private final TransferredMandateService transferredMandates; private final VerificationDetailService verificationDetails; private final WebhookService webhooks; @@ -181,11 +185,14 @@ private GoCardlessClient(HttpClient httpClient) { this.events = new EventService(httpClient); this.instalmentSchedules = new InstalmentScheduleService(httpClient); this.institutions = new InstitutionService(httpClient); + this.logos = new LogoService(httpClient); this.mandates = new MandateService(httpClient); this.mandateImports = new MandateImportService(httpClient); this.mandateImportEntries = new MandateImportEntryService(httpClient); this.mandatePdfs = new MandatePdfService(httpClient); + this.negativeBalanceLimits = new NegativeBalanceLimitService(httpClient); this.payerAuthorisations = new PayerAuthorisationService(httpClient); + this.payerThemes = new PayerThemeService(httpClient); this.payments = new PaymentService(httpClient); this.payouts = new PayoutService(httpClient); this.payoutItems = new PayoutItemService(httpClient); @@ -195,6 +202,7 @@ private GoCardlessClient(HttpClient httpClient) { this.schemeIdentifiers = new SchemeIdentifierService(httpClient); this.subscriptions = new SubscriptionService(httpClient); this.taxRates = new TaxRateService(httpClient); + this.transferredMandates = new TransferredMandateService(httpClient); this.verificationDetails = new VerificationDetailService(httpClient); this.webhooks = new WebhookService(httpClient); } @@ -304,6 +312,13 @@ public InstitutionService institutions() { return institutions; } + /** + * A service class for working with logo resources. + */ + public LogoService logos() { + return logos; + } + /** * A service class for working with mandate resources. */ @@ -332,6 +347,13 @@ public MandatePdfService mandatePdfs() { return mandatePdfs; } + /** + * A service class for working with negative balance limit resources. + */ + public NegativeBalanceLimitService negativeBalanceLimits() { + return negativeBalanceLimits; + } + /** * A service class for working with payer authorisation resources. */ @@ -339,6 +361,13 @@ public PayerAuthorisationService payerAuthorisations() { return payerAuthorisations; } + /** + * A service class for working with payer theme resources. + */ + public PayerThemeService payerThemes() { + return payerThemes; + } + /** * A service class for working with payment resources. */ @@ -402,6 +431,13 @@ public TaxRateService taxRates() { return taxRates; } + /** + * A service class for working with transferred mandate resources. + */ + public TransferredMandateService transferredMandates() { + return transferredMandates; + } + /** * A service class for working with verification detail resources. */ diff --git a/src/main/java/com/gocardless/http/HttpClient.java b/src/main/java/com/gocardless/http/HttpClient.java index d6be0a46..3094418e 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/5.14.1 java/%s %s/%s %s/%s", + String.format("gocardless-pro-java/5.26.1 java/%s %s/%s %s/%s", cleanUserAgentToken(System.getProperty("java.vm.specification.version")), cleanUserAgentToken(System.getProperty("java.vm.name")), cleanUserAgentToken(System.getProperty("java.version")), @@ -47,8 +47,9 @@ public class HttpClient { static { ImmutableMap.Builder builder = ImmutableMap.builder(); 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.14.1"); + builder.put("GoCardless-Client-Version", "5.26.1"); HEADERS = builder.build(); } private final OkHttpClient rawClient; diff --git a/src/main/java/com/gocardless/resources/BankAuthorisation.java b/src/main/java/com/gocardless/resources/BankAuthorisation.java index b15b827d..fc6ea8c6 100644 --- a/src/main/java/com/gocardless/resources/BankAuthorisation.java +++ b/src/main/java/com/gocardless/resources/BankAuthorisation.java @@ -23,6 +23,7 @@ private BankAuthorisation() { private String id; private String lastVisitedAt; private Links links; + private String qrCodeUrl; private String redirectUri; private String url; @@ -74,6 +75,15 @@ 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. * diff --git a/src/main/java/com/gocardless/resources/BillingRequest.java b/src/main/java/com/gocardless/resources/BillingRequest.java index 51ad7b04..1bb28a92 100644 --- a/src/main/java/com/gocardless/resources/BillingRequest.java +++ b/src/main/java/com/gocardless/resources/BillingRequest.java @@ -26,7 +26,7 @@ private BillingRequest() { private String id; private Links links; private MandateRequest mandateRequest; - private Map metadata; + private Map metadata; private PaymentRequest paymentRequest; private PurposeCode purposeCode; private Resources resources; @@ -51,7 +51,7 @@ public String getCreatedAt() { * Should not be set if GoCardless payment intelligence feature is used. * * See [Billing Requests: Retain customers with - * Fallbacks](https://developer.gocardless.com/getting-started/billing-requests/retain-customers-with-fallbacks/) + * Fallbacks](https://developer.gocardless.com/billing-requests/retain-customers-with-fallbacks/) * for more information. */ public Boolean getFallbackEnabled() { @@ -80,7 +80,7 @@ public MandateRequest getMandateRequest() { * 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() { + public Map getMetadata() { return metadata; } @@ -155,6 +155,7 @@ private Action() { private BankAuthorisation bankAuthorisation; private CollectCustomerDetails collectCustomerDetails; private List completesActions; + private InstitutionGuessStatus institutionGuessStatus; private Boolean required; private List requiresActions; private Status status; @@ -188,6 +189,19 @@ 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. */ @@ -216,6 +230,15 @@ 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") @@ -267,7 +290,6 @@ private BankAuthorisation() { private Adapter adapter; private AuthorisationType authorisationType; - private Boolean requiresInstitution; /** * Which authorisation adapter will be used to power these authorisations (GoCardless @@ -284,13 +306,6 @@ public AuthorisationType getAuthorisationType() { return authorisationType; } - /** - * Whether an institution is a required field when creating this bank authorisation - */ - public Boolean getRequiresInstitution() { - return requiresInstitution; - } - public enum Adapter { @SerializedName("open_banking_gateway_pis") OPEN_BANKING_GATEWAY_PIS, @SerializedName("plaid_ais") @@ -365,6 +380,7 @@ private Links() { private String mandateRequest; private String mandateRequestMandate; private String organisation; + private String paymentProvider; private String paymentRequest; private String paymentRequestPayment; @@ -427,6 +443,13 @@ public String getOrganisation() { return organisation; } + /** + * (Optional) ID of the associated payment provider + */ + public String getPaymentProvider() { + return paymentProvider; + } + /** * (Optional) ID of the associated payment request */ @@ -458,7 +481,8 @@ private MandateRequest() { private String currency; private String description; private Links links; - private Map metadata; + private Map metadata; + private Boolean payerRequestedDualSignature; private String scheme; private Verify verify; @@ -508,10 +532,21 @@ public Links getLinks() { * 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() { + 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. @@ -596,7 +631,7 @@ public String getEndDate() { } /** - * The maximum amount that can be charged for a single payment + * The maximum amount that can be charged for a single payment. Required for VRP. */ public Integer getMaxAmountPerPayment() { return maxAmountPerPayment; @@ -646,7 +681,8 @@ public Alignment getAlignment() { } /** - * The maximum number of payments that can be collected in this periodic limit + * (Optional) The maximum number of payments that can be collected in this periodic + * limit. */ public Integer getMaxPayments() { return maxPayments; @@ -654,7 +690,8 @@ public Integer getMaxPayments() { /** * The maximum total amount that can be charged for all payments in this periodic - * limit + * limit. Required for VRP. + * */ public Integer getMaxTotalAmount() { return maxTotalAmount; @@ -718,8 +755,9 @@ private PaymentRequest() { private Integer appFee; private String currency; private String description; + private FundsSettlement fundsSettlement; private Links links; - private Map metadata; + private Map metadata; private String scheme; /** @@ -756,6 +794,18 @@ 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; } @@ -764,7 +814,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } @@ -779,6 +829,13 @@ 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 @@ -843,7 +900,7 @@ private Customer() { private String givenName; private String id; private String language; - private Map metadata; + private Map metadata; private String phoneNumber; /** @@ -909,7 +966,7 @@ public String getLanguage() { * 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() { + public Map getMetadata() { return metadata; } @@ -942,7 +999,7 @@ private CustomerBankAccount() { private Boolean enabled; private String id; private Links links; - private Map metadata; + private Map metadata; /** * Name of the account holder, as known by the bank. Usually this is the same as the @@ -1026,7 +1083,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/BillingRequestFlow.java b/src/main/java/com/gocardless/resources/BillingRequestFlow.java index 576c776d..fea439d3 100644 --- a/src/main/java/com/gocardless/resources/BillingRequestFlow.java +++ b/src/main/java/com/gocardless/resources/BillingRequestFlow.java @@ -16,6 +16,7 @@ private BillingRequestFlow() { private String authorisationUrl; private Boolean autoFulfil; private String createdAt; + private Boolean customerDetailsCaptured; private String exitUri; private String expiresAt; private String id; @@ -29,6 +30,7 @@ private BillingRequestFlow() { private String redirectUri; private String sessionToken; private Boolean showRedirectButtons; + private Boolean showSuccessRedirectButton; /** * URL for a GC-controlled flow which will allow the payer to fulfil the billing request @@ -52,6 +54,13 @@ public String getCreatedAt() { return createdAt; } + /** + * Identifies whether a Billing Request belongs to a specific customer + */ + public Boolean getCustomerDetailsCaptured() { + return customerDetailsCaptured; + } + /** * URL that the payer can be taken to if there isn't a way to progress ahead in flow. */ @@ -163,6 +172,16 @@ public Boolean getShowRedirectButtons() { return showRedirectButtons; } + /** + * If true, the payer will be able to see a redirect action button on the Success page. This + * action button will provide a way to redirect the payer to the given redirect_uri. This + * functionality is helpful when merchants do not want payers to be automatically redirected or + * on Android devices, where automatic redirections are not possible. + */ + public Boolean getShowSuccessRedirectButton() { + return showSuccessRedirectButton; + } + public static class Links { private Links() { // blank to prevent instantiation diff --git a/src/main/java/com/gocardless/resources/BillingRequestTemplate.java b/src/main/java/com/gocardless/resources/BillingRequestTemplate.java index cf8ff81f..3dce4bda 100644 --- a/src/main/java/com/gocardless/resources/BillingRequestTemplate.java +++ b/src/main/java/com/gocardless/resources/BillingRequestTemplate.java @@ -6,7 +6,16 @@ /** * Represents a billing request template resource returned from the API. * - * Billing Request Templates + * Billing Request Templates are reusable templates that result in numerous Billing Requests with + * similar attributes. They provide a no-code solution for generating various types of multi-user + * payment links. + * + * Each template includes a reusable URL that can be embedded in a website or shared with customers + * via email. Every time the URL is opened, it generates a new Billing Request. + * + * Billing Request Templates overcome the key limitation of the Billing Request: a Billing Request + * cannot be shared among multiple users because it is intended for single-use and is designed to + * cater to the unique needs of individual customers. */ public class BillingRequestTemplate { private BillingRequestTemplate() { @@ -18,15 +27,15 @@ private BillingRequestTemplate() { private String id; private String mandateRequestCurrency; private String mandateRequestDescription; - private Map mandateRequestMetadata; + private Map mandateRequestMetadata; private String mandateRequestScheme; private MandateRequestVerify mandateRequestVerify; - private Map metadata; + private Map metadata; private String name; private Integer paymentRequestAmount; private String paymentRequestCurrency; private String paymentRequestDescription; - private Map paymentRequestMetadata; + private Map paymentRequestMetadata; private String paymentRequestScheme; private String redirectUri; private String updatedAt; @@ -74,7 +83,7 @@ public String getMandateRequestDescription() { * is fulfilled. Up to 3 keys are permitted, with key names up to 50 characters and values up to * 500 characters. */ - public Map getMandateRequestMetadata() { + public Map getMandateRequestMetadata() { return mandateRequestMetadata; } @@ -119,7 +128,7 @@ public MandateRequestVerify getMandateRequestVerify() { * 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() { + public Map getMetadata() { return metadata; } @@ -161,7 +170,7 @@ public String getPaymentRequestDescription() { * is fulfilled. Up to 3 keys are permitted, with key names up to 50 characters and values up to * 500 characters. */ - public Map getPaymentRequestMetadata() { + public Map getPaymentRequestMetadata() { return paymentRequestMetadata; } diff --git a/src/main/java/com/gocardless/resources/Creditor.java b/src/main/java/com/gocardless/resources/Creditor.java index 4d872f11..3b0df3cc 100644 --- a/src/main/java/com/gocardless/resources/Creditor.java +++ b/src/main/java/com/gocardless/resources/Creditor.java @@ -18,10 +18,10 @@ private Creditor() { // blank to prevent instantiation } - private Boolean activated; private String addressLine1; private String addressLine2; private String addressLine3; + private String bankReferencePrefix; private Boolean canCreateRefunds; private String city; private String countryCode; @@ -40,13 +40,6 @@ private Creditor() { private List schemeIdentifiers; private VerificationStatus verificationStatus; - /** - * Boolean value indicating whether the creditor is activated in the product. - */ - public Boolean getActivated() { - return activated; - } - /** * The first line of the creditor's address. */ @@ -69,7 +62,19 @@ public String getAddressLine3() { } /** - * Boolean indicating whether the creditor is permitted to create refunds + * Prefix for the bank reference of payouts sent to this creditor. For instance, if the + * creditor's `bank_reference_prefix` was `ACME`, the bank reference of a payout sent to that + * creditor could be `ACME-8G7Q8`. + * + * This prefix is also used for refunds in EUR and GBP. + * + */ + public String getBankReferencePrefix() { + return bankReferencePrefix; + } + + /** + * Boolean indicating whether the creditor is permitted to create refunds. */ public Boolean getCanCreateRefunds() { return canCreateRefunds; diff --git a/src/main/java/com/gocardless/resources/CreditorBankAccount.java b/src/main/java/com/gocardless/resources/CreditorBankAccount.java index dd207fec..1a177a96 100644 --- a/src/main/java/com/gocardless/resources/CreditorBankAccount.java +++ b/src/main/java/com/gocardless/resources/CreditorBankAccount.java @@ -33,7 +33,8 @@ private CreditorBankAccount() { private Boolean enabled; private String id; private Links links; - private Map metadata; + private Map metadata; + private VerificationStatus verificationStatus; /** * Name of the account holder, as known by the bank. Usually this is the same as the name stored @@ -114,10 +115,17 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } + /** + * Verification status of the Bank Account. Can be one of `pending`, `in_review` or `successful` + */ + public VerificationStatus getVerificationStatus() { + return verificationStatus; + } + public enum AccountType { @SerializedName("savings") SAVINGS, @SerializedName("checking") @@ -125,6 +133,15 @@ public enum AccountType { UNKNOWN } + public enum VerificationStatus { + @SerializedName("pending") + PENDING, @SerializedName("in_review") + IN_REVIEW, @SerializedName("successful") + SUCCESSFUL, @SerializedName("could_not_verify") + COULD_NOT_VERIFY, @SerializedName("unknown") + UNKNOWN + } + public static class Links { private Links() { // blank to prevent instantiation diff --git a/src/main/java/com/gocardless/resources/Customer.java b/src/main/java/com/gocardless/resources/Customer.java index a0f58b4a..1a9d8cc4 100644 --- a/src/main/java/com/gocardless/resources/Customer.java +++ b/src/main/java/com/gocardless/resources/Customer.java @@ -27,7 +27,7 @@ private Customer() { private String givenName; private String id; private String language; - private Map metadata; + private Map metadata; private String phoneNumber; private String postalCode; private String region; @@ -138,7 +138,7 @@ public String getLanguage() { * 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() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/CustomerBankAccount.java b/src/main/java/com/gocardless/resources/CustomerBankAccount.java index fe5b4ce4..a8c79af8 100644 --- a/src/main/java/com/gocardless/resources/CustomerBankAccount.java +++ b/src/main/java/com/gocardless/resources/CustomerBankAccount.java @@ -34,7 +34,7 @@ private CustomerBankAccount() { private Boolean enabled; private String id; private Links links; - private Map metadata; + private Map metadata; /** * Name of the account holder, as known by the bank. Usually this is the same as the name stored @@ -116,7 +116,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/Event.java b/src/main/java/com/gocardless/resources/Event.java index 94712c2b..8e48d911 100644 --- a/src/main/java/com/gocardless/resources/Event.java +++ b/src/main/java/com/gocardless/resources/Event.java @@ -24,7 +24,8 @@ private Event() { private Details details; private String id; private Links links; - private Map metadata; + private Map metadata; + private Map resourceMetadata; private ResourceType resourceType; /** @@ -67,13 +68,27 @@ public Links getLinks() { } /** - * If the `details[origin]` is `api`, this will contain any metadata you specified when - * triggering this event. In other cases it will be an empty object. + * The metadata that was passed when making the API request that triggered the event (for + * instance, cancelling a mandate). + * + * This field will only be populated if the `details[origin]` field is `api` otherwise it will + * be an empty object. + * */ - public Map getMetadata() { + public Map getMetadata() { return metadata; } + /** + * The metadata of the resource that the event is for. For example, this field will have the + * same value of the `mandate[metadata]` field on the response you would receive from performing + * a GET request on a mandate. + * + */ + public Map getResourceMetadata() { + return resourceMetadata; + } + /** * The resource type for this event. One of: *
    diff --git a/src/main/java/com/gocardless/resources/InstalmentSchedule.java b/src/main/java/com/gocardless/resources/InstalmentSchedule.java index feb3e8ac..2a8f0a09 100644 --- a/src/main/java/com/gocardless/resources/InstalmentSchedule.java +++ b/src/main/java/com/gocardless/resources/InstalmentSchedule.java @@ -28,9 +28,9 @@ private InstalmentSchedule() { private Currency currency; private String id; private Links links; - private Map metadata; + private Map metadata; private String name; - private Map paymentErrors; + private Map paymentErrors; private Status status; private Integer totalAmount; @@ -67,7 +67,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } @@ -84,7 +84,7 @@ public String getName() { * from the individual payments, arranged by the index of the payment that failed. * */ - public Map getPaymentErrors() { + public Map getPaymentErrors() { return paymentErrors; } diff --git a/src/main/java/com/gocardless/resources/Institution.java b/src/main/java/com/gocardless/resources/Institution.java index 09a95a3c..ffaf42ac 100644 --- a/src/main/java/com/gocardless/resources/Institution.java +++ b/src/main/java/com/gocardless/resources/Institution.java @@ -14,7 +14,7 @@ private Institution() { // blank to prevent instantiation } - private Boolean bankRedirect; + private Boolean autocompletesCollectBankAccount; private String countryCode; private String iconUrl; private String id; @@ -22,12 +22,12 @@ private Institution() { private String name; /** - * Flag to show if the institution supports redirection to its authorisation flow or if a - * provider's one is being used. The bank authorisation screen on the UI is visible based on - * this property. + * Flag to show if selecting this institution in the select_institution action can auto-complete + * the collect_bank_account action. The bank can return the payer's bank account details to + * GoCardless. */ - public Boolean getBankRedirect() { - return bankRedirect; + public Boolean getAutocompletesCollectBankAccount() { + return autocompletesCollectBankAccount; } /** diff --git a/src/main/java/com/gocardless/resources/Logo.java b/src/main/java/com/gocardless/resources/Logo.java new file mode 100644 index 00000000..326038b9 --- /dev/null +++ b/src/main/java/com/gocardless/resources/Logo.java @@ -0,0 +1,22 @@ +package com.gocardless.resources; + +/** + * Represents a logo resource returned from the API. + * + * Logos are image uploads that, when associated with a creditor, are shown on the [billing request + * flow](#billing-requests-billing-request-flows) payment pages. + */ +public class Logo { + private Logo() { + // blank to prevent instantiation + } + + private String id; + + /** + * Unique identifier, beginning with "LO". + */ + public String getId() { + return id; + } +} diff --git a/src/main/java/com/gocardless/resources/Mandate.java b/src/main/java/com/gocardless/resources/Mandate.java index 69b81ac0..146c2a1b 100644 --- a/src/main/java/com/gocardless/resources/Mandate.java +++ b/src/main/java/com/gocardless/resources/Mandate.java @@ -20,10 +20,12 @@ private Mandate() { private AuthorisationSource authorisationSource; private ConsentParameters consentParameters; private String createdAt; + private FundsSettlement fundsSettlement; private String id; private Links links; - private Map metadata; + private Map metadata; private String nextPossibleChargeDate; + private String nextPossibleStandardAchChargeDate; private Boolean paymentsRequireApproval; private String reference; private String scheme; @@ -58,6 +60,18 @@ public String getCreatedAt() { return createdAt; } + /** + * 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; + } + /** * Unique identifier, beginning with "MD". Note that this prefix may not apply to mandates * created before 2016. @@ -74,7 +88,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } @@ -86,6 +100,17 @@ public String getNextPossibleChargeDate() { return nextPossibleChargeDate; } + /** + * If this is an an ACH mandate, the earliest date that can be used as a `charge_date` on any + * newly created payment to be charged through standard ACH, rather than Faster ACH. This value + * will change over time. + * + * It is only present in the API response for ACH mandates. + */ + public String getNextPossibleStandardAchChargeDate() { + return nextPossibleStandardAchChargeDate; + } + /** * Boolean value showing whether payments and subscriptions under this mandate require approval * via an automated email before being processed. @@ -149,6 +174,13 @@ public enum AuthorisationSource { UNKNOWN } + public enum FundsSettlement { + @SerializedName("managed") + MANAGED, @SerializedName("direct") + DIRECT, @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/MandateImport.java b/src/main/java/com/gocardless/resources/MandateImport.java index 170f48d8..24a90a3d 100644 --- a/src/main/java/com/gocardless/resources/MandateImport.java +++ b/src/main/java/com/gocardless/resources/MandateImport.java @@ -43,6 +43,7 @@ private MandateImport() { private String createdAt; private String id; + private Links links; private Scheme scheme; private Status status; @@ -60,6 +61,13 @@ public String getId() { return id; } + /** + * Related resources + */ + public Links getLinks() { + return links; + } + /** * The scheme of the mandates to be imported.
    * All mandates in a single mandate import must be for the same scheme. @@ -109,4 +117,24 @@ public enum Status { PROCESSED, @SerializedName("unknown") UNKNOWN } + + /** + * Represents a link resource returned from the API. + * + * Related resources + */ + public static class Links { + private Links() { + // blank to prevent instantiation + } + + private String creditor; + + /** + * ID of the associated creditor. + */ + public String getCreditor() { + return creditor; + } + } } diff --git a/src/main/java/com/gocardless/resources/NegativeBalanceLimit.java b/src/main/java/com/gocardless/resources/NegativeBalanceLimit.java new file mode 100644 index 00000000..ca7d8df5 --- /dev/null +++ b/src/main/java/com/gocardless/resources/NegativeBalanceLimit.java @@ -0,0 +1,92 @@ +package com.gocardless.resources; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a negative balance limit resource returned from the API. + * + * The negative balance limit is a threshold for the creditor balance beyond which refunds are not + * permitted. The default limit is zero — refunds are not permitted if the creditor has a negative + * balance. The limit can be changed on a per-creditor basis. + * + */ +public class NegativeBalanceLimit { + private NegativeBalanceLimit() { + // blank to prevent instantiation + } + + private Integer balanceLimit; + private String createdAt; + private Currency currency; + private String id; + private Links links; + + /** + * The limit amount in pence (e.g. 10000 for a -100 GBP limit). + */ + public Integer getBalanceLimit() { + return balanceLimit; + } + + /** + * Fixed [timestamp](#api-usage-time-zones--dates), recording when this limit 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 Currency getCurrency() { + return currency; + } + + /** + * Unique identifier, beginning with "NBL". + */ + public String getId() { + return id; + } + + public Links getLinks() { + return links; + } + + public enum Currency { + @SerializedName("AUD") + AUD, @SerializedName("CAD") + CAD, @SerializedName("DKK") + DKK, @SerializedName("EUR") + EUR, @SerializedName("GBP") + GBP, @SerializedName("NZD") + NZD, @SerializedName("SEK") + SEK, @SerializedName("USD") + USD, @SerializedName("unknown") + UNKNOWN + } + + public static class Links { + private Links() { + // blank to prevent instantiation + } + + private String creatorUser; + private String creditor; + + /** + * ID of the [creator_user](#core-endpoints-creator_users) who created this limit + */ + public String getCreatorUser() { + return creatorUser; + } + + /** + * ID of [creditor](#core-endpoints-creditors) which this limit relates to + */ + public String getCreditor() { + return creditor; + } + } +} diff --git a/src/main/java/com/gocardless/resources/PayerAuthorisation.java b/src/main/java/com/gocardless/resources/PayerAuthorisation.java index f0de2a06..9e0fee45 100644 --- a/src/main/java/com/gocardless/resources/PayerAuthorisation.java +++ b/src/main/java/com/gocardless/resources/PayerAuthorisation.java @@ -162,7 +162,7 @@ private BankAccount() { private String countryCode; private String currency; private String iban; - private Map metadata; + private Map metadata; /** * Name of the account holder, as known by the bank. Usually this is the same as the name @@ -254,7 +254,7 @@ public String getIban() { * 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() { + public Map getMetadata() { return metadata; } @@ -287,7 +287,7 @@ private Customer() { private String familyName; private String givenName; private String locale; - private Map metadata; + private Map metadata; private String postalCode; private String region; private String swedishIdentityNumber; @@ -381,7 +381,7 @@ public String getLocale() { * 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() { + public Map getMetadata() { return metadata; } @@ -489,7 +489,7 @@ private Mandate() { // blank to prevent instantiation } - private Map metadata; + private Map metadata; private String payerIpAddress; private String reference; private Scheme scheme; @@ -498,7 +498,7 @@ private Mandate() { * 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() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/PayerTheme.java b/src/main/java/com/gocardless/resources/PayerTheme.java new file mode 100644 index 00000000..354fba49 --- /dev/null +++ b/src/main/java/com/gocardless/resources/PayerTheme.java @@ -0,0 +1,21 @@ +package com.gocardless.resources; + +/** + * Represents a payer theme resource returned from the API. + * + * Custom colour themes for payment pages and customer notifications. + */ +public class PayerTheme { + private PayerTheme() { + // blank to prevent instantiation + } + + private String id; + + /** + * Unique identifier, beginning with "PTH". + */ + public String getId() { + return id; + } +} diff --git a/src/main/java/com/gocardless/resources/Payment.java b/src/main/java/com/gocardless/resources/Payment.java index ecb6cbb1..da25df35 100644 --- a/src/main/java/com/gocardless/resources/Payment.java +++ b/src/main/java/com/gocardless/resources/Payment.java @@ -24,10 +24,11 @@ private Payment() { private String createdAt; private Currency currency; private String description; + private Boolean fasterAch; private Fx fx; private String id; private Links links; - private Map metadata; + private Map metadata; private String reference; private Boolean retryIfPossible; private Status status; @@ -81,6 +82,15 @@ public String getDescription() { return description; } + /** + * This field indicates whether the ACH payment is processed through Faster ACH or standard ACH. + * + * It is only present in the API response for ACH payments. + */ + public Boolean getFasterAch() { + return fasterAch; + } + public Fx getFx() { return fx; } @@ -100,7 +110,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/Payout.java b/src/main/java/com/gocardless/resources/Payout.java index 04349efc..444877dc 100644 --- a/src/main/java/com/gocardless/resources/Payout.java +++ b/src/main/java/com/gocardless/resources/Payout.java @@ -24,7 +24,7 @@ private Payout() { private Fx fx; private String id; private Links links; - private Map metadata; + private Map metadata; private PayoutType payoutType; private String reference; private Status status; @@ -99,7 +99,7 @@ public Links getLinks() { * characters and values up to 500 characters. _Note:_ This should not be used for storing PII * data. */ - public Map getMetadata() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/PayoutItem.java b/src/main/java/com/gocardless/resources/PayoutItem.java index 65ac36f7..5aa875d8 100644 --- a/src/main/java/com/gocardless/resources/PayoutItem.java +++ b/src/main/java/com/gocardless/resources/PayoutItem.java @@ -98,7 +98,8 @@ public enum Type { GOCARDLESS_FEE, @SerializedName("app_fee") APP_FEE, @SerializedName("revenue_share") REVENUE_SHARE, @SerializedName("surcharge_fee") - SURCHARGE_FEE, @SerializedName("unknown") + SURCHARGE_FEE, @SerializedName("refund_funds_returned") + REFUND_FUNDS_RETURNED, @SerializedName("unknown") UNKNOWN } diff --git a/src/main/java/com/gocardless/resources/RedirectFlow.java b/src/main/java/com/gocardless/resources/RedirectFlow.java index b23a2e8d..b65b7fe3 100644 --- a/src/main/java/com/gocardless/resources/RedirectFlow.java +++ b/src/main/java/com/gocardless/resources/RedirectFlow.java @@ -7,9 +7,9 @@ * Represents a redirect flow resource returned from the API. * *

    - * Deprecated: Redirect Flows are our legacy APIs for setting up mandates and will - * no longer be supported in the future. We strongly recommend using the [Billing Request - * flow](#billing-requests) instead. + * Deprecated: Redirect Flows are legacy APIs and cannot be used by new + * integrators. The [Billing Request flow](#billing-requests) API should be used for your payment + * flows. *

    * * Redirect flows enable you to use GoCardless' [hosted payment @@ -52,7 +52,7 @@ private RedirectFlow() { private String id; private Links links; private String mandateReference; - private Map metadata; + private Map metadata; private String redirectUrl; private Scheme scheme; private String sessionToken; @@ -108,7 +108,7 @@ public String getMandateReference() { * characters and values up to 500 characters. _Note:_ This should not be used for storing PII * data. */ - public Map getMetadata() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/Refund.java b/src/main/java/com/gocardless/resources/Refund.java index ab1f6c02..0b37fc0b 100644 --- a/src/main/java/com/gocardless/resources/Refund.java +++ b/src/main/java/com/gocardless/resources/Refund.java @@ -23,7 +23,7 @@ private Refund() { private Fx fx; private String id; private Links links; - private Map metadata; + private Map metadata; private String reference; private Status status; @@ -68,7 +68,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } diff --git a/src/main/java/com/gocardless/resources/ScenarioSimulator.java b/src/main/java/com/gocardless/resources/ScenarioSimulator.java index 878d9273..f9025be8 100644 --- a/src/main/java/com/gocardless/resources/ScenarioSimulator.java +++ b/src/main/java/com/gocardless/resources/ScenarioSimulator.java @@ -86,7 +86,7 @@ private ScenarioSimulator() { *
  • `mandate_transferred_with_resubmission`: Transitions a mandate through `transferred` and * resubmits it to the banks, can be caused be the UK's Current Account Switching Service (CASS) * or when a customer contacts GoCardless to change their bank details. It must start in the - * `pending_submission` state. Only compatible with Bacs, SEPA and Autogiro mandates.
  • + * `pending_submission` state. Only compatible with Bacs mandates. *
  • `mandate_suspended_by_payer`: Transitions a mandate to `suspended_by_payer`, as if payer * has suspended the mandate after it has been setup successfully. It must start in the * `activated` state. Only compatible with PAY_TO mandates.
  • diff --git a/src/main/java/com/gocardless/resources/Subscription.java b/src/main/java/com/gocardless/resources/Subscription.java index 5789245f..f5e15536 100644 --- a/src/main/java/com/gocardless/resources/Subscription.java +++ b/src/main/java/com/gocardless/resources/Subscription.java @@ -13,10 +13,10 @@ * * The following rules apply when specifying recurrence: * - * - The first payment must be charged within 1 year. - If `day_of_month` and `start_date` are not - * provided `start_date` will be the [mandate](#core-endpoints-mandates)'s - * `next_possible_charge_date` and the subscription will then recur based on the `interval` & - * `interval_unit` - If `month` or `day_of_month` are present the following validations apply: + * - If `day_of_month` and `start_date` are not provided `start_date` will be the + * [mandate](#core-endpoints-mandates)'s `next_possible_charge_date` and the subscription will then + * recur based on the `interval` & `interval_unit` - If `month` or `day_of_month` are present the + * following validations apply: * * | __interval_unit__ | __month__ | __day_of_month__ | | :---------------- | * :--------------------------------------------- | :----------------------------------------- | | @@ -40,7 +40,6 @@ * - if the recurrence rule specified `-1` as the `day_of_month`, the charge date will be rolled * __backwards__ to the previous business day (i.e., the last working day of the month). - otherwise * the charge date will be rolled __forwards__ to the next business day. - * */ public class Subscription { private Subscription() { @@ -59,9 +58,10 @@ private Subscription() { private Integer interval; private IntervalUnit intervalUnit; private Links links; - private Map metadata; + private Map metadata; private Month month; private String name; + private Boolean parentPlanPaused; private String paymentReference; private Boolean retryIfPossible; private String startDate; @@ -166,7 +166,7 @@ public Links getLinks() { * 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() { + public Map getMetadata() { return metadata; } @@ -187,6 +187,13 @@ public String getName() { return name; } + /** + * Whether the parent plan of this subscription is paused. + */ + public Boolean getParentPlanPaused() { + return parentPlanPaused; + } + /** * 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 diff --git a/src/main/java/com/gocardless/resources/TransferredMandate.java b/src/main/java/com/gocardless/resources/TransferredMandate.java new file mode 100644 index 00000000..f548272e --- /dev/null +++ b/src/main/java/com/gocardless/resources/TransferredMandate.java @@ -0,0 +1,67 @@ +package com.gocardless.resources; + +/** + * Represents a transferred mandate resource returned from the API. + * + * Mandates that have been transferred using Current Account Switch Service + */ +public class TransferredMandate { + private TransferredMandate() { + // blank to prevent instantiation + } + + private String encryptedCustomerBankDetails; + private String encryptedDecryptionKey; + private Links links; + private String publicKeyId; + + /** + * Encrypted customer bank account details, containing: `iban`, `account_holder_name`, + * `swift_bank_code`, `swift_branch_code`, `swift_account_number` + */ + public String getEncryptedCustomerBankDetails() { + return encryptedCustomerBankDetails; + } + + /** + * Random AES-256 key used to encrypt bank account details, itself encrypted with your public + * key. + */ + public String getEncryptedDecryptionKey() { + return encryptedDecryptionKey; + } + + public Links getLinks() { + return links; + } + + /** + * The ID of an RSA-2048 public key, from your JWKS, used to encrypt the AES key. + */ + public String getPublicKeyId() { + return publicKeyId; + } + + public static class Links { + private Links() { + // blank to prevent instantiation + } + + private String customerBankAccount; + private String mandate; + + /** + * The ID of the updated [customer_bank_account](#core-endpoints-customer-bank-accounts) + */ + public String getCustomerBankAccount() { + return customerBankAccount; + } + + /** + * The ID of the transferred mandate + */ + public String getMandate() { + return mandate; + } + } +} diff --git a/src/main/java/com/gocardless/resources/Webhook.java b/src/main/java/com/gocardless/resources/Webhook.java index 73531d26..afd77989 100644 --- a/src/main/java/com/gocardless/resources/Webhook.java +++ b/src/main/java/com/gocardless/resources/Webhook.java @@ -16,11 +16,11 @@ private Webhook() { private String id; private Boolean isTest; private String requestBody; - private Map requestHeaders; + private Map requestHeaders; private String responseBody; private Boolean responseBodyTruncated; private Integer responseCode; - private Map responseHeaders; + private Map responseHeaders; private Boolean responseHeadersContentTruncated; private Boolean responseHeadersCountTruncated; private Boolean successful; @@ -57,7 +57,7 @@ public String getRequestBody() { /** * The request headers sent with the webhook */ - public Map getRequestHeaders() { + public Map getRequestHeaders() { return requestHeaders; } @@ -85,7 +85,7 @@ public Integer getResponseCode() { /** * The headers sent with the response from the webhook URL */ - public Map getResponseHeaders() { + public Map getResponseHeaders() { return responseHeaders; } diff --git a/src/main/java/com/gocardless/services/BankAuthorisationService.java b/src/main/java/com/gocardless/services/BankAuthorisationService.java index db4e7391..f99fdc57 100644 --- a/src/main/java/com/gocardless/services/BankAuthorisationService.java +++ b/src/main/java/com/gocardless/services/BankAuthorisationService.java @@ -47,18 +47,9 @@ public BankAuthorisationGetRequest get(String identity) { */ public static final class BankAuthorisationCreateRequest extends IdempotentPostRequest { - private String authorisationType; private Links links; private String redirectUri; - /** - * Type of authorisation, can be either 'mandate' or 'payment'. - */ - public BankAuthorisationCreateRequest withAuthorisationType(String authorisationType) { - this.authorisationType = authorisationType; - return this; - } - public BankAuthorisationCreateRequest withLinks(Links links) { this.links = links; return this; diff --git a/src/main/java/com/gocardless/services/BankDetailsLookupService.java b/src/main/java/com/gocardless/services/BankDetailsLookupService.java index e681e975..f6336246 100644 --- a/src/main/java/com/gocardless/services/BankDetailsLookupService.java +++ b/src/main/java/com/gocardless/services/BankDetailsLookupService.java @@ -24,6 +24,10 @@ public BankDetailsLookupService(HttpClient httpClient) { * Performs a bank details lookup. As part of the lookup, a modulus check and reachability check * are performed. * + * For UK-based bank accounts, where an account holder name is provided (and an account number, + * a sort code or an iban are already present), we verify that the account holder name and bank + * account number match the details held by the relevant bank. + * * If your request returns an [error](#api-usage-errors) or the `available_debit_schemes` * attribute is an empty array, you will not be able to collect payments from the specified bank * account. GoCardless may be able to collect payments from an account even if no `bic` is @@ -50,6 +54,10 @@ public BankDetailsLookupCreateRequest create() { * Performs a bank details lookup. As part of the lookup, a modulus check and reachability check * are performed. * + * For UK-based bank accounts, where an account holder name is provided (and an account number, + * a sort code or an iban are already present), we verify that the account holder name and bank + * account number match the details held by the relevant bank. + * * If your request returns an [error](#api-usage-errors) or the `available_debit_schemes` * attribute is an empty array, you will not be able to collect payments from the specified bank * account. GoCardless may be able to collect payments from an account even if no `bic` is @@ -68,12 +76,22 @@ public BankDetailsLookupCreateRequest create() { */ public static final class BankDetailsLookupCreateRequest extends PostRequest { + private String accountHolderName; private String accountNumber; private String bankCode; private String branchCode; private String countryCode; private String iban; + /** + * The account holder name associated with the account number (if available). If provided + * and the country code is GB, a payer name verification will be performed. + */ + public BankDetailsLookupCreateRequest 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`. diff --git a/src/main/java/com/gocardless/services/BillingRequestFlowService.java b/src/main/java/com/gocardless/services/BillingRequestFlowService.java index 644e01de..399d234c 100644 --- a/src/main/java/com/gocardless/services/BillingRequestFlowService.java +++ b/src/main/java/com/gocardless/services/BillingRequestFlowService.java @@ -47,6 +47,7 @@ public BillingRequestFlowInitialiseRequest initialise(String identity) { public static final class BillingRequestFlowCreateRequest extends PostRequest { private Boolean autoFulfil; + private Boolean customerDetailsCaptured; private String exitUri; private String language; private Links links; @@ -57,6 +58,7 @@ public static final class BillingRequestFlowCreateRequest private PrefilledCustomer prefilledCustomer; private String redirectUri; private Boolean showRedirectButtons; + private Boolean showSuccessRedirectButton; /** * (Experimental feature) Fulfil the Billing Request on completion of the flow (true by @@ -67,6 +69,15 @@ public BillingRequestFlowCreateRequest withAutoFulfil(Boolean autoFulfil) { return this; } + /** + * Identifies whether a Billing Request belongs to a specific customer + */ + public BillingRequestFlowCreateRequest withCustomerDetailsCaptured( + Boolean customerDetailsCaptured) { + this.customerDetailsCaptured = customerDetailsCaptured; + return this; + } + /** * URL that the payer can be taken to if there isn't a way to progress ahead in flow. */ @@ -350,6 +361,18 @@ public BillingRequestFlowCreateRequest withShowRedirectButtons( return this; } + /** + * If true, the payer will be able to see a redirect action button on the Success page. This + * action button will provide a way to redirect the payer to the given redirect_uri. This + * functionality is helpful when merchants do not want payers to be automatically redirected + * or on Android devices, where automatic redirections are not possible. + */ + public BillingRequestFlowCreateRequest withShowSuccessRedirectButton( + Boolean showSuccessRedirectButton) { + this.showSuccessRedirectButton = showSuccessRedirectButton; + return this; + } + private BillingRequestFlowCreateRequest(HttpClient httpClient) { super(httpClient); } diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index 56d017f5..219b2ec7 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -59,10 +59,18 @@ public BillingRequestCollectCustomerDetailsRequest collectCustomerDetails(String * The endpoint takes the same payload as Customer Bank Accounts, but check the bank account is * valid for the billing request scheme before creating and attaching it. * + * If the scheme is PayTo and the pay_id is available, this can be included in the payload along + * with the country_code. + * * _ACH scheme_ For compliance reasons, an extra validation step is done using a third-party * provider to make sure the customer's bank account can accept Direct Debit. If a bank account * is discovered to be closed or invalid, the customer is requested to adjust the account * number/routing number and succeed in this check to continue with the flow. + * + * _BACS scheme_ [Payer Name + * Verification](https://hub.gocardless.com/s/article/Introduction-to-Payer-Name-Verification?language=en_GB) + * is enabled by default for UK based bank accounts, meaning we verify the account holder name + * and bank account number match the details held by the relevant bank. */ public BillingRequestCollectBankAccountRequest collectBankAccount(String identity) { return new BillingRequestCollectBankAccountRequest(httpClient, identity); @@ -165,7 +173,7 @@ public static final class BillingRequestCreateRequest * debit. Should not be set if GoCardless payment intelligence feature is used. * * See [Billing Requests: Retain customers with - * Fallbacks](https://developer.gocardless.com/getting-started/billing-requests/retain-customers-with-fallbacks/) + * Fallbacks](https://developer.gocardless.com/billing-requests/retain-customers-with-fallbacks/) * for more information. */ public BillingRequestCreateRequest withFallbackEnabled(Boolean fallbackEnabled) { @@ -423,6 +431,23 @@ public BillingRequestCreateRequest withPaymentRequestDescription(String descript 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 BillingRequestCreateRequest 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. @@ -584,7 +609,8 @@ public PeriodicLimits withAlignment(Alignment alignment) { } /** - * The maximum number of payments that can be collected in this periodic limit + * (Optional) The maximum number of payments that can be collected in this periodic + * limit. */ public PeriodicLimits withMaxPayments(Integer maxPayments) { this.maxPayments = maxPayments; @@ -592,7 +618,9 @@ public PeriodicLimits withMaxPayments(Integer maxPayments) { } /** - * The maximum total amount that can be charged for all payments in this periodic limit + * 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; @@ -673,7 +701,7 @@ public Constraints withEndDate(String endDate) { } /** - * The maximum amount that can be charged for a single payment + * The maximum amount that can be charged for a single payment. Required for VRP. */ public Constraints withMaxAmountPerPayment(Integer maxAmountPerPayment) { this.maxAmountPerPayment = maxAmountPerPayment; @@ -865,6 +893,7 @@ public static class PaymentRequest { private Integer appFee; private String currency; private String description; + private FundsSettlement fundsSettlement; private Map metadata; private String scheme; @@ -906,6 +935,19 @@ public PaymentRequest withDescription(String 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. @@ -926,6 +968,18 @@ 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(); + } + } } } @@ -1008,8 +1062,8 @@ public BillingRequestCollectCustomerDetailsRequest withCustomerGivenName(String * 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". + * 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 BillingRequestCollectCustomerDetailsRequest withCustomerLanguage(String language) { if (customer == null) { @@ -1277,8 +1331,9 @@ public Customer withGivenName(String givenName) { * 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". + * 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; @@ -1420,10 +1475,18 @@ public CustomerBillingDetail withSwedishIdentityNumber(String swedishIdentityNum * The endpoint takes the same payload as Customer Bank Accounts, but check the bank account is * valid for the billing request scheme before creating and attaching it. * + * If the scheme is PayTo and the pay_id is available, this can be included in the payload along + * with the country_code. + * * _ACH scheme_ For compliance reasons, an extra validation step is done using a third-party * provider to make sure the customer's bank account can accept Direct Debit. If a bank account * is discovered to be closed or invalid, the customer is requested to adjust the account * number/routing number and succeed in this check to continue with the flow. + * + * _BACS scheme_ [Payer Name + * Verification](https://hub.gocardless.com/s/article/Introduction-to-Payer-Name-Verification?language=en_GB) + * is enabled by default for UK based bank accounts, meaning we verify the account holder name + * and bank account number match the details held by the relevant bank. */ public static final class BillingRequestCollectBankAccountRequest extends PostRequest { @@ -1439,6 +1502,7 @@ public static final class BillingRequestCollectBankAccountRequest private String currency; private String iban; private Map metadata; + private String payId; /** * Name of the account holder, as known by the bank. Usually this is the same as the name @@ -1550,6 +1614,15 @@ public BillingRequestCollectBankAccountRequest withMetadata(String key, String v 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 BillingRequestCollectBankAccountRequest withPayId(String payId) { + this.payId = payId; + return this; + } + private BillingRequestCollectBankAccountRequest(HttpClient httpClient, String identity) { super(httpClient); this.identity = identity; @@ -1617,6 +1690,7 @@ public static final class BillingRequestConfirmPayerDetailsRequest @PathParam private final String identity; private Map metadata; + private Boolean payerRequestedDualSignature; /** * Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 @@ -1639,6 +1713,19 @@ public BillingRequestConfirmPayerDetailsRequest withMetadata(String key, String 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 BillingRequestConfirmPayerDetailsRequest withPayerRequestedDualSignature( + Boolean payerRequestedDualSignature) { + this.payerRequestedDualSignature = payerRequestedDualSignature; + return this; + } + private BillingRequestConfirmPayerDetailsRequest(HttpClient httpClient, String identity) { super(httpClient); this.identity = identity; diff --git a/src/main/java/com/gocardless/services/BillingRequestTemplateService.java b/src/main/java/com/gocardless/services/BillingRequestTemplateService.java index c222a31e..73668184 100644 --- a/src/main/java/com/gocardless/services/BillingRequestTemplateService.java +++ b/src/main/java/com/gocardless/services/BillingRequestTemplateService.java @@ -12,7 +12,16 @@ /** * Service class for working with billing request template resources. * - * Billing Request Templates + * Billing Request Templates are reusable templates that result in numerous Billing Requests with + * similar attributes. They provide a no-code solution for generating various types of multi-user + * payment links. + * + * Each template includes a reusable URL that can be embedded in a website or shared with customers + * via email. Every time the URL is opened, it generates a new Billing Request. + * + * Billing Request Templates overcome the key limitation of the Billing Request: a Billing Request + * cannot be shared among multiple users because it is intended for single-use and is designed to + * cater to the unique needs of individual customers. */ public class BillingRequestTemplateService { private final HttpClient httpClient; diff --git a/src/main/java/com/gocardless/services/CreditorBankAccountService.java b/src/main/java/com/gocardless/services/CreditorBankAccountService.java index 0e0667bd..17b23d32 100644 --- a/src/main/java/com/gocardless/services/CreditorBankAccountService.java +++ b/src/main/java/com/gocardless/services/CreditorBankAccountService.java @@ -373,7 +373,8 @@ public CreditorBankAccountListRequest withCreditor(String creditor) { } /** - * Boolean value showing whether the bank account is enabled or disabled + * If `true`, only return enabled bank accounts. If `false`, only return disabled bank + * accounts. */ public CreditorBankAccountListRequest withEnabled(Boolean enabled) { this.enabled = enabled; diff --git a/src/main/java/com/gocardless/services/CreditorService.java b/src/main/java/com/gocardless/services/CreditorService.java index 8018bff3..9e6f2fb3 100644 --- a/src/main/java/com/gocardless/services/CreditorService.java +++ b/src/main/java/com/gocardless/services/CreditorService.java @@ -62,28 +62,31 @@ public CreditorUpdateRequest update(String identity) { return new CreditorUpdateRequest(httpClient, identity); } - /** - * Applies a [scheme identifier](#core-endpoints-scheme-identifiers) to a creditor. If the - * creditor already has a scheme identifier for the scheme, it will be replaced, and any - * mandates attached to it transferred asynchronously. For some schemes, the application of the - * scheme identifier will be performed asynchronously. - * - */ - public CreditorApplySchemeIdentifierRequest applySchemeIdentifier(String identity) { - return new CreditorApplySchemeIdentifierRequest(httpClient, identity); - } - /** * Request class for {@link CreditorService#create }. * * Creates a new creditor. */ public static final class CreditorCreateRequest extends IdempotentPostRequest { + private String bankReferencePrefix; private String countryCode; private CreditorType creditorType; private Map links; private String name; + /** + * Prefix for the bank reference of payouts sent to this creditor. For instance, if the + * creditor's `bank_reference_prefix` was `ACME`, the bank reference of a payout sent to + * that creditor could be `ACME-8G7Q8`. + * + * This prefix is also used for refunds in EUR and GBP. + * + */ + public CreditorCreateRequest withBankReferencePrefix(String bankReferencePrefix) { + this.bankReferencePrefix = bankReferencePrefix; + return this; + } + /** * [ISO 3166-1 alpha-2 * code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) @@ -415,6 +418,7 @@ public static final class CreditorUpdateRequest extends PutRequest { private String addressLine1; private String addressLine2; private String addressLine3; + private String bankReferencePrefix; private String city; private String countryCode; private Links links; @@ -446,6 +450,19 @@ public CreditorUpdateRequest withAddressLine3(String addressLine3) { return this; } + /** + * Prefix for the bank reference of payouts sent to this creditor. For instance, if the + * creditor's `bank_reference_prefix` was `ACME`, the bank reference of a payout sent to + * that creditor could be `ACME-8G7Q8`. + * + * This prefix is also used for refunds in EUR and GBP. + * + */ + public CreditorUpdateRequest withBankReferencePrefix(String bankReferencePrefix) { + this.bankReferencePrefix = bankReferencePrefix; + return this; + } + /** * The city of the creditor's address. */ @@ -716,94 +733,4 @@ public Links withDefaultUsdPayoutAccount(String defaultUsdPayoutAccount) { } } } - - /** - * Request class for {@link CreditorService#applySchemeIdentifier }. - * - * Applies a [scheme identifier](#core-endpoints-scheme-identifiers) to a creditor. If the - * creditor already has a scheme identifier for the scheme, it will be replaced, and any - * mandates attached to it transferred asynchronously. For some schemes, the application of the - * scheme identifier will be performed asynchronously. - * - */ - public static final class CreditorApplySchemeIdentifierRequest extends PostRequest { - @PathParam - private final String identity; - private Links links; - - /** - * The ID of the scheme identifier to apply - */ - public CreditorApplySchemeIdentifierRequest withLinks(Links links) { - this.links = links; - return this; - } - - /** - * Unique identifier, usually beginning with "SU". - */ - public CreditorApplySchemeIdentifierRequest withLinksSchemeIdentifier( - String schemeIdentifier) { - if (links == null) { - links = new Links(); - } - links.withSchemeIdentifier(schemeIdentifier); - return this; - } - - private CreditorApplySchemeIdentifierRequest(HttpClient httpClient, String identity) { - super(httpClient); - this.identity = identity; - } - - public CreditorApplySchemeIdentifierRequest withHeader(String headerName, - String headerValue) { - this.addHeader(headerName, headerValue); - return this; - } - - @Override - protected Map getPathParams() { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("identity", identity); - return params.build(); - } - - @Override - protected String getPathTemplate() { - return "creditors/:identity/actions/apply_scheme_identifier"; - } - - @Override - protected String getEnvelope() { - return "creditors"; - } - - @Override - protected Class getResponseClass() { - return Creditor.class; - } - - @Override - protected boolean hasBody() { - return true; - } - - @Override - protected String getRequestEnvelope() { - return "data"; - } - - public static class Links { - private String schemeIdentifier; - - /** - * Unique identifier, usually beginning with "SU". - */ - public Links withSchemeIdentifier(String schemeIdentifier) { - this.schemeIdentifier = schemeIdentifier; - return this; - } - } - } } diff --git a/src/main/java/com/gocardless/services/CurrencyExchangeRateService.java b/src/main/java/com/gocardless/services/CurrencyExchangeRateService.java index 3fe83fd5..6270d55f 100644 --- a/src/main/java/com/gocardless/services/CurrencyExchangeRateService.java +++ b/src/main/java/com/gocardless/services/CurrencyExchangeRateService.java @@ -44,7 +44,6 @@ public CurrencyExchangeRateListRequest> all() { */ public static final class CurrencyExchangeRateListRequest extends ListRequest { - private CreatedAt createdAt; private String source; private String target; @@ -64,55 +63,6 @@ public CurrencyExchangeRateListRequest withBefore(String before) { return this; } - public CurrencyExchangeRateListRequest withCreatedAt(CreatedAt createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - * Limit to records created after the specified date-time. - */ - public CurrencyExchangeRateListRequest withCreatedAtGt(String gt) { - if (createdAt == null) { - createdAt = new CreatedAt(); - } - createdAt.withGt(gt); - return this; - } - - /** - * Limit to records created on or after the specified date-time. - */ - public CurrencyExchangeRateListRequest withCreatedAtGte(String gte) { - if (createdAt == null) { - createdAt = new CreatedAt(); - } - createdAt.withGte(gte); - return this; - } - - /** - * Limit to records created before the specified date-time. - */ - public CurrencyExchangeRateListRequest withCreatedAtLt(String lt) { - if (createdAt == null) { - createdAt = new CreatedAt(); - } - createdAt.withLt(lt); - return this; - } - - /** - * Limit to records created on or before the specified date-time. - */ - public CurrencyExchangeRateListRequest withCreatedAtLte(String lte) { - if (createdAt == null) { - createdAt = new CreatedAt(); - } - createdAt.withLte(lte); - return this; - } - /** * Number of records to return. */ @@ -152,9 +102,6 @@ public CurrencyExchangeRateListRequest withHeader(String headerName, protected Map getQueryParams() { ImmutableMap.Builder params = ImmutableMap.builder(); params.putAll(super.getQueryParams()); - if (createdAt != null) { - params.putAll(createdAt.getQueryParams()); - } if (source != null) { params.put("source", source); } @@ -178,61 +125,5 @@ protected String getEnvelope() { protected TypeToken> getTypeToken() { return new TypeToken>() {}; } - - public static class CreatedAt { - private String gt; - private String gte; - private String lt; - private String lte; - - /** - * Limit to records created after the specified date-time. - */ - public CreatedAt withGt(String gt) { - this.gt = gt; - return this; - } - - /** - * Limit to records created on or after the specified date-time. - */ - public CreatedAt withGte(String gte) { - this.gte = gte; - return this; - } - - /** - * Limit to records created before the specified date-time. - */ - public CreatedAt withLt(String lt) { - this.lt = lt; - return this; - } - - /** - * Limit to records created on or before the specified date-time. - */ - public CreatedAt withLte(String lte) { - this.lte = lte; - return this; - } - - public Map getQueryParams() { - ImmutableMap.Builder params = ImmutableMap.builder(); - if (gt != null) { - params.put("created_at[gt]", gt); - } - if (gte != null) { - params.put("created_at[gte]", gte); - } - if (lt != null) { - params.put("created_at[lt]", lt); - } - if (lte != null) { - params.put("created_at[lte]", lte); - } - return params.build(); - } - } } } diff --git a/src/main/java/com/gocardless/services/InstitutionService.java b/src/main/java/com/gocardless/services/InstitutionService.java index 4cd9fc9c..d36ae07a 100644 --- a/src/main/java/com/gocardless/services/InstitutionService.java +++ b/src/main/java/com/gocardless/services/InstitutionService.java @@ -117,9 +117,20 @@ public static final class InstitutionListForBillingRequestRequest extends ListRequest { @PathParam private final String identity; + private String countryCode; private List ids; private String search; + /** + * [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. + */ + public InstitutionListForBillingRequestRequest withCountryCode(String countryCode) { + this.countryCode = countryCode; + return this; + } + /** * ID(s) of the institution(s) to retrieve. More than one ID can be specified using a * comma-separated string. @@ -172,6 +183,9 @@ protected Map getPathParams() { protected Map getQueryParams() { ImmutableMap.Builder params = ImmutableMap.builder(); params.putAll(super.getQueryParams()); + if (countryCode != null) { + params.put("country_code", countryCode); + } if (ids != null) { params.put("ids", Joiner.on(",").join(ids)); } diff --git a/src/main/java/com/gocardless/services/LogoService.java b/src/main/java/com/gocardless/services/LogoService.java new file mode 100644 index 00000000..0f9ba10a --- /dev/null +++ b/src/main/java/com/gocardless/services/LogoService.java @@ -0,0 +1,116 @@ +package com.gocardless.services; + +import com.gocardless.http.*; +import com.gocardless.resources.Logo; + +/** + * Service class for working with logo resources. + * + * Logos are image uploads that, when associated with a creditor, are shown on the [billing request + * flow](#billing-requests-billing-request-flows) payment pages. + */ +public class LogoService { + 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#logos() }. + */ + public LogoService(HttpClient httpClient) { + this.httpClient = httpClient; + } + + /** + * Creates a new logo associated with a creditor. If a creditor already has a logo, this will + * update the existing logo linked to the creditor. + * + * We support JPG and PNG formats. Your logo will be scaled to a maximum of 300px by 40px. For + * more guidance on how to upload logos that will look great across your customer payment page + * and notification emails see + * [here](https://developer.gocardless.com/gc-embed/setting-up-branding#tips_for_uploading_your_logo). + */ + public LogoCreateForCreditorRequest createForCreditor() { + return new LogoCreateForCreditorRequest(httpClient); + } + + /** + * Request class for {@link LogoService#createForCreditor }. + * + * Creates a new logo associated with a creditor. If a creditor already has a logo, this will + * update the existing logo linked to the creditor. + * + * We support JPG and PNG formats. Your logo will be scaled to a maximum of 300px by 40px. For + * more guidance on how to upload logos that will look great across your customer payment page + * and notification emails see + * [here](https://developer.gocardless.com/gc-embed/setting-up-branding#tips_for_uploading_your_logo). + */ + public static final class LogoCreateForCreditorRequest extends PostRequest { + private String image; + private Links links; + + /** + * Base64 encoded string. + */ + public LogoCreateForCreditorRequest withImage(String image) { + this.image = image; + return this; + } + + public LogoCreateForCreditorRequest withLinks(Links links) { + this.links = links; + return this; + } + + /** + * ID of the creditor the logo belongs to + */ + public LogoCreateForCreditorRequest withLinksCreditor(String creditor) { + if (links == null) { + links = new Links(); + } + links.withCreditor(creditor); + return this; + } + + private LogoCreateForCreditorRequest(HttpClient httpClient) { + super(httpClient); + } + + public LogoCreateForCreditorRequest withHeader(String headerName, String headerValue) { + this.addHeader(headerName, headerValue); + return this; + } + + @Override + protected String getPathTemplate() { + return "branding/logos"; + } + + @Override + protected String getEnvelope() { + return "logos"; + } + + @Override + protected Class getResponseClass() { + return Logo.class; + } + + @Override + protected boolean hasBody() { + return true; + } + + public static class Links { + private String creditor; + + /** + * ID of the creditor the logo belongs to + */ + public Links withCreditor(String creditor) { + this.creditor = creditor; + return this; + } + } + } +} diff --git a/src/main/java/com/gocardless/services/MandateImportEntryService.java b/src/main/java/com/gocardless/services/MandateImportEntryService.java index a881b37f..1066dd62 100644 --- a/src/main/java/com/gocardless/services/MandateImportEntryService.java +++ b/src/main/java/com/gocardless/services/MandateImportEntryService.java @@ -3,6 +3,7 @@ import com.gocardless.http.*; import com.gocardless.resources.MandateImportEntry; import com.google.common.collect.ImmutableMap; +import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; @@ -89,6 +90,7 @@ public static final class MandateImportEntryCreateRequest private BankAccount bankAccount; private Customer customer; private Links links; + private Mandate mandate; private String recordIdentifier; public MandateImportEntryCreateRequest withAmendment(Amendment amendment) { @@ -170,6 +172,20 @@ public MandateImportEntryCreateRequest withBankAccountAccountNumber(String accou 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 MandateImportEntryCreateRequest withBankAccountAccountType( + BankAccount.AccountType accountType) { + if (bankAccount == null) { + bankAccount = new BankAccount(); + } + bankAccount.withAccountType(accountType); + return this; + } + /** * Bank code - see [local details](#appendix-local-bank-details) for more information. * Alternatively you can provide an `iban`. @@ -220,6 +236,19 @@ public MandateImportEntryCreateRequest withBankAccountIban(String 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 MandateImportEntryCreateRequest withBankAccountMetadata( + Map metadata) { + if (bankAccount == null) { + bankAccount = new BankAccount(); + } + bankAccount.withMetadata(metadata); + return this; + } + public MandateImportEntryCreateRequest withCustomer(Customer customer) { this.customer = customer; return this; @@ -360,6 +389,18 @@ public MandateImportEntryCreateRequest withCustomerLanguage(String 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 MandateImportEntryCreateRequest withCustomerMetadata(Map metadata) { + if (customer == null) { + customer = new Customer(); + } + customer.withMetadata(metadata); + return this; + } + /** * [ITU E.123](https://en.wikipedia.org/wiki/E.123) formatted phone number, including * country code. @@ -427,6 +468,36 @@ public MandateImportEntryCreateRequest withLinksMandateImport(String mandateImpo return this; } + public MandateImportEntryCreateRequest withMandate(Mandate mandate) { + this.mandate = mandate; + 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 MandateImportEntryCreateRequest withMandateMetadata(Map metadata) { + if (mandate == null) { + mandate = new Mandate(); + } + mandate.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 MandateImportEntryCreateRequest withMandateReference(String reference) { + if (mandate == null) { + mandate = new Mandate(); + } + mandate.withReference(reference); + return this; + } + /** * A unique identifier for this entry, which you can use (once the import has been processed * by GoCardless) to identify the records that have been created. Limited to 255 characters. @@ -504,10 +575,12 @@ public Amendment withOriginalMandateReference(String originalMandateReference) { public static class BankAccount { private String accountHolderName; private String accountNumber; + private AccountType accountType; private String bankCode; private String branchCode; private String countryCode; private String iban; + private Map metadata; /** * Name of the account holder, as known by the bank. Usually this is the same as the @@ -530,6 +603,16 @@ public BankAccount withAccountNumber(String accountNumber) { 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 BankAccount 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`. @@ -568,6 +651,27 @@ public BankAccount 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 BankAccount withMetadata(Map metadata) { + this.metadata = metadata; + return this; + } + + public enum AccountType { + @SerializedName("savings") + SAVINGS, @SerializedName("checking") + CHECKING, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } } public static class Customer { @@ -582,6 +686,7 @@ public static class Customer { private String familyName; private String givenName; private String language; + private Map metadata; private String phoneNumber; private String postalCode; private String region; @@ -688,6 +793,15 @@ public Customer withLanguage(String 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. @@ -740,6 +854,30 @@ public Links withMandateImport(String mandateImport) { return this; } } + + public static class Mandate { + private Map metadata; + private String reference; + + /** + * 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 Mandate 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 Mandate withReference(String reference) { + this.reference = reference; + return this; + } + } } /** diff --git a/src/main/java/com/gocardless/services/MandateImportService.java b/src/main/java/com/gocardless/services/MandateImportService.java index 29b2d27a..1e3abb82 100644 --- a/src/main/java/com/gocardless/services/MandateImportService.java +++ b/src/main/java/com/gocardless/services/MandateImportService.java @@ -97,8 +97,28 @@ public MandateImportCancelRequest cancel(String identity) { */ public static final class MandateImportCreateRequest extends IdempotentPostRequest { + private Links links; private Scheme scheme; + /** + * Related resources + */ + public MandateImportCreateRequest withLinks(Links links) { + this.links = links; + return this; + } + + /** + * ID of the associated creditor. Only required if your account manages multiple creditors. + */ + public MandateImportCreateRequest withLinksCreditor(String creditor) { + if (links == null) { + links = new Links(); + } + links.withCreditor(creditor); + return this; + } + /** * A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", "becs_nz", * "betalingsservice", "faster_payments", "pad", "pay_to" and "sepa_core" are supported. @@ -170,6 +190,19 @@ public String toString() { return name().toLowerCase(); } } + + public static class Links { + private String creditor; + + /** + * ID of the associated creditor. Only required if your account manages multiple + * creditors. + */ + public Links withCreditor(String creditor) { + this.creditor = creditor; + return this; + } + } } /** diff --git a/src/main/java/com/gocardless/services/MandatePdfService.java b/src/main/java/com/gocardless/services/MandatePdfService.java index 4f044fdb..57ed02a7 100644 --- a/src/main/java/com/gocardless/services/MandatePdfService.java +++ b/src/main/java/com/gocardless/services/MandatePdfService.java @@ -80,8 +80,11 @@ public static final class MandatePdfCreateRequest extends PostRequest> list() { + return new NegativeBalanceLimitListRequest<>(httpClient, + ListRequest.pagingExecutor()); + } + + public NegativeBalanceLimitListRequest> all() { + return new NegativeBalanceLimitListRequest<>(httpClient, + ListRequest.iteratingExecutor()); + } + + /** + * Creates a new negative balance limit, which replaces the existing limit (if present) for that + * currency and creditor combination. + * + */ + public NegativeBalanceLimitCreateRequest create() { + return new NegativeBalanceLimitCreateRequest(httpClient); + } + + /** + * Request class for {@link NegativeBalanceLimitService#list }. + * + * Returns a [cursor-paginated](#api-usage-cursor-pagination) list of negative balance limits. + */ + public static final class NegativeBalanceLimitListRequest + extends ListRequest { + private String creditor; + private Currency currency; + + /** + * Cursor pointing to the start of the desired set. + */ + public NegativeBalanceLimitListRequest withAfter(String after) { + setAfter(after); + return this; + } + + /** + * Cursor pointing to the end of the desired set. + */ + public NegativeBalanceLimitListRequest withBefore(String before) { + setBefore(before); + return this; + } + + /** + * Unique identifier, beginning with "CR". + */ + public NegativeBalanceLimitListRequest withCreditor(String creditor) { + this.creditor = creditor; + 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 NegativeBalanceLimitListRequest withCurrency(Currency currency) { + this.currency = currency; + return this; + } + + /** + * Number of records to return. + */ + public NegativeBalanceLimitListRequest withLimit(Integer limit) { + setLimit(limit); + return this; + } + + private NegativeBalanceLimitListRequest(HttpClient httpClient, + ListRequestExecutor executor) { + super(httpClient, executor); + } + + public NegativeBalanceLimitListRequest withHeader(String headerName, + String headerValue) { + this.addHeader(headerName, headerValue); + return this; + } + + @Override + protected Map getQueryParams() { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.putAll(super.getQueryParams()); + if (creditor != null) { + params.put("creditor", creditor); + } + if (currency != null) { + params.put("currency", currency); + } + return params.build(); + } + + @Override + protected String getPathTemplate() { + return "negative_balance_limits"; + } + + @Override + protected String getEnvelope() { + return "negative_balance_limits"; + } + + @Override + protected TypeToken> getTypeToken() { + return new TypeToken>() {}; + } + + public enum Currency { + @SerializedName("AUD") + AUD, @SerializedName("CAD") + CAD, @SerializedName("DKK") + DKK, @SerializedName("EUR") + EUR, @SerializedName("GBP") + GBP, @SerializedName("NZD") + NZD, @SerializedName("SEK") + SEK, @SerializedName("USD") + USD, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name(); + } + } + } + + /** + * Request class for {@link NegativeBalanceLimitService#create }. + * + * Creates a new negative balance limit, which replaces the existing limit (if present) for that + * currency and creditor combination. + * + */ + public static final class NegativeBalanceLimitCreateRequest + extends PostRequest { + private Integer balanceLimit; + private Currency currency; + private Links links; + + /** + * The limit amount in pence (e.g. 10000 for a -100 GBP limit). + */ + public NegativeBalanceLimitCreateRequest withBalanceLimit(Integer balanceLimit) { + this.balanceLimit = balanceLimit; + 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 NegativeBalanceLimitCreateRequest withCurrency(Currency currency) { + this.currency = currency; + return this; + } + + public NegativeBalanceLimitCreateRequest withLinks(Links links) { + this.links = links; + return this; + } + + /** + * ID of the [creditor](#core-endpoints-creditors) this limit relates to + */ + public NegativeBalanceLimitCreateRequest withLinksCreditor(String creditor) { + if (links == null) { + links = new Links(); + } + links.withCreditor(creditor); + return this; + } + + private NegativeBalanceLimitCreateRequest(HttpClient httpClient) { + super(httpClient); + } + + public NegativeBalanceLimitCreateRequest withHeader(String headerName, String headerValue) { + this.addHeader(headerName, headerValue); + return this; + } + + @Override + protected String getPathTemplate() { + return "negative_balance_limits"; + } + + @Override + protected String getEnvelope() { + return "negative_balance_limits"; + } + + @Override + protected Class getResponseClass() { + return NegativeBalanceLimit.class; + } + + @Override + protected boolean hasBody() { + return true; + } + + public enum Currency { + @SerializedName("AUD") + AUD, @SerializedName("CAD") + CAD, @SerializedName("DKK") + DKK, @SerializedName("EUR") + EUR, @SerializedName("GBP") + GBP, @SerializedName("NZD") + NZD, @SerializedName("SEK") + SEK, @SerializedName("USD") + USD, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name(); + } + } + + public static class Links { + private String creditor; + + /** + * ID of the [creditor](#core-endpoints-creditors) this limit relates to + */ + public Links withCreditor(String creditor) { + this.creditor = creditor; + return this; + } + } + } +} diff --git a/src/main/java/com/gocardless/services/PayerThemeService.java b/src/main/java/com/gocardless/services/PayerThemeService.java new file mode 100644 index 00000000..d41183c0 --- /dev/null +++ b/src/main/java/com/gocardless/services/PayerThemeService.java @@ -0,0 +1,136 @@ +package com.gocardless.services; + +import com.gocardless.http.*; +import com.gocardless.resources.PayerTheme; + +/** + * Service class for working with payer theme resources. + * + * Custom colour themes for payment pages and customer notifications. + */ +public class PayerThemeService { + 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#payerThemes() }. + */ + public PayerThemeService(HttpClient httpClient) { + this.httpClient = httpClient; + } + + /** + * Creates a new payer theme associated with a creditor. If a creditor already has payer themes, + * this will update the existing payer theme linked to the creditor. + */ + public PayerThemeCreateForCreditorRequest createForCreditor() { + return new PayerThemeCreateForCreditorRequest(httpClient); + } + + /** + * Request class for {@link PayerThemeService#createForCreditor }. + * + * Creates a new payer theme associated with a creditor. If a creditor already has payer themes, + * this will update the existing payer theme linked to the creditor. + */ + public static final class PayerThemeCreateForCreditorRequest extends PostRequest { + private String buttonBackgroundColour; + private String contentBoxBorderColour; + private String headerBackgroundColour; + private String linkTextColour; + private Links links; + + /** + * Colour for buttons background (hexcode) + */ + public PayerThemeCreateForCreditorRequest withButtonBackgroundColour( + String buttonBackgroundColour) { + this.buttonBackgroundColour = buttonBackgroundColour; + return this; + } + + /** + * Colour for content box border (hexcode) + */ + public PayerThemeCreateForCreditorRequest withContentBoxBorderColour( + String contentBoxBorderColour) { + this.contentBoxBorderColour = contentBoxBorderColour; + return this; + } + + /** + * Colour for header background (hexcode) + */ + public PayerThemeCreateForCreditorRequest withHeaderBackgroundColour( + String headerBackgroundColour) { + this.headerBackgroundColour = headerBackgroundColour; + return this; + } + + /** + * Colour for text links (hexcode) + */ + public PayerThemeCreateForCreditorRequest withLinkTextColour(String linkTextColour) { + this.linkTextColour = linkTextColour; + return this; + } + + public PayerThemeCreateForCreditorRequest withLinks(Links links) { + this.links = links; + return this; + } + + /** + * ID of the creditor the payer theme belongs to + */ + public PayerThemeCreateForCreditorRequest withLinksCreditor(String creditor) { + if (links == null) { + links = new Links(); + } + links.withCreditor(creditor); + return this; + } + + private PayerThemeCreateForCreditorRequest(HttpClient httpClient) { + super(httpClient); + } + + public PayerThemeCreateForCreditorRequest withHeader(String headerName, + String headerValue) { + this.addHeader(headerName, headerValue); + return this; + } + + @Override + protected String getPathTemplate() { + return "branding/payer_themes"; + } + + @Override + protected String getEnvelope() { + return "payer_themes"; + } + + @Override + protected Class getResponseClass() { + return PayerTheme.class; + } + + @Override + protected boolean hasBody() { + return true; + } + + public static class Links { + private String creditor; + + /** + * ID of the creditor the payer theme belongs to + */ + public Links withCreditor(String creditor) { + this.creditor = creditor; + return this; + } + } + } +} diff --git a/src/main/java/com/gocardless/services/PaymentService.java b/src/main/java/com/gocardless/services/PaymentService.java index b348acad..a1fe6bb5 100644 --- a/src/main/java/com/gocardless/services/PaymentService.java +++ b/src/main/java/com/gocardless/services/PaymentService.java @@ -109,6 +109,7 @@ public static final class PaymentCreateRequest extends IdempotentPostRequest metadata; private String reference; @@ -161,6 +162,16 @@ public PaymentCreateRequest withDescription(String description) { return this; } + /** + * Set this to true or false in the request to create an ACH payment to explicitly choose + * whether the payment should be processed through Faster ACH or standard ACH, rather than + * relying on the presence or absence of the charge date to indicate that. + */ + public PaymentCreateRequest withFasterAch(Boolean fasterAch) { + this.fasterAch = fasterAch; + return this; + } + public PaymentCreateRequest withLinks(Links links) { this.links = links; return this; diff --git a/src/main/java/com/gocardless/services/RedirectFlowService.java b/src/main/java/com/gocardless/services/RedirectFlowService.java index fa171959..843b90ba 100644 --- a/src/main/java/com/gocardless/services/RedirectFlowService.java +++ b/src/main/java/com/gocardless/services/RedirectFlowService.java @@ -11,9 +11,9 @@ * Service class for working with redirect flow resources. * *

    - * Deprecated: Redirect Flows are our legacy APIs for setting up mandates and will - * no longer be supported in the future. We strongly recommend using the [Billing Request - * flow](#billing-requests) instead. + * Deprecated: Redirect Flows are legacy APIs and cannot be used by new + * integrators. The [Billing Request flow](#billing-requests) API should be used for your payment + * flows. *

    * * Redirect flows enable you to use GoCardless' [hosted payment diff --git a/src/main/java/com/gocardless/services/SchemeIdentifierService.java b/src/main/java/com/gocardless/services/SchemeIdentifierService.java index 782ad316..e169019c 100644 --- a/src/main/java/com/gocardless/services/SchemeIdentifierService.java +++ b/src/main/java/com/gocardless/services/SchemeIdentifierService.java @@ -28,26 +28,32 @@ public SchemeIdentifierService(HttpClient httpClient) { } /** - * Creates a new scheme identifier. The scheme identifier must be [applied to a - * creditor](#creditors-apply-a-scheme-identifier) before payments are taken using it. The - * scheme identifier must also have the `status` of active before it can be used. For some - * schemes e.g. faster_payments this will happen instantly. For other schemes e.g. bacs this can - * take several days. + * Creates a new scheme identifier. The scheme identifier status will be `pending` while + * GoCardless is processing the request. Once the scheme identifier is ready to be used the + * status will be updated to `active`. At this point, GoCardless will emit a scheme identifier + * activated event via webhook to notify you of this change. In Bacs, it will take up to five + * working days for a scheme identifier to become active. On other schemes, including SEPA, this + * happens instantly. * - * ### Scheme identifier name validations + * #### Scheme identifier name validations * - * Each scheme has different rules for the length and permitted characters in the scheme - * identifier name field. The rules are: + * The `name` field of a scheme identifier can contain alphanumeric characters, spaces and + * special characters. * - * | __scheme__ | __maximum length__ | __allowed characters__ | __spaces__ | | :-------------- | - * :----------------- | :----------------------- | :--------- | | bacs | 18 characters | - * `a-zA-Z0-9/.&-` | yes | | sepa_core | 70 characters | `a-zA-Z0-9/?:().,+&<>'"` | yes | | ach - * | 16 characters | `a-zA-Z0-9/?:().,'+-` | yes | | faster_payments | 18 characters | - * `a-zA-Z0-9/?:().,'+-` | yes | + * Its maximum length and the special characters it supports depend on the scheme: + * + * | __scheme__ | __maximum length__ | __special characters allowed__ | | :---------------- | + * :----------------- | :-------------------------------------------------- | | `bacs` | 18 + * characters | `/` `.` `&` `-` | | `sepa` | 70 characters | `/` `?` `:` `(` `)` `.` `,` `+` `&` + * `<` `>` `'` `"` | | `ach` | 16 characters | `/` `?` `:` `(` `)` `.` `,` `'` `+` `-` | | + * `faster_payments` | 18 characters | `/` `?` `:` `(` `)` `.` `,` `'` `+` `-` | * * The validation error that gets returned for an invalid name will contain a suggested name in * the metadata that is guaranteed to pass name validations. * + * You should ensure that the name you set matches the legal name or the trading name of the + * creditor, otherwise, there is an increased risk of chargeback. + * */ public SchemeIdentifierCreateRequest create() { return new SchemeIdentifierCreateRequest(httpClient); @@ -76,32 +82,56 @@ public SchemeIdentifierGetRequest get(String identity) { /** * Request class for {@link SchemeIdentifierService#create }. * - * Creates a new scheme identifier. The scheme identifier must be [applied to a - * creditor](#creditors-apply-a-scheme-identifier) before payments are taken using it. The - * scheme identifier must also have the `status` of active before it can be used. For some - * schemes e.g. faster_payments this will happen instantly. For other schemes e.g. bacs this can - * take several days. + * Creates a new scheme identifier. The scheme identifier status will be `pending` while + * GoCardless is processing the request. Once the scheme identifier is ready to be used the + * status will be updated to `active`. At this point, GoCardless will emit a scheme identifier + * activated event via webhook to notify you of this change. In Bacs, it will take up to five + * working days for a scheme identifier to become active. On other schemes, including SEPA, this + * happens instantly. + * + * #### Scheme identifier name validations * - * ### Scheme identifier name validations + * The `name` field of a scheme identifier can contain alphanumeric characters, spaces and + * special characters. * - * Each scheme has different rules for the length and permitted characters in the scheme - * identifier name field. The rules are: + * Its maximum length and the special characters it supports depend on the scheme: * - * | __scheme__ | __maximum length__ | __allowed characters__ | __spaces__ | | :-------------- | - * :----------------- | :----------------------- | :--------- | | bacs | 18 characters | - * `a-zA-Z0-9/.&-` | yes | | sepa_core | 70 characters | `a-zA-Z0-9/?:().,+&<>'"` | yes | | ach - * | 16 characters | `a-zA-Z0-9/?:().,'+-` | yes | | faster_payments | 18 characters | - * `a-zA-Z0-9/?:().,'+-` | yes | + * | __scheme__ | __maximum length__ | __special characters allowed__ | | :---------------- | + * :----------------- | :-------------------------------------------------- | | `bacs` | 18 + * characters | `/` `.` `&` `-` | | `sepa` | 70 characters | `/` `?` `:` `(` `)` `.` `,` `+` `&` + * `<` `>` `'` `"` | | `ach` | 16 characters | `/` `?` `:` `(` `)` `.` `,` `'` `+` `-` | | + * `faster_payments` | 18 characters | `/` `?` `:` `(` `)` `.` `,` `'` `+` `-` | * * The validation error that gets returned for an invalid name will contain a suggested name in * the metadata that is guaranteed to pass name validations. * + * You should ensure that the name you set matches the legal name or the trading name of the + * creditor, otherwise, there is an increased risk of chargeback. + * */ public static final class SchemeIdentifierCreateRequest extends IdempotentPostRequest { + private Links links; private String name; private Scheme scheme; + public SchemeIdentifierCreateRequest withLinks(Links links) { + this.links = links; + return this; + } + + /** + * required ID of the associated [creditor](#core-endpoints-creditors). + * + */ + public SchemeIdentifierCreateRequest withLinksCreditor(String creditor) { + if (links == null) { + links = new Links(); + } + links.withCreditor(creditor); + return this; + } + /** * The name which appears on customers' bank statements. This should usually be the * merchant's trading name. @@ -183,6 +213,19 @@ public String toString() { return name().toLowerCase(); } } + + public static class Links { + private String creditor; + + /** + * required ID of the associated [creditor](#core-endpoints-creditors). + * + */ + public Links withCreditor(String creditor) { + this.creditor = creditor; + return this; + } + } } /** @@ -192,6 +235,8 @@ public String toString() { */ public static final class SchemeIdentifierListRequest extends ListRequest { + private String creditor; + /** * Cursor pointing to the start of the desired set. */ @@ -208,6 +253,14 @@ public SchemeIdentifierListRequest withBefore(String before) { return this; } + /** + * Unique identifier, beginning with "CR". + */ + public SchemeIdentifierListRequest withCreditor(String creditor) { + this.creditor = creditor; + return this; + } + /** * Number of records to return. */ @@ -230,6 +283,9 @@ public SchemeIdentifierListRequest withHeader(String headerName, String heade protected Map getQueryParams() { ImmutableMap.Builder params = ImmutableMap.builder(); params.putAll(super.getQueryParams()); + if (creditor != null) { + params.put("creditor", creditor); + } return params.build(); } diff --git a/src/main/java/com/gocardless/services/SubscriptionService.java b/src/main/java/com/gocardless/services/SubscriptionService.java index 7b405ceb..22d8d595 100644 --- a/src/main/java/com/gocardless/services/SubscriptionService.java +++ b/src/main/java/com/gocardless/services/SubscriptionService.java @@ -20,10 +20,10 @@ * * The following rules apply when specifying recurrence: * - * - The first payment must be charged within 1 year. - If `day_of_month` and `start_date` are not - * provided `start_date` will be the [mandate](#core-endpoints-mandates)'s - * `next_possible_charge_date` and the subscription will then recur based on the `interval` & - * `interval_unit` - If `month` or `day_of_month` are present the following validations apply: + * - If `day_of_month` and `start_date` are not provided `start_date` will be the + * [mandate](#core-endpoints-mandates)'s `next_possible_charge_date` and the subscription will then + * recur based on the `interval` & `interval_unit` - If `month` or `day_of_month` are present the + * following validations apply: * * | __interval_unit__ | __month__ | __day_of_month__ | | :---------------- | * :--------------------------------------------- | :----------------------------------------- | | @@ -47,7 +47,6 @@ * - if the recurrence rule specified `-1` as the `day_of_month`, the charge date will be rolled * __backwards__ to the previous business day (i.e., the last working day of the month). - otherwise * the charge date will be rolled __forwards__ to the next business day. - * */ public class SubscriptionService { private final HttpClient httpClient; @@ -151,7 +150,6 @@ public SubscriptionUpdateRequest update(String identity) { * * - `pause_cycles_must_be_greater_than_or_equal_to` if the provided value for `pause_cycles` * cannot be satisfied. - * */ public SubscriptionPauseRequest pause(String identity) { return new SubscriptionPauseRequest(httpClient, identity); @@ -941,7 +939,6 @@ protected boolean hasBody() { * * - `pause_cycles_must_be_greater_than_or_equal_to` if the provided value for `pause_cycles` * cannot be satisfied. - * */ public static final class SubscriptionPauseRequest extends PostRequest { @PathParam @@ -972,7 +969,11 @@ public SubscriptionPauseRequest withMetadata(String key, String value) { /** * The number of cycles to pause a subscription for. A cycle is one duration of `interval` - * and `interval_unit`. This should be a non zero positive value. + * and `interval_unit`. This should be a non zero positive value. For AUD subscriptions with + * `interval_unit: weekly` the minimum value varies between `3` & `4` because of the + * [mandatory minimum waiting period](#subscriptions-resume-a-subscription). For NZD + * subscriptions with `interval_unit: weekly` the minimum value is `2` because of the + * [mandatory minimum waiting period](#subscriptions-resume-a-subscription). */ public SubscriptionPauseRequest withPauseCycles(Integer pauseCycles) { this.pauseCycles = pauseCycles; diff --git a/src/main/java/com/gocardless/services/TaxRateService.java b/src/main/java/com/gocardless/services/TaxRateService.java index ee4299c3..8e1222c4 100644 --- a/src/main/java/com/gocardless/services/TaxRateService.java +++ b/src/main/java/com/gocardless/services/TaxRateService.java @@ -75,6 +75,14 @@ public TaxRateListRequest withJurisdiction(String jurisdiction) { return this; } + /** + * Number of records to return. + */ + public TaxRateListRequest withLimit(Integer limit) { + setLimit(limit); + return this; + } + private TaxRateListRequest(HttpClient httpClient, ListRequestExecutor executor) { super(httpClient, executor); diff --git a/src/main/java/com/gocardless/services/TransferredMandateService.java b/src/main/java/com/gocardless/services/TransferredMandateService.java new file mode 100644 index 00000000..29b05c80 --- /dev/null +++ b/src/main/java/com/gocardless/services/TransferredMandateService.java @@ -0,0 +1,83 @@ +package com.gocardless.services; + +import com.gocardless.http.*; +import com.gocardless.resources.TransferredMandate; +import com.google.common.collect.ImmutableMap; +import java.util.Map; + +/** + * Service class for working with transferred mandate resources. + * + * Mandates that have been transferred using Current Account Switch Service + */ +public class TransferredMandateService { + 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#transferredMandates() }. + */ + public TransferredMandateService(HttpClient httpClient) { + this.httpClient = httpClient; + } + + /** + * Returns new customer bank details for a mandate that's been recently transferred + */ + public TransferredMandateTransferredMandatesRequest transferredMandates(String identity) { + return new TransferredMandateTransferredMandatesRequest(httpClient, identity); + } + + /** + * Request class for {@link TransferredMandateService#transferredMandates }. + * + * Returns new customer bank details for a mandate that's been recently transferred + */ + public static final class TransferredMandateTransferredMandatesRequest + extends GetRequest { + @PathParam + private final String identity; + + private TransferredMandateTransferredMandatesRequest(HttpClient httpClient, + String identity) { + super(httpClient); + this.identity = identity; + } + + public TransferredMandateTransferredMandatesRequest withHeader(String headerName, + String headerValue) { + this.addHeader(headerName, headerValue); + return this; + } + + @Override + protected Map getPathParams() { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("identity", identity); + return params.build(); + } + + @Override + protected Map getQueryParams() { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.putAll(super.getQueryParams()); + return params.build(); + } + + @Override + protected String getPathTemplate() { + return "transferred_mandates/:identity"; + } + + @Override + protected String getEnvelope() { + return "transferred_mandates"; + } + + @Override + protected Class getResponseClass() { + return TransferredMandate.class; + } + } +}