diff --git a/.gitignore b/.gitignore index 70935fdb..c737ee92 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,8 @@ lombok.config .vscode/ .cursor .github/SKILL.md +.github/copilot-instructions.md swagger-spec.json -swagger.* \ No newline at end of file +swagger.* +.claude/ +CLAUDE.md diff --git a/src/main/java/com/checkout/GsonSerializer.java b/src/main/java/com/checkout/GsonSerializer.java index ab47de5d..f40577af 100644 --- a/src/main/java/com/checkout/GsonSerializer.java +++ b/src/main/java/com/checkout/GsonSerializer.java @@ -161,7 +161,8 @@ public final class GsonSerializer implements Serializer { // Payments - source .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(com.checkout.payments.response.source.ResponseSource.class, CheckoutUtils.TYPE, true, com.checkout.payments.response.source.AlternativePaymentSourceResponse.class) .registerSubtype(com.checkout.payments.response.source.CardResponseSource.class, identifier(PaymentSourceType.CARD)) - .registerSubtype(com.checkout.payments.response.source.CurrencyAccountResponseSource.class, identifier(PaymentSourceType.CURRENCY_ACCOUNT))) + .registerSubtype(com.checkout.payments.response.source.CurrencyAccountResponseSource.class, identifier(PaymentSourceType.CURRENCY_ACCOUNT)) + .registerSubtype(com.checkout.payments.response.source.PayPalResponseSource.class, identifier(PaymentSourceType.PAYPAL))) // Payment Contexts .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(com.checkout.payments.response.source.contexts.ResponseSource.class, CheckoutUtils.TYPE, true, com.checkout.payments.response.source.contexts.AlternativePaymentSourceResponse.class) .registerSubtype(com.checkout.payments.response.source.contexts.PaymentContextsPayPalResponseSource.class, identifier(PaymentSourceType.PAYPAL)) @@ -187,7 +188,9 @@ public final class GsonSerializer implements Serializer { .registerSubtype(com.checkout.instruments.get.GetSepaInstrumentResponse.class, identifier(InstrumentType.SEPA))) .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(com.checkout.instruments.update.UpdateInstrumentResponse.class, CheckoutUtils.TYPE) .registerSubtype(com.checkout.instruments.update.UpdateInstrumentBankAccountResponse.class, identifier(InstrumentType.BANK_ACCOUNT)) - .registerSubtype(com.checkout.instruments.update.UpdateInstrumentCardResponse.class, identifier(InstrumentType.CARD))) + .registerSubtype(com.checkout.instruments.update.UpdateInstrumentCardResponse.class, identifier(InstrumentType.CARD)) + .registerSubtype(com.checkout.instruments.update.UpdateInstrumentSepaResponse.class, identifier(InstrumentType.SEPA)) + .registerSubtype(com.checkout.instruments.update.UpdateInstrumentAchResponse.class, identifier(InstrumentType.ACH))) // Workflows CS2 .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(com.checkout.workflows.actions.response.WorkflowActionResponse.class, CheckoutUtils.TYPE) .registerSubtype(com.checkout.workflows.actions.response.WebhookWorkflowActionResponse.class, identifier(WorkflowActionType.WEBHOOK))) diff --git a/src/main/java/com/checkout/accounts/UpdatePaymentInstrumentRequest.java b/src/main/java/com/checkout/accounts/UpdatePaymentInstrumentRequest.java index 29aba57b..40fe2d68 100644 --- a/src/main/java/com/checkout/accounts/UpdatePaymentInstrumentRequest.java +++ b/src/main/java/com/checkout/accounts/UpdatePaymentInstrumentRequest.java @@ -8,10 +8,22 @@ @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) -public final class UpdatePaymentInstrumentRequest extends Headers{ +public final class UpdatePaymentInstrumentRequest extends Headers { + /** + * A reference that you can use to identify the payment instrument. + * [Optional] + */ private String label; + /** + * Whether the payment instrument should be set as the default payout destination. + * For ad-hoc payouts the instrument is specified explicitly; for scheduled payouts the first instrument + * created for a currency is used. To change the instrument for a payout schedule, update the schedule. + * [Optional] + * @deprecated Update the payout schedule instead. + */ + @Deprecated @SerializedName("default") private Boolean defaultDestination; } diff --git a/src/main/java/com/checkout/common/InstrumentType.java b/src/main/java/com/checkout/common/InstrumentType.java index 73d8e7b4..e6b606e6 100644 --- a/src/main/java/com/checkout/common/InstrumentType.java +++ b/src/main/java/com/checkout/common/InstrumentType.java @@ -17,6 +17,9 @@ public enum InstrumentType { CARD_TOKEN, @SerializedName("sepa") - SEPA + SEPA, + + @SerializedName("ach") + ACH } diff --git a/src/main/java/com/checkout/common/Link.java b/src/main/java/com/checkout/common/Link.java index 92c90c96..059f59b6 100644 --- a/src/main/java/com/checkout/common/Link.java +++ b/src/main/java/com/checkout/common/Link.java @@ -5,10 +5,34 @@ @Data public final class Link { + /** + * The link URL. + * [Optional] + */ private final String href; + /** + * The link title. + * [Optional] + */ private final String title; + /** + * The link relation type. + * [Optional] + */ private final String link; -} \ No newline at end of file + /** + * Mobile deep-link redirect URLs for Android and iOS redirect payments. + * [Optional] + */ + private MobileRedirectLink mobile; + + /** + * QR code data for redirect payments. + * [Optional] + */ + private QrCode qrCode; + +} diff --git a/src/main/java/com/checkout/common/MobileRedirectLink.java b/src/main/java/com/checkout/common/MobileRedirectLink.java new file mode 100644 index 00000000..1b2911c0 --- /dev/null +++ b/src/main/java/com/checkout/common/MobileRedirectLink.java @@ -0,0 +1,33 @@ +package com.checkout.common; + +import lombok.Data; + +/** + * Mobile deep-link redirect URLs returned in 202 payment response _links.redirect. + */ +@Data +public final class MobileRedirectLink { + + /** + * The Android deep-link redirect URL. + * [Optional] + */ + private PlatformLink android; + + /** + * The iOS deep-link redirect URL. + * [Optional] + */ + private PlatformLink ios; + + @Data + public static final class PlatformLink { + + /** + * The deep-link URL. + * [Optional] + */ + private String href; + } + +} diff --git a/src/main/java/com/checkout/common/Product.java b/src/main/java/com/checkout/common/Product.java index a34be0b1..2f9fcc20 100644 --- a/src/main/java/com/checkout/common/Product.java +++ b/src/main/java/com/checkout/common/Product.java @@ -3,17 +3,41 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; @Data @Builder +@NoArgsConstructor @AllArgsConstructor public final class Product { + /** + * The name of the product. + * [Optional] + */ private String name; + /** + * The quantity of the product. + * [Optional] + */ private Long quantity; + /** + * The price of the product in minor currency units. + * [Optional] + */ private Long price; + /** + * A reference you can use to identify the product. + * [Optional] + */ private String reference; + + /** + * The URL of the product. + * [Optional] + */ + private String url; } diff --git a/src/main/java/com/checkout/common/QrCode.java b/src/main/java/com/checkout/common/QrCode.java new file mode 100644 index 00000000..4039bf51 --- /dev/null +++ b/src/main/java/com/checkout/common/QrCode.java @@ -0,0 +1,23 @@ +package com.checkout.common; + +import lombok.Data; + +/** + * QR code data returned for payment methods that require a QR code scan, in 202 responses. + */ +@Data +public final class QrCode { + + /** + * The QR code as a base64-encoded image. + * [Optional] + */ + private String image; + + /** + * The raw text encoded in the QR code. + * [Optional] + */ + private String text; + +} diff --git a/src/main/java/com/checkout/disputes/CompellingEvidence.java b/src/main/java/com/checkout/disputes/CompellingEvidence.java index 3a9cbf81..0ad4d24a 100644 --- a/src/main/java/com/checkout/disputes/CompellingEvidence.java +++ b/src/main/java/com/checkout/disputes/CompellingEvidence.java @@ -1,37 +1,75 @@ package com.checkout.disputes; -import com.google.gson.annotations.SerializedName; - import java.time.Instant; import java.util.List; public final class CompellingEvidence { - @SerializedName("merchandise_or_service") + /** + * Whether the evidence concerns merchandise or services. + * [Required] + * Enum: "Merchandise" "Services" + */ private String merchandiseOrService; - @SerializedName("merchandise_or_service_desc") + /** + * A description of the merchandise or service provided. + * [Required] + * min 1 character, max 5000 characters + */ private String merchandiseOrServiceDesc; - @SerializedName("merchandise_or_service_provided_date") + /** + * The date the merchandise or service was provided to the customer. + * [Required] + * Format: date-time (RFC 3339) + */ private Instant merchandiseOrServiceProvidedDate; - @SerializedName("shipping_delivery_status") + /** + * The shipping or delivery status of the merchandise. + * [Optional] + */ private ShippingDeliveryStatusType shippingDeliveryStatus; - @SerializedName("tracking_information") + /** + * The tracking number for the shipment. + * [Optional] + * max 50 characters + */ private TrackingInformationType trackingInformation; - @SerializedName("user_id") + /** + * The customer's account or login identifier. + * [Optional] + * max 50 characters + */ private String userId; - @SerializedName("ip_address") + /** + * The IP address used for the transaction (IPv4 or IPv6). + * [Optional] + */ private String ipAddress; - @SerializedName("shipping_address") + /** + * The device identifier used for the transaction. + * [Optional] + * min 15 characters, max 64 characters + */ + private String deviceId; + + /** + * The shipping address used for the transaction. + * [Optional] + */ private ShippingAddress shippingAddress; - @SerializedName("historical_transactions") + /** + * Prior undisputed transactions between the merchant and the same customer. + * At least 2 items required. + * [Required] + */ private List historicalTransactions; } diff --git a/src/main/java/com/checkout/disputes/Dispute.java b/src/main/java/com/checkout/disputes/Dispute.java index df315f29..48f88b79 100644 --- a/src/main/java/com/checkout/disputes/Dispute.java +++ b/src/main/java/com/checkout/disputes/Dispute.java @@ -2,7 +2,6 @@ import com.checkout.common.Currency; import com.checkout.common.Resource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,54 +15,137 @@ @EqualsAndHashCode(callSuper = false) public final class Dispute extends Resource { + /** + * The dispute identifier. + * [Optional] + * ^(dsp)_(\w{22,26})$ + */ private String id; + /** + * The reason for the dispute. + * [Optional] + */ private DisputeCategory category; + /** + * The current status of the dispute. + * [Optional] + */ private DisputeStatus status; + /** + * The disputed amount in the processing currency. + * [Optional] + */ private Long amount; + /** + * The processing currency. + * [Optional] + */ private Currency currency; - @SerializedName("reason_code") + /** + * The card scheme reason code for the dispute. + * [Optional] + */ private String reasonCode; - @SerializedName("payment_id") + /** + * The payment identifier. + * [Optional] + */ private String paymentId; - @SerializedName("payment_action_id") + /** + * The payment action identifier. + * [Optional] + */ private String paymentActionId; - @SerializedName("payment_reference") + /** + * The payment reference or order ID. + * [Optional] + */ private String paymentReference; - @SerializedName("payment_arn") + /** + * The acquirer reference number for the payment. + * [Optional] + */ private String paymentArn; - @SerializedName("payment_method") + /** + * The payment method or card scheme. + * [Optional] + */ private String paymentMethod; - @SerializedName("evidence_required_by") + /** + * The deadline by which evidence must be submitted. + * [Optional] + * Format: date-time (RFC 3339) + */ private Instant evidenceRequiredBy; - @SerializedName("received_on") + /** + * The date and time the dispute was issued. + * [Optional] + * Format: date-time (RFC 3339) + */ private Instant receivedOn; - @SerializedName("last_update") + /** + * The date and time of the last update to the dispute. + * [Optional] + * Format: date-time (RFC 3339) + */ private Instant lastUpdate; /** - * Not available on Previous + * The reason the dispute was automatically resolved. + * [Optional] + * Enum: "rapid_dispute_resolution" "negative_amount" "already_refunded" */ + private DisputeResolvedReason resolvedReason; - @SerializedName("entity_id") + /** + * Whether the dispute is eligible for Visa Compelling Evidence 3.0. + * [Optional] + */ + private Boolean isCeCandidate; + + // Not available on Previous API + + /** + * The client entity linked to this dispute. + * [Optional] + */ private String entityId; - @SerializedName("sub_entity_id") + /** + * The sub-entity linked to this dispute. + * [Optional] + */ private String subEntityId; - @SerializedName("payment_mcc") + /** + * The processing channel linked to this dispute. + * [Optional] + */ + private String processingChannel; + + /** + * The business segment identifier. + * [Optional] + */ + private String segmentId; + + /** + * The merchant category code for the payment. + * [Optional] + */ private String paymentMcc; } diff --git a/src/main/java/com/checkout/disputes/DisputeRelevantEvidence.java b/src/main/java/com/checkout/disputes/DisputeRelevantEvidence.java index 067cd558..43a85bbe 100644 --- a/src/main/java/com/checkout/disputes/DisputeRelevantEvidence.java +++ b/src/main/java/com/checkout/disputes/DisputeRelevantEvidence.java @@ -25,6 +25,12 @@ public enum DisputeRelevantEvidence { @SerializedName("additional_evidence") ADDITIONAL_EVIDENCE, + @SerializedName("proof_of_delivery_or_service_date") + PROOF_OF_DELIVERY_OR_SERVICE_DATE, + + @SerializedName("compelling_evidence") + COMPELLING_EVIDENCE, + @SerializedName("arbitration_no_review") ARBITRATION_NO_REVIEW, diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/ApplePayConfiguration.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/ApplePayConfiguration.java index 3063fe1d..f4c2af1f 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/ApplePayConfiguration.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/ApplePayConfiguration.java @@ -18,7 +18,8 @@ public final class ApplePayConfiguration extends PaymentMethodConfigurationBase /** * The type of the Apple Pay payment total line item. Default: "final" + * [Optional] */ @Builder.Default private TotalType totalType = TotalType.FINAL; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/Customer.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/Customer.java index 20e9337d..b15f3bca 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/Customer.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/Customer.java @@ -1,7 +1,6 @@ package com.checkout.handlepaymentsandpayouts.flow.entities; import com.checkout.common.Phone; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -20,31 +19,37 @@ public final class Customer { /** * The customer's email address. Required if source.type is tamara. + * [Optional] */ private String email; /** * The customer's name. Required if source.type is tamara. + * [Optional] */ private String name; /** * The unique identifier for an existing customer. + * [Optional] */ private String id; /** * The customer's phone number. Required if source.type is tamara. + * [Optional] */ private Phone phone; /** * The customer's value-added tax (VAT) registration number. + * [Optional] */ private String taxNumber; /** - * Summary of the customer's transaction history. Used for risk assessment when source.type is Tamara + * Summary of the customer's transaction history. Used for risk assessment when source.type is Tamara. + * [Optional] */ private CustomerSummary summary; @@ -59,36 +64,46 @@ public static class CustomerSummary { /** * The date the customer registered. + * [Optional] + * Format: yyyy-MM-dd */ private LocalDate registrationDate; /** * The date of the customer's first transaction. + * [Optional] + * Format: yyyy-MM-dd */ private LocalDate firstTransactionDate; /** * The date of the customer's last payment. + * [Optional] + * Format: yyyy-MM-dd */ private LocalDate lastPaymentDate; /** * The total number of orders made by the customer. + * [Optional] */ private Integer totalOrderCount; /** * The amount of the customer's last payment. + * [Optional] */ private Double lastPaymentAmount; /** * Specifies whether the customer is a premium customer. + * [Optional] */ private Boolean isPremiumCustomer; /** * Specifies whether the customer is a returning customer. + * [Optional] */ private Boolean isReturningCustomer; @@ -96,7 +111,8 @@ public static class CustomerSummary { * The customer's lifetime value. This is the total monetary amount that the customer has ordered, * in their local currency, excluding canceled orders, rejected payments, refunded payments, and Tamara payments. * The lifetime value is an indicator of how valuable the relationship with the customer is to your company. + * [Optional] */ private Double lifetimeValue; } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/CustomerRetry.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/CustomerRetry.java index 19bae096..bcc2384e 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/CustomerRetry.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/CustomerRetry.java @@ -16,7 +16,8 @@ public final class CustomerRetry { /** * The maximum number of authorization retry attempts, excluding the initial authorization. Default: 5 + * [Optional] */ @Builder.Default private Integer maxAttempts = 5; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/GooglePayConfiguration.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/GooglePayConfiguration.java index 35f44157..b7b32739 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/GooglePayConfiguration.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/GooglePayConfiguration.java @@ -18,7 +18,8 @@ public final class GooglePayConfiguration extends PaymentMethodConfigurationBase /** * The status of the Google Pay payment total price. Default: "final" + * [Optional] */ @Builder.Default private TotalPriceStatus totalPriceStatus = TotalPriceStatus.FINAL; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentAction.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentAction.java index f55572d1..e98ff447 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentAction.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentAction.java @@ -15,17 +15,20 @@ public final class PaymentAction { /** - * The type of action required + * The type of action required. + * [Optional] */ private String type; /** - * A URL the customer should be redirected to for further action (if type requires redirect) + * A URL the customer should be redirected to for further action (if type requires redirect). + * [Optional] */ private String url; /** - * Additional data needed for the action + * Additional data needed for the action. + * [Optional] */ private Object data; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfiguration.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfiguration.java index a606d8e7..cbfed282 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfiguration.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfiguration.java @@ -17,23 +17,27 @@ public final class PaymentMethodConfiguration { /** * Configuration options specific to Apple Pay payments. + * [Optional] */ @SerializedName("applepay") private ApplePayConfiguration applePay; /** * Configuration options specific to card payments. + * [Optional] */ private CardConfiguration card; /** * Configuration options specific to Google Pay payments. + * [Optional] */ @SerializedName("googlepay") private GooglePayConfiguration googlePay; /** * Configuration options specific to stored card payments. + * [Optional] */ private StoredCardConfiguration storedCard; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfigurationBase.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfigurationBase.java index bcd97556..7585c8f5 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfigurationBase.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/PaymentMethodConfigurationBase.java @@ -16,11 +16,13 @@ public abstract class PaymentMethodConfigurationBase { /** * Specifies whether you intend to store the cardholder's payment details. Default: "disabled" + * [Optional] */ private StorePaymentDetailsType storePaymentDetails = StorePaymentDetailsType.DISABLED; /** * The account holder's details. + * [Optional] */ private AccountHolder accountHolder; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/StoredCardConfiguration.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/StoredCardConfiguration.java index 9a0dcd3b..aba2ec92 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/StoredCardConfiguration.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/entities/StoredCardConfiguration.java @@ -18,16 +18,19 @@ public final class StoredCardConfiguration { /** * The unique identifier for an existing customer. + * [Optional] */ private String customerId; /** * The unique identifiers for card Instruments. + * [Optional] */ private List instrumentIds; /** * The unique identifier for the payment instrument to present to the customer as the default option. + * [Optional] */ private String defaultInstrumentId; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionBase.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionBase.java index ef875254..4330cee3 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionBase.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionBase.java @@ -25,31 +25,38 @@ public abstract class PaymentSessionBase { * The payment amount. Provide a value of 0 to perform a card verification. * The amount must be provided in the minor currency unit. * For example, provide 10000 for £100.00, or provide 100 for ¥100 (a zero-decimal currency). + * [Optional] + * min 0 */ private Long amount; - + /** * A reference you can use to identify the payment. For example, an order number. * For Amex payments, this must be at most 30 characters. * For Benefit payments, the reference must be a unique alphanumeric value. * For iDEAL payments, the reference is required and must be an alphanumeric value with a 35-character limit. + * [Optional] */ private String reference; /** * The line items in the order. + * [Optional] */ private List items; /** * Information required for 3D Secure authentication payments. + * [Optional] */ @SerializedName("3ds") private ThreeDSRequest threeDS; /** * Must be specified for card-not-present (CNP) payments. Default: "Regular" + * [Optional] + * Enum: "Regular" "Recurring" "MOTO" "Installment" "PayLater" "Unscheduled" */ @Builder.Default private PaymentType paymentType = PaymentType.REGULAR; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCompleteRequest.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCompleteRequest.java index 78ceac75..4f5c8eec 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCompleteRequest.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCompleteRequest.java @@ -20,14 +20,16 @@ public final class PaymentSessionCompleteRequest extends PaymentSessionInfo { /** * Creates a translated version of the page in the specified language. Default: "en-GB" + * [Optional] */ @Builder.Default private LocaleType locale = LocaleType.EN_GB; /** - * A unique token representing the additional customer data captured by Flow, + * A unique token representing the additional customer data captured by Flow, * as received from the handleSubmit callback. * Do not log or store this value. + * [Optional] */ private String sessionData; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCreateRequest.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCreateRequest.java index fec9838e..6ddd34ef 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCreateRequest.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionCreateRequest.java @@ -26,38 +26,46 @@ public final class PaymentSessionCreateRequest extends PaymentSessionInfo { /** * Creates a translated version of the page in the specified language. Default: "en-GB" + * [Optional] */ @Builder.Default private LocaleType locale = LocaleType.EN_GB; /** * A timestamp specifying when the PaymentSession should expire, as an ISO 8601 code. + * [Optional] + * Format: date-time (ISO 8601) */ private Instant expiresOn; /** * Specifies which payment method options to present to the customer. + * [Optional] */ private List enabledPaymentMethods; /** * Specifies which payment method options to not present to the customer. + * [Optional] */ private List disabledPaymentMethods; /** * Configurations for payment method-specific settings. + * [Optional] */ private PaymentMethodConfiguration paymentMethodConfiguration; /** * Configuration for asynchronous retries. + * [Optional] */ private CustomerRetry customerRetry; /** * Deprecated - The Customer's IP address. Only IPv4 and IPv6 addresses are accepted. + * [Optional] */ @Deprecated private String ipAddress; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionInfo.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionInfo.java index 80e543da..fa5eac5d 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionInfo.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionInfo.java @@ -33,94 +33,116 @@ public abstract class PaymentSessionInfo extends PaymentSessionBase { /** - * The three-letter ISO currency code + * The three-letter ISO currency code. + * [Optional] + * min 3 max 3 */ private Currency currency; /** * The billing details. + * [Optional] */ private BillingInformation billing; /** - * Overrides the default success redirect URL configured on your account, + * Overrides the default success redirect URL configured on your account, * for payment methods that require a redirect. + * [Optional] + * Format: uri */ private String successUrl; /** - * Overrides the default failure redirect URL configured on your account, + * Overrides the default failure redirect URL configured on your account, * for payment methods that require a redirect. + * [Optional] + * Format: uri */ private String failureUrl; /** * A description of the purchase, which is displayed on the customer's statement. + * [Optional] */ private BillingDescriptor billingDescriptor; /** * A description for the payment. + * [Optional] */ private String description; /** * The customer's details. Required if source.type is tamara. + * [Optional] */ private Customer customer; /** - * The shipping details + * The shipping details. + * [Optional] */ private ShippingDetails shipping; /** * Information about the recipient of the payment's funds. + * [Optional] */ private PaymentRecipient recipient; /** - * Use the processing object to influence or override the data sent during card processing + * Use the processing object to influence or override the data sent during card processing. + * [Optional] */ private ProcessingSettings processing; /** * Details about the payment instruction. + * [Optional] */ private PaymentInstruction instruction; /** * The processing channel to use for the payment. + * [Optional] + * Pattern: ^(pc)_(\w{26})$ */ private String processingChannelId; /** * The sub-entities that the payment is being processed on behalf of. + * [Optional] */ private List amountAllocations; /** * Configures the risk assessment performed during payment processing. + * [Optional] */ private RiskRequest risk; /** * The merchant's display name. + * [Optional] */ private String displayName; /** * Allows you to store additional information about a transaction with custom fields. + * [Optional] */ private Map metadata; /** * The sender of the payment. + * [Optional] */ private PaymentSender sender; /** * Specifies whether to capture the payment, if applicable. Default: true + * [Optional] */ @Builder.Default private Boolean capture = true; @@ -128,6 +150,8 @@ public abstract class PaymentSessionInfo extends PaymentSessionBase { /** * A timestamp specifying when to capture the payment, as an ISO 8601 code. * If a value is provided, capture is automatically set to true. + * [Optional] + * Format: date-time (ISO 8601) */ private Instant captureOn; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionSubmitRequest.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionSubmitRequest.java index fbfd45b4..8bc91a20 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionSubmitRequest.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/requests/PaymentSessionSubmitRequest.java @@ -9,7 +9,7 @@ /** * Request to submit a payment session. - * + * * This request works with the Flow handleSubmit callback, where you can perform a customized payment submission. * You must send the unmodified response body as the response of the handleSubmit callback. */ @@ -21,20 +21,23 @@ public final class PaymentSessionSubmitRequest extends PaymentSessionInfo { /** - * A unique token representing the additional customer data captured by Flow, + * A unique token representing the additional customer data captured by Flow, * as received from the handleSubmit callback. * Do not log or store this value. + * [Optional] */ private String sessionData; /** * Configurations for payment method-specific settings. + * [Optional] */ private PaymentMethodConfiguration paymentMethodConfiguration; /** * Deprecated - The Customer's IP address. Only IPv4 and IPv6 addresses are accepted. + * [Optional] */ @Deprecated private String ipAddress; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ActionRequiredPaymentSubmissionResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ActionRequiredPaymentSubmissionResponse.java index a6893532..e555037d 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ActionRequiredPaymentSubmissionResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ActionRequiredPaymentSubmissionResponse.java @@ -1,7 +1,6 @@ package com.checkout.handlepaymentsandpayouts.flow.responses; import com.checkout.handlepaymentsandpayouts.flow.entities.PaymentAction; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -20,17 +19,20 @@ public final class ActionRequiredPaymentSubmissionResponse extends PaymentSubmis /** * Instruction for further payment action. + * [Optional] */ private PaymentAction action; /** - * The Payment Sessions unique identifier (only present in CreateAndSubmitPaymentSession response) + * The Payment Sessions unique identifier (only present in CreateAndSubmitPaymentSession response). + * [Optional] */ private String paymentSessionId; /** * The secret used by Flow to authenticate payment session requests (only present in CreateAndSubmitPaymentSession response). * Do not log or store this value. + * [Optional] */ private String paymentSessionSecret; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ApprovedPaymentSubmissionResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ApprovedPaymentSubmissionResponse.java index eb6603c2..9d3e6e66 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ApprovedPaymentSubmissionResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/ApprovedPaymentSubmissionResponse.java @@ -1,6 +1,5 @@ package com.checkout.handlepaymentsandpayouts.flow.responses; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -18,13 +17,15 @@ public final class ApprovedPaymentSubmissionResponse extends PaymentSubmissionResponse { /** - * The Payment Sessions unique identifier (only present in CreateAndSubmitPaymentSession response) + * The Payment Sessions unique identifier (only present in CreateAndSubmitPaymentSession response). + * [Optional] */ private String paymentSessionId; /** * The secret used by Flow to authenticate payment session requests (only present in CreateAndSubmitPaymentSession response). * Do not log or store this value. + * [Optional] */ private String paymentSessionSecret; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/DeclinedPaymentSubmissionResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/DeclinedPaymentSubmissionResponse.java index 5c14367f..3eac8166 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/DeclinedPaymentSubmissionResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/DeclinedPaymentSubmissionResponse.java @@ -18,6 +18,7 @@ public final class DeclinedPaymentSubmissionResponse extends PaymentSubmissionRe /** * The reason for the payment decline. + * [Optional] */ private String declineReason; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSessionResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSessionResponse.java index 2cef1fd8..125d10de 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSessionResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSessionResponse.java @@ -1,7 +1,6 @@ package com.checkout.handlepaymentsandpayouts.flow.responses; import com.checkout.common.Resource; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -19,19 +18,22 @@ public final class PaymentSessionResponse extends Resource { /** - * The Payment Sessions unique identifier + * The Payment Sessions unique identifier. + * [Optional] */ private String id; /** * A unique token representing the payment session, which you must provide when you initialize Flow. * Do not log or store this value. + * [Optional] */ private String paymentSessionToken; /** * The secret used by Flow to authenticate payment session requests. * Do not log or store this value. + * [Optional] */ private String paymentSessionSecret; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSubmissionResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSubmissionResponse.java index 557e18dc..cb2fd84c 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSubmissionResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/flow/responses/PaymentSubmissionResponse.java @@ -17,16 +17,19 @@ public abstract class PaymentSubmissionResponse extends Resource { /** * The payment identifier. + * [Optional] */ private String id; /** * The payment's status - used for polymorphic deserialization. + * [Optional] */ private PaymentSessionStatus status; /** * The payment method name. + * [Optional] */ private PaymentMethodType type; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/billing/PaymentSetupBilling.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/billing/PaymentSetupBilling.java new file mode 100644 index 00000000..02e28737 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/billing/PaymentSetupBilling.java @@ -0,0 +1,22 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.billing; + +import com.checkout.common.Address; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The billing details for the payment setup. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class PaymentSetupBilling { + + /** + * The billing address. + */ + private Address address; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/PaymentMethods.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/PaymentMethods.java index 93cb3cee..4e8ed4bf 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/PaymentMethods.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/PaymentMethods.java @@ -1,17 +1,49 @@ package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ach.Ach; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.alipay.AlipayCn; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.alipay.AlipayHk; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.alma.Alma; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.applepay.ApplePay; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.bancontact.Bancontact; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.benefit.Benefit; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.bizum.Bizum; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.card.Card; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.dana.Dana; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.eps.Eps; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.gcash.GCash; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.googlepay.GooglePay; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ideal.Ideal; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.instrument.Instrument; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.kakaopay.KakaoPay; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.klarna.Klarna; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.knet.Knet; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.mbway.MBWay; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.mobilepay.MobilePay; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.multibanco.Multibanco; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.octopus.Octopus; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.p24.P24; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.paynow.PayNow; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.paypal.PayPal; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.qpay.Qpay; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sepa.Sepa; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sequra.Sequra; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.stcpay.Stcpay; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.swish.Swish; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.tabby.Tabby; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.tamara.Tamara; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.tng.Tng; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.truemoney.TrueMoney; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.twint.Twint; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.vipps.Vipps; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.wechatpay.WeChatPay; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** - * Payment methods configuration + * Payment methods configuration for a payment setup. */ @Data @Builder @@ -20,27 +52,224 @@ public final class PaymentMethods { /** - * Klarna payment method configuration + * Instrument (saved payment source) configuration. + * [Optional] + */ + private Instrument instrument; + + /** + * Klarna payment method configuration. + * [Optional] */ private Klarna klarna; /** - * STC Pay payment method configuration + * STC Pay payment method configuration. + * [Optional] */ private Stcpay stcpay; /** - * Tabby payment method configuration + * Tabby payment method configuration. + * [Optional] */ private Tabby tabby; /** - * PayPal payment method configuration + * PayPal payment method configuration. + * [Optional] */ private PayPal paypal; /** - * Bizum payment method configuration + * Bizum payment method configuration. + * [Optional] */ private Bizum bizum; -} \ No newline at end of file + + /** + * PayNow payment method configuration. + * [Optional] + */ + private PayNow paynow; + + /** + * QPay payment method configuration. + * [Optional] + */ + private Qpay qpay; + + /** + * EPS payment method configuration. + * [Optional] + */ + private Eps eps; + + /** + * iDEAL payment method configuration. + * [Optional] + */ + private Ideal ideal; + + /** + * KNET payment method configuration. + * [Optional] + */ + private Knet knet; + + /** + * Bancontact payment method configuration. + * [Optional] + */ + private Bancontact bancontact; + + /** + * Benefit payment method configuration. + * [Optional] + */ + private Benefit benefit; + + /** + * Vipps payment method configuration. + * [Optional] + */ + private Vipps vipps; + + /** + * Twint payment method configuration. + * [Optional] + */ + private Twint twint; + + /** + * Alipay CN payment method configuration. + * [Optional] + */ + private AlipayCn alipayCn; + + /** + * Alipay HK payment method configuration. + * [Optional] + */ + private AlipayHk alipayHk; + + /** + * GCash payment method configuration. + * [Optional] + */ + private GCash gcash; + + /** + * TNG payment method configuration. + * [Optional] + */ + private Tng tng; + + /** + * Dana payment method configuration. + * [Optional] + */ + private Dana dana; + + /** + * MobilePay payment method configuration. + * [Optional] + */ + private MobilePay mobilepay; + + /** + * Tamara payment method configuration. + * [Optional] + */ + private Tamara tamara; + + /** + * MBWay payment method configuration. + * [Optional] + */ + private MBWay mbway; + + /** + * Multibanco payment method configuration. + * [Optional] + */ + private Multibanco multibanco; + + /** + * WeChatPay payment method configuration. + * [Optional] + */ + private WeChatPay wechatpay; + + /** + * KakaoPay payment method configuration. + * [Optional] + */ + private KakaoPay kakaopay; + + /** + * TrueMoney payment method configuration. + * [Optional] + */ + private TrueMoney truemoney; + + /** + * Octopus payment method configuration. + * [Optional] + */ + private Octopus octopus; + + /** + * P24 (Przelewy24) payment method configuration. + * [Optional] + */ + private P24 p24; + + /** + * Alma payment method configuration. + * [Optional] + */ + private Alma alma; + + /** + * Swish payment method configuration. + * [Optional] + */ + private Swish swish; + + /** + * Sequra payment method configuration. + * [Optional] + */ + private Sequra sequra; + + /** + * ACH (Direct Debit) payment method configuration. + * [Optional] + */ + private Ach ach; + + /** + * SEPA (Direct Debit) payment method configuration. + * [Optional] + */ + private Sepa sepa; + + /** + * GooglePay payment method configuration. + * [Optional] + */ + private GooglePay googlepay; + + /** + * ApplePay payment method configuration. + * [Optional] + */ + private ApplePay applepay; + + /** + * Card payment method configuration. + * [Optional] + */ + private Card card; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/Ach.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/Ach.java new file mode 100644 index 00000000..6fb15431 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/Ach.java @@ -0,0 +1,46 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ach; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The ACH payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Ach extends PaymentMethodBase { + + /** + * The type of Direct Debit account. + * [Optional] + */ + private AchAccountType accountType; + + /** + * The account holder details. + * [Optional] + */ + private AchAccountHolder accountHolder; + + /** + * The account number of the Direct Debit account. + * [Optional] + * min 4 characters, max 17 characters + */ + private String accountNumber; + + /** + * The bank code of the Direct Debit account. + * [Optional] + * min 8 characters, max 9 characters + */ + private String bankCode; + + /** + * The two-letter ISO country code of the bank account. + * [Optional] + * max 2 characters + */ + private String country; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountHolder.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountHolder.java new file mode 100644 index 00000000..b5cbeef4 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountHolder.java @@ -0,0 +1,53 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ach; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The ACH account holder details. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class AchAccountHolder { + + /** + * The type of account holder. + * [Optional] + */ + private AchAccountHolderType type; + + /** + * The first name of the account holder. + * [Optional] + */ + private String firstName; + + /** + * The last name of the account holder. + * [Optional] + */ + private String lastName; + + /** + * The legal name of a registered company that holds the account. + * [Optional] + */ + private String companyName; + + /** + * The account holder's date of birth. + * [Optional] + * Format: yyyy-MM-dd + */ + private String dateOfBirth; + + /** + * The account holder's government document identification. + * [Optional] + */ + private AchIdentification identification; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountHolderType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountHolderType.java new file mode 100644 index 00000000..a065458f --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountHolderType.java @@ -0,0 +1,18 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ach; + +import com.google.gson.annotations.SerializedName; + +/** + * The type of account holder. + */ +public enum AchAccountHolderType { + + @SerializedName("individual") + INDIVIDUAL, + + @SerializedName("corporate") + CORPORATE, + + @SerializedName("government") + GOVERNMENT +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountType.java new file mode 100644 index 00000000..bbd95284 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchAccountType.java @@ -0,0 +1,18 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ach; + +import com.google.gson.annotations.SerializedName; + +/** + * The type of Direct Debit account. + */ +public enum AchAccountType { + + @SerializedName("savings") + SAVINGS, + + @SerializedName("current") + CURRENT, + + @SerializedName("cash") + CASH +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchIdentification.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchIdentification.java new file mode 100644 index 00000000..af8096b9 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ach/AchIdentification.java @@ -0,0 +1,34 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ach; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The account holder's government document identification. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class AchIdentification { + + /** + * The document type. + * [Optional] + */ + private String type; + + /** + * The country where the document was issued. + * [Optional] + */ + private String issuingCountry; + + /** + * The document number. + * [Optional] + */ + private String number; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alipay/AlipayCn.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alipay/AlipayCn.java new file mode 100644 index 00000000..1686e69f --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alipay/AlipayCn.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.alipay; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Alipay CN payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class AlipayCn extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alipay/AlipayHk.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alipay/AlipayHk.java new file mode 100644 index 00000000..6c082815 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alipay/AlipayHk.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.alipay; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Alipay HK payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class AlipayHk extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alma/Alma.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alma/Alma.java new file mode 100644 index 00000000..45dc432c --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/alma/Alma.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.alma; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Alma payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Alma extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePay.java new file mode 100644 index 00000000..82b2195b --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePay.java @@ -0,0 +1,54 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.applepay; + +import com.checkout.common.Phone; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.CardAccountHolder; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.Instant; + +/** + * The Apple Pay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class ApplePay extends PaymentMethodBase { + + /** + * The Apple Pay encrypted payment token data. + * [Optional] + */ + private ApplePayTokenData tokenData; + + /** + * The Apple Pay payment token string. + * [Optional] + */ + private String token; + + /** + * The date and time the token expires. + * [Optional] + * Format: date-time (ISO 8601) + */ + private Instant expiresOn; + + /** + * Set to true if you intend to reuse the payment credentials in subsequent payments. + * [Optional] + */ + private Boolean storeForFutureUse; + + /** + * The customer's phone number. + * [Optional] + */ + private Phone phone; + + /** + * The card account holder details. + * [Optional] + */ + private CardAccountHolder accountHolder; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePayTokenData.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePayTokenData.java new file mode 100644 index 00000000..85a2f841 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePayTokenData.java @@ -0,0 +1,40 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.applepay; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The Apple Pay encrypted payment token data. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class ApplePayTokenData { + + /** + * The version of the payment token: EC_v1 for ECC-encrypted data, RSA_v1 for RSA-encrypted data. + * [Optional] + */ + private String version; + + /** + * The encrypted payment data, Base64-encoded. + * [Optional] + */ + private String data; + + /** + * The signature of the payment and header data. + * [Optional] + */ + private String signature; + + /** + * Additional version-dependent information used to decrypt and verify the payment. + * [Optional] + */ + private ApplePayTokenDataHeader header; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePayTokenDataHeader.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePayTokenDataHeader.java new file mode 100644 index 00000000..a57d996a --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/applepay/ApplePayTokenDataHeader.java @@ -0,0 +1,34 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.applepay; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Additional version-dependent information used to decrypt and verify the Apple Pay payment. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class ApplePayTokenDataHeader { + + /** + * The ephemeral public key bytes. + * [Optional] + */ + private String ephemeralPublicKey; + + /** + * The hash of the X.509 encoded public key bytes of the merchant's certificate. + * [Optional] + */ + private String publicKeyHash; + + /** + * The transaction identifier, generated on the device. + * [Optional] + */ + private String transactionId; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/bancontact/Bancontact.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/bancontact/Bancontact.java new file mode 100644 index 00000000..b7ef329e --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/bancontact/Bancontact.java @@ -0,0 +1,20 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.bancontact; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Bancontact payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Bancontact extends PaymentMethodBase { + + /** + * The account holder's name. + * [Optional] + * min 3 characters, max 100 characters + */ + private String accountHolderName; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/benefit/Benefit.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/benefit/Benefit.java new file mode 100644 index 00000000..55adfd46 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/benefit/Benefit.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.benefit; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Benefit payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Benefit extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/card/Card.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/card/Card.java new file mode 100644 index 00000000..d2956f63 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/card/Card.java @@ -0,0 +1,102 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.card; + +import com.checkout.common.Phone; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.CardAccountHolder; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.Instant; + +/** + * The Card payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Card extends PaymentMethodBase { + + /** + * The card number (without separators). Write-only. + * [Optional] + */ + private String number; + + /** + * The last four digits of the card number. Read-only. + * [Optional] + */ + private String last4; + + /** + * The card issuer's Bank Identification Number (BIN). Read-only. + * [Optional] + */ + private String bin; + + /** + * The card scheme. Read-only. + * [Optional] + */ + private String scheme; + + /** + * The expiry month of the card. + * [Optional] + */ + private Integer expiryMonth; + + /** + * The expiry year of the card. + * [Optional] + */ + private Integer expiryYear; + + /** + * The cardholder's name. Write-only. + * [Optional] + */ + private String name; + + /** + * The card verification value/code. 3 digits, except for American Express (4 digits). Write-only. + * [Optional] + */ + private String cvv; + + /** + * Set to true for payments that use stored card details. Write-only. + * [Optional] + */ + private Boolean stored; + + /** + * The time by which the card details must be confirmed. Read-only. + * [Optional] + * Format: date-time (ISO 8601) + */ + private Instant expiresOn; + + /** + * Set to true if you intend to reuse the payment credentials in subsequent payments. Write-only. + * [Optional] + */ + private Boolean storeForFutureUse; + + /** + * The customer's phone number. + * [Optional] + */ + private Phone phone; + + /** + * The card account holder details. + * [Optional] + */ + private CardAccountHolder accountHolder; + + /** + * Indicates whether to use the Real-Time Account Updater to update the card information. + * [Optional] + */ + private Boolean allowUpdate; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/CardAccountHolder.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/CardAccountHolder.java new file mode 100644 index 00000000..3f9c1669 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/CardAccountHolder.java @@ -0,0 +1,46 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Card account holder information, shared by Card, GooglePay, and ApplePay payment methods. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class CardAccountHolder { + + /** + * The card account holder type. + * [Optional] + */ + private CardAccountHolderType type; + + /** + * The card account holder's first name. + * [Optional] + */ + private String firstName; + + /** + * The card account holder's last name. + * [Optional] + */ + private String lastName; + + /** + * The card account holder's middle name. + * [Optional] + */ + private String middleName; + + /** + * Indicates whether the ANI (account name inquiry) check is performed with the card scheme. + * [Optional] + */ + private Boolean accountNameInquiry; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/CardAccountHolderType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/CardAccountHolderType.java new file mode 100644 index 00000000..af0815fa --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/CardAccountHolderType.java @@ -0,0 +1,18 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common; + +import com.google.gson.annotations.SerializedName; + +/** + * The card account holder type. + */ +public enum CardAccountHolderType { + + @SerializedName("individual") + INDIVIDUAL, + + @SerializedName("government") + GOVERNMENT, + + @SerializedName("corporate") + CORPORATE +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/OsType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/OsType.java new file mode 100644 index 00000000..293c8ca7 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/OsType.java @@ -0,0 +1,15 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common; + +import com.google.gson.annotations.SerializedName; + +/** + * The customer's operating system type. Required when terminal_type is not web. + */ +public enum OsType { + + @SerializedName("android") + ANDROID, + + @SerializedName("ios") + IOS +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodAction.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodAction.java index 52bea3d9..d844fa76 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodAction.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodAction.java @@ -1,13 +1,12 @@ package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** - * Next-step action returned by the API for a payment method (read-only). + * Next-step action returned by the API for a payment method. */ @Data @Builder @@ -16,30 +15,26 @@ public final class PaymentMethodAction { /** - * The type of action. - *

[Read-only]

- * {@code sdk} or {@code otp} (varies by payment method). + * The type of action: sdk or otp (varies by payment method). + * [Optional] */ private String type; /** * The client token for the Klarna or PayPal SDK. - *

[Read-only]

+ * [Optional] */ - @SerializedName("client_token") private String clientToken; /** * The session identifier for the Klarna payment method session. - *

[Read-only]

+ * [Optional] */ - @SerializedName("session_id") private String sessionId; /** * The PayPal order ID to use with the PayPal SDK. - *

[Read-only]

+ * [Optional] */ - @SerializedName("order_id") private String orderId; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodBase.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodBase.java index db991007..18422d00 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodBase.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/PaymentMethodBase.java @@ -12,13 +12,13 @@ public abstract class PaymentMethodBase { /** * The payment method status. - *

[Read-only]

+ * [Optional] */ private PaymentMethodStatus status; /** * An array of error codes or indicators that highlight missing or invalid information. - *

[Read-only]

+ * [Optional] */ private List flags; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/TerminalType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/TerminalType.java new file mode 100644 index 00000000..4e115e24 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/common/TerminalType.java @@ -0,0 +1,19 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common; + +import com.google.gson.annotations.SerializedName; + +/** + * The client-side terminal type. Indicates whether the customer is using a PC browser, + * mobile browser, or mobile application. + */ +public enum TerminalType { + + @SerializedName("web") + WEB, + + @SerializedName("wap") + WAP, + + @SerializedName("app") + APP +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/dana/Dana.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/dana/Dana.java new file mode 100644 index 00000000..2b754c27 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/dana/Dana.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.dana; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Dana payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Dana extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/eps/Eps.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/eps/Eps.java new file mode 100644 index 00000000..5de48a56 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/eps/Eps.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.eps; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The EPS payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Eps extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/gcash/GCash.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/gcash/GCash.java new file mode 100644 index 00000000..1b339d9b --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/gcash/GCash.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.gcash; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The GCash payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class GCash extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/googlepay/GooglePay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/googlepay/GooglePay.java new file mode 100644 index 00000000..abdc9737 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/googlepay/GooglePay.java @@ -0,0 +1,54 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.googlepay; + +import com.checkout.common.Phone; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.CardAccountHolder; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.time.Instant; + +/** + * The Google Pay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class GooglePay extends PaymentMethodBase { + + /** + * The Google Pay encrypted payment token data. + * [Optional] + */ + private GooglePayTokenData tokenData; + + /** + * The Google Pay payment token string. + * [Optional] + */ + private String token; + + /** + * The date and time the token expires. + * [Optional] + * Format: date-time (ISO 8601) + */ + private Instant expiresOn; + + /** + * Set to true if you intend to reuse the payment credentials in subsequent payments. + * [Optional] + */ + private Boolean storeForFutureUse; + + /** + * The customer's phone number. + * [Optional] + */ + private Phone phone; + + /** + * The card account holder details. + * [Optional] + */ + private CardAccountHolder accountHolder; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/googlepay/GooglePayTokenData.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/googlepay/GooglePayTokenData.java new file mode 100644 index 00000000..9450eb69 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/googlepay/GooglePayTokenData.java @@ -0,0 +1,40 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.googlepay; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The Google Pay payment token data. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class GooglePayTokenData { + + /** + * The encryption and signing scheme used to create this message. Defaults to ECv0. + * [Optional] + */ + private String protocolVersion; + + /** + * The signature that verifies the message came from Google, created using ECDSA. + * [Optional] + */ + private String signature; + + /** + * A serialized JSON string containing the encryptedMessage, ephemeralPublicKey, and tag. + * [Optional] + */ + private String signedMessage; + + /** + * The public key provided to the Google API in the tokenizationSpecification.parameters field. + * [Optional] + */ + private String tokenizationKey; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ideal/Ideal.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ideal/Ideal.java new file mode 100644 index 00000000..dc6ef3a5 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/ideal/Ideal.java @@ -0,0 +1,21 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.ideal; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The iDEAL payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Ideal extends PaymentMethodBase { + + /** + * A description of the products or services being paid for. + * Do not include HTML tags or special characters. + * [Optional] + * max 35 characters + */ + private String description; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/instrument/Instrument.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/instrument/Instrument.java new file mode 100644 index 00000000..d04e0c15 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/instrument/Instrument.java @@ -0,0 +1,26 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.instrument; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodAction; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The instrument payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Instrument extends PaymentMethodBase { + + /** + * The unique identifier of the selected instrument. + * [Optional] + */ + private String id; + + /** + * The next available action for the payment method. + * [Optional] + */ + private PaymentMethodAction action; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/kakaopay/KakaoPay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/kakaopay/KakaoPay.java new file mode 100644 index 00000000..bc3faedd --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/kakaopay/KakaoPay.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.kakaopay; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The KakaoPay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class KakaoPay extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/Klarna.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/Klarna.java index 3ce72ada..428d2992 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/Klarna.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/Klarna.java @@ -15,13 +15,13 @@ public final class Klarna extends PaymentMethodBase { /** * The initialization state of the payment method. Defaults to disabled. - *

[Optional]

+ * [Optional] */ private PaymentMethodInitialization initialization = PaymentMethodInitialization.DISABLED; /** - * The next available action. Contains type {@code sdk}, {@code client_token}, {@code session_id}. - *

[Read-only]

+ * The next available action. Contains type, client_token, and session_id. + * [Optional] */ private PaymentMethodAction action; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/KlarnaAccountHolder.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/KlarnaAccountHolder.java index 21f7a19b..7f8d10bc 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/KlarnaAccountHolder.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/klarna/KlarnaAccountHolder.java @@ -1,14 +1,13 @@ package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.klarna; import com.checkout.common.Address; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** - * Klarna account holder information + * Klarna account holder information. */ @Data @Builder @@ -17,8 +16,8 @@ public final class KlarnaAccountHolder { /** - * The billing address of the Klarna account holder + * The billing address of the Klarna account holder. + * [Optional] */ - @SerializedName("billing_address") private Address billingAddress; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/knet/Knet.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/knet/Knet.java new file mode 100644 index 00000000..173c7a99 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/knet/Knet.java @@ -0,0 +1,19 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.knet; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The KNET payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Knet extends PaymentMethodBase { + + /** + * The customer's preferred language on the issuer's site. + * [Optional] + */ + private KnetLanguage language; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/knet/KnetLanguage.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/knet/KnetLanguage.java new file mode 100644 index 00000000..8aabe438 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/knet/KnetLanguage.java @@ -0,0 +1,15 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.knet; + +import com.google.gson.annotations.SerializedName; + +/** + * The customer's preferred language for KNET payments. + */ +public enum KnetLanguage { + + @SerializedName("en") + EN, + + @SerializedName("ar") + AR +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/mbway/MBWay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/mbway/MBWay.java new file mode 100644 index 00000000..0655871d --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/mbway/MBWay.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.mbway; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The MBWay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class MBWay extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/mobilepay/MobilePay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/mobilepay/MobilePay.java new file mode 100644 index 00000000..597e0512 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/mobilepay/MobilePay.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.mobilepay; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The MobilePay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class MobilePay extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/multibanco/Multibanco.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/multibanco/Multibanco.java new file mode 100644 index 00000000..7d7a2c9b --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/multibanco/Multibanco.java @@ -0,0 +1,20 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.multibanco; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Multibanco payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Multibanco extends PaymentMethodBase { + + /** + * The account holder's name. + * [Optional] + * min 3 characters, max 100 characters + */ + private String accountHolderName; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/octopus/Octopus.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/octopus/Octopus.java new file mode 100644 index 00000000..8c4db543 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/octopus/Octopus.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.octopus; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Octopus payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Octopus extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/p24/P24.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/p24/P24.java new file mode 100644 index 00000000..1763a6cb --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/p24/P24.java @@ -0,0 +1,19 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.p24; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The P24 (Przelewy24) payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class P24 extends PaymentMethodBase { + + /** + * The account holder's details. + * [Optional] + */ + private P24AccountHolder accountHolder; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/p24/P24AccountHolder.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/p24/P24AccountHolder.java new file mode 100644 index 00000000..2aee5637 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/p24/P24AccountHolder.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.p24; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The P24 account holder's details. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class P24AccountHolder { + + /** + * The account holder's name. + * [Optional] + * min 3 characters, max 100 characters + */ + private String name; + + /** + * The account holder's email address. + * [Optional] + */ + private String email; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/paynow/PayNow.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/paynow/PayNow.java new file mode 100644 index 00000000..7c9f9579 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/paynow/PayNow.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.paynow; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The PayNow payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class PayNow extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/qpay/Qpay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/qpay/Qpay.java new file mode 100644 index 00000000..1b883419 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/qpay/Qpay.java @@ -0,0 +1,26 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.qpay; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The QPay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Qpay extends PaymentMethodBase { + + /** + * The Qatari national ID. Must start with 2 or 3, followed by 10 digits. + * [Optional] + */ + private String nationalId; + + /** + * A description of the payment order. Alphanumeric characters only. + * [Optional] + * max 255 characters + */ + private String description; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/Sepa.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/Sepa.java new file mode 100644 index 00000000..fece1a8c --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/Sepa.java @@ -0,0 +1,45 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sepa; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.common.Currency; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The SEPA payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Sepa extends PaymentMethodBase { + + /** + * The account holder details. + * [Optional] + */ + private SepaAccountHolder accountHolder; + + /** + * The account holder's IBAN. + * [Optional] + */ + private String accountNumber; + + /** + * The account's country as an ISO 3166-1 alpha-2 code. + * [Optional] + * max 2 characters + */ + private String country; + + /** + * The account holder's account currency. + * [Optional] + */ + private Currency currency; + + /** + * The SEPA mandate details. + * [Optional] + */ + private SepaMandate mandate; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaAccountHolder.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaAccountHolder.java new file mode 100644 index 00000000..569e3b0d --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaAccountHolder.java @@ -0,0 +1,40 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sepa; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The SEPA account holder details. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class SepaAccountHolder { + + /** + * The type of account holder. + * [Optional] + */ + private SepaAccountHolderType type; + + /** + * The first name of the account holder. + * [Optional] + */ + private String firstName; + + /** + * The last name of the account holder. + * [Optional] + */ + private String lastName; + + /** + * The legal name of a registered company that holds the account. + * [Optional] + */ + private String companyName; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaAccountHolderType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaAccountHolderType.java new file mode 100644 index 00000000..507e1764 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaAccountHolderType.java @@ -0,0 +1,15 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sepa; + +import com.google.gson.annotations.SerializedName; + +/** + * The type of SEPA account holder. + */ +public enum SepaAccountHolderType { + + @SerializedName("individual") + INDIVIDUAL, + + @SerializedName("corporate") + CORPORATE +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaMandate.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaMandate.java new file mode 100644 index 00000000..1a91574a --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaMandate.java @@ -0,0 +1,37 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sepa; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +/** + * The SEPA mandate details. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class SepaMandate { + + /** + * The ID of the mandate. + * [Optional] + */ + private String id; + + /** + * The type of mandate. + * [Optional] + */ + private SepaMandateType type; + + /** + * The date the mandate was signed. + * [Optional] + * Format: yyyy-MM-dd + */ + private LocalDate dateOfSignature; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaMandateType.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaMandateType.java new file mode 100644 index 00000000..8fca68d6 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sepa/SepaMandateType.java @@ -0,0 +1,15 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sepa; + +import com.google.gson.annotations.SerializedName; + +/** + * The type of SEPA mandate. + */ +public enum SepaMandateType { + + @SerializedName("core") + CORE, + + @SerializedName("b2b") + B2B +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sequra/Sequra.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sequra/Sequra.java new file mode 100644 index 00000000..e45d0b03 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/sequra/Sequra.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.sequra; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Sequra payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Sequra extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/stcpay/Stcpay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/stcpay/Stcpay.java index bfa232d3..5446286d 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/stcpay/Stcpay.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/stcpay/Stcpay.java @@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode; /** - * STC Pay payment method configuration + * STC Pay payment method configuration. */ @Data @EqualsAndHashCode(callSuper = true) @@ -15,19 +15,19 @@ public final class Stcpay extends PaymentMethodBase { /** * The initialization state of the payment method. Defaults to disabled. - *

[Optional]

+ * [Optional] */ private PaymentMethodInitialization initialization = PaymentMethodInitialization.DISABLED; /** - * The one-time password (OTP) for stc pay. - *

[Write-only]

+ * The one-time password (OTP) for STC Pay. Write-only. + * [Optional] */ private String otp; /** - * The next available action. Contains type {@code otp} when an OTP is required. - *

[Read-only]

+ * The next available action. Contains type otp when an OTP is required. + * [Optional] */ private PaymentMethodAction action; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/swish/Swish.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/swish/Swish.java new file mode 100644 index 00000000..93061b52 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/swish/Swish.java @@ -0,0 +1,25 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.swish; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Swish payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Swish extends PaymentMethodBase { + + /** + * A description that appears on the customer's billing statement. + * [Optional] + */ + private String billingDescriptor; + + /** + * The account holder's details. + * [Optional] + */ + private SwishAccountHolder accountHolder; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/swish/SwishAccountHolder.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/swish/SwishAccountHolder.java new file mode 100644 index 00000000..2acaf06f --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/swish/SwishAccountHolder.java @@ -0,0 +1,28 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.swish; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * The Swish account holder's details. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class SwishAccountHolder { + + /** + * The account holder's first name. + * [Optional] + */ + private String firstName; + + /** + * The account holder's last name. + * [Optional] + */ + private String lastName; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tabby/Tabby.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tabby/Tabby.java index 18a0e2a2..fe3f5eb6 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tabby/Tabby.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tabby/Tabby.java @@ -2,7 +2,6 @@ import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodInitialization; -import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.EqualsAndHashCode; @@ -17,14 +16,13 @@ public final class Tabby extends PaymentMethodBase { /** * The initialization state of the payment method. Defaults to disabled. - *

[Optional]

+ * [Optional] */ private PaymentMethodInitialization initialization = PaymentMethodInitialization.DISABLED; /** - * The available payment types for Tabby (for example, {@code installments}). - *

[Read-only]

+ * The available payment types for Tabby (for example, installments). + * [Optional] */ - @SerializedName("payment_types") private List paymentTypes; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tamara/Tamara.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tamara/Tamara.java new file mode 100644 index 00000000..93304016 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tamara/Tamara.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.tamara; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Tamara payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Tamara extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tng/Tng.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tng/Tng.java new file mode 100644 index 00000000..b213d398 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/tng/Tng.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.tng; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The TNG payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Tng extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/truemoney/TrueMoney.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/truemoney/TrueMoney.java new file mode 100644 index 00000000..8b89c7f3 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/truemoney/TrueMoney.java @@ -0,0 +1,29 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.truemoney; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.OsType; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.TerminalType; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The TrueMoney payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class TrueMoney extends PaymentMethodBase { + + /** + * The client-side terminal type. + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ + private TerminalType terminalType; + + /** + * The customer's operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ + private OsType osType; +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/twint/Twint.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/twint/Twint.java new file mode 100644 index 00000000..593035e8 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/twint/Twint.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.twint; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Twint payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Twint extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/vipps/Vipps.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/vipps/Vipps.java new file mode 100644 index 00000000..83eef920 --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/vipps/Vipps.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.vipps; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The Vipps payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class Vipps extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/wechatpay/WeChatPay.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/wechatpay/WeChatPay.java new file mode 100644 index 00000000..461cb5ef --- /dev/null +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/entities/paymentMethods/wechatpay/WeChatPay.java @@ -0,0 +1,13 @@ +package com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.wechatpay; + +import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.common.PaymentMethodBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * The WeChatPay payment method's details and configuration. + */ +@Data +@EqualsAndHashCode(callSuper = true) +public final class WeChatPay extends PaymentMethodBase { +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/requests/PaymentSetupsRequest.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/requests/PaymentSetupsRequest.java index 2f04f741..4676f78d 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/requests/PaymentSetupsRequest.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/requests/PaymentSetupsRequest.java @@ -2,12 +2,12 @@ import com.checkout.common.Currency; import com.checkout.payments.PaymentType; +import com.checkout.handlepaymentsandpayouts.setups.entities.billing.PaymentSetupBilling; import com.checkout.handlepaymentsandpayouts.setups.entities.customer.Customer; import com.checkout.handlepaymentsandpayouts.setups.entities.industry.Industry; import com.checkout.handlepaymentsandpayouts.setups.entities.order.Order; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.PaymentMethods; import com.checkout.handlepaymentsandpayouts.setups.entities.settings.Settings; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -23,10 +23,10 @@ public final class PaymentSetupsRequest { /** - * The processing channel to be used for the payment setup + * The processing channel to be used for the payment setup. * [Required] + * Pattern: ^(pc)_(\w{26})$ */ - @SerializedName("processing_channel_id") private String processingChannelId; /** @@ -42,10 +42,10 @@ public final class PaymentSetupsRequest { private Currency currency; /** - * The type of payment. - //// You must provide this field for card payments in which the cardholder is not present. For example, if the transaction is a recurring payment, or a mail order/telephone order (MOTO) payment. - * Enum: "Regular" "Recurring" "MOTO" "Installment" "Unscheduled" + * The type of payment. Required for card payments where the cardholder is not present, + * such as recurring or MOTO payments. * [Optional] + * Enum: "Regular" "Recurring" "MOTO" "Installment" "PayLater" "Unscheduled" */ @Builder.Default private PaymentType paymentType = PaymentType.REGULAR; @@ -66,7 +66,6 @@ public final class PaymentSetupsRequest { * The payment methods that are enabled on your account and available for use * [Optional] */ - @SerializedName("payment_methods") private PaymentMethods paymentMethods; /** @@ -92,4 +91,10 @@ public final class PaymentSetupsRequest { * [Optional] */ private Industry industry; + + /** + * The billing details for the payment. + * [Optional] + */ + private PaymentSetupBilling billing; } \ No newline at end of file diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupSource.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupSource.java index 41a98d92..707f973d 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupSource.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupSource.java @@ -11,7 +11,6 @@ import com.checkout.handlepaymentsandpayouts.payments.common.source.cardsource.AccountUpdateStatusType; import com.checkout.handlepaymentsandpayouts.payments.common.source.cardsource.accountholder.AbstractAccountHolder; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -27,156 +26,165 @@ public final class PaymentSetupSource { /** - * The payment source type. sepabank_accountalipay_cnachcardcard + * The payment source type. + * [Optional] */ private PaymentSourceType type; /** - * The expiry month + * The expiry month. + * [Optional] */ - @SerializedName("expiry_month") private Integer expiryMonth; /** - * The expiry year + * The expiry year. + * [Optional] */ - @SerializedName("expiry_year") private Integer expiryYear; /** - * The last four digits of the card number + * The last four digits of the card number. + * [Optional] */ private String last4; /** * Uniquely identifies this particular card number. You can use this to compare cards across customers. + * [Optional] */ private String fingerprint; /** - * The card issuer's Bank Identification Number (BIN) + * The card issuer's Bank Identification Number (BIN). + * [Optional] */ private String bin; /** - * The payment source identifier that can be used for subsequent payments. For new sources, this will only be returned if the payment was approved + * The payment source identifier that can be used for subsequent payments. + * For new sources, this will only be returned if the payment was approved. + * [Optional] */ private String id; /** - * The payment source owner's billing address + * The payment source owner's billing address. + * [Optional] */ - @SerializedName("billing_address") private Address billingAddress; /** - * The payment source owner's phone number + * The payment source owner's phone number. + * [Optional] */ private Phone phone; /** - * The cardholder's name + * The cardholder's name. + * [Optional] */ private String name; /** - * The card scheme + * The card scheme. + * [Optional] */ private String scheme; /** - * Deprecated Replaced by local_schemes - * The local co-branded card scheme. + * Deprecated. Replaced by local_schemes. The local co-branded card scheme. + * [Optional] */ - @SerializedName("scheme_local") private String schemeLocal; /** * The local co-branded card schemes. + * [Optional] */ - @SerializedName("local_schemes") private List localSchemes; /** - * The card type + * The card type. + * [Optional] */ - @SerializedName("card_type") private CardType cardType; /** - * The card category + * The card category. + * [Optional] */ - @SerializedName("card_category") private CardCategoryType cardCategory; /** - * The card wallet type + * The card wallet type. + * [Optional] */ - @SerializedName("card_wallet_type") private CardWalletType cardWalletType; /** - * The name of the card issuer + * The name of the card issuer. + * [Optional] */ private String issuer; /** - * The card issuer's country (two-letter ISO code) + * The card issuer's country (two-letter ISO code). + * [Optional] */ - @SerializedName("issuer_country") private String issuerCountry; /** - * The issuer/card scheme product identifier + * The issuer/card scheme product identifier. + * [Optional] */ - @SerializedName("product_id") private String productId; /** - * The issuer/card scheme product type + * The issuer/card scheme product type. + * [Optional] */ - @SerializedName("product_type") private String productType; /** - * The Address Verification System check result + * The Address Verification System check result. + * [Optional] */ - @SerializedName("avs_check") private String avsCheck; /** - * The card verification value (CVV) check result + * The card verification value (CVV) check result. + * [Optional] */ - @SerializedName("cvv_check") private String cvvCheck; /** - * A unique reference to the underlying card for network tokens (e.g., Apple Pay, Google Pay) + * A unique reference to the underlying card for network tokens (e.g., Apple Pay, Google Pay). + * [Optional] */ - @SerializedName("payment_account_reference") private String paymentAccountReference; /** * The JWE encrypted full card number that has been updated by real-time account updater. + * [Optional] */ - @SerializedName("encrypted_card_number") private String encryptedCardNumber; /** * Specifies what card information was updated by the Real-Time Account Updater. + * [Optional] */ - @SerializedName("account_update_status") private AccountUpdateStatusType accountUpdateStatus; /** * Provides the failure code if the Real-Time Account Updater fails to update the card information. + * [Optional] */ - @SerializedName("account_update_failure_code") private String accountUpdateFailureCode; /** - * Information about the account holder of the card + * Information about the account holder of the card. + * [Optional] */ - @SerializedName("account_holder") private AbstractAccountHolder accountHolder; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsConfirmResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsConfirmResponse.java index 537c0806..dcd31577 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsConfirmResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsConfirmResponse.java @@ -29,127 +29,144 @@ public final class PaymentSetupsConfirmResponse extends Resource { /** - * The payment's unique identifier + * The payment's unique identifier. + * [Optional] */ private String id; /** - * The unique identifier for the action performed against this payment + * The unique identifier for the action performed against this payment. + * [Optional] */ - @SerializedName("action_id") private String actionId; /** - * The payment amount + * The payment amount. + * [Optional] */ private Long amount; /** - * The three-letter ISO currency code of the payment + * The three-letter ISO currency code of the payment. + * [Optional] */ private Currency currency; /** - * Whether or not the authorization or capture was successful + * Whether or not the authorization or capture was successful. + * [Optional] */ private Boolean approved; /** - * The status of the payment + * The status of the payment. + * [Optional] */ private PaymentStatus status; /** - * The Gateway response code + * The Gateway response code. + * [Optional] */ - @SerializedName("response_code") private String responseCode; /** - * The date and time at which the payment was processed + * The date and time at which the payment was processed. + * [Optional] + * Format: date-time (ISO 8601) */ - @SerializedName("processed_on") private Instant processedOn; /** - * The full amount from the original authorization, if a partial authorization was requested and approved + * The full amount from the original authorization, if a partial authorization was requested and approved. + * [Optional] */ - @SerializedName("amount_requested") private Long amountRequested; /** - * The acquirer authorization code if the payment was authorized + * The acquirer authorization code if the payment was authorized. + * [Optional] */ - @SerializedName("auth_code") private String authCode; /** - * The Gateway response summary + * The Gateway response summary. + * [Optional] */ - @SerializedName("response_summary") private String responseSummary; /** - * The timestamp (ISO 8601 code) for when the authorization's validity period expires + * The timestamp for when the authorization's validity period expires. + * [Optional] + * Format: date-time (ISO 8601) */ - @SerializedName("expires_on") private String expiresOn; /** - * Provides 3D Secure enrollment status if the payment was downgraded to non-3D Secure + * Provides 3D Secure enrollment status if the payment was downgraded to non-3D Secure. + * [Optional] */ @SerializedName("3ds") private Threeds threeDSecure; /** - * Returns the payment's risk assessment results + * Returns the payment's risk assessment results. + * [Optional] */ private Risk risk; /** - * The source of the payment + * The source of the payment. + * [Optional] */ private PaymentSetupSource source; /** - * The customer associated with the payment, if provided in the request + * The customer associated with the payment, if provided in the request. + * [Optional] */ private Customer customer; /** - * The payment balances + * The payment balances. + * [Optional] */ private Balances balances; /** - * Your reference for the payment + * Your reference for the payment. + * [Optional] */ private String reference; /** - * The The details of the subscription + * The details of the subscription. + * [Optional] */ private Subscription subscription; /** - * Returns information related to the processing of the payment + * Returns information related to the processing of the payment. + * [Optional] */ private Processing processing; /** - * The final Electronic Commerce Indicator (ECI) security level used to authorize the payment. - * Applicable for 3D Secure and network token payments + * The final Electronic Commerce Indicator (ECI) security level used to authorize the payment. + * Applicable for 3D Secure and network token payments. + * [Optional] */ private String eci; /** - * The scheme transaction identifier + * The scheme transaction identifier. + * [Optional] */ - @SerializedName("scheme_id") private String schemeId; /** - * The retry information + * The retry information. + * [Optional] */ private Retry retry; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsResponse.java b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsResponse.java index c1172806..868b8b9c 100644 --- a/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsResponse.java +++ b/src/main/java/com/checkout/handlepaymentsandpayouts/setups/responses/PaymentSetupsResponse.java @@ -2,12 +2,15 @@ import com.checkout.common.Resource; import com.checkout.common.Currency; +import com.checkout.handlepaymentsandpayouts.setups.entities.billing.PaymentSetupBilling; import com.checkout.handlepaymentsandpayouts.setups.entities.customer.Customer; import com.checkout.handlepaymentsandpayouts.setups.entities.industry.Industry; import com.checkout.handlepaymentsandpayouts.setups.entities.order.Order; import com.checkout.handlepaymentsandpayouts.setups.entities.paymentMethods.PaymentMethods; import com.checkout.handlepaymentsandpayouts.setups.entities.settings.Settings; import com.checkout.payments.PaymentType; + +import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -26,61 +29,88 @@ public final class PaymentSetupsResponse extends Resource { /** * The unique identifier of the payment setup. + * [Optional] */ private String id; /** - * The processing channel used for the payment setup + * The processing channel used for the payment setup. + * [Required] + * Pattern: ^(pc)_(\w{26})$ */ private String processingChannelId; /** - * The payment amount. The exact format depends on the currency + * The payment amount in the minor currency unit. + * [Required] */ private Long amount; /** - * The three-letter ISO currency code + * The three-letter ISO currency code. + * [Required] */ private Currency currency; /** - * The type of payment method + * The type of payment. + * [Optional] + * Enum: "Regular" "Recurring" "MOTO" "Installment" "PayLater" "Unscheduled" */ private PaymentType paymentType; /** - * The reference identifier for this payment setup + * A reference you can use to identify the payment setup, such as an order number. + * [Optional] */ private String reference; /** - * A description of the payment setup + * A description of the payment setup. + * [Optional] */ private String description; /** - * The payment method configuration for this setup + * The payment method configuration for this setup. + * [Optional] */ private PaymentMethods paymentMethods; /** - * The payment setup configuration settings + * The payment setup configuration settings. + * [Optional] */ private Settings settings; /** - * Details about the customer + * Details about the customer. + * [Optional] */ private Customer customer; /** - * Details about the order associated with this payment setup + * Details about the order associated with this payment setup. + * [Optional] */ private Order order; /** - * Industry-specific information for specialized payment scenarios + * Industry-specific information for specialized payment scenarios. + * [Optional] */ private Industry industry; -} \ No newline at end of file + + /** + * The billing details for the payment. + * [Optional] + */ + private PaymentSetupBilling billing; + + /** + * An ordered list of available payment method names. The order indicates the recommended + * presentation priority, with the first item being the highest priority. + * [Optional] + */ + private List availablePaymentMethods; +} diff --git a/src/main/java/com/checkout/instruments/create/CreateInstrumentSepaRequest.java b/src/main/java/com/checkout/instruments/create/CreateInstrumentSepaRequest.java index a7fb7340..b8811d86 100644 --- a/src/main/java/com/checkout/instruments/create/CreateInstrumentSepaRequest.java +++ b/src/main/java/com/checkout/instruments/create/CreateInstrumentSepaRequest.java @@ -1,9 +1,7 @@ package com.checkout.instruments.create; import com.checkout.common.AccountHolder; -import com.checkout.common.AccountType; import com.checkout.common.InstrumentType; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,18 +14,32 @@ @ToString(callSuper = true) public final class CreateInstrumentSepaRequest extends CreateInstrumentRequest { - @SerializedName("instrument_data") + /** + * The details of the SEPA mandate, including IBAN, country, currency, payment type, and mandate ID. + * [Required] + */ private InstrumentData instrumentData; - @SerializedName("account_holder") + /** + * The account holder details. Must include first_name, last_name, and billing_address. + * [Required] + */ private AccountHolder accountHolder; + /** + * The customer details. Associates the instrument with an existing or new customer. + * [Optional] + */ + private CreateCustomerInstrumentRequest customer; + @Builder private CreateInstrumentSepaRequest(final InstrumentData instrumentData, - final AccountHolder accountHolder) { + final AccountHolder accountHolder, + final CreateCustomerInstrumentRequest customer) { super(InstrumentType.SEPA); this.instrumentData = instrumentData; this.accountHolder = accountHolder; + this.customer = customer; } public CreateInstrumentSepaRequest() { diff --git a/src/main/java/com/checkout/instruments/get/GetCardInstrumentResponse.java b/src/main/java/com/checkout/instruments/get/GetCardInstrumentResponse.java index 46a53bd3..c4e2f944 100644 --- a/src/main/java/com/checkout/instruments/get/GetCardInstrumentResponse.java +++ b/src/main/java/com/checkout/instruments/get/GetCardInstrumentResponse.java @@ -2,9 +2,9 @@ import com.checkout.common.CardCategory; import com.checkout.common.CardType; +import com.checkout.common.CardWalletType; import com.checkout.common.CountryCode; import com.checkout.common.InstrumentType; -import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -16,38 +16,107 @@ public final class GetCardInstrumentResponse extends GetInstrumentResponse { private final InstrumentType type = InstrumentType.CARD; - @SerializedName("expiry_month") + /** + * The expiry month of the card. + * [Optional] + */ private Integer expiryMonth; - @SerializedName("expiry_year") + /** + * The expiry year of the card. + * [Optional] + */ private Integer expiryYear; + /** + * The name of the cardholder. + * [Optional] + */ private String name; + /** + * The card scheme. + * [Optional] + */ private String scheme; - @SerializedName("scheme_local") + /** + * The local card scheme. + * [Optional] + */ private String schemeLocal; + /** + * The last four digits of the card number. + * [Optional] + */ private String last4; + /** + * The card BIN (Bank Identification Number). + * [Optional] + */ private String bin; - @SerializedName("card_type") + /** + * The card type. + * [Optional] + */ private CardType cardType; - @SerializedName("card_category") + /** + * The card category. + * [Optional] + */ private CardCategory cardCategory; + /** + * The name of the card issuer. + * [Optional] + */ private String issuer; - @SerializedName("issuer_country") + /** + * The country of the card issuer. + * [Optional] + */ private CountryCode issuerCountry; - @SerializedName("product_id") + /** + * The card product identifier. + * [Optional] + */ private String productId; - @SerializedName("product_type") + /** + * The card product type. + * [Optional] + */ private String productType; + /** + * The JWE-encrypted full card number. This is only present if your level of PCI compliance is SAQ-D. + * [Optional] + */ + private String encryptedCardNumber; + + /** + * The network token associated with this instrument. + * [Optional] + */ + private InstrumentNetworkToken networkToken; + + /** + * The card wallet type used for this instrument. + * [Optional] + * Enum: "googlepay" "applepay" + */ + private CardWalletType cardWalletType; + + /** + * Indicates whether the card is subject to interchange regulation. + * [Required] + */ + private Boolean regulatedIndicator; + } diff --git a/src/main/java/com/checkout/instruments/get/InstrumentNetworkToken.java b/src/main/java/com/checkout/instruments/get/InstrumentNetworkToken.java new file mode 100644 index 00000000..740fccc5 --- /dev/null +++ b/src/main/java/com/checkout/instruments/get/InstrumentNetworkToken.java @@ -0,0 +1,22 @@ +package com.checkout.instruments.get; + +import lombok.Data; + +@Data +public final class InstrumentNetworkToken { + + /** + * The unique identifier for the network token. + * [Optional] + * Pattern: ^(nt)_(\w{26})$ + */ + private String id; + + /** + * The state of the network token. + * [Optional] + * Enum: "active" "suspended" "inactive" + */ + private NetworkTokenState state; + +} diff --git a/src/main/java/com/checkout/instruments/get/NetworkTokenState.java b/src/main/java/com/checkout/instruments/get/NetworkTokenState.java new file mode 100644 index 00000000..5871e9bd --- /dev/null +++ b/src/main/java/com/checkout/instruments/get/NetworkTokenState.java @@ -0,0 +1,16 @@ +package com.checkout.instruments.get; + +import com.google.gson.annotations.SerializedName; + +public enum NetworkTokenState { + + @SerializedName("active") + ACTIVE, + + @SerializedName("suspended") + SUSPENDED, + + @SerializedName("inactive") + INACTIVE, + +} diff --git a/src/main/java/com/checkout/instruments/update/AchInstrumentAccountType.java b/src/main/java/com/checkout/instruments/update/AchInstrumentAccountType.java new file mode 100644 index 00000000..d52c76e9 --- /dev/null +++ b/src/main/java/com/checkout/instruments/update/AchInstrumentAccountType.java @@ -0,0 +1,13 @@ +package com.checkout.instruments.update; + +import com.google.gson.annotations.SerializedName; + +public enum AchInstrumentAccountType { + + @SerializedName("savings") + SAVINGS, + + @SerializedName("checking") + CHECKING + +} diff --git a/src/main/java/com/checkout/instruments/update/SepaPaymentType.java b/src/main/java/com/checkout/instruments/update/SepaPaymentType.java new file mode 100644 index 00000000..97b55fd6 --- /dev/null +++ b/src/main/java/com/checkout/instruments/update/SepaPaymentType.java @@ -0,0 +1,13 @@ +package com.checkout.instruments.update; + +import com.google.gson.annotations.SerializedName; + +public enum SepaPaymentType { + + @SerializedName("recurring") + RECURRING, + + @SerializedName("regular") + REGULAR + +} diff --git a/src/main/java/com/checkout/instruments/update/UpdateInstrumentAchRequest.java b/src/main/java/com/checkout/instruments/update/UpdateInstrumentAchRequest.java new file mode 100644 index 00000000..d9f2148b --- /dev/null +++ b/src/main/java/com/checkout/instruments/update/UpdateInstrumentAchRequest.java @@ -0,0 +1,56 @@ +package com.checkout.instruments.update; + +import com.checkout.common.AccountHolder; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import com.checkout.common.InstrumentType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public final class UpdateInstrumentAchRequest extends UpdateInstrumentRequest { + + private AchInstrumentData instrumentData; + + private AccountHolder accountHolder; + + @Builder + private UpdateInstrumentAchRequest(final AchInstrumentData instrumentData, + final AccountHolder accountHolder) { + super(InstrumentType.ACH); + this.instrumentData = instrumentData; + this.accountHolder = accountHolder; + } + + public UpdateInstrumentAchRequest() { + super(InstrumentType.ACH); + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static final class AchInstrumentData { + + private AchInstrumentAccountType accountType; + + private String accountNumber; + + private String bankCode; + + private Currency currency; + + private CountryCode country; + + } + +} diff --git a/src/main/java/com/checkout/instruments/update/UpdateInstrumentAchResponse.java b/src/main/java/com/checkout/instruments/update/UpdateInstrumentAchResponse.java new file mode 100644 index 00000000..cb825724 --- /dev/null +++ b/src/main/java/com/checkout/instruments/update/UpdateInstrumentAchResponse.java @@ -0,0 +1,15 @@ +package com.checkout.instruments.update; + +import com.checkout.common.InstrumentType; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public final class UpdateInstrumentAchResponse extends UpdateInstrumentResponse { + + private final InstrumentType type = InstrumentType.ACH; + +} diff --git a/src/main/java/com/checkout/instruments/update/UpdateInstrumentSepaRequest.java b/src/main/java/com/checkout/instruments/update/UpdateInstrumentSepaRequest.java new file mode 100644 index 00000000..a3ac4c47 --- /dev/null +++ b/src/main/java/com/checkout/instruments/update/UpdateInstrumentSepaRequest.java @@ -0,0 +1,100 @@ +package com.checkout.instruments.update; + +import com.checkout.common.AccountHolder; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import com.checkout.common.InstrumentType; +import com.checkout.payments.request.source.apm.MandateType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +import java.time.LocalDate; + +@Getter +@Setter +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public final class UpdateInstrumentSepaRequest extends UpdateInstrumentRequest { + + /** + * SEPA-specific instrument data to update. + * [Optional] + */ + private SepaInstrumentData instrumentData; + + /** + * The account holder details. + * [Optional] + */ + private AccountHolder accountHolder; + + @Builder + private UpdateInstrumentSepaRequest(final SepaInstrumentData instrumentData, + final AccountHolder accountHolder) { + super(InstrumentType.SEPA); + this.instrumentData = instrumentData; + this.accountHolder = accountHolder; + } + + public UpdateInstrumentSepaRequest() { + super(InstrumentType.SEPA); + } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static final class SepaInstrumentData { + + /** + * The SEPA mandate type. + * [Optional] + */ + private MandateType type; + + /** + * The IBAN account number. + * [Optional] + */ + private String accountNumber; + + /** + * The two-letter ISO country code. + * [Optional] + */ + private CountryCode country; + + /** + * The three-letter ISO currency code. + * [Optional] + */ + private Currency currency; + + /** + * The SEPA payment type. + * [Optional] + */ + private SepaPaymentType paymentType; + + /** + * The SEPA mandate identifier. + * [Optional] + */ + private String mandateId; + + /** + * The date the SEPA mandate was signed. + * [Optional] + * Format: yyyy-MM-dd + */ + private LocalDate dateOfSignature; + + } + +} diff --git a/src/main/java/com/checkout/instruments/update/UpdateInstrumentSepaResponse.java b/src/main/java/com/checkout/instruments/update/UpdateInstrumentSepaResponse.java new file mode 100644 index 00000000..87f43378 --- /dev/null +++ b/src/main/java/com/checkout/instruments/update/UpdateInstrumentSepaResponse.java @@ -0,0 +1,15 @@ +package com.checkout.instruments.update; + +import com.checkout.common.InstrumentType; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public final class UpdateInstrumentSepaResponse extends UpdateInstrumentResponse { + + private final InstrumentType type = InstrumentType.SEPA; + +} diff --git a/src/main/java/com/checkout/issuing/cards/requests/create/ShippingInstruction.java b/src/main/java/com/checkout/issuing/cards/requests/create/ShippingInstruction.java index ec003f8c..c7f33af9 100644 --- a/src/main/java/com/checkout/issuing/cards/requests/create/ShippingInstruction.java +++ b/src/main/java/com/checkout/issuing/cards/requests/create/ShippingInstruction.java @@ -1,7 +1,6 @@ package com.checkout.issuing.cards.requests.create; import com.checkout.common.Address; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.Data; @@ -9,12 +8,25 @@ @Builder public final class ShippingInstruction { - @SerializedName("shipping_recipient") + /** + * The name of the person the card will be shipped to. + * [Optional] + * @deprecated No longer supported. + */ + @Deprecated private String shippingRecipient; - @SerializedName("shipping_address") + /** + * The address to ship the physical card to. + * [Optional] + */ private Address shippingAddress; - @SerializedName("additional_comment") + /** + * Any additional comment on shipping. + * [Optional] + * @deprecated No longer supported. + */ + @Deprecated private String additionalComment; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/AccommodationData.java b/src/main/java/com/checkout/payments/AccommodationData.java new file mode 100644 index 00000000..d540a746 --- /dev/null +++ b/src/main/java/com/checkout/payments/AccommodationData.java @@ -0,0 +1,100 @@ +package com.checkout.payments; + +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Phone; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class AccommodationData { + + /** + * The name of the accommodation property. + * [Optional] + */ + private String name; + + /** + * The booking reference for this accommodation. + * [Optional] + */ + private String bookingReference; + + /** + * The check-in date. + * [Optional] + * Format: date (yyyy-MM-dd) + */ + private LocalDate checkInDate; + + /** + * The check-out date. + * [Optional] + * Format: date (yyyy-MM-dd) + */ + private LocalDate checkOutDate; + + /** + * The address of the accommodation property. + * [Optional] + */ + private Address address; + + /** + * The state or region code where the property is located, as an ISO 3166-2 subdivision code. + * [Optional] + */ + private String state; + + /** + * The country where the property is located, as an ISO 3166-1 alpha-2 code. + * [Optional] + */ + private CountryCode country; + + /** + * The city where the property is located. + * [Optional] + */ + private String city; + + /** + * The number of rooms booked. + * [Optional] + */ + private Integer numberOfRooms; + + /** + * The list of guests for this booking. + * [Optional] + */ + private List guests; + + /** + * The room details for this booking. + * [Optional] + */ + private List room; + + /** + * The property's phone numbers. + * [Optional] + */ + private List propertyPhone; + + /** + * The customer service phone numbers for the property. + * [Optional] + */ + private List customerServicePhone; + +} diff --git a/src/main/java/com/checkout/payments/AccommodationGuest.java b/src/main/java/com/checkout/payments/AccommodationGuest.java new file mode 100644 index 00000000..3fe37bd1 --- /dev/null +++ b/src/main/java/com/checkout/payments/AccommodationGuest.java @@ -0,0 +1,35 @@ +package com.checkout.payments; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class AccommodationGuest { + + /** + * The guest's first name. + * [Optional] + */ + private String firstName; + + /** + * The guest's last name. + * [Optional] + */ + private String lastName; + + /** + * The guest's date of birth. + * [Optional] + * Format: date (yyyy-MM-dd) + */ + private LocalDate dateOfBirth; + +} diff --git a/src/main/java/com/checkout/payments/AccommodationRoom.java b/src/main/java/com/checkout/payments/AccommodationRoom.java new file mode 100644 index 00000000..c1b65a45 --- /dev/null +++ b/src/main/java/com/checkout/payments/AccommodationRoom.java @@ -0,0 +1,26 @@ +package com.checkout.payments; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class AccommodationRoom { + + /** + * The room rate amount. + * [Optional] + */ + private String rate; + + /** + * The number of nights at the specified room rate. + * [Optional] + */ + private String numberOfNightsAtRoomRate; + +} diff --git a/src/main/java/com/checkout/payments/AchServiceType.java b/src/main/java/com/checkout/payments/AchServiceType.java new file mode 100644 index 00000000..162b03a7 --- /dev/null +++ b/src/main/java/com/checkout/payments/AchServiceType.java @@ -0,0 +1,13 @@ +package com.checkout.payments; + +import com.google.gson.annotations.SerializedName; + +public enum AchServiceType { + + @SerializedName("same_day") + SAME_DAY, + + @SerializedName("standard") + STANDARD + +} diff --git a/src/main/java/com/checkout/payments/Aggregator.java b/src/main/java/com/checkout/payments/Aggregator.java new file mode 100644 index 00000000..cc188a3e --- /dev/null +++ b/src/main/java/com/checkout/payments/Aggregator.java @@ -0,0 +1,31 @@ +package com.checkout.payments; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Information about the payment aggregator. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public final class Aggregator { + + /** + * The sub-merchant ID. + */ + private String subMerchantId; + + /** + * The Visa identifier for the payment aggregator. + */ + private String aggregatorIdVisa; + + /** + * The Mastercard identifier for the payment aggregator. + */ + private String aggregatorIdMc; +} diff --git a/src/main/java/com/checkout/payments/PaymentProcessing.java b/src/main/java/com/checkout/payments/PaymentProcessing.java index 6bf3ed27..d1b0760c 100644 --- a/src/main/java/com/checkout/payments/PaymentProcessing.java +++ b/src/main/java/com/checkout/payments/PaymentProcessing.java @@ -1,7 +1,6 @@ package com.checkout.payments; import com.checkout.common.CountryCode; -import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @@ -9,91 +8,198 @@ @Data public final class PaymentProcessing { - @SerializedName("retrieval_reference_number") + /** + * A unique identifier for the authorization submitted to the card scheme during processing. + * [Optional] + */ private String retrievalReferenceNumber; - @SerializedName("acquirer_transaction_id") + /** + * A unique identifier for the transaction generated by the acquirer. + * [Optional] + */ private String acquirerTransactionId; - @SerializedName("acquirer_name") + /** + * The name of the acquirer that processed the payment. + * [Optional] + */ private String acquirerName; - @SerializedName("acquirer_country_code") + /** + * The two-letter ISO country code of the acquirer country. + * [Optional] + */ private CountryCode acquirerCountryCode; - @SerializedName("recommendation_code") + /** + * A code representing the recommended follow-up action for the payment, as provided by Checkout.com. + * [Optional] + */ private String recommendationCode; - + + /** + * The scheme the transaction was processed with. + * [Optional] + */ private String scheme; - @SerializedName("partner_merchant_advice_code") + /** + * The Merchant Advice Code (MAC) provided by Mastercard with additional transaction information. + * [Optional] + */ private String partnerMerchantAdviceCode; - - @SerializedName("partner_response_code") + + /** + * The original authorization response code sent by the scheme (raw response code). + * [Optional] + */ private String partnerResponseCode; - @SerializedName("partner_order_id") + /** + * Unique order identification of an Afterpay payment. + * [Optional] + */ private String partnerOrderId; - @SerializedName("partner_session_id") + /** + * The partner session identifier associated with the payment. + * [Optional] + */ private String partnerSessionId; - @SerializedName("partner_client_token") + /** + * The client token returned by the partner for client-side initialization. + * [Optional] + */ private String partnerClientToken; - @SerializedName("partner_payment_id") + /** + * Unique identification of a payment provided by partner. + * [Optional] + */ private String partnerPaymentId; - @SerializedName("pan_type_processed") + /** + * The type of Primary Account Number (PAN) used: fpan (full card) or dpan (network token). + * [Optional] + * Enum: "fpan" "dpan" + */ private PanProcessedType panTypeProcessed; - @SerializedName("continuation_payload") + /** + * A payload used to continue processing for multi-step payment flows. + * [Optional] + */ private String continuationPayload; + /** + * The Payment Unique Number (PUN) assigned to the payment. + * [Optional] + */ private String pun; - @SerializedName("partner_status") + /** + * The status of the payment as reported by the partner. + * [Optional] + */ private String partnerStatus; - @SerializedName("partner_transaction_id") + /** + * Unique transaction identification provided by partner. + * [Optional] + */ private String partnerTransactionId; - @SerializedName("partner_error_codes") + /** + * Error codes provided by the partner for a failed or declined payment. + * [Optional] + */ private List partnerErrorCodes; - @SerializedName("partner_error_message") + /** + * Error description provided by the partner. + * [Optional] + */ private String partnerErrorMessage; - @SerializedName("partner_authorization_code") + /** + * Authorization code provided by the partner. + * [Optional] + */ private String partnerAuthorizationCode; - @SerializedName("partner_authorization_response_code") + /** + * Authorization response code provided by the partner. + * [Optional] + */ private String partnerAuthorizationResponseCode; - - @SerializedName("surcharge_amount") + + /** + * Surcharge amount applied to the transaction in minor currency units. + * [Optional] + */ private Long surchargeAmount; - @SerializedName("cko_network_token_available") + /** + * Indicates whether a Checkout.com Network Token was available for the payment. + * [Optional] + */ private Boolean ckoNetworkTokenAvailable; - @SerializedName("purchase_country") + /** + * The country where the purchase was made. ISO 3166-1 alpha-2 country code. + * [Optional] + * max 2 characters + */ private CountryCode purchaseCountry; - @SerializedName("scheme_merchant_id") + /** + * The merchant identifier configured with the scheme and used for the payment. + * [Optional] + */ private String schemeMerchantId; - @SerializedName("foreign_retailer_amount") + /** + * The foreign retailer amount applied by the merchant, in minor currency units. + * [Optional] + */ private Long foreignRetailerAmount; - @SerializedName("provision_network_token") + /** + * Indicates whether a network token should be provisioned for the payment. + * [Optional] + */ private Boolean provisionNetworkToken; - @SerializedName("merchant_category_code") + /** + * The merchant category code (MCC) associated with the payment. + * [Optional] + */ private String merchantCategoryCode; + /** + * Indicates whether this is an Account Funding Transaction (AFT). + * [Optional] + */ private Boolean aft; - @SerializedName("bizum_payment_id") + /** + * The Bizum payment identifier returned when processing a Bizum payment. + * [Optional] + */ private String bizumPaymentId; + /** + * A reconciliation identifier for the payment. + * [Optional] + */ + private String reconciliationId; + + /** + * The aggregator information for this payment. + * [Optional] + */ + private Aggregator aggregator; + } diff --git a/src/main/java/com/checkout/payments/PaymentRecipient.java b/src/main/java/com/checkout/payments/PaymentRecipient.java index 8d006a19..ad28c04a 100644 --- a/src/main/java/com/checkout/payments/PaymentRecipient.java +++ b/src/main/java/com/checkout/payments/PaymentRecipient.java @@ -9,19 +9,44 @@ @Builder public final class PaymentRecipient { + /** + * The recipient's date of birth. + * [Optional] + * Format: yyyy-MM-dd + */ @SerializedName("dob") private String dateOfBirth; - @SerializedName("account_number") + /** + * Any identifier related to the primary recipient's account, such as part of the PAN, + * an IBAN, an internal account number, or a phone number. + * [Optional] + */ private String accountNumber; + /** + * The recipient's address. + * [Optional] + */ private Address address; + /** + * The first part of the UK postcode (e.g., SW1A 1AA would be SW1A). Replaced by address.zip. + * [Optional] + * @deprecated Use {@code address.zip} instead. + */ + @Deprecated private String zip; - @SerializedName("first_name") + /** + * The recipient's first name. + * [Optional] + */ private String firstName; - @SerializedName("last_name") + /** + * The recipient's last name. + * [Optional] + */ private String lastName; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/ProcessingSettings.java b/src/main/java/com/checkout/payments/ProcessingSettings.java index d1642032..b3dd84f9 100644 --- a/src/main/java/com/checkout/payments/ProcessingSettings.java +++ b/src/main/java/com/checkout/payments/ProcessingSettings.java @@ -4,7 +4,6 @@ import com.checkout.common.CountryCode; import com.checkout.common.ShippingInfo; import com.checkout.payments.previous.request.SenderInformation; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -19,116 +18,286 @@ @AllArgsConstructor public final class ProcessingSettings { - @SerializedName("order_id") + /** + * The cardholder-provided purchase order or invoice number. + * [Optional] + * max 15 characters + */ private String orderId; - @SerializedName("tax_amount") + /** + * The total amount of sales tax on the total purchase amount. + * [Optional] + */ private Long taxAmount; - @SerializedName("discount_amount") + /** + * The surcharge amount applied to the transaction in minor currency units by the merchant. + * [Optional] + */ + private Long surchargeAmount; + + /** + * The discount amount applied to the transaction by the merchant. + * [Optional] + */ private Long discountAmount; - @SerializedName("duty_amount") + /** + * The total charges for any import or export duty included in the transaction. + * [Optional] + */ private Long dutyAmount; - @SerializedName("shipping_amount") + /** + * The total freight or shipping and handling charges for the transaction. + * [Optional] + */ private Long shippingAmount; - @SerializedName("shipping_tax_amount") + /** + * The tax amount on the freight or shipping and handling charges for the transaction. + * [Optional] + */ private Long shippingTaxAmount; + /** + * Indicates if the payment is an Account Funding Transaction (AFT). + * [Optional] + */ private boolean aft; - @SerializedName("preferred_scheme") + /** + * The preferred scheme for co-badged card payment processing. + * [Optional] + * Enum: "mastercard" "visa" "cartes_bancaires" + */ private PreferredSchema preferredScheme; - @SerializedName("merchant_initiated_reason") + /** + * Indicates the reason for a merchant-initiated payment request. + * [Optional] + * Enum: "Delayed_charge" "Resubmission" "No_show" "Reauthorization" + */ private MerchantInitiatedReason merchantInitiatedReason; - @SerializedName("campaign_id") + /** + * Unique number of the campaign this payment will run in. Required for Afterpay campaign invoices. + * [Optional] + */ private Long campaignId; - @SerializedName("product_type") + /** + * The product type of the payment. Required for wechatpay and sequra; optional for tamara. + * [Optional] + */ private ProductType productType; - @SerializedName("open_id") + /** + * The OpenID obtained from WeChat Web Authorization API. Required for Official Account or Mini Program payments. + * [Optional] + */ private String openId; - @SerializedName("original_order_amount") + /** + * The original order amount when a payment is split. Indicates the full order price. + * [Optional] + */ private Long originalOrderAmount; - @SerializedName("receipt_id") + /** + * Merchant receipt ID. + * [Optional] + * max 32 characters + */ private String receiptId; - @SerializedName("terminal_type") + /** + * The client-side terminal type: APP, WAP (mobile browser), or WEB (PC browser). + * [Optional] + * Enum: "APP" "WAP" "WEB" + */ private TerminalType terminalType; - @SerializedName("os_type") + /** + * The operating system type. Required when terminal_type is not WEB. + * [Optional] + * Enum: "ANDROID" "IOS" + */ private OsType osType; - @SerializedName("invoice_id") + /** + * Invoice ID number. + * [Optional] + * max 127 characters + */ private String invoiceId; - @SerializedName("brand_name") + /** + * The label that overrides the business name in the PayPal account on PayPal pages. + * [Optional] + * max 127 characters + */ private String brandName; + /** + * The language and region of the customer in ISO 639-2 format (e.g. en-US). + * [Optional] + * Pattern: ^[a-z]{2}(?:-[A-Z][a-z]{3})?(?:-(?:[A-Z]{2}))?$ + * min 2 characters, max 10 characters + */ private String locale; - @SerializedName("shipping_preference") + /** + * Shipping preference for PayPal payments. + * [Optional] + * Enum: "no_shipping" "set_provided_address" "get_from_file" + */ private ShippingPreference shippingPreference; - @SerializedName("user_action") + /** + * Property required by PayPal to determine the appropriate payment flow. + * [Optional] + * Enum: "pay_now" "continue" + */ private UserAction userAction; - @SerializedName("set_transaction_context") + /** + * An array of key-value pairs with merchant-specific transaction context data for PayPal. + * [Optional] + */ private List> setTransactionContext; - @SerializedName("airline_data") + /** + * Airline ticket and flight information for the payment. + * [Optional] + */ private List airlineData; - @SerializedName("otp_value") + /** + * The accommodation data for hotel or lodging payments. + * [Optional] + */ + private List accommodationData; + + /** + * A one-time password value for OTP-based payment flows. + * [Optional] + */ private String otpValue; - @SerializedName("purchase_country") + /** + * The two-letter ISO country code of the purchase country. + * [Optional] + * max 2 characters + */ private CountryCode purchaseCountry; - @SerializedName("custom_payment_method_ids") + /** + * Custom payment method IDs (Klarna promo codes) defining which payment options to show. + * [Optional] + */ private List customPaymentMethodIds; - @SerializedName("merchant_callback_url") + /** + * A URL to notify the customer when the order has been created (used by some APMs). + * [Optional] + */ private String merchantCallbackUrl; - @SerializedName("line_of_business") + /** + * The line of business that the payment is associated with. + * [Optional] + */ private String lineOfBusiness; - @SerializedName("shipping_delay") + /** + * The number of days by which the shipping is delayed. + * [Optional] + */ private Long shippingDelay; - @SerializedName("shipping_info") + /** + * Shipping information for the transaction. + * [Optional] + */ private List shippingInfo; - @SerializedName("provision_network_token") + /** + * Indicates whether to provision a network token for the payment. + * [Optional] + */ private Boolean provisionNetworkToken; - @SerializedName("pan_preference") + /** + * Specifies the preferred type of Primary Account Number (PAN): fpan or dpan. + * [Optional] + * Enum: "fpan" "dpan" + */ private PanProcessedType panPreference; - @SerializedName("hub_model_origination_country") + /** + * The ACH service type to use for the payment when source.type is ach. + * [Optional] + * Enum: "same_day" "standard" + */ + private AchServiceType serviceType; + + /** + * The foreign retailer amount the merchant applied to the transaction, in minor currency units. + * [Optional] + */ + private Long foreignRetailerAmount; + + /** + * A reconciliation identifier for the payment. + * [Optional] + */ + private String reconciliationId; + + /** + * The aggregator information for this payment. + * [Optional] + */ + private Aggregator aggregator; + + /** + * The origination country for hub model payments. + * [Optional] + */ private CountryCode hubModelOriginationCountry; - //Previous + /** + * DLocal-specific processing settings. Used for Previous API only. + * [Optional] + */ private DLocalProcessingSettings dlocal; - @SerializedName("senderInformation") + /** + * Sender information. Used for Previous API only. + * [Optional] + */ private SenderInformation senderInformation; - @SerializedName("card_type") + /** + * Specifies whether to process the payment as credit or debit when a combo card is used. + * [Optional] + * Enum: "credit" "debit" + */ private CardType cardType; - @SerializedName("affiliate_id") + /** + * The unique identifier for a Visa-registered ramp provider. Must be alphanumeric. + * [Optional] + * Pattern: ^[a-zA-Z0-9]{1,15}$ + * max 15 characters + */ private String affiliateId; - @SerializedName("affiliate_url") + /** + * The affiliate URL. Required if you are a Visa-registered ramp provider operating with affiliates. + * [Optional] + */ private String affiliateUrl; -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/ThreeDSData.java b/src/main/java/com/checkout/payments/ThreeDSData.java index 11b0ae05..2bb85d94 100644 --- a/src/main/java/com/checkout/payments/ThreeDSData.java +++ b/src/main/java/com/checkout/payments/ThreeDSData.java @@ -2,36 +2,93 @@ import com.checkout.common.Exemption; import com.checkout.common.ThreeDSEnrollmentStatus; -import com.google.gson.annotations.SerializedName; import lombok.Data; @Data public final class ThreeDSData { + /** + * Whether the 3DS authentication was downgraded. + * [Optional] + */ private Boolean downgraded; + /** + * The 3DS enrollment status of the card. + * [Optional] + */ private ThreeDSEnrollmentStatus enrolled; - @SerializedName("upgrade_reason") + /** + * The reason for the 3DS upgrade. + * [Optional] + */ private String upgradeReason; - @SerializedName("signature_valid") + /** + * Whether the 3DS signature is valid. + * [Optional] + */ private String signatureValid; - @SerializedName("authentication_response") + /** + * The 3DS authentication response code. + * [Optional] + */ private String authenticationResponse; + /** + * The 3DS cryptogram (CAVV) for the transaction. + * [Optional] + */ private String cryptogram; + /** + * The 3DS transaction identifier (XID). + * [Optional] + */ private String xid; + /** + * The 3DS protocol version used for authentication. + * [Optional] + */ private String version; + /** + * The 3DS exemption type applied to the payment. + * [Optional] + */ private Exemption exemption; - @SerializedName("exemption_applied") + /** + * The 3DS exemption type that was applied by the issuer. + * [Optional] + */ private String exemptionApplied; + /** + * Whether the cardholder was challenged during authentication. + * [Optional] + */ private Boolean challenged; + /** + * The Electronic Commerce Indicator (ECI) value from the 3DS authentication. + * [Optional] + */ + private String eci; + + /** + * The reason for the authentication status result. + * [Optional] + */ + private String authenticationStatusReason; + + /** + * The trusted listing status for the cardholder. + * [Optional] + */ + private TrustedListing trustedListing; + } diff --git a/src/main/java/com/checkout/payments/TrustedListing.java b/src/main/java/com/checkout/payments/TrustedListing.java new file mode 100644 index 00000000..605d078a --- /dev/null +++ b/src/main/java/com/checkout/payments/TrustedListing.java @@ -0,0 +1,20 @@ +package com.checkout.payments; + +import lombok.Data; + +@Data +public final class TrustedListing { + + /** + * The trusted listing status for the cardholder. + * [Optional] + */ + private TrustedListingStatus status; + + /** + * The source of the trusted listing entry. + * [Optional] + */ + private String source; + +} diff --git a/src/main/java/com/checkout/payments/TrustedListingStatus.java b/src/main/java/com/checkout/payments/TrustedListingStatus.java new file mode 100644 index 00000000..466691e3 --- /dev/null +++ b/src/main/java/com/checkout/payments/TrustedListingStatus.java @@ -0,0 +1,31 @@ +package com.checkout.payments; + +import com.google.gson.annotations.SerializedName; + +public enum TrustedListingStatus { + + /** 3DS Requestor is allowlisted by cardholder. */ + @SerializedName("Y") + ALLOWLISTED, + + /** 3DS Requestor is not allowlisted by cardholder. */ + @SerializedName("N") + NOT_ALLOWLISTED, + + /** Not eligible as determined by issuer. */ + @SerializedName("E") + NOT_ELIGIBLE, + + /** Pending confirmation by cardholder. */ + @SerializedName("P") + PENDING, + + /** Cardholder rejected. */ + @SerializedName("R") + REJECTED, + + /** Allowlist status unknown, unavailable, or does not apply. */ + @SerializedName("U") + UNKNOWN + +} diff --git a/src/main/java/com/checkout/payments/contexts/PaymentContexts.java b/src/main/java/com/checkout/payments/contexts/PaymentContexts.java index 4cd4538a..57cb2234 100644 --- a/src/main/java/com/checkout/payments/contexts/PaymentContexts.java +++ b/src/main/java/com/checkout/payments/contexts/PaymentContexts.java @@ -3,48 +3,116 @@ import com.checkout.common.Currency; import com.checkout.payments.PaymentType; import com.checkout.payments.ShippingDetails; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.util.List; +import java.util.Map; @Data @AllArgsConstructor @NoArgsConstructor public class PaymentContexts { + /** + * The payment amount in minor currency units. + * [Required] + * min 0 + */ private Long amount; + /** + * The three-letter ISO currency code. + * [Required] + * min 3 characters, max 3 characters + */ private Currency currency; - @SerializedName("payment_type") + /** + * Must be "Recurring" if the payment is paid in multiple installments. + * [Optional] + * Enum: "Regular" "Recurring" + */ private PaymentType paymentType; - @SerializedName("authorization_type") + /** + * The authorization type for the payment. + * [Optional] + */ private String authorizationType; + /** + * Whether to capture the later payment. + * [Optional] + */ private Boolean capture; + /** + * The customer details. Required if source.type is StcPay or Tabby. + * [Optional] + */ private PaymentContextsCustomerRequest customer; + /** + * The shipping details. + * [Optional] + */ private ShippingDetails shipping; + /** + * Use the processing object to influence or override the data during payment processing. + * [Optional] + */ private PaymentContextsProcessing processing; - @SerializedName("processing_channel_id") + /** + * The processing channel to be used for the payment. + * [Optional] + * Pattern: ^(pc)_(\w{26})$ + */ private String processingChannelId; + /** + * A reference you can later use to identify this Payment Context, such as an order number. + * [Optional] + * max 50 characters + */ private String reference; + /** + * A description of the Payment Context. + * [Optional] + * max 100 characters + */ private String description; - @SerializedName("success_url") + /** + * For redirect payment methods, this overrides the default success redirect URL configured on your account. + * [Optional] + * Format: uri + * max 1024 characters + */ private String successUrl; - @SerializedName("failure_url") + /** + * For redirect payment methods, this overrides the default failure redirect URL configured on your account. + * [Optional] + * Format: uri + * max 1024 characters + */ private String failureUrl; + /** + * The order's line items. Required for Klarna payments. + * [Optional] + */ private List items; + + /** + * A set of key-value pairs to store additional information about the transaction. + * Up to 20 fields, max 255 characters per value. + * [Optional] + */ + private Map metadata; } diff --git a/src/main/java/com/checkout/payments/contexts/PaymentContextsAccommodationData.java b/src/main/java/com/checkout/payments/contexts/PaymentContextsAccommodationData.java index 63390f11..298249d9 100644 --- a/src/main/java/com/checkout/payments/contexts/PaymentContextsAccommodationData.java +++ b/src/main/java/com/checkout/payments/contexts/PaymentContextsAccommodationData.java @@ -2,7 +2,7 @@ import com.checkout.common.Address; import com.checkout.common.CountryCode; -import com.google.gson.annotations.SerializedName; +import com.checkout.common.Phone; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -27,7 +27,6 @@ public final class PaymentContextsAccommodationData { * The booking reference. * [Optional] */ - @SerializedName("booking_reference") private String bookingReference; /** @@ -35,7 +34,6 @@ public final class PaymentContextsAccommodationData { * [Optional] * Format: yyyy-MM-dd */ - @SerializedName("check_in_date") private LocalDate checkInDate; /** @@ -43,7 +41,6 @@ public final class PaymentContextsAccommodationData { * [Optional] * Format: yyyy-MM-dd */ - @SerializedName("check_out_date") private LocalDate checkOutDate; /** @@ -74,20 +71,29 @@ public final class PaymentContextsAccommodationData { * The number of rooms booked. * [Optional] */ - @SerializedName("number_of_rooms") private Integer numberOfRooms; /** * Information about the guests staying at the accommodation. * [Optional] */ - @SerializedName("guests") private List guests; /** * Information about the rooms booked by the customer. * [Optional] */ - @SerializedName("room") private List room; + + /** + * The property's phone information. + * [Optional] + */ + private List propertyPhone; + + /** + * The customer service phone information. + * [Optional] + */ + private List customerServicePhone; } diff --git a/src/main/java/com/checkout/payments/contexts/PaymentContextsRequest.java b/src/main/java/com/checkout/payments/contexts/PaymentContextsRequest.java index 60406925..211705bf 100644 --- a/src/main/java/com/checkout/payments/contexts/PaymentContextsRequest.java +++ b/src/main/java/com/checkout/payments/contexts/PaymentContextsRequest.java @@ -11,6 +11,7 @@ import lombok.ToString; import java.util.List; +import java.util.Map; @Data @ToString(callSuper = true) @@ -18,6 +19,10 @@ @NoArgsConstructor public final class PaymentContextsRequest extends PaymentContexts { + /** + * The source of the payment. Discriminated by type: klarna, paypal, stcpay, tabby. + * [Required] + */ private AbstractRequestSource source; @Builder @@ -36,10 +41,11 @@ private PaymentContextsRequest( final String failureUrl, final List items, final String authorizationType, - final PaymentContextsCustomerRequest customer + final PaymentContextsCustomerRequest customer, + final Map metadata ) { super(amount, currency, paymentType, authorizationType, capture, customer, shipping, processing, - processingChannelId, reference, description, successUrl, failureUrl, items); + processingChannelId, reference, description, successUrl, failureUrl, items, metadata); this.source = source; } } diff --git a/src/main/java/com/checkout/payments/hosted/HostedPaymentRequest.java b/src/main/java/com/checkout/payments/hosted/HostedPaymentRequest.java index efa5c5bc..801428ac 100644 --- a/src/main/java/com/checkout/payments/hosted/HostedPaymentRequest.java +++ b/src/main/java/com/checkout/payments/hosted/HostedPaymentRequest.java @@ -30,81 +30,203 @@ @Builder public final class HostedPaymentRequest { + /** + * The three-letter ISO currency code of the payment. + * [Required] + * min 3 characters, max 3 characters + */ private Currency currency; + /** + * The billing information for the payment, including address and phone. + * [Required] + */ private BillingInformation billing; - @SerializedName("success_url") + /** + * For redirect payment methods, overrides the default success redirect URL configured on your account. + * [Required] + * Format: uri + * max 255 characters + */ private String successUrl; - @SerializedName("cancel_url") + /** + * The URL to which the customer should be directed if they cancel the payment. + * [Required] + * Format: uri + * max 255 characters + */ private String cancelUrl; - @SerializedName("failure_url") + /** + * For redirect payment methods, overrides the default failure redirect URL configured on your account. + * [Required] + * Format: uri + * max 255 characters + */ private String failureUrl; + /** + * The payment amount in minor currency units. The exact format depends on the currency. + * [Optional] + * min 0 + */ private Long amount; + /** + * The type of payment. Must be specified for card payments where the cardholder is not present. + * [Optional] + * Enum: "Regular" "Recurring" + */ @Builder.Default - @SerializedName("payment_type") private PaymentType paymentType = PaymentType.REGULAR; - @SerializedName("payment_ip") + /** + * @deprecated Deprecated in the API on 2025-03-11. Use {@code risk.device.network.ipv4} or {@code risk.device.network.ipv6} instead. + */ + @Deprecated private String paymentIp; - @SerializedName("billing_descriptor") + /** + * An optional description displayed on the customer's statement identifying a purchase. + * [Optional] + */ private BillingDescriptor billingDescriptor; + /** + * A reference you can use to identify the payment, such as an order number. + * [Optional] + */ private String reference; + /** + * A description of the payment. + * [Optional] + * max 100 characters + */ private String description; - @SerializedName("display_name") + /** + * The merchant name to display to customers on the checkout page. + * [Optional] + */ private String displayName; - @SerializedName("processing_channel_id") + /** + * The processing channel to be used for the payment. + * [Optional] + * Pattern: ^(pc)_(\w{26})$ + */ private String processingChannelId; - @SerializedName("amount_allocations") + /** + * The amount allocations for marketplace or split payments. + * [Optional] + */ private List amountAllocations; + /** + * The customer details. + * [Optional] + */ private CustomerRequest customer; + /** + * The shipping details. + * [Optional] + */ private ShippingDetails shipping; + /** + * The recipient of the payment. Used for financial regulations compliance. + * [Optional] + */ private PaymentRecipient recipient; + /** + * Use the processing object to influence or override data during payment processing. + * [Optional] + */ private ProcessingSettings processing; - @SerializedName("allow_payment_methods") + /** + * Specifies which payment method options to present to the customer. + * [Optional] + */ private List allowPaymentMethods; - @SerializedName("disabled_payment_methods") + /** + * Specifies which payment method options to hide from the customer. + * [Optional] + */ private List disabledPaymentMethods; + /** + * The line items or products included in the purchase. + * [Optional] + */ private List products; + /** + * The risk assessment configuration for the payment. + * [Optional] + */ private RiskRequest risk; - @SerializedName("customer_retry") + /** + * The customer retry configuration for failed payments. + * [Optional] + */ private PaymentRetryRequest customerRetry; + /** + * The sender of the payment. Required for financial regulations in some jurisdictions. + * [Optional] + */ private Sender sender; + /** + * Key-value pairs to store additional information about the transaction. + * [Optional] + */ private Map metadata; + /** + * Creates a translated version of the hosted page in the specified language. + * [Optional] + */ private LocaleType locale; + /** + * The 3D Secure (3DS) authentication configuration for the payment. + * [Optional] + */ @SerializedName("3ds") private ThreeDSRequest threeDS; + /** + * Whether to capture the payment immediately (if applicable). + * [Optional] + */ private Boolean capture; - @SerializedName("capture_on") + /** + * The date and time at which the payment should be captured (ISO 8601). + * [Optional] + * Format: date-time (RFC 3339) + */ private Instant captureOn; + /** + * The payment instruction details, such as purpose of payment. + * [Optional] + */ private PaymentInstruction instruction; - @SerializedName("payment_method_configuration") + /** + * The payment method configuration for stored card and wallet methods. + * [Optional] + */ private PaymentMethodConfiguration paymentMethodConfiguration; } diff --git a/src/main/java/com/checkout/payments/links/PaymentLinkRequest.java b/src/main/java/com/checkout/payments/links/PaymentLinkRequest.java index 86ccbbf6..b612e4e4 100644 --- a/src/main/java/com/checkout/payments/links/PaymentLinkRequest.java +++ b/src/main/java/com/checkout/payments/links/PaymentLinkRequest.java @@ -30,77 +30,190 @@ @Builder public final class PaymentLinkRequest { + /** + * The payment amount in minor currency units. The exact format depends on the currency. + * [Required] + * min 0 + */ private Long amount; + /** + * The three-letter ISO currency code of the payment. + * [Required] + * min 3 characters, max 3 characters + */ private Currency currency; + /** + * The billing information for the payment, including address and phone. + * [Required] + */ private BillingInformation billing; - @SerializedName("payment_type") + /** + * The type of payment. Must be specified for card payments where the cardholder is not present. + * [Optional] + * Enum: "Regular" "Recurring" "MOTO" "Installment" "Unscheduled" + */ private PaymentType paymentType; - @SerializedName("payment_ip") + /** + * @deprecated Deprecated in the API on 2025-03-11. Use {@code risk.device.network.ipv4} or {@code risk.device.network.ipv6} instead. + */ + @Deprecated private String paymentIp; - @SerializedName("billing_descriptor") + /** + * An optional description displayed on the customer's statement identifying a purchase. + * [Optional] + */ private BillingDescriptor billingDescriptor; + /** + * A reference you can use to identify the payment, such as an order number. + * [Optional] + */ private String reference; + /** + * A description of the payment. + * [Optional] + * max 100 characters + */ private String description; - @SerializedName("display_name") + /** + * The merchant name to display to customers on the checkout page. + * [Optional] + */ private String displayName; - @SerializedName("processing_channel_id") + /** + * The processing channel to be used for the payment. + * [Optional] + * Pattern: ^(pc)_(\w{26})$ + */ private String processingChannelId; - @SerializedName("amount_allocations") + /** + * The amount allocations for marketplace or split payments. + * [Optional] + */ private List amountAllocations; - @SerializedName("expires_in") + /** + * The time for which the Payment Link remains valid, in seconds. + * [Optional] + */ private Integer expiresIn; + /** + * The customer details. + * [Optional] + */ private CustomerRequest customer; + /** + * The shipping details. + * [Optional] + */ private ShippingDetails shipping; + /** + * The recipient of the payment. Used for financial regulations compliance. + * [Optional] + */ private PaymentRecipient recipient; + /** + * Use the processing object to influence or override data during payment processing. + * [Optional] + */ private ProcessingSettings processing; - @SerializedName("allow_payment_methods") + /** + * Specifies which payment method options to present to the customer. + * [Optional] + */ private List allowPaymentMethods; - @SerializedName("disabled_payment_methods") + /** + * Specifies which payment method options to hide from the customer. + * [Optional] + */ private List disabledPaymentMethods; + /** + * The line items or products included in the purchase. + * [Optional] + */ private List products; + /** + * Key-value pairs to store additional information about the transaction. + * [Optional] + */ private Map metadata; + /** + * The 3D Secure (3DS) authentication configuration for the payment. + * [Optional] + */ @SerializedName("3ds") private ThreeDSRequest threeDS; + /** + * The risk assessment configuration for the payment. + * [Optional] + */ private RiskRequest risk; - @SerializedName("customer_retry") + /** + * The customer retry configuration for failed payments. + * [Optional] + */ private PaymentRetryRequest customerRetry; + /** + * The sender of the payment. Required for financial regulations in some jurisdictions. + * [Optional] + */ private PaymentSender sender; - @SerializedName("return_url") + /** + * If provided, the success page will include a button that redirects the customer to this URL. + * [Optional] + */ private String returnUrl; + /** + * Creates a translated version of the hosted page in the specified language. + * [Optional] + */ private LocaleType locale; + /** + * Whether to capture the payment immediately (if applicable). + * [Optional] + */ private boolean capture; - @SerializedName("capture_on") + /** + * The date and time at which the payment should be captured (ISO 8601). + * [Optional] + * Format: date-time (RFC 3339) + */ private Instant captureOn; + /** + * The payment instruction details, such as purpose of payment. + * [Optional] + */ private PaymentInstruction instruction; - @SerializedName("payment_method_configuration") + /** + * The payment method configuration for stored card and wallet methods. + * [Optional] + */ private PaymentMethodConfiguration paymentMethodConfiguration; } diff --git a/src/main/java/com/checkout/payments/request/DowntimeRetryRequest.java b/src/main/java/com/checkout/payments/request/DowntimeRetryRequest.java new file mode 100644 index 00000000..422ace8d --- /dev/null +++ b/src/main/java/com/checkout/payments/request/DowntimeRetryRequest.java @@ -0,0 +1,20 @@ +package com.checkout.payments.request; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public final class DowntimeRetryRequest { + + /** + * Whether downtime retries are enabled. + * [Optional] + */ + private Boolean enabled; + +} diff --git a/src/main/java/com/checkout/payments/request/DunningRetryRequest.java b/src/main/java/com/checkout/payments/request/DunningRetryRequest.java new file mode 100644 index 00000000..ee2d2226 --- /dev/null +++ b/src/main/java/com/checkout/payments/request/DunningRetryRequest.java @@ -0,0 +1,32 @@ +package com.checkout.payments.request; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public final class DunningRetryRequest { + + /** + * Whether dunning retries are enabled. + * [Optional] + */ + private Boolean enabled; + + /** + * The maximum number of retry attempts. + * [Optional] + */ + private Integer maxAttempts; + + /** + * The number of days after which retries stop. + * [Optional] + */ + private Integer endAfterDays; + +} diff --git a/src/main/java/com/checkout/payments/request/PaymentRequest.java b/src/main/java/com/checkout/payments/request/PaymentRequest.java index 0abe92b8..7bd5158f 100644 --- a/src/main/java/com/checkout/payments/request/PaymentRequest.java +++ b/src/main/java/com/checkout/payments/request/PaymentRequest.java @@ -30,120 +30,249 @@ @Data @Builder public final class PaymentRequest { - - @SerializedName("payment_context_id") + + /** + * The unique identifier of a Payment Context. Used to initiate a payment from a context. + * [Optional] + */ private String paymentContextId; + /** + * The source of the payment. Discriminated by type. + * [Optional] + */ private AbstractRequestSource source; + /** + * The payment amount in minor currency units. To perform a card verification, do not provide + * the amount or provide a value of 0. + * [Optional] + * min 0 + */ private Long amount; + /** + * The three-letter ISO currency code of the payment. + * [Required] + * min 3 characters, max 3 characters + */ private Currency currency; + /** + * The type of payment. Required for card payments where the cardholder is not present, + * such as recurring or MOTO payments. For MITs, must not be set to Regular. + * [Optional] + * Enum: "Regular" "Recurring" "MOTO" "Installment" "PayLater" "Unscheduled" + */ @Builder.Default - @SerializedName("payment_type") private PaymentType paymentType = PaymentType.REGULAR; - @SerializedName("payment_plan") + /** + * The details of a recurring subscription or installment. + * [Optional] + */ private PaymentPlan paymentPlan; - @SerializedName("merchant_initiated") + /** + * Whether the payment is a merchant-initiated transaction (MIT). + * Must be set to true for all MITs. If true, payment_type must not be Regular. + * [Optional] + */ private Boolean merchantInitiated; + /** + * A reference you can use to identify the payment, such as an order number. + * [Optional] + * max 80 characters + */ private String reference; + /** + * A description of the payment. + * [Optional] + * max 100 characters + */ private String description; + /** + * Information required to authenticate the payment. + * [Optional] + */ private Authentication authentication; - @SerializedName("authorization_type") + /** + * The authorization type for the payment. + * [Optional] + * Enum: "Final" "Estimated" + */ private AuthorizationType authorizationType; - @SerializedName("partial_authorization") + /** + * The partial authorization configuration for the payment. + * [Optional] + */ private PartialAuthorization partialAuthorization; + /** + * Whether to capture the payment immediately (if applicable). + * [Optional] + */ private Boolean capture; - @SerializedName("capture_on") + /** + * A timestamp (ISO 8601) that determines when the payment should be captured. + * Providing this field will automatically set capture to true. + * [Optional] + * Format: date-time (RFC 3339) + */ private Instant captureOn; /** * The date and time when the Multibanco payment expires in UTC. - *

* [Optional] - *

* Format: date-time (ISO 8601) */ - @SerializedName("expire_on") private Instant expireOn; + /** + * The customer details for the payment. + * [Optional] + */ private CustomerRequest customer; - @SerializedName("billing_descriptor") + /** + * An optional description displayed on the customer's statement identifying a purchase. + * [Optional] + */ private BillingDescriptor billingDescriptor; + /** + * The shipping details for the payment. + * [Optional] + */ private ShippingDetails shipping; + /** + * Information required for 3D Secure authentication payments. + * [Optional] + */ @SerializedName("3ds") private ThreeDSRequest threeDS; - @SerializedName("processing_channel_id") + /** + * The processing channel to be used for the payment. + * [Optional] + * Pattern: ^(pc)_(\w{26})$ + */ private String processingChannelId; - @SerializedName("previous_payment_id") + /** + * An identifier that links the payment to an existing series of payments. + * Only pass this field for merchant-initiated transactions (MITs) in a recurring payment series. + * [Optional] + * max 100 characters + */ private String previousPaymentId; + /** + * The risk assessment configuration for the payment. + * [Optional] + */ private RiskRequest risk; - @SerializedName("success_url") + /** + * For redirect payment methods, overrides the default success redirect URL configured on your account. + * [Optional] + * Format: uri + * max 1024 characters + */ private String successUrl; - @SerializedName("failure_url") + /** + * For redirect payment methods, overrides the default failure redirect URL configured on your account. + * [Optional] + * Format: uri + * max 1024 characters + */ private String failureUrl; - @SerializedName("payment_ip") + /** + * @deprecated Deprecated in the API on 2025-03-11. Use {@code risk.device.network.ipv4} or {@code risk.device.network.ipv6} instead. + */ + @Deprecated private String paymentIp; + /** + * The sender of the payment. Required for financial regulations in some jurisdictions. + * [Optional] + */ private PaymentSender sender; + /** + * The recipient of the payment. Used for financial regulations compliance. + * [Optional] + */ private PaymentRecipient recipient; /** - * @deprecated This property will be removed in the future, and should be used - * {@link PaymentRequest#amountAllocations} instead + * @deprecated Use {@link PaymentRequest#amountAllocations} instead. */ @Deprecated private MarketplaceData marketplace; - @SerializedName("amount_allocations") + /** + * The amount allocations for marketplace or split payments. + * [Optional] + */ private List amountAllocations; + /** + * Use the processing object to influence or override data during payment processing. + * [Optional] + */ private ProcessingSettings processing; + /** + * The line items or products included in the purchase. + * [Optional] + */ private List items; + /** + * The retry configuration for failed payment attempts. + * [Optional] + */ private PaymentRetryRequest retry; /** - * The details of the subscription. - *

+ * The details of the subscription associated with this payment. * [Optional] - *

*/ private PaymentSubscription subscription; + /** + * Key-value pairs to store additional information about the transaction. + * Supports string, number, and boolean fields. Max 20 fields; each value max 255 characters. + * [Optional] + */ @Builder.Default private Map metadata = new HashMap<>(); + /** + * The segment data for the payment, used for analytics and reporting. + * [Optional] + */ private PaymentSegment segment; + /** + * The payment instruction details, such as purpose of payment. + * [Optional] + */ private PaymentInstruction instruction; /** * Controls processor attempts at the payment level. - *

* [Optional] - *

*/ private PaymentRouting routing; diff --git a/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java b/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java index 9b9a05ee..0603d866 100644 --- a/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java +++ b/src/main/java/com/checkout/payments/request/PaymentRetryRequest.java @@ -1,6 +1,5 @@ package com.checkout.payments.request; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -12,12 +11,38 @@ @NoArgsConstructor public final class PaymentRetryRequest { + /** + * Configuration of asynchronous Dunning retries. + * [Optional] + */ + private DunningRetryRequest dunning; + + /** + * Configuration of asynchronous Downtime retries. + * [Optional] + */ + private DowntimeRetryRequest downtime; + + // ======================================== + // Deprecated — use dunning.enabled instead + // ======================================== + + /** + * @deprecated Use {@link DunningRetryRequest#enabled} via {@link #dunning} instead. + */ + @Deprecated private Boolean enabled; - @SerializedName("max_attempts") + /** + * @deprecated Use {@link DunningRetryRequest#maxAttempts} via {@link #dunning} instead. + */ + @Deprecated private Integer maxAttempts; - @SerializedName("end_after_days") + /** + * @deprecated Use {@link DunningRetryRequest#endAfterDays} via {@link #dunning} instead. + */ + @Deprecated private Integer endAfterDays; } diff --git a/src/main/java/com/checkout/payments/request/PayoutRequest.java b/src/main/java/com/checkout/payments/request/PayoutRequest.java index cbb7e39f..4ebfc314 100644 --- a/src/main/java/com/checkout/payments/request/PayoutRequest.java +++ b/src/main/java/com/checkout/payments/request/PayoutRequest.java @@ -5,7 +5,6 @@ import com.checkout.payments.request.destination.PaymentRequestDestination; import com.checkout.payments.request.source.PayoutRequestSource; import com.checkout.payments.sender.PaymentSender; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.Data; @@ -15,28 +14,82 @@ @Builder public final class PayoutRequest { + /** + * The source of the payout. Discriminated by type. + * [Required] + */ private PayoutRequestSource source; + /** + * The destination of the payout. Discriminated by type. + * [Required] + */ private PaymentRequestDestination destination; + /** + * The amount to pay out in minor currency units. + * [Optional] + * min 0 + */ private Long amount; + /** + * The three-letter ISO 4217 currency code for the payout currency. + * [Required] + */ private Currency currency; + /** + * A custom reference to identify the payout, such as an order number. + * [Optional] + * max 50 characters + */ private String reference; - @SerializedName("billing_descriptor") + /** + * An optional description displayed on the recipient's statement identifying the payout. + * [Optional] + */ private PayoutBillingDescriptor billingDescriptor; + /** + * The sender of the payout. Required for financial regulations in some jurisdictions. + * [Optional] + */ private PaymentSender sender; + /** + * Additional details about the payout instruction, such as purpose of payment. + * [Required] + */ private PaymentInstruction instruction; - @SerializedName("processing_channel_id") + /** + * The processing channel to be used for the payout. + * [Required] + * Pattern: ^(pc)_(\w{26})$ + * max 29 characters + */ private String processingChannelId; + /** + * Use the processing object to influence or override data during payout processing. + * [Optional] + */ private ProcessingSettings processing; + /** + * The business segment dimension details for this payout. + * At least one dimension (brand, business_category, or market) required. + * [Optional] + */ + private PaymentSegment segment; + + /** + * Key-value pairs to store additional information about the payout. + * Supports primitive data types only; objects and arrays are not supported. + * [Optional] + */ private Map metadata; } diff --git a/src/main/java/com/checkout/payments/request/source/AbstractRequestSource.java b/src/main/java/com/checkout/payments/request/source/AbstractRequestSource.java index f6f31bde..47e56c89 100644 --- a/src/main/java/com/checkout/payments/request/source/AbstractRequestSource.java +++ b/src/main/java/com/checkout/payments/request/source/AbstractRequestSource.java @@ -6,6 +6,10 @@ @Data public abstract class AbstractRequestSource { + /** + * The payment source type. + * [Required] + */ protected final PaymentSourceType type; protected AbstractRequestSource(final PaymentSourceType type) { diff --git a/src/main/java/com/checkout/payments/request/source/PayoutRequestCurrencyAccountSource.java b/src/main/java/com/checkout/payments/request/source/PayoutRequestCurrencyAccountSource.java index 5446f09c..c8a60c0c 100644 --- a/src/main/java/com/checkout/payments/request/source/PayoutRequestCurrencyAccountSource.java +++ b/src/main/java/com/checkout/payments/request/source/PayoutRequestCurrencyAccountSource.java @@ -12,6 +12,10 @@ @ToString(callSuper = true) public final class PayoutRequestCurrencyAccountSource extends PayoutRequestSource { + /** + * The currency account identifier. + * [Required] + */ private String id; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/PayoutRequestEntitySource.java b/src/main/java/com/checkout/payments/request/source/PayoutRequestEntitySource.java index 8e94e2d1..22efa909 100644 --- a/src/main/java/com/checkout/payments/request/source/PayoutRequestEntitySource.java +++ b/src/main/java/com/checkout/payments/request/source/PayoutRequestEntitySource.java @@ -12,6 +12,10 @@ @ToString(callSuper = true) public final class PayoutRequestEntitySource extends PayoutRequestSource { + /** + * The entity identifier. + * [Required] + */ private String id; @Builder @@ -25,4 +29,4 @@ public PayoutRequestEntitySource() { super(PayoutSourceType.ENTITY); } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/request/source/PayoutRequestSource.java b/src/main/java/com/checkout/payments/request/source/PayoutRequestSource.java index cdfdedcf..5aae2188 100644 --- a/src/main/java/com/checkout/payments/request/source/PayoutRequestSource.java +++ b/src/main/java/com/checkout/payments/request/source/PayoutRequestSource.java @@ -7,8 +7,16 @@ @AllArgsConstructor public abstract class PayoutRequestSource { + /** + * The payout source type. + * [Required] + */ protected PayoutSourceType type; + /** + * The amount to debit from the source. If not provided, the full payment amount is used. + * [Optional] + */ protected Long amount; protected PayoutRequestSource(final PayoutSourceType type) { diff --git a/src/main/java/com/checkout/payments/request/source/RequestBankAccountSource.java b/src/main/java/com/checkout/payments/request/source/RequestBankAccountSource.java index 87ef573d..d0f6ffa7 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestBankAccountSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestBankAccountSource.java @@ -4,7 +4,6 @@ import com.checkout.common.AccountType; import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -17,21 +16,40 @@ @ToString(callSuper = true) public final class RequestBankAccountSource extends AbstractRequestSource { - @SerializedName("payment_method") + /** + * The payment method to use. For example, "ach". + * [Optional] + */ private String paymentMethod; - @SerializedName("account_type") + /** + * The type of account. + * [Optional] + */ private AccountType accountType; + /** + * The two-letter ISO country code of the bank account. + * [Optional] + */ private CountryCode country; - @SerializedName("account_number") + /** + * The account number. + * [Optional] + */ private String accountNumber; - @SerializedName("bank_code") + /** + * The bank routing code. + * [Optional] + */ private String bankCode; - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; public RequestBankAccountSource() { diff --git a/src/main/java/com/checkout/payments/request/source/RequestCardSource.java b/src/main/java/com/checkout/payments/request/source/RequestCardSource.java index ddd352c0..d3ab9930 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestCardSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestCardSource.java @@ -4,7 +4,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.common.Phone; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -17,29 +16,64 @@ @ToString(callSuper = true) public final class RequestCardSource extends AbstractRequestSource { + /** + * The card number (without separators). Write-only. + * [Optional] + */ private String number; - @SerializedName("expiry_month") + /** + * The expiry month of the card. + * [Optional] + */ private Integer expiryMonth; - @SerializedName("expiry_year") + /** + * The expiry year of the card. + * [Optional] + */ private Integer expiryYear; + /** + * The cardholder's name. Write-only. + * [Optional] + */ private String name; + /** + * The card verification value/code. 3 digits, except for American Express (4 digits). Write-only. + * [Optional] + */ private String cvv; + /** + * Set to true for payments that use stored card details. Write-only. + * [Optional] + */ private Boolean stored; - @SerializedName("store_for_future_use") + /** + * Set to true if you intend to reuse the payment credentials in subsequent payments. Write-only. + * [Optional] + */ private Boolean storeForFutureUse; - @SerializedName("billing_address") + /** + * The payment source owner's billing address. + * [Optional] + */ private Address billingAddress; + /** + * The payment source owner's phone number. + * [Optional] + */ private Phone phone; - @SerializedName("account_holder") + /** + * The card account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/RequestCustomerSource.java b/src/main/java/com/checkout/payments/request/source/RequestCustomerSource.java index 55b44694..024ad23d 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestCustomerSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestCustomerSource.java @@ -1,8 +1,9 @@ package com.checkout.payments.request.source; import com.checkout.common.AccountHolder; +import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; -import com.google.gson.annotations.SerializedName; +import com.checkout.common.Phone; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -15,17 +16,49 @@ @ToString(callSuper = true) public final class RequestCustomerSource extends AbstractRequestSource { + /** + * The unique identifier of an existing customer. + * [Optional] + * Pattern: ^(cus)_(\w{26})$ + */ private String id; - @SerializedName("account_holder") + /** + * The customer's billing address. + * [Optional] + */ + private Address billingAddress; + + /** + * The customer's phone number. + * [Optional] + */ + private Phone phone; + + /** + * The account holder information for the customer. + * [Optional] + */ private AccountHolder accountHolder; + /** + * Whether to update the stored customer information with the data provided. + * [Optional] + */ + private Boolean allowUpdate; + @Builder private RequestCustomerSource(final String id, - final AccountHolder accountHolder) { + final Address billingAddress, + final Phone phone, + final AccountHolder accountHolder, + final Boolean allowUpdate) { super(PaymentSourceType.CUSTOMER); this.id = id; + this.billingAddress = billingAddress; + this.phone = phone; this.accountHolder = accountHolder; + this.allowUpdate = allowUpdate; } public RequestCustomerSource() { diff --git a/src/main/java/com/checkout/payments/request/source/RequestIdSource.java b/src/main/java/com/checkout/payments/request/source/RequestIdSource.java index aa1c66a8..aeebbd4b 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestIdSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestIdSource.java @@ -1,8 +1,9 @@ package com.checkout.payments.request.source; import com.checkout.common.AccountHolder; +import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; -import com.google.gson.annotations.SerializedName; +import com.checkout.common.Phone; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -15,35 +16,82 @@ @ToString(callSuper = true) public final class RequestIdSource extends AbstractRequestSource { + /** + * The payment instrument identifier. + * [Required] + * Pattern: ^(src)_(\w{26})$ + */ private String id; + /** + * The card verification value (CVV) of the card. + * [Optional] + * min 3 characters, max 4 characters + */ private String cvv; - @SerializedName("payment_method") + /** + * The payment method to be used. + * [Optional] + */ private String paymentMethod; + /** + * Whether this payment instrument was previously stored for future use. + * [Optional] + */ private Boolean stored; - @SerializedName("store_for_future_use") + /** + * Whether to store the payment instrument for future use. + * [Optional] + */ private Boolean storeForFutureUse; - @SerializedName("account_holder") + /** + * The billing address associated with the payment instrument. + * [Optional] + */ + private Address billingAddress; + + /** + * The phone number associated with the payment instrument. + * [Optional] + */ + private Phone phone; + + /** + * The account holder information for the payment instrument. + * [Optional] + */ private AccountHolder accountHolder; + /** + * Whether to update the stored instrument information with the data provided. + * [Optional] + */ + private Boolean allowUpdate; + @Builder private RequestIdSource(final String id, final String cvv, final String paymentMethod, final Boolean stored, final Boolean storeForFutureUse, - final AccountHolder accountHolder) { + final Address billingAddress, + final Phone phone, + final AccountHolder accountHolder, + final Boolean allowUpdate) { super(PaymentSourceType.ID); this.id = id; this.cvv = cvv; this.paymentMethod = paymentMethod; this.stored = stored; this.storeForFutureUse = storeForFutureUse; + this.billingAddress = billingAddress; + this.phone = phone; this.accountHolder = accountHolder; + this.allowUpdate = allowUpdate; } public RequestIdSource() { diff --git a/src/main/java/com/checkout/payments/request/source/RequestNetworkTokenSource.java b/src/main/java/com/checkout/payments/request/source/RequestNetworkTokenSource.java index 352c2968..e23ff339 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestNetworkTokenSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestNetworkTokenSource.java @@ -4,7 +4,6 @@ import com.checkout.common.Address; import com.checkout.common.Phone; import com.checkout.payments.NetworkTokenType; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -19,36 +18,82 @@ @ToString(callSuper = true) public final class RequestNetworkTokenSource extends AbstractRequestSource { + /** + * The network token value. + * [Optional] + */ private String token; - @SerializedName("expiry_month") + /** + * The expiry month of the token. + * [Optional] + */ private Integer expiryMonth; - @SerializedName("expiry_year") + /** + * The expiry year of the token. + * [Optional] + */ private Integer expiryYear; - @SerializedName("token_type") + /** + * The network token type. + * [Optional] + */ private NetworkTokenType tokenType; + /** + * The cryptogram for the network token (device pan). Required for Visa and Mastercard DPAN payments. + * [Optional] + */ private String cryptogram; + /** + * The Electronic Commerce Indicator (ECI) security level. + * [Optional] + */ private String eci; + /** + * Set to true for payments that use stored card details. Write-only. + * [Optional] + */ private Boolean stored; - @SerializedName("store_for_future_use") + /** + * Set to true if you intend to reuse the payment credentials in subsequent payments. Write-only. + * [Optional] + */ private Boolean storeForFutureUse; + /** + * The cardholder's name. Write-only. + * [Optional] + */ private String name; + /** + * The card verification value/code. 3 digits, except for American Express (4 digits). Write-only. + * [Optional] + */ private String cvv; - @SerializedName("billing_address") + /** + * The payment source owner's billing address. + * [Optional] + */ private Address billingAddress; + /** + * The payment source owner's phone number. + * [Optional] + */ private Phone phone; - @SerializedName("account_holder") + /** + * The card account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/RequestProviderTokenSource.java b/src/main/java/com/checkout/payments/request/source/RequestProviderTokenSource.java index dbb6c65f..25d8bc73 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestProviderTokenSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestProviderTokenSource.java @@ -2,7 +2,6 @@ import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -15,12 +14,22 @@ @ToString(callSuper = true) public final class RequestProviderTokenSource extends AbstractRequestSource { - @SerializedName("payment_method") + /** + * The payment method to use. + * [Optional] + */ private String paymentMethod; + /** + * The provider token value. + * [Optional] + */ private String token; - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/RequestTokenSource.java b/src/main/java/com/checkout/payments/request/source/RequestTokenSource.java index 07e10fba..45a2f698 100644 --- a/src/main/java/com/checkout/payments/request/source/RequestTokenSource.java +++ b/src/main/java/com/checkout/payments/request/source/RequestTokenSource.java @@ -4,7 +4,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.common.Phone; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -17,19 +16,40 @@ @ToString(callSuper = true) public final class RequestTokenSource extends AbstractRequestSource { + /** + * The Checkout.com token value. + * [Optional] + */ private String token; - @SerializedName("billing_address") + /** + * The payment source owner's billing address. + * [Optional] + */ private Address billingAddress; + /** + * The payment source owner's phone number. + * [Optional] + */ private Phone phone; + /** + * Set to true for payments that use stored card details. Write-only. + * [Optional] + */ private Boolean stored; - @SerializedName("store_for_future_use") + /** + * Set to true if you intend to reuse the payment credentials in subsequent payments. Write-only. + * [Optional] + */ private Boolean storeForFutureUse; - @SerializedName("account_holder") + /** + * The card account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/MandateType.java b/src/main/java/com/checkout/payments/request/source/apm/MandateType.java new file mode 100644 index 00000000..08e89309 --- /dev/null +++ b/src/main/java/com/checkout/payments/request/source/apm/MandateType.java @@ -0,0 +1,13 @@ +package com.checkout.payments.request.source.apm; + +import com.google.gson.annotations.SerializedName; + +public enum MandateType { + + @SerializedName("Core") + CORE, + + @SerializedName("B2B") + B2B, + +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestAchSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestAchSource.java index 231975d5..10a68a15 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestAchSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestAchSource.java @@ -5,7 +5,6 @@ import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -18,19 +17,39 @@ @ToString(callSuper = true) public final class RequestAchSource extends AbstractRequestSource { - @SerializedName("account_type") + /** + * The type of Direct Debit account. + * [Required] + * Enum: "savings" "checking" "cash" + */ private AccountType accountType; - @SerializedName("country") + /** + * The source country as an ISO 3166-1 alpha-2 code. + * [Required] + * min 2 characters, max 2 characters + */ private CountryCode country; - @SerializedName("account_number") + /** + * The account number of the Direct Debit account. + * [Required] + * min 4 characters, max 17 characters + */ private String accountNumber; - @SerializedName("bank_code") + /** + * The bank code (ABA routing number) of the Direct Debit account. + * [Required] + * min 8 characters, max 9 characters + */ private String bankCode; - @SerializedName("account_holder") + /** + * The account holder's personal information. + * Supports date_of_birth and identification (SSN) fields. + * [Required] + */ private AccountHolder accountHolder; @Builder @@ -51,4 +70,4 @@ private RequestAchSource( public RequestAchSource() { super(PaymentSourceType.ACH); } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestAfterPaySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestAfterPaySource.java index c49cfe7c..9edea45c 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestAfterPaySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestAfterPaySource.java @@ -3,7 +3,6 @@ import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,7 +15,10 @@ @ToString(callSuper = true) public final class RequestAfterPaySource extends AbstractRequestSource { - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestAlmaSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestAlmaSource.java index 2b58f2d3..06b6b728 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestAlmaSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestAlmaSource.java @@ -3,7 +3,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,7 +15,10 @@ @ToString(callSuper = true) public final class RequestAlmaSource extends AbstractRequestSource { - @SerializedName("billing_address") + /** + * The customer's billing address. + * [Optional] + */ private Address billingAddress; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestBancontactSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestBancontactSource.java index f199a370..4e09d30c 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestBancontactSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestBancontactSource.java @@ -3,7 +3,6 @@ import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,15 +15,29 @@ @ToString(callSuper = true) public final class RequestBancontactSource extends AbstractRequestSource { - @SerializedName("payment_country") + /** + * The two-letter ISO country code of the payment. + * [Optional] + */ private CountryCode paymentCountry; - @SerializedName("account_holder_name") + /** + * The account holder's name. + * [Optional] + * min 3 max 100 + */ private String accountHolderName; - @SerializedName("billing_descriptor") + /** + * A description of the purchase shown on the customer's statement. + * [Optional] + */ private String billingDescriptor; + /** + * The language to display the payment page in. + * [Optional] + */ private String language; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestBizumSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestBizumSource.java index eeae284e..180f0052 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestBizumSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestBizumSource.java @@ -2,7 +2,6 @@ import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -15,7 +14,12 @@ @ToString(callSuper = true) public final class RequestBizumSource extends AbstractRequestSource { - @SerializedName("mobile_number") + /** + * The customer's mobile number. + * [Optional] + * @deprecated Removed from the API on 2025/02/10. Use the customer object instead. + */ + @Deprecated private String mobileNumber; @Builder @@ -27,4 +31,4 @@ private RequestBizumSource(final String mobileNumber) { public RequestBizumSource() { super(PaymentSourceType.BIZUM); } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestCvConnectSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestCvConnectSource.java index 4c16b194..c2481d80 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestCvConnectSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestCvConnectSource.java @@ -3,7 +3,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,7 +15,10 @@ @ToString(callSuper = true) public final class RequestCvConnectSource extends AbstractRequestSource { - @SerializedName("billing_address") + /** + * The customer's billing address. + * [Optional] + */ private Address billingAddress; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestEpsSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestEpsSource.java index e838fab3..69fb81c6 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestEpsSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestEpsSource.java @@ -3,7 +3,6 @@ import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,9 +15,16 @@ @ToString(callSuper = true) public final class RequestEpsSource extends AbstractRequestSource { + /** + * The purpose of the payment. + * [Optional] + */ private String purpose; - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestFawrySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestFawrySource.java index a2cb0b09..5a9e44c1 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestFawrySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestFawrySource.java @@ -21,20 +21,41 @@ @ToString(callSuper = true) public final class RequestFawrySource extends AbstractRequestSource { + /** + * The description of the payment. + * [Optional] + */ private String description; - @SerializedName("customer_profile_id") + /** + * The customer's profile ID. + * [Optional] + */ private String customerProfileId; - @SerializedName("customer_email") + /** + * The customer's email address. + * [Optional] + */ private String customerEmail; - @SerializedName("customer_mobile") + /** + * The customer's mobile number. + * [Optional] + */ private String customerMobile; - @SerializedName("expires_on") + /** + * The timestamp after which the payment expires. + * [Optional] + * Format: date-time (ISO 8601) + */ private Instant expiresOn; + /** + * The products included in the order. + * [Optional] + */ private List products; @Builder @@ -63,15 +84,31 @@ public RequestFawrySource() { @AllArgsConstructor public static class Product { + /** + * The product identifier. + * [Optional] + */ @SerializedName("product_id") private String id; + /** + * The quantity of the product. + * [Optional] + */ private Long quantity; + /** + * The price of the product in minor currency units. + * [Optional] + */ private Long price; + /** + * The description of the product. + * [Optional] + */ private String description; } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java index 3378d909..aabaeaec 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestGiropaySource.java @@ -3,7 +3,6 @@ import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -22,19 +21,25 @@ public final class RequestGiropaySource extends AbstractRequestSource { /** + * The purpose of the payment. + * [Optional] * @deprecated GiroPay doesn't support this field anymore, will be removed in the future */ @Deprecated private String purpose; /** + * Additional information fields for the payment. + * [Optional] * @deprecated GiroPay doesn't support this field anymore, will be removed in the future */ @Deprecated - @SerializedName("info_fields") private List infoFields; - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder @@ -56,7 +61,17 @@ public RequestGiropaySource() { @NoArgsConstructor @AllArgsConstructor public static class InfoFields { + + /** + * The label for the information field. + * [Optional] + */ private String label; + + /** + * The text content of the information field. + * [Optional] + */ private String text; } diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestIdealSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestIdealSource.java index 69473f41..6427c50b 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestIdealSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestIdealSource.java @@ -14,8 +14,17 @@ @ToString(callSuper = true) public final class RequestIdealSource extends AbstractRequestSource { + /** + * A description of the payment shown to the customer. + * [Optional] + * max 35 characters + */ private String description; + /** + * The language to display the payment page in. + * [Optional] + */ private String language; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestIllicadoSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestIllicadoSource.java index ab836d78..c41cbde1 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestIllicadoSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestIllicadoSource.java @@ -11,6 +11,10 @@ @ToString(callSuper = true) public final class RequestIllicadoSource extends AbstractRequestSource { + /** + * The customer's billing address. + * [Optional] + */ private Address billingAddress; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestKlarnaSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestKlarnaSource.java index fe2cc1e9..2ffd7f97 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestKlarnaSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestKlarnaSource.java @@ -3,7 +3,6 @@ import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,15 +15,16 @@ @ToString(callSuper = true) public final class RequestKlarnaSource extends AbstractRequestSource { - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; - @Builder private RequestKlarnaSource(final AccountHolder accountHolder) { super(PaymentSourceType.KLARNA); this.accountHolder = accountHolder; - } public RequestKlarnaSource() { diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestKnetSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestKnetSource.java index fd6efb9a..b0e06813 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestKnetSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestKnetSource.java @@ -4,7 +4,6 @@ import com.checkout.payments.PaymentMethodDetails; import com.checkout.payments.request.source.AbstractRequestSource; import com.checkout.tokens.ApplePayTokenData; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -17,35 +16,70 @@ @ToString(callSuper = true) public final class RequestKnetSource extends AbstractRequestSource { + /** + * The language to display the payment page in. + * [Optional] + */ private String language; - @SerializedName("user_defined_field1") + /** + * User-defined field 1. + * [Optional] + */ private String userDefinedField1; - @SerializedName("user_defined_field2") + /** + * User-defined field 2. + * [Optional] + */ private String userDefinedField2; - @SerializedName("user_defined_field3") + /** + * User-defined field 3. + * [Optional] + */ private String userDefinedField3; - @SerializedName("user_defined_field4") + /** + * User-defined field 4. + * [Optional] + */ private String userDefinedField4; - @SerializedName("user_defined_field5") + /** + * User-defined field 5. + * [Optional] + */ private String userDefinedField5; - @SerializedName("card_token") + /** + * The card token for the payment. + * [Optional] + */ private String cardToken; + /** + * The PTLF value. + * [Optional] + */ private String ptlf; - @SerializedName("token_type") + /** + * The type of token. + * [Optional] + */ private String tokenType; - @SerializedName("token_data") + /** + * The token data for Apple Pay payments. + * [Optional] + */ private ApplePayTokenData tokenData; - @SerializedName("payment_method_details") + /** + * Additional payment method details. + * [Optional] + */ private PaymentMethodDetails paymentMethodDetails; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestMultiBancoSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestMultiBancoSource.java index f5fc127d..498ac7ab 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestMultiBancoSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestMultiBancoSource.java @@ -3,7 +3,6 @@ import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,13 +15,23 @@ @ToString(callSuper = true) public final class RequestMultiBancoSource extends AbstractRequestSource { - @SerializedName("payment_country") + /** + * The two-letter ISO country code of the payment. + * [Optional] + */ private CountryCode paymentCountry; - @SerializedName("account_holder_name") + /** + * The account holder's name. + * [Optional] + * min 3 max 100 + */ private String accountHolderName; - @SerializedName("billing_descriptor") + /** + * A description of the purchase shown on the customer's statement. + * [Optional] + */ private String billingDescriptor; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestP24Source.java b/src/main/java/com/checkout/payments/request/source/apm/RequestP24Source.java index 0216afb0..1feadf0b 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestP24Source.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestP24Source.java @@ -3,7 +3,6 @@ import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,16 +15,29 @@ @ToString(callSuper = true) public final class RequestP24Source extends AbstractRequestSource { - @SerializedName("payment_country") + /** + * The two-letter ISO country code of the payment. + * [Optional] + */ private CountryCode paymentCountry; - @SerializedName("account_holder_name") + /** + * The account holder's name. + * [Optional] + * min 3 max 100 + */ private String accountHolderName; - @SerializedName("account_holder_email") + /** + * The account holder's email address. + * [Optional] + */ private String accountHolderEmail; - @SerializedName("billing_descriptor") + /** + * A description of the purchase shown on the customer's statement. + * [Optional] + */ private String billingDescriptor; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestPayPalSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestPayPalSource.java index 3d1d2a41..ceec52c7 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestPayPalSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestPayPalSource.java @@ -15,6 +15,10 @@ @ToString(callSuper = true) public final class RequestPayPalSource extends AbstractRequestSource { + /** + * The billing plan details for recurring PayPal payments. + * [Optional] + */ private BillingPlan plan; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestPlaidSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestPlaidSource.java index 730d1537..4c03c49c 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestPlaidSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestPlaidSource.java @@ -3,7 +3,6 @@ import com.checkout.common.AccountHolder; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,10 +15,16 @@ @ToString(callSuper = true) public final class RequestPlaidSource extends AbstractRequestSource { - @SerializedName("token") + /** + * The Plaid processor token. + * [Optional] + */ private String token; - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; @Builder @@ -32,4 +37,4 @@ private RequestPlaidSource(final String token, final AccountHolder accountHolder public RequestPlaidSource() { super(PaymentSourceType.PLAID); } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestPostFinanceSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestPostFinanceSource.java index 99400a20..eb4be737 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestPostFinanceSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestPostFinanceSource.java @@ -3,7 +3,6 @@ import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,13 +15,22 @@ @ToString(callSuper = true) public final class RequestPostFinanceSource extends AbstractRequestSource { - @SerializedName("payment_country") + /** + * The two-letter ISO country code of the payment. + * [Optional] + */ private CountryCode paymentCountry; - @SerializedName("account_holder_name") + /** + * The account holder's name. + * [Optional] + */ private String accountHolderName; - @SerializedName("billing_descriptor") + /** + * A description of the purchase shown on the customer's statement. + * [Optional] + */ private String billingDescriptor; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestQPaySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestQPaySource.java index 990c34ba..78ecf1d0 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestQPaySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestQPaySource.java @@ -2,7 +2,6 @@ import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -15,13 +14,29 @@ @ToString(callSuper = true) public final class RequestQPaySource extends AbstractRequestSource { + /** + * The number of items in the order. + * [Optional] + */ private Integer quantity; + /** + * A description of the payment. + * [Optional] + * max 255 + */ private String description; + /** + * The language to display the payment page in. + * [Optional] + */ private String language; - @SerializedName("national_id") + /** + * The customer's national ID. + * [Optional] + */ private String nationalId; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestSepaSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestSepaSource.java index 13bbd611..ec86cf4f 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestSepaSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestSepaSource.java @@ -1,9 +1,15 @@ package com.checkout.payments.request.source.apm; -import com.checkout.common.*; +import com.checkout.common.AccountHolder; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; -import lombok.*; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; @Getter @Setter @@ -11,23 +17,53 @@ @ToString(callSuper = true) public final class RequestSepaSource extends AbstractRequestSource { + /** + * The account's country, as an ISO 3166-1 alpha-2 code. + * [Required] + */ private CountryCode country; - @SerializedName("account_number") + /** + * The account holder's IBAN. + * [Required] + */ private String accountNumber; - @SerializedName("bank_code") + /** + * The BIC/SWIFT code of the bank. + * [Optional] + */ private String bankCode; + /** + * The account holder's account currency. + * [Required] + */ private Currency currency; - @SerializedName("mandate_id") + /** + * The ID of the mandate. + * [Optional] + */ private String mandateId; - @SerializedName("date_of_signature") + /** + * The type of mandate. + * [Optional] + * Enum: "Core" "B2B" + */ + private MandateType mandateType; + + /** + * The date the mandate was signed, in the format yyyy-MM-dd. + * [Optional] + */ private String dateOfSignature; - @SerializedName("account_holder") + /** + * The account holder's personal information. + * [Required] + */ private AccountHolder accountHolder; @Builder @@ -37,6 +73,7 @@ private RequestSepaSource( final String bankCode, final Currency currency, final String mandateId, + final MandateType mandateType, final String dateOfSignature, final AccountHolder accountHolder ) { @@ -46,6 +83,7 @@ private RequestSepaSource( this.bankCode = bankCode; this.currency = currency; this.mandateId = mandateId; + this.mandateType = mandateType; this.dateOfSignature = dateOfSignature; this.accountHolder = accountHolder; } diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestSequraSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestSequraSource.java index fa2d3431..295d0e27 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestSequraSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestSequraSource.java @@ -3,7 +3,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,7 +15,10 @@ @ToString(callSuper = true) public final class RequestSequraSource extends AbstractRequestSource { - @SerializedName("billing_address") + /** + * The customer's billing address. + * [Optional] + */ private Address billingAddress; @Builder @@ -28,4 +30,4 @@ private RequestSequraSource(final Address billingAddress) { public RequestSequraSource() { super(PaymentSourceType.SEQURA); } -} \ No newline at end of file +} diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestSofortSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestSofortSource.java index 177a7581..028b5aa7 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestSofortSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestSofortSource.java @@ -3,23 +3,32 @@ import com.checkout.common.CountryCode; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; +/** + * @deprecated Sofort was deprecated as a payment source type on 2024/12/03. + */ +@Deprecated @Getter @Setter @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public final class RequestSofortSource extends AbstractRequestSource { - @SerializedName("countryCode") + /** + * The ISO 3166-1 alpha-2 country code for the Sofort payment. + * [Optional] + */ private CountryCode countryCode; - @SerializedName("languageCode") + /** + * The language code for the Sofort payment. + * [Optional] + */ private String languageCode; @Builder @@ -29,6 +38,7 @@ private RequestSofortSource(final CountryCode countryCode, final String language this.languageCode = languageCode; } + @Deprecated public RequestSofortSource() { super(PaymentSourceType.SOFORT); } diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestSwishSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestSwishSource.java index 5a7a11f1..46813b62 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestSwishSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestSwishSource.java @@ -4,7 +4,6 @@ import com.checkout.common.PaymentSourceType; import com.checkout.payments.BillingDescriptor; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -17,13 +16,22 @@ @ToString(callSuper = true) public final class RequestSwishSource extends AbstractRequestSource { - @SerializedName("payment_country") + /** + * The two-letter ISO country code of the payment. + * [Optional] + */ private String paymentCountry; - @SerializedName("account_holder") + /** + * The account holder's details. + * [Optional] + */ private AccountHolder accountHolder; - @SerializedName("billing_descriptor") + /** + * A description of the purchase shown on the customer's statement. + * [Optional] + */ private BillingDescriptor billingDescriptor; @Builder diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestTamaraSource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestTamaraSource.java index e8b2a283..a73029ab 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestTamaraSource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestTamaraSource.java @@ -3,7 +3,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -19,7 +18,10 @@ public RequestTamaraSource() { super(PaymentSourceType.TAMARA); } - @SerializedName("billing_address") + /** + * The customer's billing address. + * [Optional] + */ private Address billingAddress; } diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestTrustlySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestTrustlySource.java index b1ca8177..9cd9350d 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestTrustlySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestTrustlySource.java @@ -3,20 +3,26 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; +/** + * @deprecated Trustly was removed as a payment method on 2024/09/17. + */ +@Deprecated @Getter @Setter @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public final class RequestTrustlySource extends AbstractRequestSource { - @SerializedName("billing_address") + /** + * The billing address for the Trustly payment. + * [Optional] + */ private Address billingAddress; @Builder @@ -25,6 +31,7 @@ private RequestTrustlySource(final Address billingAddress) { this.billingAddress = billingAddress; } + @Deprecated public RequestTrustlySource() { super(PaymentSourceType.TRUSTLY); } diff --git a/src/main/java/com/checkout/payments/request/source/apm/RequestWeChatPaySource.java b/src/main/java/com/checkout/payments/request/source/apm/RequestWeChatPaySource.java index f00211d3..245496be 100644 --- a/src/main/java/com/checkout/payments/request/source/apm/RequestWeChatPaySource.java +++ b/src/main/java/com/checkout/payments/request/source/apm/RequestWeChatPaySource.java @@ -3,7 +3,6 @@ import com.checkout.common.Address; import com.checkout.common.PaymentSourceType; import com.checkout.payments.request.source.AbstractRequestSource; -import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -16,7 +15,10 @@ @EqualsAndHashCode(callSuper = true) public final class RequestWeChatPaySource extends AbstractRequestSource { - @SerializedName("billing_address") + /** + * The customer's billing address. + * [Optional] + */ private Address billingAddress; public RequestWeChatPaySource() { diff --git a/src/main/java/com/checkout/payments/response/source/PayPalResponseSource.java b/src/main/java/com/checkout/payments/response/source/PayPalResponseSource.java new file mode 100644 index 00000000..cc6a4e13 --- /dev/null +++ b/src/main/java/com/checkout/payments/response/source/PayPalResponseSource.java @@ -0,0 +1,41 @@ +package com.checkout.payments.response.source; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import static com.checkout.common.PaymentSourceType.PAYPAL; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public final class PayPalResponseSource extends AbstractResponseSource implements ResponseSource { + + /** + * The PayPal account holder details. + * [Optional] + */ + private AccountHolder accountHolder; + + public PayPalResponseSource() { + this.type = PAYPAL; + } + + @Data + public static final class AccountHolder { + + /** + * The PayPal account holder's email address. + * [Optional] + */ + private String email; + + /** + * The PayPal account holder's full name. + * [Optional] + */ + private String fullName; + + } + +} diff --git a/src/main/java/com/checkout/payments/sender/PaymentIndividualSender.java b/src/main/java/com/checkout/payments/sender/PaymentIndividualSender.java index 0f3bdc02..37fcc9ca 100644 --- a/src/main/java/com/checkout/payments/sender/PaymentIndividualSender.java +++ b/src/main/java/com/checkout/payments/sender/PaymentIndividualSender.java @@ -22,28 +22,24 @@ public final class PaymentIndividualSender extends PaymentSender { * The sender's first name. * [Required] */ - @SerializedName("first_name") private String firstName; /** * The sender's middle name. * [Optional] */ - @SerializedName("middle_name") private String middleName; /** * The sender's last name. * [Required] */ - @SerializedName("last_name") private String lastName; /** - * The sender's date of birth. - * [Optional] - * Format: yyyy-MM-dd + * @deprecated Renamed to {@link #dateOfBirth} (date_of_birth) per API changelog 2025/02/21. */ + @Deprecated @SerializedName("dob") private String dob; @@ -63,30 +59,26 @@ public final class PaymentIndividualSender extends PaymentSender { * The reference type for the sender. * [Optional] */ - @SerializedName("reference_type") private String referenceType; /** * The source of funds for the sender. * [Optional] */ - @SerializedName("source_of_funds") private SourceOfFunds sourceOfFunds; /** - * The sender's date of birth (yyyy-MM-dd). + * The sender's date of birth. * [Optional] * Format: yyyy-MM-dd - * <= 10 characters + * max 10 characters */ - @SerializedName("date_of_birth") private LocalDate dateOfBirth; /** * The sender's country of birth. * [Optional] */ - @SerializedName("country_of_birth") private CountryCode countryOfBirth; /** diff --git a/src/test/java/com/checkout/instruments/CreateInstrumentSepaRequestSerializationTest.java b/src/test/java/com/checkout/instruments/CreateInstrumentSepaRequestSerializationTest.java new file mode 100644 index 00000000..01941859 --- /dev/null +++ b/src/test/java/com/checkout/instruments/CreateInstrumentSepaRequestSerializationTest.java @@ -0,0 +1,194 @@ +package com.checkout.instruments; + +import com.checkout.GsonSerializer; +import com.checkout.common.AccountHolder; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import com.checkout.instruments.create.CreateCustomerInstrumentRequest; +import com.checkout.instruments.create.CreateInstrumentSepaRequest; +import com.checkout.instruments.create.InstrumentData; +import com.checkout.payments.PaymentType; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class CreateInstrumentSepaRequestSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeTypeAsSepa() { + final CreateInstrumentSepaRequest request = CreateInstrumentSepaRequest.builder() + .instrumentData(InstrumentData.builder() + .accoountNumber("FR7630006000011234567890189") + .country(CountryCode.FR) + .currency(Currency.EUR) + .build()) + .accountHolder(AccountHolder.builder() + .firstName("Jane") + .lastName("Smith") + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"type\":\"sepa\"")); + } + + @Test + void shouldSerializeInstrumentData() { + final CreateInstrumentSepaRequest request = CreateInstrumentSepaRequest.builder() + .instrumentData(InstrumentData.builder() + .accoountNumber("DE89370400440532013000") + .country(CountryCode.DE) + .currency(Currency.EUR) + .paymentType(PaymentType.RECURRING) + .build()) + .accountHolder(AccountHolder.builder() + .firstName("Hans") + .lastName("Muller") + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"instrument_data\"")); + assertTrue(json.contains("\"account_number\":\"DE89370400440532013000\"")); + assertTrue(json.contains("\"country\":\"DE\"")); + assertTrue(json.contains("\"currency\":\"EUR\"")); + } + + @Test + void shouldSerializeAccountHolder() { + final CreateInstrumentSepaRequest request = CreateInstrumentSepaRequest.builder() + .instrumentData(InstrumentData.builder().build()) + .accountHolder(AccountHolder.builder() + .firstName("Marie") + .lastName("Dupont") + .billingAddress(Address.builder() + .addressLine1("10 Rue de la Paix") + .city("Paris") + .country(CountryCode.FR) + .build()) + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"account_holder\"")); + assertTrue(json.contains("\"first_name\":\"Marie\"")); + assertTrue(json.contains("\"last_name\":\"Dupont\"")); + assertTrue(json.contains("\"billing_address\"")); + } + + @Test + void shouldSerializeOptionalCustomer() { + final CreateInstrumentSepaRequest request = CreateInstrumentSepaRequest.builder() + .instrumentData(InstrumentData.builder().build()) + .accountHolder(AccountHolder.builder().build()) + .customer(CreateCustomerInstrumentRequest.builder() + .email("customer@example.com") + .name("Jane Smith") + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"customer\"")); + assertTrue(json.contains("\"email\":\"customer@example.com\"")); + assertTrue(json.contains("\"name\":\"Jane Smith\"")); + } + + @Test + void shouldDeserializeInstrumentData() { + final String json = "{" + + "\"type\":\"sepa\"," + + "\"instrument_data\":{" + + " \"account_number\":\"FR7630006000011234567890189\"," + + " \"country\":\"FR\"," + + " \"currency\":\"EUR\"" + + "}," + + "\"account_holder\":{" + + " \"first_name\":\"Jean\"," + + " \"last_name\":\"Martin\"" + + "}" + + "}"; + + final CreateInstrumentSepaRequest request = serializer.fromJson(json, CreateInstrumentSepaRequest.class); + + assertNotNull(request); + assertNotNull(request.getInstrumentData()); + assertEquals("FR7630006000011234567890189", request.getInstrumentData().getAccoountNumber()); + assertEquals(CountryCode.FR, request.getInstrumentData().getCountry()); + assertEquals(Currency.EUR, request.getInstrumentData().getCurrency()); + assertNotNull(request.getAccountHolder()); + assertEquals("Jean", request.getAccountHolder().getFirstName()); + assertEquals("Martin", request.getAccountHolder().getLastName()); + } + + @Test + void shouldRoundTripSerialize() { + final CreateInstrumentSepaRequest original = CreateInstrumentSepaRequest.builder() + .instrumentData(InstrumentData.builder() + .accoountNumber("ES9121000418450200051332") + .country(CountryCode.ES) + .currency(Currency.EUR) + .paymentType(PaymentType.RECURRING) + .build()) + .accountHolder(AccountHolder.builder() + .firstName("Carlos") + .lastName("García") + .billingAddress(Address.builder() + .addressLine1("Calle Mayor 1") + .city("Madrid") + .country(CountryCode.ES) + .build()) + .build()) + .build(); + + final String json = serializer.toJson(original); + final CreateInstrumentSepaRequest deserialized = serializer.fromJson(json, CreateInstrumentSepaRequest.class); + + assertNotNull(deserialized); + assertNotNull(deserialized.getInstrumentData()); + assertEquals("ES9121000418450200051332", deserialized.getInstrumentData().getAccoountNumber()); + assertEquals(CountryCode.ES, deserialized.getInstrumentData().getCountry()); + assertNotNull(deserialized.getAccountHolder()); + assertEquals("Carlos", deserialized.getAccountHolder().getFirstName()); + assertEquals("García", deserialized.getAccountHolder().getLastName()); + } + + @Test + void shouldNotSerializeNullOptionalCustomer() { + final CreateInstrumentSepaRequest request = CreateInstrumentSepaRequest.builder() + .instrumentData(InstrumentData.builder().build()) + .accountHolder(AccountHolder.builder().build()) + .build(); + + final String json = serializer.toJson(request); + + assertFalse(json.contains("\"customer\"")); + } + + @Test + void shouldHandleAbsentOptionalCustomer() { + final String json = "{" + + "\"type\":\"sepa\"," + + "\"instrument_data\":{}," + + "\"account_holder\":{}" + + "}"; + + final CreateInstrumentSepaRequest request = serializer.fromJson(json, CreateInstrumentSepaRequest.class); + + assertNotNull(request); + assertDoesNotThrow(() -> serializer.toJson(request)); + assertNull(request.getCustomer()); + } +} diff --git a/src/test/java/com/checkout/instruments/get/GetCardInstrumentResponseSerializationTest.java b/src/test/java/com/checkout/instruments/get/GetCardInstrumentResponseSerializationTest.java new file mode 100644 index 00000000..06264525 --- /dev/null +++ b/src/test/java/com/checkout/instruments/get/GetCardInstrumentResponseSerializationTest.java @@ -0,0 +1,187 @@ +package com.checkout.instruments.get; + +import com.checkout.GsonSerializer; +import com.checkout.common.CardCategory; +import com.checkout.common.CardType; +import com.checkout.common.CardWalletType; +import com.checkout.common.CountryCode; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class GetCardInstrumentResponseSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldDeserializeMinimalResponse() { + final String json = "{" + + "\"type\":\"card\"," + + "\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"," + + "\"expiry_month\":6," + + "\"expiry_year\":2025," + + "\"last4\":\"1234\"," + + "\"regulated_indicator\":true" + + "}"; + + final GetCardInstrumentResponse response = serializer.fromJson(json, GetCardInstrumentResponse.class); + + assertNotNull(response); + assertEquals(6, response.getExpiryMonth()); + assertEquals(2025, response.getExpiryYear()); + assertEquals("1234", response.getLast4()); + assertTrue(response.getRegulatedIndicator()); + } + + @Test + void shouldDeserializeEncryptedCardNumber() { + final String json = "{" + + "\"type\":\"card\"," + + "\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"," + + "\"last4\":\"4242\"," + + "\"regulated_indicator\":false," + + "\"encrypted_card_number\":\"eyJhbGciOiJSU0EtT0FFUC0yNTYifQ...\"" + + "}"; + + final GetCardInstrumentResponse response = serializer.fromJson(json, GetCardInstrumentResponse.class); + + assertNotNull(response); + assertEquals("eyJhbGciOiJSU0EtT0FFUC0yNTYifQ...", response.getEncryptedCardNumber()); + } + + @Test + void shouldDeserializeNetworkToken() { + final String json = "{" + + "\"type\":\"card\"," + + "\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"," + + "\"last4\":\"4242\"," + + "\"regulated_indicator\":false," + + "\"network_token\":{" + + " \"id\":\"nt_abcdefghijklmnopqrstuvwxyz12\"," + + " \"state\":\"active\"" + + "}" + + "}"; + + final GetCardInstrumentResponse response = serializer.fromJson(json, GetCardInstrumentResponse.class); + + assertNotNull(response); + assertNotNull(response.getNetworkToken()); + assertEquals("nt_abcdefghijklmnopqrstuvwxyz12", response.getNetworkToken().getId()); + assertEquals(NetworkTokenState.ACTIVE, response.getNetworkToken().getState()); + } + + @Test + void shouldDeserializeNetworkTokenStates() { + for (final String state : new String[]{"active", "suspended", "inactive"}) { + final String json = "{\"type\":\"card\",\"last4\":\"4242\",\"regulated_indicator\":false," + + "\"network_token\":{\"id\":\"nt_abcdefghijklmnopqrstuvwxyz12\",\"state\":\"" + state + "\"}}"; + final GetCardInstrumentResponse response = serializer.fromJson(json, GetCardInstrumentResponse.class); + assertNotNull(response.getNetworkToken().getState(), "State should not be null for: " + state); + } + } + + @Test + void shouldDeserializeCardWalletType() { + final String jsonGpay = "{" + + "\"type\":\"card\",\"last4\":\"4242\",\"regulated_indicator\":false," + + "\"card_wallet_type\":\"googlepay\"" + + "}"; + final String jsonApay = "{" + + "\"type\":\"card\",\"last4\":\"4242\",\"regulated_indicator\":false," + + "\"card_wallet_type\":\"applepay\"" + + "}"; + + final GetCardInstrumentResponse gpay = serializer.fromJson(jsonGpay, GetCardInstrumentResponse.class); + final GetCardInstrumentResponse apay = serializer.fromJson(jsonApay, GetCardInstrumentResponse.class); + + assertEquals(CardWalletType.GOOGLEPAY, gpay.getCardWalletType()); + assertEquals(CardWalletType.APPLEPAY, apay.getCardWalletType()); + } + + @Test + void shouldDeserializeFullResponse() { + final String json = "{" + + "\"type\":\"card\"," + + "\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"," + + "\"fingerprint\":\"vnsdrvikkvre3dtrjpwv7ire7u\"," + + "\"expiry_month\":6," + + "\"expiry_year\":2025," + + "\"name\":\"John Smith\"," + + "\"scheme\":\"Visa\"," + + "\"scheme_local\":\"Cartes Bancaires\"," + + "\"last4\":\"4242\"," + + "\"bin\":\"424242\"," + + "\"card_type\":\"Credit\"," + + "\"card_category\":\"Consumer\"," + + "\"issuer\":\"JPMORGAN CHASE BANK NA\"," + + "\"issuer_country\":\"US\"," + + "\"product_id\":\"A\"," + + "\"product_type\":\"Visa Traditional\"," + + "\"encrypted_card_number\":\"eyJhbGciOiJSU0EtT0FFUC0yNTYifQ...\"," + + "\"network_token\":{\"id\":\"nt_abcdefghijklmnopqrstuvwxyz12\",\"state\":\"active\"}," + + "\"card_wallet_type\":\"googlepay\"," + + "\"regulated_indicator\":true" + + "}"; + + final GetCardInstrumentResponse response = serializer.fromJson(json, GetCardInstrumentResponse.class); + + assertNotNull(response); + assertEquals("src_wmlfc3zyhqzehihu7giusaaawu", response.getId()); + assertEquals(6, response.getExpiryMonth()); + assertEquals("John Smith", response.getName()); + assertEquals("Visa", response.getScheme()); + assertEquals("4242", response.getLast4()); + assertEquals(CardType.CREDIT, response.getCardType()); + assertEquals(CardCategory.CONSUMER, response.getCardCategory()); + assertEquals(CountryCode.US, response.getIssuerCountry()); + assertEquals("eyJhbGciOiJSU0EtT0FFUC0yNTYifQ...", response.getEncryptedCardNumber()); + assertNotNull(response.getNetworkToken()); + assertEquals(NetworkTokenState.ACTIVE, response.getNetworkToken().getState()); + assertEquals(CardWalletType.GOOGLEPAY, response.getCardWalletType()); + assertTrue(response.getRegulatedIndicator()); + } + + @Test + void shouldRoundTripSerialize() { + final String original = "{" + + "\"type\":\"card\"," + + "\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"," + + "\"last4\":\"4242\"," + + "\"encrypted_card_number\":\"eyJhbGciOiJSU0EtT0FFUC0yNTYifQ...\"," + + "\"network_token\":{\"id\":\"nt_abcdefghijklmnopqrstuvwxyz12\",\"state\":\"suspended\"}," + + "\"card_wallet_type\":\"applepay\"," + + "\"regulated_indicator\":true" + + "}"; + + final GetCardInstrumentResponse response = serializer.fromJson(original, GetCardInstrumentResponse.class); + final String reserialised = serializer.toJson(response); + final GetCardInstrumentResponse roundTripped = serializer.fromJson(reserialised, GetCardInstrumentResponse.class); + + assertNotNull(roundTripped); + assertEquals(response.getId(), roundTripped.getId()); + assertEquals(response.getEncryptedCardNumber(), roundTripped.getEncryptedCardNumber()); + assertEquals(response.getNetworkToken().getState(), roundTripped.getNetworkToken().getState()); + assertEquals(response.getCardWalletType(), roundTripped.getCardWalletType()); + assertEquals(response.getRegulatedIndicator(), roundTripped.getRegulatedIndicator()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{" + + "\"type\":\"card\"," + + "\"last4\":\"4242\"," + + "\"regulated_indicator\":false" + + "}"; + + final GetCardInstrumentResponse response = serializer.fromJson(json, GetCardInstrumentResponse.class); + + assertNotNull(response); + assertDoesNotThrow(() -> serializer.toJson(response)); + assertEquals(null, response.getEncryptedCardNumber()); + assertEquals(null, response.getNetworkToken()); + assertEquals(null, response.getCardWalletType()); + } +} diff --git a/src/test/java/com/checkout/payments/AccommodationDataSerializationTest.java b/src/test/java/com/checkout/payments/AccommodationDataSerializationTest.java new file mode 100644 index 00000000..e600277d --- /dev/null +++ b/src/test/java/com/checkout/payments/AccommodationDataSerializationTest.java @@ -0,0 +1,165 @@ +package com.checkout.payments; + +import com.checkout.GsonSerializer; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Phone; +import org.junit.jupiter.api.Test; + +import java.time.LocalDate; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +class AccommodationDataSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeWithRequiredFields() { + final AccommodationData data = AccommodationData.builder() + .name("Grand Hotel") + .checkInDate(LocalDate.of(2025, 6, 1)) + .checkOutDate(LocalDate.of(2025, 6, 5)) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(data)); + } + + @Test + void shouldSerializeWithAllOptionalFields() { + final AccommodationData data = AccommodationData.builder() + .name("Grand Hotel") + .bookingReference("BK-12345") + .checkInDate(LocalDate.of(2025, 6, 1)) + .checkOutDate(LocalDate.of(2025, 6, 5)) + .address(Address.builder() + .addressLine1("1 Hotel Plaza") + .city("Paris") + .country(CountryCode.FR) + .build()) + .country(CountryCode.FR) + .city("Paris") + .numberOfRooms(2) + .guests(Arrays.asList( + AccommodationGuest.builder() + .firstName("John") + .lastName("Smith") + .dateOfBirth(LocalDate.of(1985, 3, 15)) + .build() + )) + .room(Arrays.asList( + AccommodationRoom.builder() + .rate("150.00") + .numberOfNightsAtRoomRate("4") + .build() + )) + .propertyPhone(Arrays.asList( + Phone.builder().countryCode("+33").number("123456789").build() + )) + .customerServicePhone(Arrays.asList( + Phone.builder().countryCode("+33").number("987654321").build() + )) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(data)); + } + + @Test + void shouldSerializeDatesAsLocalDate() { + final AccommodationData data = AccommodationData.builder() + .checkInDate(LocalDate.of(2025, 6, 1)) + .checkOutDate(LocalDate.of(2025, 6, 5)) + .build(); + + final String json = serializer.toJson(data); + + assertNotNull(json); + } + + @Test + void shouldDeserializeFromJson() { + final String json = "{" + + "\"name\":\"Grand Hotel\"," + + "\"booking_reference\":\"BK-12345\"," + + "\"check_in_date\":\"2025-06-01\"," + + "\"check_out_date\":\"2025-06-05\"," + + "\"country\":\"FR\"," + + "\"city\":\"Paris\"," + + "\"number_of_rooms\":2," + + "\"guests\":[{" + + " \"first_name\":\"John\"," + + " \"last_name\":\"Smith\"," + + " \"date_of_birth\":\"1985-03-15\"" + + "}]," + + "\"room\":[{" + + " \"rate\":\"150.00\"," + + " \"number_of_nights_at_room_rate\":\"4\"" + + "}]" + + "}"; + + final AccommodationData data = serializer.fromJson(json, AccommodationData.class); + + assertNotNull(data); + assertEquals("Grand Hotel", data.getName()); + assertEquals("BK-12345", data.getBookingReference()); + assertEquals(LocalDate.of(2025, 6, 1), data.getCheckInDate()); + assertEquals(LocalDate.of(2025, 6, 5), data.getCheckOutDate()); + assertEquals(CountryCode.FR, data.getCountry()); + assertEquals("Paris", data.getCity()); + assertEquals(2, data.getNumberOfRooms()); + assertNotNull(data.getGuests()); + assertEquals(1, data.getGuests().size()); + assertEquals("John", data.getGuests().get(0).getFirstName()); + assertEquals(LocalDate.of(1985, 3, 15), data.getGuests().get(0).getDateOfBirth()); + assertNotNull(data.getRoom()); + assertEquals("150.00", data.getRoom().get(0).getRate()); + } + + @Test + void shouldRoundTripSerialize() { + final AccommodationData original = AccommodationData.builder() + .name("Grand Hotel") + .bookingReference("BK-12345") + .checkInDate(LocalDate.of(2025, 6, 1)) + .checkOutDate(LocalDate.of(2025, 6, 5)) + .country(CountryCode.FR) + .numberOfRooms(1) + .guests(Arrays.asList( + AccommodationGuest.builder() + .firstName("John") + .lastName("Smith") + .build() + )) + .build(); + + final String json = serializer.toJson(original); + final AccommodationData deserialized = serializer.fromJson(json, AccommodationData.class); + + assertNotNull(deserialized); + assertEquals("Grand Hotel", deserialized.getName()); + assertEquals("BK-12345", deserialized.getBookingReference()); + assertEquals(LocalDate.of(2025, 6, 1), deserialized.getCheckInDate()); + assertEquals(CountryCode.FR, deserialized.getCountry()); + assertEquals(1, deserialized.getNumberOfRooms()); + assertNotNull(deserialized.getGuests()); + assertEquals("John", deserialized.getGuests().get(0).getFirstName()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{}"; + + final AccommodationData data = serializer.fromJson(json, AccommodationData.class); + + assertNotNull(data); + assertDoesNotThrow(() -> serializer.toJson(data)); + assertNull(data.getName()); + assertNull(data.getCheckInDate()); + assertNull(data.getGuests()); + assertNull(data.getRoom()); + } +} diff --git a/src/test/java/com/checkout/payments/PaymentProcessingSerializationTest.java b/src/test/java/com/checkout/payments/PaymentProcessingSerializationTest.java new file mode 100644 index 00000000..16574973 --- /dev/null +++ b/src/test/java/com/checkout/payments/PaymentProcessingSerializationTest.java @@ -0,0 +1,228 @@ +package com.checkout.payments; + +import com.checkout.GsonSerializer; +import com.checkout.common.CountryCode; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +class PaymentProcessingSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldDeserializeRetrievalReferenceNumber() { + final String json = "{\"retrieval_reference_number\":\"RRN123456\"}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("RRN123456", processing.getRetrievalReferenceNumber()); + } + + @Test + void shouldDeserializeAcquirerFields() { + final String json = "{" + + "\"acquirer_transaction_id\":\"TXN001\"," + + "\"acquirer_name\":\"Test Acquirer\"," + + "\"acquirer_country_code\":\"US\"" + + "}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("TXN001", processing.getAcquirerTransactionId()); + assertEquals("Test Acquirer", processing.getAcquirerName()); + assertEquals(CountryCode.US, processing.getAcquirerCountryCode()); + } + + @Test + void shouldDeserializePanTypeProcessedFpan() { + final String json = "{\"pan_type_processed\":\"fpan\"}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals(PanProcessedType.FPAN, processing.getPanTypeProcessed()); + } + + @Test + void shouldDeserializePanTypeProcessedDpan() { + final String json = "{\"pan_type_processed\":\"dpan\"}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals(PanProcessedType.DPAN, processing.getPanTypeProcessed()); + } + + @Test + void shouldDeserializeCkoNetworkTokenAvailable() { + final String json = "{\"cko_network_token_available\":true}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals(Boolean.TRUE, processing.getCkoNetworkTokenAvailable()); + } + + @Test + void shouldDeserializeBizumPaymentId() { + final String json = "{\"bizum_payment_id\":\"bizum_abc123\"}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("bizum_abc123", processing.getBizumPaymentId()); + } + + @Test + void shouldDeserializeReconciliationId() { + final String json = "{\"reconciliation_id\":\"recon_001\"}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("recon_001", processing.getReconciliationId()); + } + + @Test + void shouldDeserializePartnerFields() { + final String json = "{" + + "\"partner_order_id\":\"po_001\"," + + "\"partner_session_id\":\"ps_001\"," + + "\"partner_client_token\":\"pct_001\"," + + "\"partner_payment_id\":\"pp_001\"," + + "\"partner_status\":\"APPROVED\"," + + "\"partner_transaction_id\":\"pt_001\"," + + "\"partner_merchant_advice_code\":\"01\"," + + "\"partner_response_code\":\"00\"," + + "\"partner_authorization_code\":\"auth_001\"," + + "\"partner_authorization_response_code\":\"resp_001\"," + + "\"partner_error_codes\":[\"ERR001\",\"ERR002\"]," + + "\"partner_error_message\":\"Declined\"" + + "}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("po_001", processing.getPartnerOrderId()); + assertEquals("ps_001", processing.getPartnerSessionId()); + assertEquals("pct_001", processing.getPartnerClientToken()); + assertEquals("pp_001", processing.getPartnerPaymentId()); + assertEquals("APPROVED", processing.getPartnerStatus()); + assertEquals("pt_001", processing.getPartnerTransactionId()); + assertEquals("01", processing.getPartnerMerchantAdviceCode()); + assertEquals("00", processing.getPartnerResponseCode()); + assertEquals("auth_001", processing.getPartnerAuthorizationCode()); + assertEquals("resp_001", processing.getPartnerAuthorizationResponseCode()); + assertEquals(Arrays.asList("ERR001", "ERR002"), processing.getPartnerErrorCodes()); + assertEquals("Declined", processing.getPartnerErrorMessage()); + } + + @Test + void shouldDeserializeSchemeMerchantId() { + final String json = "{" + + "\"scheme_merchant_id\":\"sm_001\"," + + "\"recommendation_code\":\"RC001\"," + + "\"merchant_category_code\":\"5411\"," + + "\"scheme\":\"Visa\"," + + "\"pun\":\"PUN123456\"" + + "}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("sm_001", processing.getSchemeMerchantId()); + assertEquals("RC001", processing.getRecommendationCode()); + assertEquals("5411", processing.getMerchantCategoryCode()); + assertEquals("Visa", processing.getScheme()); + assertEquals("PUN123456", processing.getPun()); + } + + @Test + void shouldDeserializeForeignRetailerAmount() { + final String json = "{" + + "\"foreign_retailer_amount\":750," + + "\"surcharge_amount\":50," + + "\"provision_network_token\":true," + + "\"aft\":true" + + "}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals(750L, processing.getForeignRetailerAmount()); + assertEquals(50L, processing.getSurchargeAmount()); + assertEquals(Boolean.TRUE, processing.getProvisionNetworkToken()); + assertEquals(Boolean.TRUE, processing.getAft()); + } + + @Test + void shouldDeserializeFullSwaggerExample() { + final String json = "{" + + "\"retrieval_reference_number\":\"RRN001\"," + + "\"acquirer_transaction_id\":\"ACQ001\"," + + "\"acquirer_name\":\"Acquirer Bank\"," + + "\"acquirer_country_code\":\"GB\"," + + "\"recommendation_code\":\"R001\"," + + "\"scheme\":\"Mastercard\"," + + "\"pan_type_processed\":\"fpan\"," + + "\"cko_network_token_available\":false," + + "\"purchase_country\":\"GB\"," + + "\"scheme_merchant_id\":\"SMI001\"," + + "\"foreign_retailer_amount\":100," + + "\"provision_network_token\":false," + + "\"merchant_category_code\":\"5812\"," + + "\"aft\":false," + + "\"bizum_payment_id\":\"biz_001\"," + + "\"reconciliation_id\":\"rec_001\"" + + "}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertEquals("RRN001", processing.getRetrievalReferenceNumber()); + assertEquals("ACQ001", processing.getAcquirerTransactionId()); + assertEquals("Acquirer Bank", processing.getAcquirerName()); + assertEquals(CountryCode.GB, processing.getAcquirerCountryCode()); + assertEquals(PanProcessedType.FPAN, processing.getPanTypeProcessed()); + assertEquals(Boolean.FALSE, processing.getCkoNetworkTokenAvailable()); + assertEquals(CountryCode.GB, processing.getPurchaseCountry()); + assertEquals("SMI001", processing.getSchemeMerchantId()); + assertEquals(100L, processing.getForeignRetailerAmount()); + assertEquals("biz_001", processing.getBizumPaymentId()); + assertEquals("rec_001", processing.getReconciliationId()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{}"; + + final PaymentProcessing processing = serializer.fromJson(json, PaymentProcessing.class); + + assertNotNull(processing); + assertDoesNotThrow(() -> serializer.toJson(processing)); + assertNull(processing.getRetrievalReferenceNumber()); + assertNull(processing.getPanTypeProcessed()); + assertNull(processing.getCkoNetworkTokenAvailable()); + assertNull(processing.getBizumPaymentId()); + } + + @Test + void shouldNotSerializeNullFields() { + final PaymentProcessing processing = new PaymentProcessing(); + + final String json = serializer.toJson(processing); + + assertFalse(json.contains("\"retrieval_reference_number\"")); + assertFalse(json.contains("\"pan_type_processed\"")); + assertFalse(json.contains("\"cko_network_token_available\"")); + } +} diff --git a/src/test/java/com/checkout/payments/ProcessingSettingsSerializationTest.java b/src/test/java/com/checkout/payments/ProcessingSettingsSerializationTest.java new file mode 100644 index 00000000..c890349b --- /dev/null +++ b/src/test/java/com/checkout/payments/ProcessingSettingsSerializationTest.java @@ -0,0 +1,205 @@ +package com.checkout.payments; + +import com.checkout.GsonSerializer; +import com.checkout.common.CardType; +import com.checkout.common.CountryCode; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ProcessingSettingsSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializePanPreferenceFpan() { + final ProcessingSettings settings = ProcessingSettings.builder() + .panPreference(PanProcessedType.FPAN) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"pan_preference\":\"fpan\"")); + } + + @Test + void shouldSerializePanPreferenceDpan() { + final ProcessingSettings settings = ProcessingSettings.builder() + .panPreference(PanProcessedType.DPAN) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"pan_preference\":\"dpan\"")); + } + + @Test + void shouldSerializeServiceTypeSameDay() { + final ProcessingSettings settings = ProcessingSettings.builder() + .serviceType(AchServiceType.SAME_DAY) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"service_type\":\"same_day\"")); + } + + @Test + void shouldSerializeServiceTypeStandard() { + final ProcessingSettings settings = ProcessingSettings.builder() + .serviceType(AchServiceType.STANDARD) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"service_type\":\"standard\"")); + } + + @Test + void shouldSerializeAffiliateFields() { + final ProcessingSettings settings = ProcessingSettings.builder() + .affiliateId("AFFILIATE123") + .affiliateUrl("https://affiliate.example.com") + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"affiliate_id\":\"AFFILIATE123\"")); + assertTrue(json.contains("\"affiliate_url\":\"https://affiliate.example.com\"")); + } + + @Test + void shouldSerializeCardTypeCredit() { + final ProcessingSettings settings = ProcessingSettings.builder() + .cardType(CardType.CREDIT) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"card_type\":\"Credit\"")); + } + + @Test + void shouldSerializeCardTypeDebit() { + final ProcessingSettings settings = ProcessingSettings.builder() + .cardType(CardType.DEBIT) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"card_type\":\"Debit\"")); + } + + @Test + void shouldSerializeForeignRetailerAmount() { + final ProcessingSettings settings = ProcessingSettings.builder() + .foreignRetailerAmount(500L) + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"foreign_retailer_amount\":500")); + } + + @Test + void shouldSerializeReconciliationId() { + final ProcessingSettings settings = ProcessingSettings.builder() + .reconciliationId("recon_abc123") + .build(); + + final String json = serializer.toJson(settings); + + assertTrue(json.contains("\"reconciliation_id\":\"recon_abc123\"")); + } + + @Test + void shouldDeserializePanPreference() { + final String json = "{\"pan_preference\":\"fpan\",\"service_type\":\"standard\"}"; + + final ProcessingSettings settings = serializer.fromJson(json, ProcessingSettings.class); + + assertNotNull(settings); + assertEquals(PanProcessedType.FPAN, settings.getPanPreference()); + assertEquals(AchServiceType.STANDARD, settings.getServiceType()); + } + + @Test + void shouldDeserializeAffiliateAndCardType() { + final String json = "{" + + "\"affiliate_id\":\"AFF001\"," + + "\"affiliate_url\":\"https://aff.example.com\"," + + "\"card_type\":\"Debit\"," + + "\"foreign_retailer_amount\":1000," + + "\"reconciliation_id\":\"rec_001\"" + + "}"; + + final ProcessingSettings settings = serializer.fromJson(json, ProcessingSettings.class); + + assertNotNull(settings); + assertEquals("AFF001", settings.getAffiliateId()); + assertEquals("https://aff.example.com", settings.getAffiliateUrl()); + assertEquals(CardType.DEBIT, settings.getCardType()); + assertEquals(1000L, settings.getForeignRetailerAmount()); + assertEquals("rec_001", settings.getReconciliationId()); + } + + @Test + void shouldRoundTripSerialize() { + final ProcessingSettings original = ProcessingSettings.builder() + .panPreference(PanProcessedType.DPAN) + .serviceType(AchServiceType.SAME_DAY) + .affiliateId("AFF123") + .affiliateUrl("https://example.com") + .cardType(CardType.CREDIT) + .foreignRetailerAmount(250L) + .reconciliationId("rec_xyz") + .hubModelOriginationCountry(CountryCode.GB) + .build(); + + final String json = serializer.toJson(original); + final ProcessingSettings deserialized = serializer.fromJson(json, ProcessingSettings.class); + + assertNotNull(deserialized); + assertEquals(PanProcessedType.DPAN, deserialized.getPanPreference()); + assertEquals(AchServiceType.SAME_DAY, deserialized.getServiceType()); + assertEquals("AFF123", deserialized.getAffiliateId()); + assertEquals("https://example.com", deserialized.getAffiliateUrl()); + assertEquals(CardType.CREDIT, deserialized.getCardType()); + assertEquals(250L, deserialized.getForeignRetailerAmount()); + assertEquals("rec_xyz", deserialized.getReconciliationId()); + assertEquals(CountryCode.GB, deserialized.getHubModelOriginationCountry()); + } + + @Test + void shouldNotSerializeNullOptionalFields() { + final ProcessingSettings settings = ProcessingSettings.builder() + .orderId("order_001") + .build(); + + final String json = serializer.toJson(settings); + + assertFalse(json.contains("\"pan_preference\"")); + assertFalse(json.contains("\"service_type\"")); + assertFalse(json.contains("\"affiliate_id\"")); + assertFalse(json.contains("\"card_type\"")); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{}"; + + final ProcessingSettings settings = serializer.fromJson(json, ProcessingSettings.class); + + assertNotNull(settings); + assertDoesNotThrow(() -> serializer.toJson(settings)); + assertNull(settings.getPanPreference()); + assertNull(settings.getServiceType()); + assertNull(settings.getAffiliateId()); + assertNull(settings.getCardType()); + } +} diff --git a/src/test/java/com/checkout/payments/ThreeDSDataSerializationTest.java b/src/test/java/com/checkout/payments/ThreeDSDataSerializationTest.java new file mode 100644 index 00000000..bff0f7d3 --- /dev/null +++ b/src/test/java/com/checkout/payments/ThreeDSDataSerializationTest.java @@ -0,0 +1,149 @@ +package com.checkout.payments; + +import com.checkout.GsonSerializer; +import com.checkout.common.ThreeDSEnrollmentStatus; +import org.junit.jupiter.api.Test; +import static com.checkout.payments.TrustedListingStatus.ALLOWLISTED; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ThreeDSDataSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldDeserializeMinimalResponse() { + final String json = "{\"downgraded\":false}"; + + final ThreeDSData data = serializer.fromJson(json, ThreeDSData.class); + + assertNotNull(data); + assertEquals(false, data.getDowngraded()); + } + + @Test + void shouldDeserializeEciField() { + final String json = "{" + + "\"eci\":\"05\"," + + "\"challenged\":true," + + "\"version\":\"2.1.0\"" + + "}"; + + final ThreeDSData data = serializer.fromJson(json, ThreeDSData.class); + + assertNotNull(data); + assertEquals("05", data.getEci()); + assertTrue(data.getChallenged()); + assertEquals("2.1.0", data.getVersion()); + } + + @Test + void shouldDeserializeAuthenticationStatusReason() { + final String json = "{" + + "\"authentication_status_reason\":\"01\"," + + "\"eci\":\"06\"" + + "}"; + + final ThreeDSData data = serializer.fromJson(json, ThreeDSData.class); + + assertNotNull(data); + assertEquals("01", data.getAuthenticationStatusReason()); + assertEquals("06", data.getEci()); + } + + @Test + void shouldDeserializeTrustedListing() { + final String json = "{" + + "\"trusted_listing\":{" + + " \"status\":\"Y\"," + + " \"source\":\"01\"" + + "}" + + "}"; + + final ThreeDSData data = serializer.fromJson(json, ThreeDSData.class); + + assertNotNull(data); + assertNotNull(data.getTrustedListing()); + assertEquals(ALLOWLISTED, data.getTrustedListing().getStatus()); + assertEquals("01", data.getTrustedListing().getSource()); + } + + @Test + void shouldDeserializeFullResponse() { + final String json = "{" + + "\"downgraded\":false," + + "\"enrolled\":\"Y\"," + + "\"upgrade_reason\":\"02\"," + + "\"signature_valid\":\"Y\"," + + "\"authentication_response\":\"Y\"," + + "\"cryptogram\":\"AgAAAAAAAIR8CQrXcIhbQAAAAAA\"," + + "\"xid\":\"MDAwMDAwMDAwMDAwMDAwMzIyNzY\"," + + "\"version\":\"2.1.0\"," + + "\"exemption_applied\":\"low_value\"," + + "\"challenged\":true," + + "\"eci\":\"05\"," + + "\"authentication_status_reason\":\"01\"," + + "\"trusted_listing\":{" + + " \"status\":\"Y\"," + + " \"source\":\"01\"" + + "}" + + "}"; + + final ThreeDSData data = serializer.fromJson(json, ThreeDSData.class); + + assertNotNull(data); + assertEquals(false, data.getDowngraded()); + assertEquals(ThreeDSEnrollmentStatus.ISSUER_ENROLLED, data.getEnrolled()); + assertEquals("02", data.getUpgradeReason()); + assertEquals("Y", data.getSignatureValid()); + assertEquals("Y", data.getAuthenticationResponse()); + assertEquals("AgAAAAAAAIR8CQrXcIhbQAAAAAA", data.getCryptogram()); + assertEquals("MDAwMDAwMDAwMDAwMDAwMzIyNzY", data.getXid()); + assertEquals("2.1.0", data.getVersion()); + assertEquals("low_value", data.getExemptionApplied()); + assertTrue(data.getChallenged()); + assertEquals("05", data.getEci()); + assertEquals("01", data.getAuthenticationStatusReason()); + assertNotNull(data.getTrustedListing()); + assertEquals(ALLOWLISTED, data.getTrustedListing().getStatus()); + } + + @Test + void shouldRoundTripSerialize() { + final String original = "{" + + "\"eci\":\"05\"," + + "\"authentication_status_reason\":\"01\"," + + "\"trusted_listing\":{\"status\":\"Y\",\"source\":\"01\"}," + + "\"challenged\":true," + + "\"version\":\"2.2.0\"" + + "}"; + + final ThreeDSData data = serializer.fromJson(original, ThreeDSData.class); + final String reserialised = serializer.toJson(data); + final ThreeDSData roundTripped = serializer.fromJson(reserialised, ThreeDSData.class); + + assertNotNull(roundTripped); + assertEquals(data.getEci(), roundTripped.getEci()); + assertEquals(data.getAuthenticationStatusReason(), roundTripped.getAuthenticationStatusReason()); + assertEquals(data.getTrustedListing().getStatus(), roundTripped.getTrustedListing().getStatus()); + assertEquals(data.getChallenged(), roundTripped.getChallenged()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{}"; + + final ThreeDSData data = serializer.fromJson(json, ThreeDSData.class); + + assertNotNull(data); + assertDoesNotThrow(() -> serializer.toJson(data)); + assertNull(data.getEci()); + assertNull(data.getAuthenticationStatusReason()); + assertNull(data.getTrustedListing()); + assertNull(data.getChallenged()); + } +} diff --git a/src/test/java/com/checkout/payments/hosted/HostedPaymentRequestSerializationTest.java b/src/test/java/com/checkout/payments/hosted/HostedPaymentRequestSerializationTest.java new file mode 100644 index 00000000..5378dca0 --- /dev/null +++ b/src/test/java/com/checkout/payments/hosted/HostedPaymentRequestSerializationTest.java @@ -0,0 +1,222 @@ +package com.checkout.payments.hosted; + +import com.checkout.GsonSerializer; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import com.checkout.payments.BillingInformation; +import com.checkout.payments.PaymentType; +import org.junit.jupiter.api.Test; + +import java.time.Instant; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class HostedPaymentRequestSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeRequiredFields() { + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.USD) + .billing(BillingInformation.builder() + .address(Address.builder() + .addressLine1("123 Main St") + .city("New York") + .country(CountryCode.US) + .build()) + .build()) + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"currency\":\"USD\"")); + assertTrue(json.contains("\"billing\"")); + assertTrue(json.contains("\"success_url\":\"https://example.com/success\"")); + assertTrue(json.contains("\"cancel_url\":\"https://example.com/cancel\"")); + assertTrue(json.contains("\"failure_url\":\"https://example.com/failure\"")); + } + + @Test + void shouldSerializeAmount() { + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.GBP) + .amount(1000L) + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"amount\":1000")); + assertTrue(json.contains("\"currency\":\"GBP\"")); + } + + @Test + void shouldSerializePaymentType() { + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.EUR) + .paymentType(PaymentType.RECURRING) + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"payment_type\":\"Recurring\"")); + } + + @Test + void shouldSerializeProcessingChannelId() { + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.USD) + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"processing_channel_id\":\"pc_abcdefghijklmnopqrstuvwxyz\"")); + } + + @Test + void shouldSerializeCaptureFields() { + final Instant captureOn = Instant.parse("2026-06-01T12:00:00Z"); + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.USD) + .capture(true) + .captureOn(captureOn) + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"capture\":true")); + assertTrue(json.contains("\"capture_on\"")); + } + + @Test + void shouldSerializeReferenceAndDescription() { + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.USD) + .reference("ORD-12345") + .description("Test payment") + .displayName("My Shop") + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"reference\":\"ORD-12345\"")); + assertTrue(json.contains("\"description\":\"Test payment\"")); + assertTrue(json.contains("\"display_name\":\"My Shop\"")); + } + + @Test + void shouldDeserializeRequiredFields() { + final String json = "{" + + "\"currency\":\"USD\"," + + "\"success_url\":\"https://example.com/success\"," + + "\"cancel_url\":\"https://example.com/cancel\"," + + "\"failure_url\":\"https://example.com/failure\"," + + "\"amount\":500" + + "}"; + + final HostedPaymentRequest request = serializer.fromJson(json, HostedPaymentRequest.class); + + assertNotNull(request); + assertEquals(Currency.USD, request.getCurrency()); + assertEquals("https://example.com/success", request.getSuccessUrl()); + assertEquals("https://example.com/cancel", request.getCancelUrl()); + assertEquals("https://example.com/failure", request.getFailureUrl()); + assertEquals(500L, request.getAmount()); + } + + @Test + void shouldDeserializePaymentType() { + final String json = "{\"payment_type\":\"Recurring\",\"currency\":\"GBP\"}"; + + final HostedPaymentRequest request = serializer.fromJson(json, HostedPaymentRequest.class); + + assertNotNull(request); + assertEquals(PaymentType.RECURRING, request.getPaymentType()); + } + + @Test + void shouldRoundTripSerialize() { + final HostedPaymentRequest original = HostedPaymentRequest.builder() + .currency(Currency.EUR) + .amount(2500L) + .paymentType(PaymentType.REGULAR) + .reference("REF-001") + .description("Round trip test") + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(original); + final HostedPaymentRequest deserialized = serializer.fromJson(json, HostedPaymentRequest.class); + + assertNotNull(deserialized); + assertEquals(Currency.EUR, deserialized.getCurrency()); + assertEquals(2500L, deserialized.getAmount()); + assertEquals("REF-001", deserialized.getReference()); + assertEquals("Round trip test", deserialized.getDescription()); + assertEquals("pc_abcdefghijklmnopqrstuvwxyz", deserialized.getProcessingChannelId()); + assertEquals("https://example.com/success", deserialized.getSuccessUrl()); + assertEquals("https://example.com/cancel", deserialized.getCancelUrl()); + assertEquals("https://example.com/failure", deserialized.getFailureUrl()); + } + + @Test + void shouldNotSerializeNullOptionalFields() { + final HostedPaymentRequest request = HostedPaymentRequest.builder() + .currency(Currency.USD) + .successUrl("https://example.com/success") + .cancelUrl("https://example.com/cancel") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertFalse(json.contains("\"amount\"")); + assertFalse(json.contains("\"description\"")); + assertFalse(json.contains("\"processing_channel_id\"")); + assertFalse(json.contains("\"capture_on\"")); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"currency\":\"USD\"}"; + + final HostedPaymentRequest request = serializer.fromJson(json, HostedPaymentRequest.class); + + assertNotNull(request); + assertDoesNotThrow(() -> serializer.toJson(request)); + assertNull(request.getAmount()); + assertNull(request.getReference()); + assertNull(request.getSuccessUrl()); + assertNull(request.getCancelUrl()); + assertNull(request.getFailureUrl()); + } +} diff --git a/src/test/java/com/checkout/payments/links/PaymentLinkRequestSerializationTest.java b/src/test/java/com/checkout/payments/links/PaymentLinkRequestSerializationTest.java new file mode 100644 index 00000000..edf89097 --- /dev/null +++ b/src/test/java/com/checkout/payments/links/PaymentLinkRequestSerializationTest.java @@ -0,0 +1,216 @@ +package com.checkout.payments.links; + +import com.checkout.GsonSerializer; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import com.checkout.payments.BillingInformation; +import com.checkout.payments.PaymentType; +import org.junit.jupiter.api.Test; + +import java.time.Instant; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class PaymentLinkRequestSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeRequiredFields() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(1500L) + .currency(Currency.GBP) + .billing(BillingInformation.builder() + .address(Address.builder() + .addressLine1("1 High Street") + .city("London") + .country(CountryCode.GB) + .build()) + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"amount\":1500")); + assertTrue(json.contains("\"currency\":\"GBP\"")); + assertTrue(json.contains("\"billing\"")); + } + + @Test + void shouldSerializeExpiresIn() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(1000L) + .currency(Currency.USD) + .expiresIn(86400) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"expires_in\":86400")); + } + + @Test + void shouldSerializeReturnUrl() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(1000L) + .currency(Currency.USD) + .returnUrl("https://example.com/return") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"return_url\":\"https://example.com/return\"")); + } + + @Test + void shouldSerializeProcessingChannelId() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(1000L) + .currency(Currency.EUR) + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"processing_channel_id\":\"pc_abcdefghijklmnopqrstuvwxyz\"")); + } + + @Test + void shouldSerializePaymentType() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(500L) + .currency(Currency.USD) + .paymentType(PaymentType.RECURRING) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"payment_type\":\"Recurring\"")); + } + + @Test + void shouldSerializeCaptureFields() { + final Instant captureOn = Instant.parse("2026-07-01T10:00:00Z"); + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(1000L) + .currency(Currency.USD) + .capture(true) + .captureOn(captureOn) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"capture\":true")); + assertTrue(json.contains("\"capture_on\"")); + } + + @Test + void shouldSerializeReferenceAndDescription() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(750L) + .currency(Currency.USD) + .reference("ORD-2024-001") + .description("Order payment") + .displayName("My Store") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"reference\":\"ORD-2024-001\"")); + assertTrue(json.contains("\"description\":\"Order payment\"")); + assertTrue(json.contains("\"display_name\":\"My Store\"")); + } + + @Test + void shouldDeserializeRequiredFields() { + final String json = "{" + + "\"amount\":2000," + + "\"currency\":\"EUR\"," + + "\"expires_in\":3600," + + "\"return_url\":\"https://example.com/return\"," + + "\"processing_channel_id\":\"pc_test\"" + + "}"; + + final PaymentLinkRequest request = serializer.fromJson(json, PaymentLinkRequest.class); + + assertNotNull(request); + assertEquals(2000L, request.getAmount()); + assertEquals(Currency.EUR, request.getCurrency()); + assertEquals(3600, request.getExpiresIn()); + assertEquals("https://example.com/return", request.getReturnUrl()); + assertEquals("pc_test", request.getProcessingChannelId()); + } + + @Test + void shouldDeserializePaymentType() { + final String json = "{\"payment_type\":\"Installment\",\"amount\":500,\"currency\":\"USD\"}"; + + final PaymentLinkRequest request = serializer.fromJson(json, PaymentLinkRequest.class); + + assertNotNull(request); + assertEquals(PaymentType.INSTALLMENT, request.getPaymentType()); + } + + @Test + void shouldRoundTripSerialize() { + final PaymentLinkRequest original = PaymentLinkRequest.builder() + .amount(3000L) + .currency(Currency.GBP) + .expiresIn(7200) + .returnUrl("https://example.com/return") + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .reference("REF-RT-001") + .description("Round-trip test") + .paymentType(PaymentType.REGULAR) + .capture(true) + .build(); + + final String json = serializer.toJson(original); + final PaymentLinkRequest deserialized = serializer.fromJson(json, PaymentLinkRequest.class); + + assertNotNull(deserialized); + assertEquals(3000L, deserialized.getAmount()); + assertEquals(Currency.GBP, deserialized.getCurrency()); + assertEquals(7200, deserialized.getExpiresIn()); + assertEquals("https://example.com/return", deserialized.getReturnUrl()); + assertEquals("pc_abcdefghijklmnopqrstuvwxyz", deserialized.getProcessingChannelId()); + assertEquals("REF-RT-001", deserialized.getReference()); + assertEquals("Round-trip test", deserialized.getDescription()); + assertTrue(deserialized.isCapture()); + } + + @Test + void shouldNotSerializeNullOptionalFields() { + final PaymentLinkRequest request = PaymentLinkRequest.builder() + .amount(1000L) + .currency(Currency.USD) + .build(); + + final String json = serializer.toJson(request); + + assertFalse(json.contains("\"expires_in\"")); + assertFalse(json.contains("\"return_url\"")); + assertFalse(json.contains("\"description\"")); + assertFalse(json.contains("\"processing_channel_id\"")); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"amount\":500,\"currency\":\"USD\"}"; + + final PaymentLinkRequest request = serializer.fromJson(json, PaymentLinkRequest.class); + + assertNotNull(request); + assertDoesNotThrow(() -> serializer.toJson(request)); + assertNull(request.getExpiresIn()); + assertNull(request.getReturnUrl()); + assertNull(request.getDescription()); + } +} diff --git a/src/test/java/com/checkout/payments/request/PaymentRequestSerializationTest.java b/src/test/java/com/checkout/payments/request/PaymentRequestSerializationTest.java new file mode 100644 index 00000000..3e84216d --- /dev/null +++ b/src/test/java/com/checkout/payments/request/PaymentRequestSerializationTest.java @@ -0,0 +1,256 @@ +package com.checkout.payments.request; + +import com.checkout.GsonSerializer; +import com.checkout.common.Currency; +import com.checkout.payments.AuthorizationType; +import com.checkout.payments.PaymentType; +import org.junit.jupiter.api.Test; + +import java.time.Instant; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class PaymentRequestSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeRequiredCurrencyField() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"currency\":\"USD\"")); + } + + @Test + void shouldSerializePaymentContextId() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .paymentContextId("ctx_abc123") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"payment_context_id\":\"ctx_abc123\"")); + } + + @Test + void shouldSerializeMerchantInitiated() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .merchantInitiated(true) + .paymentType(PaymentType.RECURRING) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"merchant_initiated\":true")); + assertTrue(json.contains("\"payment_type\":\"Recurring\"")); + } + + @Test + void shouldSerializePaymentTypeEnum() { + for (final PaymentType paymentType : PaymentType.values()) { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .paymentType(paymentType) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(request)); + } + } + + @Test + void shouldSerializeAuthorizationType() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .authorizationType(AuthorizationType.ESTIMATED) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"authorization_type\":\"Estimated\"")); + } + + @Test + void shouldSerializeCaptureFields() { + final Instant captureOn = Instant.parse("2026-08-01T14:00:00Z"); + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .capture(true) + .captureOn(captureOn) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"capture\":true")); + assertTrue(json.contains("\"capture_on\"")); + } + + @Test + void shouldSerializeProcessingChannelId() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.GBP) + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"processing_channel_id\":\"pc_abcdefghijklmnopqrstuvwxyz\"")); + } + + @Test + void shouldSerializePreviousPaymentId() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .previousPaymentId("pay_cr4hxwizzp6k7biycuk2ibltnm") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"previous_payment_id\":\"pay_cr4hxwizzp6k7biycuk2ibltnm\"")); + } + + @Test + void shouldSerializeSuccessAndFailureUrls() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .successUrl("https://example.com/success") + .failureUrl("https://example.com/failure") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"success_url\":\"https://example.com/success\"")); + assertTrue(json.contains("\"failure_url\":\"https://example.com/failure\"")); + } + + @Test + void shouldSerializeReferenceAndDescription() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.EUR) + .reference("ORD-001") + .description("Test order") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"reference\":\"ORD-001\"")); + assertTrue(json.contains("\"description\":\"Test order\"")); + } + + @Test + void shouldSerializeAmount() { + final PaymentRequest request = PaymentRequest.builder() + .amount(4999L) + .currency(Currency.USD) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"amount\":4999")); + } + + @Test + void shouldDeserializeKeyFields() { + final String json = "{" + + "\"payment_context_id\":\"ctx_001\"," + + "\"amount\":1500," + + "\"currency\":\"GBP\"," + + "\"payment_type\":\"Unscheduled\"," + + "\"merchant_initiated\":true," + + "\"reference\":\"REF-001\"," + + "\"description\":\"Test\"," + + "\"processing_channel_id\":\"pc_test\"," + + "\"previous_payment_id\":\"pay_abc\"," + + "\"success_url\":\"https://example.com/success\"," + + "\"failure_url\":\"https://example.com/failure\"," + + "\"capture\":false" + + "}"; + + final PaymentRequest request = serializer.fromJson(json, PaymentRequest.class); + + assertNotNull(request); + assertEquals("ctx_001", request.getPaymentContextId()); + assertEquals(1500L, request.getAmount()); + assertEquals(Currency.GBP, request.getCurrency()); + assertEquals(PaymentType.UNSCHEDULED, request.getPaymentType()); + assertEquals(Boolean.TRUE, request.getMerchantInitiated()); + assertEquals("REF-001", request.getReference()); + assertEquals("Test", request.getDescription()); + assertEquals("pc_test", request.getProcessingChannelId()); + assertEquals("pay_abc", request.getPreviousPaymentId()); + assertEquals("https://example.com/success", request.getSuccessUrl()); + assertEquals("https://example.com/failure", request.getFailureUrl()); + assertEquals(Boolean.FALSE, request.getCapture()); + } + + @Test + void shouldRoundTripSerialize() { + final PaymentRequest original = PaymentRequest.builder() + .amount(2000L) + .currency(Currency.USD) + .paymentType(PaymentType.MOTO) + .reference("RT-001") + .description("Round-trip") + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .previousPaymentId("pay_prev") + .successUrl("https://example.com/success") + .failureUrl("https://example.com/failure") + .capture(true) + .merchantInitiated(false) + .build(); + + final String json = serializer.toJson(original); + final PaymentRequest deserialized = serializer.fromJson(json, PaymentRequest.class); + + assertNotNull(deserialized); + assertEquals(2000L, deserialized.getAmount()); + assertEquals(Currency.USD, deserialized.getCurrency()); + assertEquals(PaymentType.MOTO, deserialized.getPaymentType()); + assertEquals("RT-001", deserialized.getReference()); + assertEquals("pc_abcdefghijklmnopqrstuvwxyz", deserialized.getProcessingChannelId()); + assertEquals("pay_prev", deserialized.getPreviousPaymentId()); + assertEquals("https://example.com/success", deserialized.getSuccessUrl()); + assertEquals("https://example.com/failure", deserialized.getFailureUrl()); + assertEquals(Boolean.TRUE, deserialized.getCapture()); + } + + @Test + void shouldNotSerializeNullOptionalFields() { + final PaymentRequest request = PaymentRequest.builder() + .currency(Currency.USD) + .build(); + + final String json = serializer.toJson(request); + + assertFalse(json.contains("\"payment_context_id\"")); + assertFalse(json.contains("\"previous_payment_id\"")); + assertFalse(json.contains("\"success_url\"")); + assertFalse(json.contains("\"failure_url\"")); + assertFalse(json.contains("\"merchant_initiated\"")); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"currency\":\"USD\"}"; + + final PaymentRequest request = serializer.fromJson(json, PaymentRequest.class); + + assertNotNull(request); + assertDoesNotThrow(() -> serializer.toJson(request)); + assertNull(request.getPaymentContextId()); + assertNull(request.getAmount()); + assertNull(request.getMerchantInitiated()); + assertNull(request.getPreviousPaymentId()); + } +} diff --git a/src/test/java/com/checkout/payments/request/PaymentRetryRequestSerializationTest.java b/src/test/java/com/checkout/payments/request/PaymentRetryRequestSerializationTest.java new file mode 100644 index 00000000..2922a5ad --- /dev/null +++ b/src/test/java/com/checkout/payments/request/PaymentRetryRequestSerializationTest.java @@ -0,0 +1,126 @@ +package com.checkout.payments.request; + +import com.checkout.GsonSerializer; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class PaymentRetryRequestSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeWithDunningConfig() { + final PaymentRetryRequest request = PaymentRetryRequest.builder() + .dunning(DunningRetryRequest.builder() + .enabled(true) + .maxAttempts(3) + .endAfterDays(7) + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"dunning\"")); + assertTrue(json.contains("\"enabled\":true")); + assertTrue(json.contains("\"max_attempts\":3")); + assertTrue(json.contains("\"end_after_days\":7")); + } + + @Test + void shouldSerializeWithDowntimeConfig() { + final PaymentRetryRequest request = PaymentRetryRequest.builder() + .downtime(DowntimeRetryRequest.builder() + .enabled(true) + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"downtime\"")); + assertTrue(json.contains("\"enabled\":true")); + } + + @Test + void shouldSerializeWithBothDunningAndDowntime() { + final PaymentRetryRequest request = PaymentRetryRequest.builder() + .dunning(DunningRetryRequest.builder() + .enabled(true) + .maxAttempts(5) + .endAfterDays(14) + .build()) + .downtime(DowntimeRetryRequest.builder() + .enabled(false) + .build()) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(request)); + } + + @Test + void shouldDeserializeDunningFromJson() { + final String json = "{" + + "\"dunning\":{" + + " \"enabled\":true," + + " \"max_attempts\":3," + + " \"end_after_days\":7" + + "}," + + "\"downtime\":{" + + " \"enabled\":false" + + "}" + + "}"; + + final PaymentRetryRequest request = serializer.fromJson(json, PaymentRetryRequest.class); + + assertNotNull(request); + assertNotNull(request.getDunning()); + assertTrue(request.getDunning().getEnabled()); + assertEquals(3, request.getDunning().getMaxAttempts()); + assertEquals(7, request.getDunning().getEndAfterDays()); + assertNotNull(request.getDowntime()); + assertEquals(false, request.getDowntime().getEnabled()); + } + + @Test + void shouldRoundTripSerialize() { + final PaymentRetryRequest original = PaymentRetryRequest.builder() + .dunning(DunningRetryRequest.builder() + .enabled(true) + .maxAttempts(3) + .endAfterDays(7) + .build()) + .downtime(DowntimeRetryRequest.builder() + .enabled(true) + .build()) + .build(); + + final String json = serializer.toJson(original); + final PaymentRetryRequest deserialized = serializer.fromJson(json, PaymentRetryRequest.class); + + assertNotNull(deserialized); + assertNotNull(deserialized.getDunning()); + assertEquals(true, deserialized.getDunning().getEnabled()); + assertEquals(3, deserialized.getDunning().getMaxAttempts()); + assertEquals(7, deserialized.getDunning().getEndAfterDays()); + assertNotNull(deserialized.getDowntime()); + assertEquals(true, deserialized.getDowntime().getEnabled()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{}"; + + final PaymentRetryRequest request = serializer.fromJson(json, PaymentRetryRequest.class); + + assertNotNull(request); + assertDoesNotThrow(() -> serializer.toJson(request)); + assertNull(request.getDunning()); + assertNull(request.getDowntime()); + } +} diff --git a/src/test/java/com/checkout/payments/request/PayoutRequestSerializationTest.java b/src/test/java/com/checkout/payments/request/PayoutRequestSerializationTest.java new file mode 100644 index 00000000..7f1a7aeb --- /dev/null +++ b/src/test/java/com/checkout/payments/request/PayoutRequestSerializationTest.java @@ -0,0 +1,156 @@ +package com.checkout.payments.request; + +import com.checkout.GsonSerializer; +import com.checkout.common.Currency; +import com.checkout.payments.request.source.PayoutRequestCurrencyAccountSource; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class PayoutRequestSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeCurrencyAndAmount() { + final PayoutRequest request = PayoutRequest.builder() + .currency(Currency.USD) + .amount(5000L) + .source(PayoutRequestCurrencyAccountSource.builder().id("ca_abc123").build()) + .build(); + + final String json = serializer.toJson(request); + + assertNotNull(json); + assertTrue(json.contains("\"currency\":\"USD\"")); + assertTrue(json.contains("\"amount\":5000")); + } + + @Test + void shouldSerializeReference() { + final PayoutRequest request = PayoutRequest.builder() + .currency(Currency.GBP) + .reference("PO-2024-001") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"reference\":\"PO-2024-001\"")); + } + + @Test + void shouldSerializeProcessingChannelId() { + final PayoutRequest request = PayoutRequest.builder() + .currency(Currency.EUR) + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"processing_channel_id\":\"pc_abcdefghijklmnopqrstuvwxyz\"")); + } + + @Test + void shouldSerializeBillingDescriptor() { + final PayoutRequest request = PayoutRequest.builder() + .currency(Currency.USD) + .billingDescriptor(PayoutBillingDescriptor.builder() + .reference("Payout reference") + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"billing_descriptor\"")); + assertTrue(json.contains("\"reference\":\"Payout reference\"")); + } + + @Test + void shouldSerializeInstruction() { + final PayoutRequest request = PayoutRequest.builder() + .currency(Currency.USD) + .instruction(PaymentInstruction.builder() + .purpose("salary") + .build()) + .build(); + + final String json = serializer.toJson(request); + + assertTrue(json.contains("\"instruction\"")); + assertTrue(json.contains("\"purpose\":\"salary\"")); + } + + @Test + void shouldDeserializeKeyFields() { + final String json = "{" + + "\"amount\":10000," + + "\"currency\":\"GBP\"," + + "\"reference\":\"PO-001\"," + + "\"processing_channel_id\":\"pc_test\"" + + "}"; + + final PayoutRequest request = serializer.fromJson(json, PayoutRequest.class); + + assertNotNull(request); + assertEquals(10000L, request.getAmount()); + assertEquals(Currency.GBP, request.getCurrency()); + assertEquals("PO-001", request.getReference()); + assertEquals("pc_test", request.getProcessingChannelId()); + } + + @Test + void shouldRoundTripSerialize() { + final PayoutRequest original = PayoutRequest.builder() + .currency(Currency.EUR) + .amount(7500L) + .reference("RT-PAYOUT-001") + .processingChannelId("pc_abcdefghijklmnopqrstuvwxyz") + .billingDescriptor(PayoutBillingDescriptor.builder() + .reference("RT descriptor") + .build()) + .build(); + + final String json = serializer.toJson(original); + final PayoutRequest deserialized = serializer.fromJson(json, PayoutRequest.class); + + assertNotNull(deserialized); + assertEquals(Currency.EUR, deserialized.getCurrency()); + assertEquals(7500L, deserialized.getAmount()); + assertEquals("RT-PAYOUT-001", deserialized.getReference()); + assertEquals("pc_abcdefghijklmnopqrstuvwxyz", deserialized.getProcessingChannelId()); + assertNotNull(deserialized.getBillingDescriptor()); + assertEquals("RT descriptor", deserialized.getBillingDescriptor().getReference()); + } + + @Test + void shouldNotSerializeNullOptionalFields() { + final PayoutRequest request = PayoutRequest.builder() + .currency(Currency.USD) + .build(); + + final String json = serializer.toJson(request); + + assertFalse(json.contains("\"amount\"")); + assertFalse(json.contains("\"reference\"")); + assertFalse(json.contains("\"billing_descriptor\"")); + assertFalse(json.contains("\"processing_channel_id\"")); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"currency\":\"USD\"}"; + + final PayoutRequest request = serializer.fromJson(json, PayoutRequest.class); + + assertNotNull(request); + assertDoesNotThrow(() -> serializer.toJson(request)); + assertNull(request.getAmount()); + assertNull(request.getReference()); + assertNull(request.getBillingDescriptor()); + } +} diff --git a/src/test/java/com/checkout/payments/request/source/RequestCustomerSourceSerializationTest.java b/src/test/java/com/checkout/payments/request/source/RequestCustomerSourceSerializationTest.java new file mode 100644 index 00000000..73ec0652 --- /dev/null +++ b/src/test/java/com/checkout/payments/request/source/RequestCustomerSourceSerializationTest.java @@ -0,0 +1,148 @@ +package com.checkout.payments.request.source; + +import com.checkout.GsonSerializer; +import com.checkout.common.AccountHolder; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Phone; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class RequestCustomerSourceSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeWithCustomerId() { + final RequestCustomerSource source = RequestCustomerSource.builder() + .id("cus_y3oqhf46pyzuxjbcn2giaqnb44") + .build(); + + final String json = serializer.toJson(source); + + assertNotNull(json); + assertTrue(json.contains("\"type\":\"customer\"")); + assertTrue(json.contains("\"id\":\"cus_y3oqhf46pyzuxjbcn2giaqnb44\"")); + } + + @Test + void shouldSerializeWithAllOptionalFields() { + final RequestCustomerSource source = RequestCustomerSource.builder() + .id("cus_y3oqhf46pyzuxjbcn2giaqnb44") + .billingAddress(Address.builder() + .addressLine1("123 High Street") + .city("London") + .zip("SW1A 1AA") + .country(CountryCode.GB) + .build()) + .phone(Phone.builder() + .countryCode("+44") + .number("7911123456") + .build()) + .accountHolder(AccountHolder.builder() + .firstName("John") + .lastName("Smith") + .build()) + .allowUpdate(true) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(source)); + } + + @Test + void shouldSerializeBillingAddress() { + final RequestCustomerSource source = RequestCustomerSource.builder() + .id("cus_y3oqhf46pyzuxjbcn2giaqnb44") + .billingAddress(Address.builder() + .addressLine1("123 High Street") + .country(CountryCode.GB) + .build()) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"billing_address\"")); + assertTrue(json.contains("\"address_line1\":\"123 High Street\"")); + } + + @Test + void shouldSerializeAllowUpdate() { + final RequestCustomerSource source = RequestCustomerSource.builder() + .id("cus_y3oqhf46pyzuxjbcn2giaqnb44") + .allowUpdate(true) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"allow_update\":true")); + } + + @Test + void shouldDeserializeSwaggerExample() { + final String swaggerJson = "{" + + "\"type\":\"customer\"," + + "\"id\":\"cus_y3oqhf46pyzuxjbcn2giaqnb44\"," + + "\"billing_address\":{" + + " \"address_line1\":\"123 High Street\"," + + " \"city\":\"London\"," + + " \"zip\":\"SW1A 1AA\"," + + " \"country\":\"GB\"" + + "}," + + "\"phone\":{" + + " \"country_code\":\"+44\"," + + " \"number\":\"7911123456\"" + + "}," + + "\"allow_update\":true" + + "}"; + + final RequestCustomerSource source = serializer.fromJson(swaggerJson, RequestCustomerSource.class); + + assertNotNull(source); + assertEquals("cus_y3oqhf46pyzuxjbcn2giaqnb44", source.getId()); + assertNotNull(source.getBillingAddress()); + assertEquals("123 High Street", source.getBillingAddress().getAddressLine1()); + assertNotNull(source.getPhone()); + assertEquals("+44", source.getPhone().getCountryCode()); + assertTrue(source.getAllowUpdate()); + } + + @Test + void shouldRoundTripSerialize() { + final RequestCustomerSource original = RequestCustomerSource.builder() + .id("cus_y3oqhf46pyzuxjbcn2giaqnb44") + .billingAddress(Address.builder() + .addressLine1("123 High Street") + .country(CountryCode.GB) + .build()) + .allowUpdate(true) + .build(); + + final String json = serializer.toJson(original); + final RequestCustomerSource deserialized = serializer.fromJson(json, RequestCustomerSource.class); + + assertNotNull(deserialized); + assertEquals("cus_y3oqhf46pyzuxjbcn2giaqnb44", deserialized.getId()); + assertNotNull(deserialized.getBillingAddress()); + assertEquals("123 High Street", deserialized.getBillingAddress().getAddressLine1()); + assertTrue(deserialized.getAllowUpdate()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"type\":\"customer\",\"id\":\"cus_y3oqhf46pyzuxjbcn2giaqnb44\"}"; + + final RequestCustomerSource source = serializer.fromJson(json, RequestCustomerSource.class); + + assertNotNull(source); + assertDoesNotThrow(() -> serializer.toJson(source)); + assertNull(source.getBillingAddress()); + assertNull(source.getPhone()); + assertNull(source.getAccountHolder()); + assertNull(source.getAllowUpdate()); + } +} diff --git a/src/test/java/com/checkout/payments/request/source/RequestIdSourceSerializationTest.java b/src/test/java/com/checkout/payments/request/source/RequestIdSourceSerializationTest.java new file mode 100644 index 00000000..01dcd223 --- /dev/null +++ b/src/test/java/com/checkout/payments/request/source/RequestIdSourceSerializationTest.java @@ -0,0 +1,172 @@ +package com.checkout.payments.request.source; + +import com.checkout.GsonSerializer; +import com.checkout.common.AccountHolder; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Phone; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class RequestIdSourceSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeWithRequiredId() { + final RequestIdSource source = RequestIdSource.builder() + .id("src_wmlfc3zyhqzehihu7giusaaawu") + .build(); + + final String json = serializer.toJson(source); + + assertNotNull(json); + assertTrue(json.contains("\"type\":\"id\"")); + assertTrue(json.contains("\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"")); + } + + @Test + void shouldSerializeWithAllOptionalFields() { + final RequestIdSource source = RequestIdSource.builder() + .id("src_wmlfc3zyhqzehihu7giusaaawu") + .cvv("100") + .paymentMethod("visa") + .stored(true) + .storeForFutureUse(false) + .billingAddress(Address.builder() + .addressLine1("123 High Street") + .city("London") + .zip("SW1A 1AA") + .country(CountryCode.GB) + .build()) + .phone(Phone.builder() + .countryCode("+44") + .number("7911123456") + .build()) + .accountHolder(AccountHolder.builder() + .firstName("John") + .lastName("Smith") + .build()) + .allowUpdate(true) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(source)); + } + + @Test + void shouldSerializeBillingAddress() { + final RequestIdSource source = RequestIdSource.builder() + .id("src_wmlfc3zyhqzehihu7giusaaawu") + .billingAddress(Address.builder() + .addressLine1("123 High Street") + .country(CountryCode.GB) + .build()) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"billing_address\"")); + assertTrue(json.contains("\"address_line1\":\"123 High Street\"")); + } + + @Test + void shouldSerializeAllowUpdate() { + final RequestIdSource source = RequestIdSource.builder() + .id("src_wmlfc3zyhqzehihu7giusaaawu") + .allowUpdate(true) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"allow_update\":true")); + } + + @Test + void shouldSerializeStoreForFutureUse() { + final RequestIdSource source = RequestIdSource.builder() + .id("src_wmlfc3zyhqzehihu7giusaaawu") + .storeForFutureUse(true) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"store_for_future_use\":true")); + } + + @Test + void shouldDeserializeSwaggerExample() { + final String swaggerJson = "{" + + "\"type\":\"id\"," + + "\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"," + + "\"cvv\":\"100\"," + + "\"stored\":false," + + "\"billing_address\":{" + + " \"address_line1\":\"123 High Street\"," + + " \"city\":\"London\"," + + " \"zip\":\"SW1A 1AA\"," + + " \"country\":\"GB\"" + + "}," + + "\"phone\":{" + + " \"country_code\":\"+44\"," + + " \"number\":\"7911123456\"" + + "}," + + "\"allow_update\":false" + + "}"; + + final RequestIdSource source = serializer.fromJson(swaggerJson, RequestIdSource.class); + + assertNotNull(source); + assertEquals("src_wmlfc3zyhqzehihu7giusaaawu", source.getId()); + assertEquals("100", source.getCvv()); + assertEquals(false, source.getStored()); + assertNotNull(source.getBillingAddress()); + assertEquals("123 High Street", source.getBillingAddress().getAddressLine1()); + assertEquals(CountryCode.GB, source.getBillingAddress().getCountry()); + assertNotNull(source.getPhone()); + assertEquals("+44", source.getPhone().getCountryCode()); + assertEquals(false, source.getAllowUpdate()); + } + + @Test + void shouldRoundTripSerialize() { + final RequestIdSource original = RequestIdSource.builder() + .id("src_wmlfc3zyhqzehihu7giusaaawu") + .cvv("100") + .stored(true) + .billingAddress(Address.builder() + .addressLine1("123 High Street") + .country(CountryCode.GB) + .build()) + .allowUpdate(true) + .build(); + + final String json = serializer.toJson(original); + final RequestIdSource deserialized = serializer.fromJson(json, RequestIdSource.class); + + assertNotNull(deserialized); + assertEquals("src_wmlfc3zyhqzehihu7giusaaawu", deserialized.getId()); + assertEquals("100", deserialized.getCvv()); + assertTrue(deserialized.getStored()); + assertNotNull(deserialized.getBillingAddress()); + assertTrue(deserialized.getAllowUpdate()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"type\":\"id\",\"id\":\"src_wmlfc3zyhqzehihu7giusaaawu\"}"; + + final RequestIdSource source = serializer.fromJson(json, RequestIdSource.class); + + assertNotNull(source); + assertDoesNotThrow(() -> serializer.toJson(source)); + assertNull(source.getCvv()); + assertNull(source.getBillingAddress()); + assertNull(source.getPhone()); + assertNull(source.getAllowUpdate()); + } +} diff --git a/src/test/java/com/checkout/payments/request/source/apm/RequestSepaSourceSerializationTest.java b/src/test/java/com/checkout/payments/request/source/apm/RequestSepaSourceSerializationTest.java new file mode 100644 index 00000000..e717e5e3 --- /dev/null +++ b/src/test/java/com/checkout/payments/request/source/apm/RequestSepaSourceSerializationTest.java @@ -0,0 +1,170 @@ +package com.checkout.payments.request.source.apm; + +import com.checkout.GsonSerializer; +import com.checkout.common.AccountHolder; +import com.checkout.common.AccountHolderType; +import com.checkout.common.Address; +import com.checkout.common.CountryCode; +import com.checkout.common.Currency; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class RequestSepaSourceSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldSerializeWithRequiredFields() { + final RequestSepaSource source = RequestSepaSource.builder() + .country(CountryCode.FR) + .accountNumber("FR7630006000011234567890189") + .currency(Currency.EUR) + .accountHolder(AccountHolder.builder() + .firstName("John") + .lastName("Smith") + .billingAddress(Address.builder() + .addressLine1("123 Rue de la Paix") + .city("Paris") + .zip("75000") + .country(CountryCode.FR) + .build()) + .build()) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(source)); + } + + @Test + void shouldSerializeWithAllOptionalFields() { + final RequestSepaSource source = RequestSepaSource.builder() + .country(CountryCode.FR) + .accountNumber("FR7630006000011234567890189") + .currency(Currency.EUR) + .mandateId("123456") + .mandateType(MandateType.B2B) + .dateOfSignature("2022-08-02") + .accountHolder(AccountHolder.builder() + .type(AccountHolderType.CORPORATE) + .firstName("John") + .lastName("Smith") + .companyName("Acme Corp") + .billingAddress(Address.builder() + .addressLine1("123 Rue de la Paix") + .city("Paris") + .zip("75000") + .country(CountryCode.FR) + .build()) + .build()) + .build(); + + assertDoesNotThrow(() -> serializer.toJson(source)); + } + + @Test + void shouldSerializeMandateTypeB2B() { + final RequestSepaSource source = RequestSepaSource.builder() + .country(CountryCode.FR) + .accountNumber("FR7630006000011234567890189") + .currency(Currency.EUR) + .mandateType(MandateType.B2B) + .accountHolder(AccountHolder.builder() + .firstName("John") + .lastName("Smith") + .billingAddress(Address.builder() + .country(CountryCode.FR).build()) + .build()) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"mandate_type\":\"B2B\""), + "mandate_type should serialize as 'B2B'. Got: " + json); + } + + @Test + void shouldSerializeMandateTypeCore() { + final RequestSepaSource source = RequestSepaSource.builder() + .country(CountryCode.FR) + .accountNumber("FR7630006000011234567890189") + .currency(Currency.EUR) + .mandateType(MandateType.CORE) + .accountHolder(AccountHolder.builder() + .firstName("John") + .lastName("Smith") + .billingAddress(Address.builder() + .country(CountryCode.FR).build()) + .build()) + .build(); + + final String json = serializer.toJson(source); + + assertTrue(json.contains("\"mandate_type\":\"Core\""), + "mandate_type should serialize as 'Core'. Got: " + json); + } + + @Test + void shouldRoundTripSerialize() { + final RequestSepaSource original = RequestSepaSource.builder() + .country(CountryCode.FR) + .accountNumber("FR7630006000011234567890189") + .currency(Currency.EUR) + .mandateId("123456") + .mandateType(MandateType.B2B) + .dateOfSignature("2022-08-02") + .accountHolder(AccountHolder.builder() + .firstName("John") + .lastName("Smith") + .billingAddress(Address.builder() + .country(CountryCode.FR).build()) + .build()) + .build(); + + final String json = serializer.toJson(original); + final RequestSepaSource deserialized = serializer.fromJson(json, RequestSepaSource.class); + + assertNotNull(deserialized); + assertEquals(CountryCode.FR, deserialized.getCountry()); + assertEquals("FR7630006000011234567890189", deserialized.getAccountNumber()); + assertEquals(MandateType.B2B, deserialized.getMandateType()); + assertEquals("123456", deserialized.getMandateId()); + } + + @Test + void shouldDeserializeSwaggerExample() { + final String swaggerJson = "{" + + "\"type\":\"sepa\"," + + "\"country\":\"FR\"," + + "\"account_number\":\"FR7630006000011234567890189\"," + + "\"currency\":\"EUR\"," + + "\"mandate_id\":\"123456\"," + + "\"mandate_type\":\"B2B\"," + + "\"date_of_signature\":\"2022-08-02\"," + + "\"account_holder\":{" + + " \"first_name\":\"John\"," + + " \"last_name\":\"Wick\"," + + " \"type\":\"Corporate\"," + + " \"company_name\":\"Checkout.com\"," + + " \"billing_address\":{" + + " \"address_line1\":\"Evergreen Terrace\"," + + " \"address_line2\":\"742\"," + + " \"city\":\"Paris\"," + + " \"zip\":\"75000\"," + + " \"country\":\"FR\"" + + " }" + + "}" + + "}"; + + final RequestSepaSource source = serializer.fromJson(swaggerJson, RequestSepaSource.class); + + assertNotNull(source); + assertEquals(CountryCode.FR, source.getCountry()); + assertEquals("FR7630006000011234567890189", source.getAccountNumber()); + assertEquals(MandateType.B2B, source.getMandateType()); + assertNotNull(source.getAccountHolder()); + assertEquals("John", source.getAccountHolder().getFirstName()); + } +} diff --git a/src/test/java/com/checkout/payments/response/source/PayPalResponseSourceSerializationTest.java b/src/test/java/com/checkout/payments/response/source/PayPalResponseSourceSerializationTest.java new file mode 100644 index 00000000..2864b92a --- /dev/null +++ b/src/test/java/com/checkout/payments/response/source/PayPalResponseSourceSerializationTest.java @@ -0,0 +1,98 @@ +package com.checkout.payments.response.source; + +import com.checkout.GsonSerializer; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +class PayPalResponseSourceSerializationTest { + + private final GsonSerializer serializer = new GsonSerializer(); + + @Test + void shouldDeserializeWithAccountHolder() { + final String json = "{" + + "\"type\":\"paypal\"," + + "\"account_holder\":{" + + " \"email\":\"john.smith@example.com\"," + + " \"full_name\":\"John Smith\"" + + "}" + + "}"; + + final PayPalResponseSource source = serializer.fromJson(json, PayPalResponseSource.class); + + assertNotNull(source); + assertNotNull(source.getAccountHolder()); + assertEquals("john.smith@example.com", source.getAccountHolder().getEmail()); + assertEquals("John Smith", source.getAccountHolder().getFullName()); + } + + @Test + void shouldDeserializeWithEmailOnly() { + final String json = "{" + + "\"type\":\"paypal\"," + + "\"account_holder\":{" + + " \"email\":\"buyer@example.com\"" + + "}" + + "}"; + + final PayPalResponseSource source = serializer.fromJson(json, PayPalResponseSource.class); + + assertNotNull(source); + assertNotNull(source.getAccountHolder()); + assertEquals("buyer@example.com", source.getAccountHolder().getEmail()); + assertNull(source.getAccountHolder().getFullName()); + } + + @Test + void shouldDeserializeSwaggerExample() { + final String swaggerJson = "{" + + "\"type\":\"paypal\"," + + "\"account_holder\":{" + + " \"email\":\"payer@example.com\"," + + " \"full_name\":\"Jane Doe\"" + + "}" + + "}"; + + final PayPalResponseSource source = serializer.fromJson(swaggerJson, PayPalResponseSource.class); + + assertNotNull(source); + assertNotNull(source.getAccountHolder()); + assertEquals("payer@example.com", source.getAccountHolder().getEmail()); + assertEquals("Jane Doe", source.getAccountHolder().getFullName()); + } + + @Test + void shouldRoundTripSerialize() { + final String original = "{" + + "\"type\":\"paypal\"," + + "\"account_holder\":{" + + " \"email\":\"john.smith@example.com\"," + + " \"full_name\":\"John Smith\"" + + "}" + + "}"; + + final PayPalResponseSource source = serializer.fromJson(original, PayPalResponseSource.class); + final String reserialised = serializer.toJson(source); + final PayPalResponseSource roundTripped = serializer.fromJson(reserialised, PayPalResponseSource.class); + + assertNotNull(roundTripped); + assertNotNull(roundTripped.getAccountHolder()); + assertEquals("john.smith@example.com", roundTripped.getAccountHolder().getEmail()); + assertEquals("John Smith", roundTripped.getAccountHolder().getFullName()); + } + + @Test + void shouldHandleAbsentOptionalFields() { + final String json = "{\"type\":\"paypal\"}"; + + final PayPalResponseSource source = serializer.fromJson(json, PayPalResponseSource.class); + + assertNotNull(source); + assertDoesNotThrow(() -> serializer.toJson(source)); + assertNull(source.getAccountHolder()); + } +}