From cc36679d1395ebb652aeb27fb7145a6711c70c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:26:23 +0200 Subject: [PATCH] Add network_token destination request. Fix challenge indicator and exemption (#447) --- .../checkout/common/ChallengeIndicator.java | 10 ---- .../java/com/checkout/common/Exemption.java | 32 +++++----- .../payments/PaymentDestinationType.java | 2 + ...PaymentRequestNetworkTokenDestination.java | 59 +++++++++++++++++++ 4 files changed, 79 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/checkout/payments/request/destination/PaymentRequestNetworkTokenDestination.java diff --git a/src/main/java/com/checkout/common/ChallengeIndicator.java b/src/main/java/com/checkout/common/ChallengeIndicator.java index 3c8ef06f..1c8f995a 100644 --- a/src/main/java/com/checkout/common/ChallengeIndicator.java +++ b/src/main/java/com/checkout/common/ChallengeIndicator.java @@ -8,19 +8,9 @@ public enum ChallengeIndicator { CHALLENGE_REQUESTED, @SerializedName("challenge_requested_mandate") CHALLENGE_REQUESTED_MANDATE, - @SerializedName("data_share") - DATA_SHARE, - @SerializedName("low_value") - LOW_VALUE, @SerializedName("no_challenge_requested") NO_CHALLENGE_REQUESTED, @SerializedName("no_preference") NO_PREFERENCE, - @SerializedName("transaction_risk_assessment") - TRANSACTION_RISK_ASSESSMENT, - @SerializedName("trusted_listing") - TRUSTED_LISTING, - @SerializedName("trusted_listing_prompt") - TRUSTED_LISTING_PROMPT } diff --git a/src/main/java/com/checkout/common/Exemption.java b/src/main/java/com/checkout/common/Exemption.java index 67ab4cdb..53bfb4b2 100644 --- a/src/main/java/com/checkout/common/Exemption.java +++ b/src/main/java/com/checkout/common/Exemption.java @@ -4,27 +4,31 @@ public enum Exemption { - @SerializedName("3ds_outage") - THREE_DS_OUTAGE, - @SerializedName("None") - NONE, - @SerializedName("low_risk_program") - LOW_RISK_PROGRAM, @SerializedName("low_value") LOW_VALUE, - @SerializedName("other") - OTHER, + @SerializedName("trusted_listing") + TRUSTED_LISTING, + @SerializedName("trusted_listing_prompt") + TRUSTED_LISTING_PROMPT, + @SerializedName("transaction_risk_assessment") + TRANSACTION_RISK_ASSESSMENT, + @SerializedName("3ds_outage") + THREE_DS_OUTAGE, + @SerializedName("sca_delegation") + SCA_DELEGATION, @SerializedName("out_of_sca_scope") OUT_OF_SCA_SCOPE, + @SerializedName("low_risk_program") + LOW_RISK_PROGRAM, @SerializedName("recurring_operation") RECURRING_OPERATION, - @SerializedName("sca_delegation") - SCA_DELEGATION, + @SerializedName("data_share") + DATA_SHARE, + @SerializedName("other") + OTHER, + @SerializedName(value = "None", alternate = {"NONE", "none"}) + NONE, @SerializedName("secure_corporate_payment") SECURE_CORPORATE_PAYMENT, - @SerializedName("transaction_risk_assessment") - TRANSACTION_RISK_ASSESSMENT, - @SerializedName("trusted_listing") - TRUSTED_LISTING, } diff --git a/src/main/java/com/checkout/payments/PaymentDestinationType.java b/src/main/java/com/checkout/payments/PaymentDestinationType.java index 51d41243..eb6248fe 100644 --- a/src/main/java/com/checkout/payments/PaymentDestinationType.java +++ b/src/main/java/com/checkout/payments/PaymentDestinationType.java @@ -10,6 +10,8 @@ public enum PaymentDestinationType { ID, @SerializedName("token") TOKEN, + @SerializedName("network_token") + NETWORK_TOKEN, @SerializedName("bank_account") BANK_ACCOUNT; diff --git a/src/main/java/com/checkout/payments/request/destination/PaymentRequestNetworkTokenDestination.java b/src/main/java/com/checkout/payments/request/destination/PaymentRequestNetworkTokenDestination.java new file mode 100644 index 00000000..287362bd --- /dev/null +++ b/src/main/java/com/checkout/payments/request/destination/PaymentRequestNetworkTokenDestination.java @@ -0,0 +1,59 @@ +package com.checkout.payments.request.destination; + +import com.checkout.common.AccountHolder; +import com.checkout.payments.NetworkTokenType; +import com.checkout.payments.PaymentDestinationType; +import com.google.gson.annotations.SerializedName; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public final class PaymentRequestNetworkTokenDestination extends PaymentRequestDestination { + + private String token; + + @SerializedName("expiry_month") + private Integer expiryMonth; + + @SerializedName("expiry_year") + private Integer expiryYear; + + @SerializedName("token_type") + private NetworkTokenType tokenType; + + private String cryptogram; + + private String eci; + + @SerializedName("account_holder") + private AccountHolder accountHolder; + + @Builder + private PaymentRequestNetworkTokenDestination(final String token, + final Integer expiryMonth, + final Integer expiryYear, + final NetworkTokenType tokenType, + final String cryptogram, + final String eci, + final AccountHolder accountHolder) { + super(PaymentDestinationType.NETWORK_TOKEN); + this.token = token; + this.expiryMonth = expiryMonth; + this.expiryYear = expiryYear; + this.tokenType = tokenType; + this.cryptogram = cryptogram; + this.eci = eci; + this.accountHolder = accountHolder; + } + + public PaymentRequestNetworkTokenDestination() { + super(PaymentDestinationType.NETWORK_TOKEN); + } + +}