diff --git a/src/main/java/com/adyen/Client.java b/src/main/java/com/adyen/Client.java index 60293b418..f61474251 100644 --- a/src/main/java/com/adyen/Client.java +++ b/src/main/java/com/adyen/Client.java @@ -45,6 +45,8 @@ public class Client { public static final String CHECKOUT_ENDPOINT_TEST = "https://checkout-test.adyen.com/checkout"; public static final String CHECKOUT_ENDPOINT_LIVE_SUFFIX = "-checkout-live.adyenpayments.com/checkout"; public static final String CHECKOUT_API_VERSION = "v41"; + public static final String BIN_LOOKUP_PAL_SUFFIX = "/pal/servlet/BinLookup/"; + public static final String BIN_LOOKUP_API_VERSION = "v40"; public static final String CHECKOUT_UTILITY_API_VERSION = "v1"; public static final String ENDPOINT_PROTOCOL = "https://"; diff --git a/src/main/java/com/adyen/model/binlookup/CardBin.java b/src/main/java/com/adyen/model/binlookup/CardBin.java new file mode 100755 index 000000000..8b32ee09b --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/CardBin.java @@ -0,0 +1,312 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * CardBin + */ + +public class CardBin { + + @SerializedName("bin") + private String bin = null; + + @SerializedName("commercial") + private Boolean commercial = null; + + @SerializedName("fundingSource") + private String fundingSource = null; + + @SerializedName("fundsAvailability") + private String fundsAvailability = null; + + @SerializedName("issuingBank") + private String issuingBank = null; + + @SerializedName("issuingCountry") + private String issuingCountry = null; + + @SerializedName("issuingCurrency") + private String issuingCurrency = null; + + @SerializedName("paymentMethod") + private String paymentMethod = null; + + @SerializedName("payoutEligible") + private String payoutEligible = null; + + @SerializedName("summary") + private String summary = null; + + public CardBin bin(String bin) { + this.bin = bin; + return this; + } + + + /** + * The first 6 digit of the card number. Enable this field via merchant account settings. + * + * @return bin + **/ + public String getBin() { + return bin; + } + + public void setBin(String bin) { + this.bin = bin; + } + + public CardBin commercial(Boolean commercial) { + this.commercial = commercial; + return this; + } + + + /** + * If true, it indicates a commercial card. Enable this field via merchant account settings. + * + * @return commercial + **/ + public Boolean isCommercial() { + return commercial; + } + + public void setCommercial(Boolean commercial) { + this.commercial = commercial; + } + + public CardBin fundingSource(String fundingSource) { + this.fundingSource = fundingSource; + return this; + } + + + /** + * The card funding source. Valid values are: * CREDIT * DEBIT * PREPAID * PREPAID_RELOADABLE * DEFERRED_DEBIT * CHARGED > Enable this field via merchant account settings. + * + * @return fundingSource + **/ + public String getFundingSource() { + return fundingSource; + } + + public void setFundingSource(String fundingSource) { + this.fundingSource = fundingSource; + } + + public CardBin fundsAvailability(String fundsAvailability) { + this.fundsAvailability = fundsAvailability; + return this; + } + + + /** + * Indicates availability of funds. Visa: * \"I\" (fast funds are supported) * \"N\" (otherwise) Mastercard: * \"I\" (product type is Prepaid or Debit, or issuing + * country is in CEE/HGEM list) * \"N\" (otherwise) > Returned when you verify a card BIN or estimate costs, and only if `payoutEligible` is different from \"N\" + * or \"U\". + * + * @return fundsAvailability + **/ + public String getFundsAvailability() { + return fundsAvailability; + } + + public void setFundsAvailability(String fundsAvailability) { + this.fundsAvailability = fundsAvailability; + } + + public CardBin issuingBank(String issuingBank) { + this.issuingBank = issuingBank; + return this; + } + + + /** + * The issuing bank of the card. + * + * @return issuingBank + **/ + public String getIssuingBank() { + return issuingBank; + } + + public void setIssuingBank(String issuingBank) { + this.issuingBank = issuingBank; + } + + public CardBin issuingCountry(String issuingCountry) { + this.issuingCountry = issuingCountry; + return this; + } + + + /** + * The country where the card was issued from. + * + * @return issuingCountry + **/ + public String getIssuingCountry() { + return issuingCountry; + } + + public void setIssuingCountry(String issuingCountry) { + this.issuingCountry = issuingCountry; + } + + public CardBin issuingCurrency(String issuingCurrency) { + this.issuingCurrency = issuingCurrency; + return this; + } + + + /** + * The currency of the card. + * + * @return issuingCurrency + **/ + public String getIssuingCurrency() { + return issuingCurrency; + } + + public void setIssuingCurrency(String issuingCurrency) { + this.issuingCurrency = issuingCurrency; + } + + public CardBin paymentMethod(String paymentMethod) { + this.paymentMethod = paymentMethod; + return this; + } + + + /** + * The payment method associated with the card (e.g. visa, mc, or amex). + * + * @return paymentMethod + **/ + public String getPaymentMethod() { + return paymentMethod; + } + + public void setPaymentMethod(String paymentMethod) { + this.paymentMethod = paymentMethod; + } + + public CardBin payoutEligible(String payoutEligible) { + this.payoutEligible = payoutEligible; + return this; + } + + + /** + * Indicates whether a payout is eligible or not for this card. Visa: * \"Y\" * \"N\" Mastercard: * \"Y\" (domestic and cross-border) * \"D\" (only + * domestic) * \"N\" (no MoneySend) * \"U\" (unknown) > Returned when you verify a card BIN or estimate costs, and only if `payoutEligible` is different from + * \"N\" or \"U\". + * + * @return payoutEligible + **/ + public String getPayoutEligible() { + return payoutEligible; + } + + public void setPayoutEligible(String payoutEligible) { + this.payoutEligible = payoutEligible; + } + + public CardBin summary(String summary) { + this.summary = summary; + return this; + } + + + /** + * The last four digits of the card number. + * + * @return summary + **/ + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CardBin cardBin = (CardBin) o; + return Objects.equals(this.bin, cardBin.bin) + && Objects.equals(this.commercial, cardBin.commercial) + && Objects.equals(this.fundingSource, cardBin.fundingSource) + && Objects.equals(this.fundsAvailability, cardBin.fundsAvailability) + && Objects.equals(this.issuingBank, cardBin.issuingBank) + && Objects.equals(this.issuingCountry, cardBin.issuingCountry) + && Objects.equals(this.issuingCurrency, cardBin.issuingCurrency) + && Objects.equals(this.paymentMethod, cardBin.paymentMethod) + && Objects.equals(this.payoutEligible, cardBin.payoutEligible) + && Objects.equals(this.summary, cardBin.summary); + } + + @Override + public int hashCode() { + return Objects.hash(bin, commercial, fundingSource, fundsAvailability, issuingBank, issuingCountry, issuingCurrency, paymentMethod, payoutEligible, summary); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CardBin {\n"); + + sb.append(" bin: ").append(toIndentedString(bin)).append("\n"); + sb.append(" commercial: ").append(toIndentedString(commercial)).append("\n"); + sb.append(" fundingSource: ").append(toIndentedString(fundingSource)).append("\n"); + sb.append(" fundsAvailability: ").append(toIndentedString(fundsAvailability)).append("\n"); + sb.append(" issuingBank: ").append(toIndentedString(issuingBank)).append("\n"); + sb.append(" issuingCountry: ").append(toIndentedString(issuingCountry)).append("\n"); + sb.append(" issuingCurrency: ").append(toIndentedString(issuingCurrency)).append("\n"); + sb.append(" paymentMethod: ").append(toIndentedString(paymentMethod)).append("\n"); + sb.append(" payoutEligible: ").append(toIndentedString(payoutEligible)).append("\n"); + sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/CostEstimateAssumptions.java b/src/main/java/com/adyen/model/binlookup/CostEstimateAssumptions.java new file mode 100755 index 000000000..abc410647 --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/CostEstimateAssumptions.java @@ -0,0 +1,140 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * CostEstimateAssumptions + */ + +public class CostEstimateAssumptions { + + @SerializedName("assume3DSecureAuthenticated") + private Boolean assume3DSecureAuthenticated = null; + + @SerializedName("assumeLevel3Data") + private Boolean assumeLevel3Data = null; + + @SerializedName("installments") + private Integer installments = null; + + public CostEstimateAssumptions assume3DSecureAuthenticated(Boolean assume3DSecureAuthenticated) { + this.assume3DSecureAuthenticated = assume3DSecureAuthenticated; + return this; + } + + + /** + * If true, the cardholder is expected to successfully authorise via 3D Secure. + * + * @return assume3DSecureAuthenticated + **/ + public Boolean isAssume3DSecureAuthenticated() { + return assume3DSecureAuthenticated; + } + + public void setAssume3DSecureAuthenticated(Boolean assume3DSecureAuthenticated) { + this.assume3DSecureAuthenticated = assume3DSecureAuthenticated; + } + + public CostEstimateAssumptions assumeLevel3Data(Boolean assumeLevel3Data) { + this.assumeLevel3Data = assumeLevel3Data; + return this; + } + + + /** + * If true, the transaction is expected to have valid Level 3 data. + * + * @return assumeLevel3Data + **/ + public Boolean isAssumeLevel3Data() { + return assumeLevel3Data; + } + + public void setAssumeLevel3Data(Boolean assumeLevel3Data) { + this.assumeLevel3Data = assumeLevel3Data; + } + + public CostEstimateAssumptions installments(Integer installments) { + this.installments = installments; + return this; + } + + + /** + * If not zero, the number of installments. + * + * @return installments + **/ + public Integer getInstallments() { + return installments; + } + + public void setInstallments(Integer installments) { + this.installments = installments; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostEstimateAssumptions costEstimateAssumptions = (CostEstimateAssumptions) o; + return Objects.equals(this.assume3DSecureAuthenticated, costEstimateAssumptions.assume3DSecureAuthenticated) + && Objects.equals(this.assumeLevel3Data, costEstimateAssumptions.assumeLevel3Data) + && Objects.equals(this.installments, costEstimateAssumptions.installments); + } + + @Override + public int hashCode() { + return Objects.hash(assume3DSecureAuthenticated, assumeLevel3Data, installments); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CostEstimateAssumptions {\n"); + + sb.append(" assume3DSecureAuthenticated: ").append(toIndentedString(assume3DSecureAuthenticated)).append("\n"); + sb.append(" assumeLevel3Data: ").append(toIndentedString(assumeLevel3Data)).append("\n"); + sb.append(" installments: ").append(toIndentedString(installments)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/CostEstimateRequest.java b/src/main/java/com/adyen/model/binlookup/CostEstimateRequest.java new file mode 100755 index 000000000..129b2cf0b --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/CostEstimateRequest.java @@ -0,0 +1,377 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import com.adyen.model.Amount; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.Objects; + +/** + * CostEstimateRequest + */ + +public class CostEstimateRequest { + + @SerializedName("amount") + private Amount amount = null; + + @SerializedName("assumptions") + private CostEstimateAssumptions assumptions = null; + + @SerializedName("cardNumber") + private String cardNumber = null; + + @SerializedName("encryptedCard") + private String encryptedCard = null; + + @SerializedName("merchantAccount") + private String merchantAccount = null; + + @SerializedName("merchantDetails") + private MerchantDetails merchantDetails = null; + + @SerializedName("recurring") + private Recurring recurring = null; + + @SerializedName("selectedRecurringDetailReference") + private String selectedRecurringDetailReference = null; + + /** + * Specifies the sales channel, through which the shopper gives their card details, and whether the shopper is a returning customer. For the web service API, Adyen assumes Ecommerce shopper + * interaction by default. This field has the following possible values: * `Ecommerce` - Online transactions where the cardholder is present (online). For better authorisation rates, + * we recommend sending the card security code (CSC) along with the request. * `ContAuth` - Card on file and/or subscription transactions, where the card holder is known to the merchant + * (returning customer). If the shopper is present (online), you can supply also the CSC to improve authorisation (one-click payment). * `Moto` - Mail-order and telephone-order + * transactions where the shopper is in contact with the merchant via email or telephone. * `POS` - Point-of-sale transactions where the shopper is physically present to make a payment + * using a secure payment terminal. + */ + @JsonAdapter(ShopperInteractionEnum.Adapter.class) + public enum ShopperInteractionEnum { + ECOMMERCE("Ecommerce"), + CONTAUTH("ContAuth"), + MOTO("Moto"), + POS("POS"); + + private String value; + + ShopperInteractionEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ShopperInteractionEnum fromValue(String text) { + for (ShopperInteractionEnum b : ShopperInteractionEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ShopperInteractionEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ShopperInteractionEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ShopperInteractionEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("shopperInteraction") + private ShopperInteractionEnum shopperInteraction = null; + + @SerializedName("shopperReference") + private String shopperReference = null; + + public CostEstimateRequest amount(Amount amount) { + this.amount = amount; + return this; + } + + + /** + * Get amount + * + * @return amount + **/ + public Amount getAmount() { + return amount; + } + + public void setAmount(Amount amount) { + this.amount = amount; + } + + public CostEstimateRequest assumptions(CostEstimateAssumptions assumptions) { + this.assumptions = assumptions; + return this; + } + + + /** + * Get assumptions + * + * @return assumptions + **/ + public CostEstimateAssumptions getAssumptions() { + return assumptions; + } + + public void setAssumptions(CostEstimateAssumptions assumptions) { + this.assumptions = assumptions; + } + + public CostEstimateRequest cardNumber(String cardNumber) { + this.cardNumber = cardNumber; + return this; + } + + + /** + * The card number (4-19 characters) for PCI compliant use cases. Do not use any separators. > Either the `cardNumber` or `encryptedCard` field must be provided in a + * payment request. + * + * @return cardNumber + **/ + public String getCardNumber() { + return cardNumber; + } + + public void setCardNumber(String cardNumber) { + this.cardNumber = cardNumber; + } + + public CostEstimateRequest encryptedCard(String encryptedCard) { + this.encryptedCard = encryptedCard; + return this; + } + + + /** + * Encrypted data that stores card information for non PCI-compliant use cases. The encrypted data must be created with the Client-Side Encryption library and must contain at least the ` + * number` and `generationtime` fields. > Either the `cardNumber` or `encryptedCard` field must be provided in a payment request. + * + * @return encryptedCard + **/ + public String getEncryptedCard() { + return encryptedCard; + } + + public void setEncryptedCard(String encryptedCard) { + this.encryptedCard = encryptedCard; + } + + public CostEstimateRequest merchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + return this; + } + + + /** + * The merchant account identifier you want to process the (transaction) request with. + * + * @return merchantAccount + **/ + public String getMerchantAccount() { + return merchantAccount; + } + + public void setMerchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + } + + public CostEstimateRequest merchantDetails(MerchantDetails merchantDetails) { + this.merchantDetails = merchantDetails; + return this; + } + + + /** + * Get merchantDetails + * + * @return merchantDetails + **/ + public MerchantDetails getMerchantDetails() { + return merchantDetails; + } + + public void setMerchantDetails(MerchantDetails merchantDetails) { + this.merchantDetails = merchantDetails; + } + + public CostEstimateRequest recurring(Recurring recurring) { + this.recurring = recurring; + return this; + } + + + /** + * Get recurring + * + * @return recurring + **/ + public Recurring getRecurring() { + return recurring; + } + + public void setRecurring(Recurring recurring) { + this.recurring = recurring; + } + + public CostEstimateRequest selectedRecurringDetailReference(String selectedRecurringDetailReference) { + this.selectedRecurringDetailReference = selectedRecurringDetailReference; + return this; + } + + + /** + * The `recurringDetailReference` you want to use for this cost estimate. The value `LATEST` can be used to select the most recently stored recurring detail. + * + * @return selectedRecurringDetailReference + **/ + public String getSelectedRecurringDetailReference() { + return selectedRecurringDetailReference; + } + + public void setSelectedRecurringDetailReference(String selectedRecurringDetailReference) { + this.selectedRecurringDetailReference = selectedRecurringDetailReference; + } + + public CostEstimateRequest shopperInteraction(ShopperInteractionEnum shopperInteraction) { + this.shopperInteraction = shopperInteraction; + return this; + } + + + /** + * Specifies the sales channel, through which the shopper gives their card details, and whether the shopper is a returning customer. For the web service API, Adyen assumes Ecommerce shopper + * interaction by default. This field has the following possible values: * `Ecommerce` - Online transactions where the cardholder is present (online). For better authorisation rates, + * we recommend sending the card security code (CSC) along with the request. * `ContAuth` - Card on file and/or subscription transactions, where the card holder is known to the merchant + * (returning customer). If the shopper is present (online), you can supply also the CSC to improve authorisation (one-click payment). * `Moto` - Mail-order and telephone-order + * transactions where the shopper is in contact with the merchant via email or telephone. * `POS` - Point-of-sale transactions where the shopper is physically present to make a payment + * using a secure payment terminal. + * + * @return shopperInteraction + **/ + public ShopperInteractionEnum getShopperInteraction() { + return shopperInteraction; + } + + public void setShopperInteraction(ShopperInteractionEnum shopperInteraction) { + this.shopperInteraction = shopperInteraction; + } + + public CostEstimateRequest shopperReference(String shopperReference) { + this.shopperReference = shopperReference; + return this; + } + + + /** + * The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID). > This field is required for recurring payments. + * + * @return shopperReference + **/ + public String getShopperReference() { + return shopperReference; + } + + public void setShopperReference(String shopperReference) { + this.shopperReference = shopperReference; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostEstimateRequest costEstimateRequest = (CostEstimateRequest) o; + return Objects.equals(this.amount, costEstimateRequest.amount) + && Objects.equals(this.assumptions, costEstimateRequest.assumptions) + && Objects.equals(this.cardNumber, + costEstimateRequest.cardNumber) + && Objects.equals(this.encryptedCard, costEstimateRequest.encryptedCard) + && Objects.equals(this.merchantAccount, costEstimateRequest.merchantAccount) + && Objects.equals(this.merchantDetails, + costEstimateRequest.merchantDetails) + && Objects.equals(this.recurring, costEstimateRequest.recurring) + && Objects.equals(this.selectedRecurringDetailReference, costEstimateRequest.selectedRecurringDetailReference) + && Objects.equals(this.shopperInteraction, costEstimateRequest.shopperInteraction) + && Objects.equals(this.shopperReference, costEstimateRequest.shopperReference); + } + + @Override + public int hashCode() { + return Objects.hash(amount, assumptions, cardNumber, encryptedCard, merchantAccount, merchantDetails, recurring, selectedRecurringDetailReference, shopperInteraction, shopperReference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CostEstimateRequest {\n"); + + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" assumptions: ").append(toIndentedString(assumptions)).append("\n"); + sb.append(" cardNumber: ").append(toIndentedString(cardNumber)).append("\n"); + sb.append(" encryptedCard: ").append(toIndentedString(encryptedCard)).append("\n"); + sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n"); + sb.append(" merchantDetails: ").append(toIndentedString(merchantDetails)).append("\n"); + sb.append(" recurring: ").append(toIndentedString(recurring)).append("\n"); + sb.append(" selectedRecurringDetailReference: ").append(toIndentedString(selectedRecurringDetailReference)).append("\n"); + sb.append(" shopperInteraction: ").append(toIndentedString(shopperInteraction)).append("\n"); + sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/CostEstimateResponse.java b/src/main/java/com/adyen/model/binlookup/CostEstimateResponse.java new file mode 100755 index 000000000..440d5574b --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/CostEstimateResponse.java @@ -0,0 +1,167 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.Objects; +import com.adyen.model.Amount; +import com.google.gson.annotations.SerializedName; + +/** + * CostEstimateResponse + */ + +public class CostEstimateResponse { + + @SerializedName("cardBin") + private CardBin cardBin = null; + + @SerializedName("costEstimateAmount") + private Amount costEstimateAmount = null; + + @SerializedName("resultCode") + private String resultCode = null; + + @SerializedName("surchargeType") + private String surchargeType = null; + + public CostEstimateResponse cardBin(CardBin cardBin) { + this.cardBin = cardBin; + return this; + } + + + /** + * Get cardBin + * + * @return cardBin + **/ + public CardBin getCardBin() { + return cardBin; + } + + public void setCardBin(CardBin cardBin) { + this.cardBin = cardBin; + } + + public CostEstimateResponse costEstimateAmount(Amount costEstimateAmount) { + this.costEstimateAmount = costEstimateAmount; + return this; + } + + + /** + * Get costEstimateAmount + * + * @return costEstimateAmount + **/ + public Amount getCostEstimateAmount() { + return costEstimateAmount; + } + + public void setCostEstimateAmount(Amount costEstimateAmount) { + this.costEstimateAmount = costEstimateAmount; + } + + public CostEstimateResponse resultCode(String resultCode) { + this.resultCode = resultCode; + return this; + } + + + /** + * The result of the cost estimation. + * + * @return resultCode + **/ + public String getResultCode() { + return resultCode; + } + + public void setResultCode(String resultCode) { + this.resultCode = resultCode; + } + + public CostEstimateResponse surchargeType(String surchargeType) { + this.surchargeType = surchargeType; + return this; + } + + + /** + * Indicates the way the charges can be passed on to the cardholder. The following values are possible: * `ZERO` - the charges are not allowed to pass on * `PASSTHROUGH` - the + * charges can be passed on * `UNLIMITED` - there is no limit on how much surcharge is passed on + * + * @return surchargeType + **/ + public String getSurchargeType() { + return surchargeType; + } + + public void setSurchargeType(String surchargeType) { + this.surchargeType = surchargeType; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostEstimateResponse costEstimateResponse = (CostEstimateResponse) o; + return Objects.equals(this.cardBin, costEstimateResponse.cardBin) + && Objects.equals(this.costEstimateAmount, costEstimateResponse.costEstimateAmount) + && Objects.equals(this.resultCode, + costEstimateResponse.resultCode) + && Objects.equals(this.surchargeType, costEstimateResponse.surchargeType); + } + + @Override + public int hashCode() { + return Objects.hash(cardBin, costEstimateAmount, resultCode, surchargeType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CostEstimateResponse {\n"); + + sb.append(" cardBin: ").append(toIndentedString(cardBin)).append("\n"); + sb.append(" costEstimateAmount: ").append(toIndentedString(costEstimateAmount)).append("\n"); + sb.append(" resultCode: ").append(toIndentedString(resultCode)).append("\n"); + sb.append(" surchargeType: ").append(toIndentedString(surchargeType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/DSPublicKeyDetail.java b/src/main/java/com/adyen/model/binlookup/DSPublicKeyDetail.java new file mode 100755 index 000000000..288fdf9a6 --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/DSPublicKeyDetail.java @@ -0,0 +1,143 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.Objects; + +import com.adyen.serializer.ByteArrayToBase64TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; + +/** + * DSPublicKeyDetail + */ + +public class DSPublicKeyDetail { + + @SerializedName("brand") + private String brand = null; + + @SerializedName("directoryServerId") + private String directoryServerId = null; + + @SerializedName("publicKey") + @JsonAdapter(ByteArrayToBase64TypeAdapter.class) + private byte[] publicKey = null; + + public DSPublicKeyDetail brand(String brand) { + this.brand = brand; + return this; + } + + + /** + * Card brand. + * + * @return brand + **/ + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand = brand; + } + + public DSPublicKeyDetail directoryServerId(String directoryServerId) { + this.directoryServerId = directoryServerId; + return this; + } + + + /** + * Directory Server (DS) identifier. + * + * @return directoryServerId + **/ + public String getDirectoryServerId() { + return directoryServerId; + } + + public void setDirectoryServerId(String directoryServerId) { + this.directoryServerId = directoryServerId; + } + + public DSPublicKeyDetail publicKey(byte[] publicKey) { + this.publicKey = publicKey; + return this; + } + + + /** + * Public key. The 3D Secure 2 SDK encrypts the device information by using the DS public key. + * + * @return publicKey + **/ + public byte[] getPublicKey() { + return publicKey; + } + + public void setPublicKey(byte[] publicKey) { + this.publicKey = publicKey; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DSPublicKeyDetail dsPublicKeyDetail = (DSPublicKeyDetail) o; + return Objects.equals(this.brand, dsPublicKeyDetail.brand) && Objects.equals(this.directoryServerId, dsPublicKeyDetail.directoryServerId) && Objects.equals(this.publicKey, + dsPublicKeyDetail.publicKey); + } + + @Override + public int hashCode() { + return Objects.hash(brand, directoryServerId, publicKey); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DSPublicKeyDetail {\n"); + + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" directoryServerId: ").append(toIndentedString(directoryServerId)).append("\n"); + sb.append(" publicKey: ").append(toIndentedString(publicKey)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/MerchantDetails.java b/src/main/java/com/adyen/model/binlookup/MerchantDetails.java new file mode 100755 index 000000000..01c456636 --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/MerchantDetails.java @@ -0,0 +1,140 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * MerchantDetails + */ + +public class MerchantDetails { + + @SerializedName("countryCode") + private String countryCode = null; + + @SerializedName("enrolledIn3DSecure") + private Boolean enrolledIn3DSecure = null; + + @SerializedName("mcc") + private String mcc = null; + + public MerchantDetails countryCode(String countryCode) { + this.countryCode = countryCode; + return this; + } + + + /** + * 2-letter ISO 3166 country code of the card acceptor location. > This parameter is required for the merchants who don't use Adyen as the payment authorisation gateway. + * + * @return countryCode + **/ + public String getCountryCode() { + return countryCode; + } + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + public MerchantDetails enrolledIn3DSecure(Boolean enrolledIn3DSecure) { + this.enrolledIn3DSecure = enrolledIn3DSecure; + return this; + } + + + /** + * If true, indicates that the merchant is enrolled in 3D Secure for the card network. + * + * @return enrolledIn3DSecure + **/ + public Boolean isEnrolledIn3DSecure() { + return enrolledIn3DSecure; + } + + public void setEnrolledIn3DSecure(Boolean enrolledIn3DSecure) { + this.enrolledIn3DSecure = enrolledIn3DSecure; + } + + public MerchantDetails mcc(String mcc) { + this.mcc = mcc; + return this; + } + + + /** + * The merchant category code (MCC) is a four-digit number which relates to a particular market segment. This code reflects the predominant activity that is conducted by the merchant. The list + * of MCCs can be found [here](https://en.wikipedia.org/wiki/Merchant_category_code). + * + * @return mcc + **/ + public String getMcc() { + return mcc; + } + + public void setMcc(String mcc) { + this.mcc = mcc; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MerchantDetails merchantDetails = (MerchantDetails) o; + return Objects.equals(this.countryCode, merchantDetails.countryCode) && Objects.equals(this.enrolledIn3DSecure, merchantDetails.enrolledIn3DSecure) && Objects.equals(this.mcc, + merchantDetails.mcc); + } + + @Override + public int hashCode() { + return Objects.hash(countryCode, enrolledIn3DSecure, mcc); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MerchantDetails {\n"); + + sb.append(" countryCode: ").append(toIndentedString(countryCode)).append("\n"); + sb.append(" enrolledIn3DSecure: ").append(toIndentedString(enrolledIn3DSecure)).append("\n"); + sb.append(" mcc: ").append(toIndentedString(mcc)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/Recurring.java b/src/main/java/com/adyen/model/binlookup/Recurring.java new file mode 100755 index 000000000..f7532ff3e --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/Recurring.java @@ -0,0 +1,294 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.Date; +import java.util.Objects; + +/** + * Recurring + */ + +public class Recurring { + /** + * The type of recurring contract to be used. Possible values: * `ONECLICK` – Payment details can be used to initiate a one-click payment, where the shopper enters the [card security + * code (CVC/CVV)](https://docs.adyen.com/payment-glossary#cardsecuritycodecvccvvcid). * `RECURRING` – Payment details can be used without the card security code to initiate + * [card-not-present transactions](https://docs.adyen.com/payment-glossary#cardnotpresentcnp). * `ONECLICK,RECURRING` – Payment details can be used regardless of whether the shopper is + * on your site or not. * `PAYOUT` – Payment details can be used to [make a payout](https://docs.adyen.com/features/third-party-payouts). + */ + @JsonAdapter(ContractEnum.Adapter.class) + public enum ContractEnum { + ONECLICK("ONECLICK"), + RECURRING("RECURRING"), + PAYOUT("PAYOUT"); + + private String value; + + ContractEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ContractEnum fromValue(String text) { + for (ContractEnum b : ContractEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ContractEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ContractEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ContractEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("contract") + private ContractEnum contract = null; + + @SerializedName("recurringDetailName") + private String recurringDetailName = null; + + @SerializedName("recurringExpiry") + private Date recurringExpiry = null; + + @SerializedName("recurringFrequency") + private String recurringFrequency = null; + + /** + * The name of the token service. + */ + @JsonAdapter(TokenServiceEnum.Adapter.class) + public enum TokenServiceEnum { + VISATOKENSERVICE("VISATOKENSERVICE"), + MCTOKENSERVICE("MCTOKENSERVICE"); + + private String value; + + TokenServiceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TokenServiceEnum fromValue(String text) { + for (TokenServiceEnum b : TokenServiceEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TokenServiceEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TokenServiceEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TokenServiceEnum.fromValue(String.valueOf(value)); + } + } + } + + @SerializedName("tokenService") + private TokenServiceEnum tokenService = null; + + public Recurring contract(ContractEnum contract) { + this.contract = contract; + return this; + } + + + /** + * The type of recurring contract to be used. Possible values: * `ONECLICK` – Payment details can be used to initiate a one-click payment, where the shopper enters the [card security + * code (CVC/CVV)](https://docs.adyen.com/payment-glossary#cardsecuritycodecvccvvcid). * `RECURRING` – Payment details can be used without the card security code to initiate + * [card-not-present transactions](https://docs.adyen.com/payment-glossary#cardnotpresentcnp). * `ONECLICK,RECURRING` – Payment details can be used regardless of whether the shopper is + * on your site or not. * `PAYOUT` – Payment details can be used to [make a payout](https://docs.adyen.com/features/third-party-payouts). + * + * @return contract + **/ + public ContractEnum getContract() { + return contract; + } + + public void setContract(ContractEnum contract) { + this.contract = contract; + } + + public Recurring recurringDetailName(String recurringDetailName) { + this.recurringDetailName = recurringDetailName; + return this; + } + + + /** + * A descriptive name for this detail. + * + * @return recurringDetailName + **/ + public String getRecurringDetailName() { + return recurringDetailName; + } + + public void setRecurringDetailName(String recurringDetailName) { + this.recurringDetailName = recurringDetailName; + } + + public Recurring recurringExpiry(Date recurringExpiry) { + this.recurringExpiry = recurringExpiry; + return this; + } + + + /** + * Date after which no further authorisations shall be performed. Only for 3D Secure 2. + * + * @return recurringExpiry + **/ + public Date getRecurringExpiry() { + return recurringExpiry; + } + + public void setRecurringExpiry(Date recurringExpiry) { + this.recurringExpiry = recurringExpiry; + } + + public Recurring recurringFrequency(String recurringFrequency) { + this.recurringFrequency = recurringFrequency; + return this; + } + + + /** + * Minimum number of days between authorisations. Only for 3D Secure 2. + * + * @return recurringFrequency + **/ + public String getRecurringFrequency() { + return recurringFrequency; + } + + public void setRecurringFrequency(String recurringFrequency) { + this.recurringFrequency = recurringFrequency; + } + + public Recurring tokenService(TokenServiceEnum tokenService) { + this.tokenService = tokenService; + return this; + } + + + /** + * The name of the token service. + * + * @return tokenService + **/ + public TokenServiceEnum getTokenService() { + return tokenService; + } + + public void setTokenService(TokenServiceEnum tokenService) { + this.tokenService = tokenService; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Recurring recurring = (Recurring) o; + return Objects.equals(this.contract, recurring.contract) + && Objects.equals(this.recurringDetailName, recurring.recurringDetailName) + && Objects.equals(this.recurringExpiry, + recurring.recurringExpiry) + && Objects.equals(this.recurringFrequency, recurring.recurringFrequency) + && Objects.equals(this.tokenService, recurring.tokenService); + } + + @Override + public int hashCode() { + return Objects.hash(contract, recurringDetailName, recurringExpiry, recurringFrequency, tokenService); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Recurring {\n"); + + sb.append(" contract: ").append(toIndentedString(contract)).append("\n"); + sb.append(" recurringDetailName: ").append(toIndentedString(recurringDetailName)).append("\n"); + sb.append(" recurringExpiry: ").append(toIndentedString(recurringExpiry)).append("\n"); + sb.append(" recurringFrequency: ").append(toIndentedString(recurringFrequency)).append("\n"); + sb.append(" tokenService: ").append(toIndentedString(tokenService)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/ThreeDS2CardRangeDetail.java b/src/main/java/com/adyen/model/binlookup/ThreeDS2CardRangeDetail.java new file mode 100755 index 000000000..76f6dff35 --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/ThreeDS2CardRangeDetail.java @@ -0,0 +1,189 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * ThreeDS2CardRangeDetail + */ + +public class ThreeDS2CardRangeDetail { + + @SerializedName("brandCode") + private String brandCode = null; + + @SerializedName("endRange") + private String endRange = null; + + @SerializedName("startRange") + private String startRange = null; + + @SerializedName("threeDS2Version") + private String threeDS2Version = null; + + @SerializedName("threeDSMethodURL") + private String threeDSMethodURL = null; + + public ThreeDS2CardRangeDetail brandCode(String brandCode) { + this.brandCode = brandCode; + return this; + } + + + /** + * Card brand. + * + * @return brandCode + **/ + public String getBrandCode() { + return brandCode; + } + + public void setBrandCode(String brandCode) { + this.brandCode = brandCode; + } + + public ThreeDS2CardRangeDetail endRange(String endRange) { + this.endRange = endRange; + return this; + } + + + /** + * BIN end range. + * + * @return endRange + **/ + public String getEndRange() { + return endRange; + } + + public void setEndRange(String endRange) { + this.endRange = endRange; + } + + public ThreeDS2CardRangeDetail startRange(String startRange) { + this.startRange = startRange; + return this; + } + + + /** + * BIN start range. + * + * @return startRange + **/ + public String getStartRange() { + return startRange; + } + + public void setStartRange(String startRange) { + this.startRange = startRange; + } + + public ThreeDS2CardRangeDetail threeDS2Version(String threeDS2Version) { + this.threeDS2Version = threeDS2Version; + return this; + } + + + /** + * 3D Secure protocol version. + * + * @return threeDS2Version + **/ + public String getThreeDS2Version() { + return threeDS2Version; + } + + public void setThreeDS2Version(String threeDS2Version) { + this.threeDS2Version = threeDS2Version; + } + + public ThreeDS2CardRangeDetail threeDSMethodURL(String threeDSMethodURL) { + this.threeDSMethodURL = threeDSMethodURL; + return this; + } + + + /** + * In a 3D Secure 2 browser-based flow, this is the URL where you should send the device fingerprint to. + * + * @return threeDSMethodURL + **/ + public String getThreeDSMethodURL() { + return threeDSMethodURL; + } + + public void setThreeDSMethodURL(String threeDSMethodURL) { + this.threeDSMethodURL = threeDSMethodURL; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThreeDS2CardRangeDetail threeDS2CardRangeDetail = (ThreeDS2CardRangeDetail) o; + return Objects.equals(this.brandCode, threeDS2CardRangeDetail.brandCode) + && Objects.equals(this.endRange, threeDS2CardRangeDetail.endRange) + && Objects.equals(this.startRange, + threeDS2CardRangeDetail.startRange) + && Objects.equals(this.threeDS2Version, threeDS2CardRangeDetail.threeDS2Version) + && Objects.equals(this.threeDSMethodURL, threeDS2CardRangeDetail.threeDSMethodURL); + } + + @Override + public int hashCode() { + return Objects.hash(brandCode, endRange, startRange, threeDS2Version, threeDSMethodURL); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ThreeDS2CardRangeDetail {\n"); + + sb.append(" brandCode: ").append(toIndentedString(brandCode)).append("\n"); + sb.append(" endRange: ").append(toIndentedString(endRange)).append("\n"); + sb.append(" startRange: ").append(toIndentedString(startRange)).append("\n"); + sb.append(" threeDS2Version: ").append(toIndentedString(threeDS2Version)).append("\n"); + sb.append(" threeDSMethodURL: ").append(toIndentedString(threeDSMethodURL)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/ThreeDSAvailabilityRequest.java b/src/main/java/com/adyen/model/binlookup/ThreeDSAvailabilityRequest.java new file mode 100755 index 000000000..155bb90dd --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/ThreeDSAvailabilityRequest.java @@ -0,0 +1,220 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * ThreeDSAvailabilityRequest + */ + +public class ThreeDSAvailabilityRequest { + + @SerializedName("additionalData") + private Object additionalData = null; + + @SerializedName("brands") + private List brands = new ArrayList(); + + @SerializedName("cardNumber") + private String cardNumber = null; + + @SerializedName("merchantAccount") + private String merchantAccount = null; + + @SerializedName("recurringDetailReference") + private String recurringDetailReference = null; + + @SerializedName("shopperReference") + private String shopperReference = null; + + public ThreeDSAvailabilityRequest additionalData(Object additionalData) { + this.additionalData = additionalData; + return this; + } + + + /** + * This field contains additional data, which may be required for a particular request. The `additionalData` object consists of entries, each of which includes the key and value. For + * more information on possible key-value pairs, refer to the [additionalData section](https://docs.adyen.com/api-reference/payments-api#paymentrequestadditionaldata). + * + * @return additionalData + **/ + public Object getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(Object additionalData) { + this.additionalData = additionalData; + } + + public ThreeDSAvailabilityRequest brands(List brands) { + this.brands = brands; + return this; + } + + public ThreeDSAvailabilityRequest addBrandsItem(String brandsItem) { + this.brands.add(brandsItem); + return this; + } + + /** + * List of brands. + * + * @return brands + **/ + public List getBrands() { + return brands; + } + + public void setBrands(List brands) { + this.brands = brands; + } + + public ThreeDSAvailabilityRequest cardNumber(String cardNumber) { + this.cardNumber = cardNumber; + return this; + } + + + /** + * Card number or BIN. + * + * @return cardNumber + **/ + public String getCardNumber() { + return cardNumber; + } + + public void setCardNumber(String cardNumber) { + this.cardNumber = cardNumber; + } + + public ThreeDSAvailabilityRequest merchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + return this; + } + + + /** + * The merchant account identifier. + * + * @return merchantAccount + **/ + public String getMerchantAccount() { + return merchantAccount; + } + + public void setMerchantAccount(String merchantAccount) { + this.merchantAccount = merchantAccount; + } + + public ThreeDSAvailabilityRequest recurringDetailReference(String recurringDetailReference) { + this.recurringDetailReference = recurringDetailReference; + return this; + } + + + /** + * A recurring detail reference corresponding to a card. + * + * @return recurringDetailReference + **/ + public String getRecurringDetailReference() { + return recurringDetailReference; + } + + public void setRecurringDetailReference(String recurringDetailReference) { + this.recurringDetailReference = recurringDetailReference; + } + + public ThreeDSAvailabilityRequest shopperReference(String shopperReference) { + this.shopperReference = shopperReference; + return this; + } + + + /** + * The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID). + * + * @return shopperReference + **/ + public String getShopperReference() { + return shopperReference; + } + + public void setShopperReference(String shopperReference) { + this.shopperReference = shopperReference; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThreeDSAvailabilityRequest threeDSAvailabilityRequest = (ThreeDSAvailabilityRequest) o; + return Objects.equals(this.additionalData, threeDSAvailabilityRequest.additionalData) + && Objects.equals(this.brands, threeDSAvailabilityRequest.brands) + && Objects.equals(this.cardNumber, + threeDSAvailabilityRequest.cardNumber) + && Objects.equals(this.merchantAccount, threeDSAvailabilityRequest.merchantAccount) + && Objects.equals(this.recurringDetailReference, threeDSAvailabilityRequest.recurringDetailReference) + && Objects.equals(this.shopperReference, threeDSAvailabilityRequest.shopperReference); + } + + @Override + public int hashCode() { + return Objects.hash(additionalData, brands, cardNumber, merchantAccount, recurringDetailReference, shopperReference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ThreeDSAvailabilityRequest {\n"); + + sb.append(" additionalData: ").append(toIndentedString(additionalData)).append("\n"); + sb.append(" brands: ").append(toIndentedString(brands)).append("\n"); + sb.append(" cardNumber: ").append(toIndentedString(cardNumber)).append("\n"); + sb.append(" merchantAccount: ").append(toIndentedString(merchantAccount)).append("\n"); + sb.append(" recurringDetailReference: ").append(toIndentedString(recurringDetailReference)).append("\n"); + sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/model/binlookup/ThreeDSAvailabilityResponse.java b/src/main/java/com/adyen/model/binlookup/ThreeDSAvailabilityResponse.java new file mode 100755 index 000000000..f793fb619 --- /dev/null +++ b/src/main/java/com/adyen/model/binlookup/ThreeDSAvailabilityResponse.java @@ -0,0 +1,179 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen.model.binlookup; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * ThreeDSAvailabilityResponse + */ + +public class ThreeDSAvailabilityResponse { + + @SerializedName("dsPublicKeys") + private List dsPublicKeys = null; + + @SerializedName("threeDS1Supported") + private Boolean threeDS1Supported = null; + + @SerializedName("threeDS2CardRangeDetails") + private List threeDS2CardRangeDetails = null; + + @SerializedName("threeDS2supported") + private Boolean threeDS2supported = null; + + public ThreeDSAvailabilityResponse dsPublicKeys(List dsPublicKeys) { + this.dsPublicKeys = dsPublicKeys; + return this; + } + + public ThreeDSAvailabilityResponse addDsPublicKeysItem(DSPublicKeyDetail dsPublicKeysItem) { + if (this.dsPublicKeys == null) { + this.dsPublicKeys = new ArrayList(); + } + this.dsPublicKeys.add(dsPublicKeysItem); + return this; + } + + /** + * List of Directory Server (DS) public keys. + * + * @return dsPublicKeys + **/ + public List getDsPublicKeys() { + return dsPublicKeys; + } + + public void setDsPublicKeys(List dsPublicKeys) { + this.dsPublicKeys = dsPublicKeys; + } + + public ThreeDSAvailabilityResponse threeDS1Supported(Boolean threeDS1Supported) { + this.threeDS1Supported = threeDS1Supported; + return this; + } + + + /** + * Indicator if 3D Secure 1 is supported. + * + * @return threeDS1Supported + **/ + public Boolean isThreeDS1Supported() { + return threeDS1Supported; + } + + public void setThreeDS1Supported(Boolean threeDS1Supported) { + this.threeDS1Supported = threeDS1Supported; + } + + public ThreeDSAvailabilityResponse threeDS2CardRangeDetails(List threeDS2CardRangeDetails) { + this.threeDS2CardRangeDetails = threeDS2CardRangeDetails; + return this; + } + + public ThreeDSAvailabilityResponse addThreeDS2CardRangeDetailsItem(ThreeDS2CardRangeDetail threeDS2CardRangeDetailsItem) { + if (this.threeDS2CardRangeDetails == null) { + this.threeDS2CardRangeDetails = new ArrayList(); + } + this.threeDS2CardRangeDetails.add(threeDS2CardRangeDetailsItem); + return this; + } + + /** + * List of brand and card range pairs. + * + * @return threeDS2CardRangeDetails + **/ + public List getThreeDS2CardRangeDetails() { + return threeDS2CardRangeDetails; + } + + public void setThreeDS2CardRangeDetails(List threeDS2CardRangeDetails) { + this.threeDS2CardRangeDetails = threeDS2CardRangeDetails; + } + + public ThreeDSAvailabilityResponse threeDS2supported(Boolean threeDS2supported) { + this.threeDS2supported = threeDS2supported; + return this; + } + + + /** + * Indicator if 3D Secure 2 is supported. + * + * @return threeDS2supported + **/ + public Boolean isThreeDS2supported() { + return threeDS2supported; + } + + public void setThreeDS2supported(Boolean threeDS2supported) { + this.threeDS2supported = threeDS2supported; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ThreeDSAvailabilityResponse threeDSAvailabilityResponse = (ThreeDSAvailabilityResponse) o; + return Objects.equals(this.dsPublicKeys, threeDSAvailabilityResponse.dsPublicKeys) && Objects.equals(this.threeDS1Supported, threeDSAvailabilityResponse.threeDS1Supported) && Objects.equals( + this.threeDS2CardRangeDetails, + threeDSAvailabilityResponse.threeDS2CardRangeDetails) && Objects.equals(this.threeDS2supported, threeDSAvailabilityResponse.threeDS2supported); + } + + @Override + public int hashCode() { + return Objects.hash(dsPublicKeys, threeDS1Supported, threeDS2CardRangeDetails, threeDS2supported); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ThreeDSAvailabilityResponse {\n"); + + sb.append(" dsPublicKeys: ").append(toIndentedString(dsPublicKeys)).append("\n"); + sb.append(" threeDS1Supported: ").append(toIndentedString(threeDS1Supported)).append("\n"); + sb.append(" threeDS2CardRangeDetails: ").append(toIndentedString(threeDS2CardRangeDetails)).append("\n"); + sb.append(" threeDS2supported: ").append(toIndentedString(threeDS2supported)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} diff --git a/src/main/java/com/adyen/serializer/ByteArrayToBase64TypeAdapter.java b/src/main/java/com/adyen/serializer/ByteArrayToBase64TypeAdapter.java new file mode 100644 index 000000000..45ab152d8 --- /dev/null +++ b/src/main/java/com/adyen/serializer/ByteArrayToBase64TypeAdapter.java @@ -0,0 +1,43 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ + +package com.adyen.serializer; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import org.apache.commons.codec.binary.Base64; + +import java.lang.reflect.Type; + +public class ByteArrayToBase64TypeAdapter implements JsonSerializer, JsonDeserializer { + public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + return Base64.decodeBase64(json.getAsString()); + } + + public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(Base64.encodeBase64String(src)); + } +} \ No newline at end of file diff --git a/src/main/java/com/adyen/service/BinLookup.java b/src/main/java/com/adyen/service/BinLookup.java new file mode 100644 index 000000000..9d625aba4 --- /dev/null +++ b/src/main/java/com/adyen/service/BinLookup.java @@ -0,0 +1,47 @@ +package com.adyen.service; + +import com.adyen.ApiKeyAuthenticatedService; +import com.adyen.Client; +import com.adyen.model.binlookup.CostEstimateRequest; +import com.adyen.model.binlookup.CostEstimateResponse; +import com.adyen.model.binlookup.ThreeDSAvailabilityRequest; +import com.adyen.model.binlookup.ThreeDSAvailabilityResponse; +import com.adyen.service.resource.binlookup.Get3dsAvailability; +import com.adyen.service.resource.binlookup.GetCostEstimate; +import com.google.gson.reflect.TypeToken; + +public class BinLookup extends ApiKeyAuthenticatedService { + + private Get3dsAvailability get3dsAvailability; + private GetCostEstimate getCostEstimate; + + public BinLookup(Client client) { + super(client); + get3dsAvailability = new Get3dsAvailability(this); + getCostEstimate = new GetCostEstimate(this); + } + + + public ThreeDSAvailabilityResponse get3dsAvailability(ThreeDSAvailabilityRequest accountHolderRequest) throws Exception { + String jsonRequest = GSON.toJson(accountHolderRequest); + + String jsonResult = get3dsAvailability.request(jsonRequest); + + ThreeDSAvailabilityResponse threeDSAvailabilityResponse = GSON.fromJson(jsonResult, new TypeToken() { + }.getType()); + + return threeDSAvailabilityResponse; + } + + public CostEstimateResponse getCostEstimate(CostEstimateRequest costEstimateRequest) throws Exception { + String jsonRequest = GSON.toJson(costEstimateRequest); + + String jsonResult = getCostEstimate.request(jsonRequest); + + CostEstimateResponse costEstimateResponse = GSON.fromJson(jsonResult, new TypeToken() { + }.getType()); + + return costEstimateResponse; + } + +} diff --git a/src/main/java/com/adyen/service/resource/binlookup/Get3dsAvailability.java b/src/main/java/com/adyen/service/resource/binlookup/Get3dsAvailability.java new file mode 100644 index 000000000..de8416501 --- /dev/null +++ b/src/main/java/com/adyen/service/resource/binlookup/Get3dsAvailability.java @@ -0,0 +1,15 @@ +package com.adyen.service.resource.binlookup; + +import java.util.Arrays; +import com.adyen.Client; +import com.adyen.Service; +import com.adyen.service.Resource; + +public class Get3dsAvailability extends Resource { + + public Get3dsAvailability(Service service) { + super(service, + service.getClient().getConfig().getEndpoint() + Client.BIN_LOOKUP_PAL_SUFFIX + Client.BIN_LOOKUP_API_VERSION + "/get3dsAvailability", + Arrays.asList("merchantAccount", "cardNumber")); + } +} diff --git a/src/main/java/com/adyen/service/resource/binlookup/GetCostEstimate.java b/src/main/java/com/adyen/service/resource/binlookup/GetCostEstimate.java new file mode 100644 index 000000000..7e547144b --- /dev/null +++ b/src/main/java/com/adyen/service/resource/binlookup/GetCostEstimate.java @@ -0,0 +1,15 @@ +package com.adyen.service.resource.binlookup; + +import java.util.Arrays; +import com.adyen.Client; +import com.adyen.Service; +import com.adyen.service.Resource; + +public class GetCostEstimate extends Resource { + + public GetCostEstimate(Service service) { + super(service, + service.getClient().getConfig().getEndpoint() + Client.BIN_LOOKUP_PAL_SUFFIX + Client.BIN_LOOKUP_API_VERSION + "/getCostEstimate", + Arrays.asList("merchantAccount", "amount")); + } +} diff --git a/src/test/java/com/adyen/BinLookupTest.java b/src/test/java/com/adyen/BinLookupTest.java new file mode 100644 index 000000000..90a0592e3 --- /dev/null +++ b/src/test/java/com/adyen/BinLookupTest.java @@ -0,0 +1,215 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2019 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +package com.adyen; + +import com.adyen.model.Amount; +import com.adyen.model.binlookup.CostEstimateAssumptions; +import com.adyen.model.binlookup.CostEstimateRequest; +import com.adyen.model.binlookup.CostEstimateResponse; +import com.adyen.model.binlookup.MerchantDetails; +import com.adyen.model.binlookup.ThreeDSAvailabilityRequest; +import com.adyen.model.binlookup.ThreeDSAvailabilityResponse; +import com.adyen.service.BinLookup; +import com.adyen.service.exception.ApiException; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +/** + * Tests for + * /get3dsAvailability + * /getCostEstimate + */ +public class BinLookupTest extends BaseTest { + + + @Test + public void TestGet3dsAvailabilitySuccessMocked() throws Exception { + Client client = createMockClientFromFile("mocks/binlookup/get3dsavailability-success.json"); + BinLookup binLookup = new BinLookup(client); + + ThreeDSAvailabilityRequest threeDSAvailabilityRequest = new ThreeDSAvailabilityRequest(); + threeDSAvailabilityRequest.setMerchantAccount("merchantAccount"); + threeDSAvailabilityRequest.setCardNumber("4111111111111111"); + + ThreeDSAvailabilityResponse threeDSAvailabilityResponse = binLookup.get3dsAvailability(threeDSAvailabilityRequest); + assertEquals("visa", threeDSAvailabilityResponse.getDsPublicKeys().get(0).getBrand()); + assertEquals("visa", threeDSAvailabilityResponse.getThreeDS2CardRangeDetails().get(0).getBrandCode()); + assertEquals(true, threeDSAvailabilityResponse.isThreeDS1Supported()); + } + + @Test + public void TestGet3dsAvailabilityInvalidMerchantMocked() throws Exception { + Client client = createMockClientForErrors(403,"mocks/binlookup/get3dsavailability-error-merchant.json"); + BinLookup binLookup = new BinLookup(client); + + ThreeDSAvailabilityRequest threeDSAvailabilityRequest = new ThreeDSAvailabilityRequest(); + threeDSAvailabilityRequest.setMerchantAccount(null); + threeDSAvailabilityRequest.setCardNumber("4111111111111111"); + + try { + binLookup.get3dsAvailability(threeDSAvailabilityRequest); + fail("Exception expected"); + } catch (ApiException e) { + assertNotNull(e.getError()); + assertEquals("901", e.getError().getErrorCode()); + assertEquals(403, e.getError().getStatus()); + } + } + + @Test + public void TestGetCostEstimateSuccessMocked() throws Exception { + + Client client = createMockClientFromFile("mocks/binlookup/getcostestimate-success.json"); + BinLookup binLookup = new BinLookup(client); + + CostEstimateRequest costEstimateRequest = new CostEstimateRequest(); + Amount amount = new Amount(); + amount.setCurrency("EUR"); + amount.setValue(new Long("1000")); + costEstimateRequest.setAmount(amount); + + CostEstimateAssumptions costEstimateAssumptions = new CostEstimateAssumptions(); + costEstimateAssumptions.setAssumeLevel3Data(true); + costEstimateAssumptions.setAssume3DSecureAuthenticated(true); + + costEstimateRequest.setAssumptions(costEstimateAssumptions); + costEstimateRequest.setCardNumber("4111111111111111"); + costEstimateRequest.setMerchantAccount("merchantAccount"); + MerchantDetails merchantDetails = new MerchantDetails(); + merchantDetails.setCountryCode("NL"); + merchantDetails.setMcc("7411"); + merchantDetails.setEnrolledIn3DSecure(true); + costEstimateRequest.setMerchantDetails(merchantDetails); + costEstimateRequest.setShopperInteraction(CostEstimateRequest.ShopperInteractionEnum.ECOMMERCE); + + + CostEstimateResponse costEstimateResponse = binLookup.getCostEstimate(costEstimateRequest); + assertEquals("1111", costEstimateResponse.getCardBin().getSummary()); + assertEquals("Unsupported", costEstimateResponse.getResultCode()); + assertEquals("ZERO", costEstimateResponse.getSurchargeType()); + } + + @Test + public void TestGetCostEstimateInvalidMerchantMocked() throws Exception { + Client client = createMockClientForErrors(500,"mocks/binlookup/getcostestimate-error-merchant.json"); + BinLookup binLookup = new BinLookup(client); + + CostEstimateRequest costEstimateRequest = new CostEstimateRequest(); + Amount amount = new Amount(); + amount.setCurrency("EUR"); + amount.setValue(new Long("1000")); + costEstimateRequest.setAmount(amount); + + CostEstimateAssumptions costEstimateAssumptions = new CostEstimateAssumptions(); + costEstimateAssumptions.setAssumeLevel3Data(true); + costEstimateAssumptions.setAssume3DSecureAuthenticated(true); + + costEstimateRequest.setAssumptions(costEstimateAssumptions); + costEstimateRequest.setCardNumber("4111111111111111"); + costEstimateRequest.setMerchantAccount(null); + MerchantDetails merchantDetails = new MerchantDetails(); + merchantDetails.setCountryCode("NL"); + merchantDetails.setMcc("7411"); + merchantDetails.setEnrolledIn3DSecure(true); + costEstimateRequest.setMerchantDetails(merchantDetails); + costEstimateRequest.setShopperInteraction(CostEstimateRequest.ShopperInteractionEnum.ECOMMERCE); + + try { + binLookup.getCostEstimate(costEstimateRequest); + fail("Exception expected"); + } catch (ApiException e) { + assertNotNull(e.getError()); + assertEquals("901", e.getError().getErrorCode()); + assertEquals(500, e.getError().getStatus()); + } + } + + @Test + public void TestGetCostEstimateInvalidCardNumberMocked() throws Exception { + Client client = createMockClientForErrors(422,"mocks/binlookup/getcostestimate-error-cardnumber.json"); + BinLookup binLookup = new BinLookup(client); + + CostEstimateRequest costEstimateRequest = new CostEstimateRequest(); + Amount amount = new Amount(); + amount.setCurrency("EUR"); + amount.setValue(new Long("1000")); + costEstimateRequest.setAmount(amount); + + CostEstimateAssumptions costEstimateAssumptions = new CostEstimateAssumptions(); + costEstimateAssumptions.setAssumeLevel3Data(true); + costEstimateAssumptions.setAssume3DSecureAuthenticated(true); + + costEstimateRequest.setAssumptions(costEstimateAssumptions); + costEstimateRequest.setCardNumber(null); + costEstimateRequest.setMerchantAccount("merchantAccount"); + MerchantDetails merchantDetails = new MerchantDetails(); + merchantDetails.setCountryCode("NL"); + merchantDetails.setMcc("7411"); + merchantDetails.setEnrolledIn3DSecure(true); + costEstimateRequest.setMerchantDetails(merchantDetails); + costEstimateRequest.setShopperInteraction(CostEstimateRequest.ShopperInteractionEnum.ECOMMERCE); + + try { + binLookup.getCostEstimate(costEstimateRequest); + fail("Exception expected"); + } catch (ApiException e) { + assertNotNull(e.getError()); + assertEquals("000", e.getError().getErrorCode()); + assertEquals(422, e.getError().getStatus()); + } + } + + @Test + public void TestGetCostEstimateInvalidAmountMocked() throws Exception { + Client client = createMockClientForErrors(422,"mocks/binlookup/getcostestimate-error-amount.json"); + BinLookup binLookup = new BinLookup(client); + + CostEstimateRequest costEstimateRequest = new CostEstimateRequest(); + costEstimateRequest.setAmount(null); + + CostEstimateAssumptions costEstimateAssumptions = new CostEstimateAssumptions(); + costEstimateAssumptions.setAssumeLevel3Data(true); + costEstimateAssumptions.setAssume3DSecureAuthenticated(true); + + costEstimateRequest.setAssumptions(costEstimateAssumptions); + costEstimateRequest.setCardNumber("4111111111111111"); + costEstimateRequest.setMerchantAccount("merchantAccount"); + MerchantDetails merchantDetails = new MerchantDetails(); + merchantDetails.setCountryCode("NL"); + merchantDetails.setMcc("7411"); + merchantDetails.setEnrolledIn3DSecure(true); + costEstimateRequest.setMerchantDetails(merchantDetails); + costEstimateRequest.setShopperInteraction(CostEstimateRequest.ShopperInteractionEnum.ECOMMERCE); + + try { + binLookup.getCostEstimate(costEstimateRequest); + fail("Exception expected"); + } catch (ApiException e) { + assertNotNull(e.getError()); + assertEquals("100", e.getError().getErrorCode()); + assertEquals(422, e.getError().getStatus()); + } + } + +} \ No newline at end of file diff --git a/src/test/resources/mocks/binlookup/get3dsavailability-error-merchant.json b/src/test/resources/mocks/binlookup/get3dsavailability-error-merchant.json new file mode 100644 index 000000000..28afc9887 --- /dev/null +++ b/src/test/resources/mocks/binlookup/get3dsavailability-error-merchant.json @@ -0,0 +1,6 @@ +{ + "status": 403, + "errorCode": "901", + "message": "Invalid Merchant Account", + "errorType": "security" +} \ No newline at end of file diff --git a/src/test/resources/mocks/binlookup/get3dsavailability-success.json b/src/test/resources/mocks/binlookup/get3dsavailability-success.json new file mode 100644 index 000000000..2b02aea94 --- /dev/null +++ b/src/test/resources/mocks/binlookup/get3dsavailability-success.json @@ -0,0 +1,16 @@ +{ + "dsPublicKeys": [{ + "brand": "visa", + "directoryServerId": "F013371337", + "publicKey": "eyJrdHkiOiJSU0EiLCJlIjoiQVFBQiIsIm4iOiI4VFBxZkFOWk4xSUEzcHFuMkdhUVZjZ1g4LUpWZ1Y0M2diWURtYmdTY0N5SkVSN3lPWEJqQmQyaTBEcVFBQWpVUVBXVUxZU1FsRFRKYm91bVB1aXVoeVMxUHN2NTM4UHBRRnEySkNaSERkaV85WThVZG9hbmlrU095c2NHQWtBVmJJWHA5cnVOSm1wTTBwZ0s5VGxJSWVHYlE3ZEJaR01OQVJLQXRKeTY3dVlvbVpXV0ZBbWpwM2d4SDVzNzdCR2xkaE9RUVlQTFdybDdyS0pLQlUwNm1tZlktUDNpazk5MmtPUTNEak02bHR2WmNvLThET2RCR0RKYmdWRGFmb29LUnVNd2NUTXhDdTRWYWpyNmQyZkppVXlqNUYzcVBrYng4WDl6a1c3UmlxVno2SU1qdE54NzZicmg3aU9Vd2JiWmoxYWF6VG1GQ2xEb0dyY2JxOV80Nnc9PSJ9" + }], + "threeDS1Supported": true, + "threeDS2CardRangeDetails": [{ + "brandCode": "visa", + "endRange": "411111111111", + "startRange": "411111111111", + "threeDS2Version": "2.1.0", + "threeDSMethodURL": "https://pal-test.adyen.com/threeds2simulator/acs/startMethod.shtml" + }], + "threeDS2supported": true +} \ No newline at end of file diff --git a/src/test/resources/mocks/binlookup/getcostestimate-error-amount.json b/src/test/resources/mocks/binlookup/getcostestimate-error-amount.json new file mode 100644 index 000000000..28fa25cc0 --- /dev/null +++ b/src/test/resources/mocks/binlookup/getcostestimate-error-amount.json @@ -0,0 +1,6 @@ +{ + "status": 422, + "errorCode": "100", + "message": "No amount specified", + "errorType": "validation" +} \ No newline at end of file diff --git a/src/test/resources/mocks/binlookup/getcostestimate-error-cardnumber.json b/src/test/resources/mocks/binlookup/getcostestimate-error-cardnumber.json new file mode 100644 index 000000000..6a2ccce97 --- /dev/null +++ b/src/test/resources/mocks/binlookup/getcostestimate-error-cardnumber.json @@ -0,0 +1,6 @@ +{ + "status": 422, + "errorCode": "000", + "message": "Card number missing", + "errorType": "validation" +} \ No newline at end of file diff --git a/src/test/resources/mocks/binlookup/getcostestimate-error-merchant.json b/src/test/resources/mocks/binlookup/getcostestimate-error-merchant.json new file mode 100644 index 000000000..c4c6adaec --- /dev/null +++ b/src/test/resources/mocks/binlookup/getcostestimate-error-merchant.json @@ -0,0 +1,6 @@ +{ + "status": 500, + "errorCode": "901", + "message": "Invalid Merchant Account", + "errorType": "internal" +} \ No newline at end of file diff --git a/src/test/resources/mocks/binlookup/getcostestimate-success.json b/src/test/resources/mocks/binlookup/getcostestimate-success.json new file mode 100644 index 000000000..b8a902b8d --- /dev/null +++ b/src/test/resources/mocks/binlookup/getcostestimate-success.json @@ -0,0 +1,7 @@ +{ + "cardBin": { + "summary": "1111" + }, + "resultCode": "Unsupported", + "surchargeType": "ZERO" +} \ No newline at end of file