diff --git a/src/main/java/com/gocardless/GoCardlessClient.java b/src/main/java/com/gocardless/GoCardlessClient.java index 4d87f53f..ceb32ea1 100644 --- a/src/main/java/com/gocardless/GoCardlessClient.java +++ b/src/main/java/com/gocardless/GoCardlessClient.java @@ -32,6 +32,7 @@ public class GoCardlessClient { private final CustomerNotificationService customerNotifications; private final EventService events; private final ExportService exports; + private final FundsAvailabilityService fundsAvailabilities; private final InstalmentScheduleService instalmentSchedules; private final InstitutionService institutions; private final LogoService logos; @@ -196,6 +197,7 @@ private GoCardlessClient(HttpClient httpClient) { this.customerNotifications = new CustomerNotificationService(httpClient); this.events = new EventService(httpClient); this.exports = new ExportService(httpClient); + this.fundsAvailabilities = new FundsAvailabilityService(httpClient); this.instalmentSchedules = new InstalmentScheduleService(httpClient); this.institutions = new InstitutionService(httpClient); this.logos = new LogoService(httpClient); @@ -349,6 +351,13 @@ public ExportService exports() { return exports; } + /** + * A service class for working with funds availability resources. + */ + public FundsAvailabilityService fundsAvailabilities() { + return fundsAvailabilities; + } + /** * A service class for working with instalment schedule resources. */ diff --git a/src/main/java/com/gocardless/resources/BillingRequest.java b/src/main/java/com/gocardless/resources/BillingRequest.java index 0f8d9516..b687bd20 100644 --- a/src/main/java/com/gocardless/resources/BillingRequest.java +++ b/src/main/java/com/gocardless/resources/BillingRequest.java @@ -33,6 +33,8 @@ private BillingRequest() { private Links links; private MandateRequest mandateRequest; private Map metadata; + private PaymentContextCode paymentContextCode; + private String paymentPurposeCode; private PaymentRequest paymentRequest; private PurposeCode purposeCode; private Resources resources; @@ -106,6 +108,27 @@ public Map getMetadata() { return metadata; } + /** + * Specifies the context or scenario in which the payment is being made. Defines whether the + * payment is for advance/arrears billing, point of sale transactions, ecommerce, or account + * transfers. This helps banks and payment processors understand the payment scenario and apply + * appropriate processing rules and risk controls. + */ + public PaymentContextCode getPaymentContextCode() { + return paymentContextCode; + } + + /** + * Specifies the underlying purpose of the payment. Defines the specific reason or type of + * service/goods the payment relates to, improving straight-through processing and compliance. + * See [VRP Commercial Payment Purpose + * Codes](https://developer.gocardless.com/vrp-commercial-payment-purpose-codes/) for the + * complete list of valid codes. + */ + public String getPaymentPurposeCode() { + return paymentPurposeCode; + } + /** * Request for a one-off strongly authorised payment */ @@ -114,10 +137,11 @@ public PaymentRequest getPaymentRequest() { } /** - * Specifies the high-level purpose of a mandate and/or payment using a set of pre-defined - * categories. Required for the PayTo scheme, optional for all others. Currently `mortgage`, - * `utility`, `loan`, `dependant_support`, `gambling`, `retail`, `salary`, `personal`, - * `government`, `pension`, `tax` and `other` are supported. + * Specifies the high-level purpose/category of a mandate and/or payment using a set of + * pre-defined categories. Provides context on the nature and reason for the payment to + * facilitate processing and compliance. See [Billing Request Purpose + * Codes](https://developer.gocardless.com/billing-request-purpose-codes/) for the complete list + * of valid codes. */ public PurposeCode getPurposeCode() { return purposeCode; @@ -148,6 +172,17 @@ public SubscriptionRequest getSubscriptionRequest() { return subscriptionRequest; } + public enum PaymentContextCode { + @SerializedName("billing_goods_and_services_in_advance") + BILLING_GOODS_AND_SERVICES_IN_ADVANCE, @SerializedName("billing_goods_and_services_in_arrears") + BILLING_GOODS_AND_SERVICES_IN_ARREARS, @SerializedName("face_to_face_point_of_sale") + FACE_TO_FACE_POINT_OF_SALE, @SerializedName("ecommerce_merchant_initiated_payment") + ECOMMERCE_MERCHANT_INITIATED_PAYMENT, @SerializedName("transfer_to_self") + TRANSFER_TO_SELF, @SerializedName("transfer_to_third_party") + TRANSFER_TO_THIRD_PARTY, @SerializedName("unknown") + UNKNOWN + } + public enum PurposeCode { @SerializedName("mortgage") MORTGAGE, @SerializedName("utility") @@ -161,11 +196,50 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("Epayment") - EPAYMENT, @SerializedName("Commercial") - COMMERCIAL, @SerializedName("OtherPayment") - OTHERPAYMENT, @SerializedName("Trade") - TRADE, @SerializedName("unknown") + OTHER, @SerializedName("bonus_payment") + BONUS_PAYMENT, @SerializedName("cash_management_transfer") + CASH_MANAGEMENT_TRANSFER, @SerializedName("card_bulk_clearing") + CARD_BULK_CLEARING, @SerializedName("credit_card_payment") + CREDIT_CARD_PAYMENT, @SerializedName("trade_settlement_payment") + TRADE_SETTLEMENT_PAYMENT, @SerializedName("debit_card_payment") + DEBIT_CARD_PAYMENT, @SerializedName("dividend") + DIVIDEND, @SerializedName("deliver_against_payment") + DELIVER_AGAINST_PAYMENT, @SerializedName("epayment") + EPAYMENT, @SerializedName("fee_collection_and_interest") + FEE_COLLECTION_AND_INTEREST, @SerializedName("fee_collection") + FEE_COLLECTION, @SerializedName("person_to_person_payment") + PERSON_TO_PERSON_PAYMENT, @SerializedName("government_payment") + GOVERNMENT_PAYMENT, @SerializedName("hedging_transaction") + HEDGING_TRANSACTION, @SerializedName("irrevocable_credit_card_payment") + IRREVOCABLE_CREDIT_CARD_PAYMENT, @SerializedName("irrevocable_debit_card_payment") + IRREVOCABLE_DEBIT_CARD_PAYMENT, @SerializedName("intra_company_payment") + INTRA_COMPANY_PAYMENT, @SerializedName("interest") + INTEREST, @SerializedName("lockbox_transactions") + LOCKBOX_TRANSACTIONS, @SerializedName("commercial") + COMMERCIAL, @SerializedName("consumer") + CONSUMER, @SerializedName("other_payment") + OTHER_PAYMENT, @SerializedName("pension_payment") + PENSION_PAYMENT, @SerializedName("represented") + REPRESENTED, @SerializedName("reimbursement_received_credit_transfer") + REIMBURSEMENT_RECEIVED_CREDIT_TRANSFER, @SerializedName("receive_against_payment") + RECEIVE_AGAINST_PAYMENT, @SerializedName("salary_payment") + SALARY_PAYMENT, @SerializedName("securities") + SECURITIES, @SerializedName("social_security_benefit") + SOCIAL_SECURITY_BENEFIT, @SerializedName("supplier_payment") + SUPPLIER_PAYMENT, @SerializedName("tax_payment") + TAX_PAYMENT, @SerializedName("trade") + TRADE, @SerializedName("treasury_payment") + TREASURY_PAYMENT, @SerializedName("value_added_tax_payment") + VALUE_ADDED_TAX_PAYMENT, @SerializedName("with_holding") + WITH_HOLDING, @SerializedName("cash_management_sweep_account") + CASH_MANAGEMENT_SWEEP_ACCOUNT, @SerializedName("cash_management_top_account") + CASH_MANAGEMENT_TOP_ACCOUNT, @SerializedName("cash_management_zero_balance_account") + CASH_MANAGEMENT_ZERO_BALANCE_ACCOUNT, @SerializedName("crossborder_mi_payments") + CROSSBORDER_MI_PAYMENTS, @SerializedName("foreign_currency_domestic_transfer") + FOREIGN_CURRENCY_DOMESTIC_TRANSFER, @SerializedName("cash_in_pre_credit") + CASH_IN_PRE_CREDIT, @SerializedName("cash_out_notes_coins") + CASH_OUT_NOTES_COINS, @SerializedName("carrier_guarded_wholesale_valuables") + CARRIER_GUARDED_WHOLESALE_VALUABLES, @SerializedName("unknown") UNKNOWN } diff --git a/src/main/java/com/gocardless/resources/BillingRequestFlow.java b/src/main/java/com/gocardless/resources/BillingRequestFlow.java index 05df7caf..63e01714 100644 --- a/src/main/java/com/gocardless/resources/BillingRequestFlow.java +++ b/src/main/java/com/gocardless/resources/BillingRequestFlow.java @@ -63,7 +63,9 @@ public Boolean getCustomerDetailsCaptured() { } /** - * URL that the payer can be taken to if there isn't a way to progress ahead in flow. + * URL that the payer can be taken to if there isn't a way to progress ahead in flow, for + * example if the customer searches for a bank that doesn't exist or isn't supported on the + * scheme. */ public String getExitUri() { return exitUri; diff --git a/src/main/java/com/gocardless/resources/BillingRequestWithAction.java b/src/main/java/com/gocardless/resources/BillingRequestWithAction.java index 368af23f..6a580257 100644 --- a/src/main/java/com/gocardless/resources/BillingRequestWithAction.java +++ b/src/main/java/com/gocardless/resources/BillingRequestWithAction.java @@ -234,6 +234,8 @@ private BillingRequests() { private Links links; private MandateRequest mandateRequest; private Map metadata; + private PaymentContextCode paymentContextCode; + private String paymentPurposeCode; private PaymentRequest paymentRequest; private PurposeCode purposeCode; private Resources resources; @@ -307,6 +309,27 @@ public Map getMetadata() { return metadata; } + /** + * Specifies the context or scenario in which the payment is being made. Defines whether the + * payment is for advance/arrears billing, point of sale transactions, ecommerce, or account + * transfers. This helps banks and payment processors understand the payment scenario and + * apply appropriate processing rules and risk controls. + */ + public PaymentContextCode getPaymentContextCode() { + return paymentContextCode; + } + + /** + * Specifies the underlying purpose of the payment. Defines the specific reason or type of + * service/goods the payment relates to, improving straight-through processing and + * compliance. See [VRP Commercial Payment Purpose + * Codes](https://developer.gocardless.com/vrp-commercial-payment-purpose-codes/) for the + * complete list of valid codes. + */ + public String getPaymentPurposeCode() { + return paymentPurposeCode; + } + /** * Request for a one-off strongly authorised payment */ @@ -315,10 +338,11 @@ public PaymentRequest getPaymentRequest() { } /** - * Specifies the high-level purpose of a mandate and/or payment using a set of pre-defined - * categories. Required for the PayTo scheme, optional for all others. Currently `mortgage`, - * `utility`, `loan`, `dependant_support`, `gambling`, `retail`, `salary`, `personal`, - * `government`, `pension`, `tax` and `other` are supported. + * Specifies the high-level purpose/category of a mandate and/or payment using a set of + * pre-defined categories. Provides context on the nature and reason for the payment to + * facilitate processing and compliance. See [Billing Request Purpose + * Codes](https://developer.gocardless.com/billing-request-purpose-codes/) for the complete + * list of valid codes. */ public PurposeCode getPurposeCode() { return purposeCode; @@ -349,6 +373,17 @@ public SubscriptionRequest getSubscriptionRequest() { return subscriptionRequest; } + public enum PaymentContextCode { + @SerializedName("billing_goods_and_services_in_advance") + BILLING_GOODS_AND_SERVICES_IN_ADVANCE, @SerializedName("billing_goods_and_services_in_arrears") + BILLING_GOODS_AND_SERVICES_IN_ARREARS, @SerializedName("face_to_face_point_of_sale") + FACE_TO_FACE_POINT_OF_SALE, @SerializedName("ecommerce_merchant_initiated_payment") + ECOMMERCE_MERCHANT_INITIATED_PAYMENT, @SerializedName("transfer_to_self") + TRANSFER_TO_SELF, @SerializedName("transfer_to_third_party") + TRANSFER_TO_THIRD_PARTY, @SerializedName("unknown") + UNKNOWN + } + public enum PurposeCode { @SerializedName("mortgage") MORTGAGE, @SerializedName("utility") @@ -362,11 +397,50 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("Epayment") - EPAYMENT, @SerializedName("Commercial") - COMMERCIAL, @SerializedName("OtherPayment") - OTHERPAYMENT, @SerializedName("Trade") - TRADE, @SerializedName("unknown") + OTHER, @SerializedName("bonus_payment") + BONUS_PAYMENT, @SerializedName("cash_management_transfer") + CASH_MANAGEMENT_TRANSFER, @SerializedName("card_bulk_clearing") + CARD_BULK_CLEARING, @SerializedName("credit_card_payment") + CREDIT_CARD_PAYMENT, @SerializedName("trade_settlement_payment") + TRADE_SETTLEMENT_PAYMENT, @SerializedName("debit_card_payment") + DEBIT_CARD_PAYMENT, @SerializedName("dividend") + DIVIDEND, @SerializedName("deliver_against_payment") + DELIVER_AGAINST_PAYMENT, @SerializedName("epayment") + EPAYMENT, @SerializedName("fee_collection_and_interest") + FEE_COLLECTION_AND_INTEREST, @SerializedName("fee_collection") + FEE_COLLECTION, @SerializedName("person_to_person_payment") + PERSON_TO_PERSON_PAYMENT, @SerializedName("government_payment") + GOVERNMENT_PAYMENT, @SerializedName("hedging_transaction") + HEDGING_TRANSACTION, @SerializedName("irrevocable_credit_card_payment") + IRREVOCABLE_CREDIT_CARD_PAYMENT, @SerializedName("irrevocable_debit_card_payment") + IRREVOCABLE_DEBIT_CARD_PAYMENT, @SerializedName("intra_company_payment") + INTRA_COMPANY_PAYMENT, @SerializedName("interest") + INTEREST, @SerializedName("lockbox_transactions") + LOCKBOX_TRANSACTIONS, @SerializedName("commercial") + COMMERCIAL, @SerializedName("consumer") + CONSUMER, @SerializedName("other_payment") + OTHER_PAYMENT, @SerializedName("pension_payment") + PENSION_PAYMENT, @SerializedName("represented") + REPRESENTED, @SerializedName("reimbursement_received_credit_transfer") + REIMBURSEMENT_RECEIVED_CREDIT_TRANSFER, @SerializedName("receive_against_payment") + RECEIVE_AGAINST_PAYMENT, @SerializedName("salary_payment") + SALARY_PAYMENT, @SerializedName("securities") + SECURITIES, @SerializedName("social_security_benefit") + SOCIAL_SECURITY_BENEFIT, @SerializedName("supplier_payment") + SUPPLIER_PAYMENT, @SerializedName("tax_payment") + TAX_PAYMENT, @SerializedName("trade") + TRADE, @SerializedName("treasury_payment") + TREASURY_PAYMENT, @SerializedName("value_added_tax_payment") + VALUE_ADDED_TAX_PAYMENT, @SerializedName("with_holding") + WITH_HOLDING, @SerializedName("cash_management_sweep_account") + CASH_MANAGEMENT_SWEEP_ACCOUNT, @SerializedName("cash_management_top_account") + CASH_MANAGEMENT_TOP_ACCOUNT, @SerializedName("cash_management_zero_balance_account") + CASH_MANAGEMENT_ZERO_BALANCE_ACCOUNT, @SerializedName("crossborder_mi_payments") + CROSSBORDER_MI_PAYMENTS, @SerializedName("foreign_currency_domestic_transfer") + FOREIGN_CURRENCY_DOMESTIC_TRANSFER, @SerializedName("cash_in_pre_credit") + CASH_IN_PRE_CREDIT, @SerializedName("cash_out_notes_coins") + CASH_OUT_NOTES_COINS, @SerializedName("carrier_guarded_wholesale_valuables") + CARRIER_GUARDED_WHOLESALE_VALUABLES, @SerializedName("unknown") UNKNOWN } diff --git a/src/main/java/com/gocardless/resources/FundsAvailability.java b/src/main/java/com/gocardless/resources/FundsAvailability.java new file mode 100644 index 00000000..d3023011 --- /dev/null +++ b/src/main/java/com/gocardless/resources/FundsAvailability.java @@ -0,0 +1,22 @@ +package com.gocardless.resources; + +/** + * Represents a funds availability resource returned from the API. + * + * Checks if the payer's current balance is sufficient to cover the amount the merchant wants to + * charge within the consent parameters defined on the mandate. + */ +public class FundsAvailability { + private FundsAvailability() { + // blank to prevent instantiation + } + + private Boolean available; + + /** + * Indicates if the amount is available + */ + public Boolean getAvailable() { + return available; + } +} diff --git a/src/main/java/com/gocardless/services/BillingRequestFlowService.java b/src/main/java/com/gocardless/services/BillingRequestFlowService.java index 4eeddcec..92ecd394 100644 --- a/src/main/java/com/gocardless/services/BillingRequestFlowService.java +++ b/src/main/java/com/gocardless/services/BillingRequestFlowService.java @@ -80,7 +80,9 @@ public BillingRequestFlowCreateRequest withCustomerDetailsCaptured( } /** - * URL that the payer can be taken to if there isn't a way to progress ahead in flow. + * URL that the payer can be taken to if there isn't a way to progress ahead in flow, for + * example if the customer searches for a bank that doesn't exist or isn't supported on the + * scheme. */ public BillingRequestFlowCreateRequest withExitUri(String exitUri) { this.exitUri = exitUri; diff --git a/src/main/java/com/gocardless/services/BillingRequestService.java b/src/main/java/com/gocardless/services/BillingRequestService.java index 795ff2cf..1ca4e925 100644 --- a/src/main/java/com/gocardless/services/BillingRequestService.java +++ b/src/main/java/com/gocardless/services/BillingRequestService.java @@ -176,6 +176,8 @@ public static final class BillingRequestCreateRequest private Links links; private MandateRequest mandateRequest; private Map metadata; + private PaymentContextCode paymentContextCode; + private String paymentPurposeCode; private PaymentRequest paymentRequest; private PurposeCode purposeCode; private SubscriptionRequest subscriptionRequest; @@ -562,6 +564,30 @@ public BillingRequestCreateRequest withMetadata(String key, String value) { return this; } + /** + * Specifies the context or scenario in which the payment is being made. Defines whether the + * payment is for advance/arrears billing, point of sale transactions, ecommerce, or account + * transfers. This helps banks and payment processors understand the payment scenario and + * apply appropriate processing rules and risk controls. + */ + public BillingRequestCreateRequest withPaymentContextCode( + PaymentContextCode paymentContextCode) { + this.paymentContextCode = paymentContextCode; + return this; + } + + /** + * Specifies the underlying purpose of the payment. Defines the specific reason or type of + * service/goods the payment relates to, improving straight-through processing and + * compliance. See [VRP Commercial Payment Purpose + * Codes](https://developer.gocardless.com/vrp-commercial-payment-purpose-codes/) for the + * complete list of valid codes. + */ + public BillingRequestCreateRequest withPaymentPurposeCode(String paymentPurposeCode) { + this.paymentPurposeCode = paymentPurposeCode; + return this; + } + public BillingRequestCreateRequest withPaymentRequest(PaymentRequest paymentRequest) { this.paymentRequest = paymentRequest; return this; @@ -697,10 +723,11 @@ public BillingRequestCreateRequest withPaymentRequestScheme(String scheme) { } /** - * Specifies the high-level purpose of a mandate and/or payment using a set of pre-defined - * categories. Required for the PayTo scheme, optional for all others. Currently `mortgage`, - * `utility`, `loan`, `dependant_support`, `gambling`, `retail`, `salary`, `personal`, - * `government`, `pension`, `tax` and `other` are supported. + * Specifies the high-level purpose/category of a mandate and/or payment using a set of + * pre-defined categories. Provides context on the nature and reason for the payment to + * facilitate processing and compliance. See [Billing Request Purpose + * Codes](https://developer.gocardless.com/billing-request-purpose-codes/) for the complete + * list of valid codes. */ public BillingRequestCreateRequest withPurposeCode(PurposeCode purposeCode) { this.purposeCode = purposeCode; @@ -925,6 +952,22 @@ protected boolean hasBody() { return true; } + public enum PaymentContextCode { + @SerializedName("billing_goods_and_services_in_advance") + BILLING_GOODS_AND_SERVICES_IN_ADVANCE, @SerializedName("billing_goods_and_services_in_arrears") + BILLING_GOODS_AND_SERVICES_IN_ARREARS, @SerializedName("face_to_face_point_of_sale") + FACE_TO_FACE_POINT_OF_SALE, @SerializedName("ecommerce_merchant_initiated_payment") + ECOMMERCE_MERCHANT_INITIATED_PAYMENT, @SerializedName("transfer_to_self") + TRANSFER_TO_SELF, @SerializedName("transfer_to_third_party") + TRANSFER_TO_THIRD_PARTY, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + public enum PurposeCode { @SerializedName("mortgage") MORTGAGE, @SerializedName("utility") @@ -938,11 +981,50 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("Epayment") - EPAYMENT, @SerializedName("Commercial") - COMMERCIAL, @SerializedName("OtherPayment") - OTHERPAYMENT, @SerializedName("Trade") - TRADE, @SerializedName("unknown") + OTHER, @SerializedName("bonus_payment") + BONUS_PAYMENT, @SerializedName("cash_management_transfer") + CASH_MANAGEMENT_TRANSFER, @SerializedName("card_bulk_clearing") + CARD_BULK_CLEARING, @SerializedName("credit_card_payment") + CREDIT_CARD_PAYMENT, @SerializedName("trade_settlement_payment") + TRADE_SETTLEMENT_PAYMENT, @SerializedName("debit_card_payment") + DEBIT_CARD_PAYMENT, @SerializedName("dividend") + DIVIDEND, @SerializedName("deliver_against_payment") + DELIVER_AGAINST_PAYMENT, @SerializedName("epayment") + EPAYMENT, @SerializedName("fee_collection_and_interest") + FEE_COLLECTION_AND_INTEREST, @SerializedName("fee_collection") + FEE_COLLECTION, @SerializedName("person_to_person_payment") + PERSON_TO_PERSON_PAYMENT, @SerializedName("government_payment") + GOVERNMENT_PAYMENT, @SerializedName("hedging_transaction") + HEDGING_TRANSACTION, @SerializedName("irrevocable_credit_card_payment") + IRREVOCABLE_CREDIT_CARD_PAYMENT, @SerializedName("irrevocable_debit_card_payment") + IRREVOCABLE_DEBIT_CARD_PAYMENT, @SerializedName("intra_company_payment") + INTRA_COMPANY_PAYMENT, @SerializedName("interest") + INTEREST, @SerializedName("lockbox_transactions") + LOCKBOX_TRANSACTIONS, @SerializedName("commercial") + COMMERCIAL, @SerializedName("consumer") + CONSUMER, @SerializedName("other_payment") + OTHER_PAYMENT, @SerializedName("pension_payment") + PENSION_PAYMENT, @SerializedName("represented") + REPRESENTED, @SerializedName("reimbursement_received_credit_transfer") + REIMBURSEMENT_RECEIVED_CREDIT_TRANSFER, @SerializedName("receive_against_payment") + RECEIVE_AGAINST_PAYMENT, @SerializedName("salary_payment") + SALARY_PAYMENT, @SerializedName("securities") + SECURITIES, @SerializedName("social_security_benefit") + SOCIAL_SECURITY_BENEFIT, @SerializedName("supplier_payment") + SUPPLIER_PAYMENT, @SerializedName("tax_payment") + TAX_PAYMENT, @SerializedName("trade") + TRADE, @SerializedName("treasury_payment") + TREASURY_PAYMENT, @SerializedName("value_added_tax_payment") + VALUE_ADDED_TAX_PAYMENT, @SerializedName("with_holding") + WITH_HOLDING, @SerializedName("cash_management_sweep_account") + CASH_MANAGEMENT_SWEEP_ACCOUNT, @SerializedName("cash_management_top_account") + CASH_MANAGEMENT_TOP_ACCOUNT, @SerializedName("cash_management_zero_balance_account") + CASH_MANAGEMENT_ZERO_BALANCE_ACCOUNT, @SerializedName("crossborder_mi_payments") + CROSSBORDER_MI_PAYMENTS, @SerializedName("foreign_currency_domestic_transfer") + FOREIGN_CURRENCY_DOMESTIC_TRANSFER, @SerializedName("cash_in_pre_credit") + CASH_IN_PRE_CREDIT, @SerializedName("cash_out_notes_coins") + CASH_OUT_NOTES_COINS, @SerializedName("carrier_guarded_wholesale_valuables") + CARRIER_GUARDED_WHOLESALE_VALUABLES, @SerializedName("unknown") UNKNOWN; @Override diff --git a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java index 84925a12..66083e37 100644 --- a/src/main/java/com/gocardless/services/BillingRequestWithActionService.java +++ b/src/main/java/com/gocardless/services/BillingRequestWithActionService.java @@ -54,6 +54,8 @@ public static final class BillingRequestWithActionCreateWithActionsRequest private Links links; private MandateRequest mandateRequest; private Map metadata; + private PaymentContextCode paymentContextCode; + private String paymentPurposeCode; private PaymentRequest paymentRequest; private PurposeCode purposeCode; @@ -374,6 +376,31 @@ public BillingRequestWithActionCreateWithActionsRequest withMetadata(String key, return this; } + /** + * Specifies the context or scenario in which the payment is being made. Defines whether the + * payment is for advance/arrears billing, point of sale transactions, ecommerce, or account + * transfers. This helps banks and payment processors understand the payment scenario and + * apply appropriate processing rules and risk controls. + */ + public BillingRequestWithActionCreateWithActionsRequest withPaymentContextCode( + PaymentContextCode paymentContextCode) { + this.paymentContextCode = paymentContextCode; + return this; + } + + /** + * Specifies the underlying purpose of the payment. Defines the specific reason or type of + * service/goods the payment relates to, improving straight-through processing and + * compliance. See [VRP Commercial Payment Purpose + * Codes](https://developer.gocardless.com/vrp-commercial-payment-purpose-codes/) for the + * complete list of valid codes. + */ + public BillingRequestWithActionCreateWithActionsRequest withPaymentPurposeCode( + String paymentPurposeCode) { + this.paymentPurposeCode = paymentPurposeCode; + return this; + } + public BillingRequestWithActionCreateWithActionsRequest withPaymentRequest( PaymentRequest paymentRequest) { this.paymentRequest = paymentRequest; @@ -516,10 +543,11 @@ public BillingRequestWithActionCreateWithActionsRequest withPaymentRequestScheme } /** - * Specifies the high-level purpose of a mandate and/or payment using a set of pre-defined - * categories. Required for the PayTo scheme, optional for all others. Currently `mortgage`, - * `utility`, `loan`, `dependant_support`, `gambling`, `retail`, `salary`, `personal`, - * `government`, `pension`, `tax` and `other` are supported. + * Specifies the high-level purpose/category of a mandate and/or payment using a set of + * pre-defined categories. Provides context on the nature and reason for the payment to + * facilitate processing and compliance. See [Billing Request Purpose + * Codes](https://developer.gocardless.com/billing-request-purpose-codes/) for the complete + * list of valid codes. */ public BillingRequestWithActionCreateWithActionsRequest withPurposeCode( PurposeCode purposeCode) { @@ -557,6 +585,22 @@ protected boolean hasBody() { return true; } + public enum PaymentContextCode { + @SerializedName("billing_goods_and_services_in_advance") + BILLING_GOODS_AND_SERVICES_IN_ADVANCE, @SerializedName("billing_goods_and_services_in_arrears") + BILLING_GOODS_AND_SERVICES_IN_ARREARS, @SerializedName("face_to_face_point_of_sale") + FACE_TO_FACE_POINT_OF_SALE, @SerializedName("ecommerce_merchant_initiated_payment") + ECOMMERCE_MERCHANT_INITIATED_PAYMENT, @SerializedName("transfer_to_self") + TRANSFER_TO_SELF, @SerializedName("transfer_to_third_party") + TRANSFER_TO_THIRD_PARTY, @SerializedName("unknown") + UNKNOWN; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + public enum PurposeCode { @SerializedName("mortgage") MORTGAGE, @SerializedName("utility") @@ -570,11 +614,50 @@ public enum PurposeCode { GOVERNMENT, @SerializedName("pension") PENSION, @SerializedName("tax") TAX, @SerializedName("other") - OTHER, @SerializedName("Epayment") - EPAYMENT, @SerializedName("Commercial") - COMMERCIAL, @SerializedName("OtherPayment") - OTHERPAYMENT, @SerializedName("Trade") - TRADE, @SerializedName("unknown") + OTHER, @SerializedName("bonus_payment") + BONUS_PAYMENT, @SerializedName("cash_management_transfer") + CASH_MANAGEMENT_TRANSFER, @SerializedName("card_bulk_clearing") + CARD_BULK_CLEARING, @SerializedName("credit_card_payment") + CREDIT_CARD_PAYMENT, @SerializedName("trade_settlement_payment") + TRADE_SETTLEMENT_PAYMENT, @SerializedName("debit_card_payment") + DEBIT_CARD_PAYMENT, @SerializedName("dividend") + DIVIDEND, @SerializedName("deliver_against_payment") + DELIVER_AGAINST_PAYMENT, @SerializedName("epayment") + EPAYMENT, @SerializedName("fee_collection_and_interest") + FEE_COLLECTION_AND_INTEREST, @SerializedName("fee_collection") + FEE_COLLECTION, @SerializedName("person_to_person_payment") + PERSON_TO_PERSON_PAYMENT, @SerializedName("government_payment") + GOVERNMENT_PAYMENT, @SerializedName("hedging_transaction") + HEDGING_TRANSACTION, @SerializedName("irrevocable_credit_card_payment") + IRREVOCABLE_CREDIT_CARD_PAYMENT, @SerializedName("irrevocable_debit_card_payment") + IRREVOCABLE_DEBIT_CARD_PAYMENT, @SerializedName("intra_company_payment") + INTRA_COMPANY_PAYMENT, @SerializedName("interest") + INTEREST, @SerializedName("lockbox_transactions") + LOCKBOX_TRANSACTIONS, @SerializedName("commercial") + COMMERCIAL, @SerializedName("consumer") + CONSUMER, @SerializedName("other_payment") + OTHER_PAYMENT, @SerializedName("pension_payment") + PENSION_PAYMENT, @SerializedName("represented") + REPRESENTED, @SerializedName("reimbursement_received_credit_transfer") + REIMBURSEMENT_RECEIVED_CREDIT_TRANSFER, @SerializedName("receive_against_payment") + RECEIVE_AGAINST_PAYMENT, @SerializedName("salary_payment") + SALARY_PAYMENT, @SerializedName("securities") + SECURITIES, @SerializedName("social_security_benefit") + SOCIAL_SECURITY_BENEFIT, @SerializedName("supplier_payment") + SUPPLIER_PAYMENT, @SerializedName("tax_payment") + TAX_PAYMENT, @SerializedName("trade") + TRADE, @SerializedName("treasury_payment") + TREASURY_PAYMENT, @SerializedName("value_added_tax_payment") + VALUE_ADDED_TAX_PAYMENT, @SerializedName("with_holding") + WITH_HOLDING, @SerializedName("cash_management_sweep_account") + CASH_MANAGEMENT_SWEEP_ACCOUNT, @SerializedName("cash_management_top_account") + CASH_MANAGEMENT_TOP_ACCOUNT, @SerializedName("cash_management_zero_balance_account") + CASH_MANAGEMENT_ZERO_BALANCE_ACCOUNT, @SerializedName("crossborder_mi_payments") + CROSSBORDER_MI_PAYMENTS, @SerializedName("foreign_currency_domestic_transfer") + FOREIGN_CURRENCY_DOMESTIC_TRANSFER, @SerializedName("cash_in_pre_credit") + CASH_IN_PRE_CREDIT, @SerializedName("cash_out_notes_coins") + CASH_OUT_NOTES_COINS, @SerializedName("carrier_guarded_wholesale_valuables") + CARRIER_GUARDED_WHOLESALE_VALUABLES, @SerializedName("unknown") UNKNOWN; @Override diff --git a/src/main/java/com/gocardless/services/FundsAvailabilityService.java b/src/main/java/com/gocardless/services/FundsAvailabilityService.java new file mode 100644 index 00000000..7aaa29e1 --- /dev/null +++ b/src/main/java/com/gocardless/services/FundsAvailabilityService.java @@ -0,0 +1,95 @@ +package com.gocardless.services; + +import com.gocardless.http.*; +import com.gocardless.resources.FundsAvailability; +import com.google.common.collect.ImmutableMap; +import java.util.Map; + +/** + * Service class for working with funds availability resources. + * + * Checks if the payer's current balance is sufficient to cover the amount the merchant wants to + * charge within the consent parameters defined on the mandate. + */ +public class FundsAvailabilityService { + 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#fundsAvailabilities() }. + */ + public FundsAvailabilityService(HttpClient httpClient) { + this.httpClient = httpClient; + } + + /** + * Checks if the payer's current balance is sufficient to cover the amount the merchant wants to + * charge within the consent parameters defined on the mandate. + */ + public FundsAvailabilityCheckRequest check(String identity) { + return new FundsAvailabilityCheckRequest(httpClient, identity); + } + + /** + * Request class for {@link FundsAvailabilityService#check }. + * + * Checks if the payer's current balance is sufficient to cover the amount the merchant wants to + * charge within the consent parameters defined on the mandate. + */ + public static final class FundsAvailabilityCheckRequest extends GetRequest { + @PathParam + private final String identity; + private String amount; + + /** + * The amount of the payment + */ + public FundsAvailabilityCheckRequest withAmount(String amount) { + this.amount = amount; + return this; + } + + private FundsAvailabilityCheckRequest(HttpClient httpClient, String identity) { + super(httpClient); + this.identity = identity; + } + + public FundsAvailabilityCheckRequest 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()); + if (amount != null) { + params.put("amount", amount); + } + return params.build(); + } + + @Override + protected String getPathTemplate() { + return "funds_availability/:identity"; + } + + @Override + protected String getEnvelope() { + return "funds_availability"; + } + + @Override + protected Class getResponseClass() { + return FundsAvailability.class; + } + } +}