diff --git a/src/main/java/com/adyen/model/checkout/DefaultPaymentMethodDetails.java b/src/main/java/com/adyen/model/checkout/DefaultPaymentMethodDetails.java new file mode 100755 index 000000000..ed2858193 --- /dev/null +++ b/src/main/java/com/adyen/model/checkout/DefaultPaymentMethodDetails.java @@ -0,0 +1,328 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 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.checkout; + +import com.adyen.model.Address; +import com.google.gson.annotations.SerializedName; + +public class DefaultPaymentMethodDetails implements PaymentMethodDetails { + @SerializedName("type") + private String type; + @SerializedName("number") + private String number; + @SerializedName("expiryMonth") + private String expiryMonth; + @SerializedName("expiryYear") + private String expiryYear; + @SerializedName("holderName") + private String holderName; + @SerializedName("cvc") + private String cvc; + @SerializedName("installmentConfigurationKey") + private String installmentConfigurationKey; + @SerializedName("personalDetails") + private PersonalDetails personalDetails; + @SerializedName("billingAddress") + private Address billingAddress; + @SerializedName("deliveryAddress") + private Address deliveryAddress; + @SerializedName("encryptedCardNumber") + private String encryptedCardNumber; + @SerializedName("encryptedExpiryMonth") + private String encryptedExpiryMonth; + @SerializedName("encryptedExpiryYear") + private String encryptedExpiryYear; + @SerializedName("encryptedSecurityCode") + private String encryptedSecurityCode; + @SerializedName("recurringDetailReference") + private String recurringDetailReference; + @SerializedName("storeDetails") + private Boolean storeDetails; + @SerializedName("idealIssuer") + private String idealIssuer; + + @Override + public String getType() { + return type; + } + + @Override + public void setType(String type) { + this.type = type; + } + + public DefaultPaymentMethodDetails type(String type) { + this.type = type; + return this; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public DefaultPaymentMethodDetails number(String number) { + this.number = number; + return this; + } + + public String getExpiryMonth() { + return expiryMonth; + } + + public void setExpiryMonth(String expiryMonth) { + this.expiryMonth = expiryMonth; + } + + public DefaultPaymentMethodDetails expiryMonth(String expiryMonth) { + this.expiryMonth = expiryMonth; + return this; + } + + public String getExpiryYear() { + return expiryYear; + } + + public void setExpiryYear(String expiryYear) { + this.expiryYear = expiryYear; + } + + public DefaultPaymentMethodDetails expiryYear(String expiryYear) { + this.expiryYear = expiryYear; + return this; + } + + public String getHolderName() { + return holderName; + } + + public void setHolderName(String holderName) { + this.holderName = holderName; + } + + public DefaultPaymentMethodDetails holderName(String holderName) { + this.holderName = holderName; + return this; + } + + public String getCvc() { + return cvc; + } + + public void setCvc(String cvc) { + this.cvc = cvc; + } + + public DefaultPaymentMethodDetails cvc(String cvc) { + this.cvc = cvc; + return this; + } + + public String getInstallmentConfigurationKey() { + return installmentConfigurationKey; + } + + public void setInstallmentConfigurationKey(String installmentConfigurationKey) { + this.installmentConfigurationKey = installmentConfigurationKey; + } + + public DefaultPaymentMethodDetails installmentConfigurationKey(String installmentConfigurationKey) { + this.installmentConfigurationKey = installmentConfigurationKey; + return this; + } + + public PersonalDetails getPersonalDetails() { + return personalDetails; + } + + public void setPersonalDetails(PersonalDetails personalDetails) { + this.personalDetails = personalDetails; + } + + public DefaultPaymentMethodDetails personalDetails(PersonalDetails personalDetails) { + this.personalDetails = personalDetails; + return this; + } + + public Address getBillingAddress() { + return billingAddress; + } + + public void setBillingAddress(Address billingAddress) { + this.billingAddress = billingAddress; + } + + public DefaultPaymentMethodDetails billingAddress(Address billingAddress) { + this.billingAddress = billingAddress; + return this; + } + + public Address getDeliveryAddress() { + return deliveryAddress; + } + + public void setDeliveryAddress(Address deliveryAddress) { + this.deliveryAddress = deliveryAddress; + } + + public DefaultPaymentMethodDetails deliveryAddress(Address deliveryAddress) { + this.deliveryAddress = deliveryAddress; + return this; + } + + public String getEncryptedCardNumber() { + return encryptedCardNumber; + } + + public void setEncryptedCardNumber(String encryptedCardNumber) { + this.encryptedCardNumber = encryptedCardNumber; + } + + public DefaultPaymentMethodDetails encryptedCardNumber(String encryptedCardNumber) { + this.encryptedCardNumber = encryptedCardNumber; + return this; + } + + public String getEncryptedExpiryMonth() { + return encryptedExpiryMonth; + } + + public void setEncryptedExpiryMonth(String encryptedExpiryMonth) { + this.encryptedExpiryMonth = encryptedExpiryMonth; + } + + public DefaultPaymentMethodDetails encryptedExpiryMonth(String encryptedExpiryMonth) { + this.encryptedExpiryMonth = encryptedExpiryMonth; + return this; + } + + public String getEncryptedExpiryYear() { + return encryptedExpiryYear; + } + + public void setEncryptedExpiryYear(String encryptedExpiryYear) { + this.encryptedExpiryYear = encryptedExpiryYear; + } + + public DefaultPaymentMethodDetails encryptedExpiryYear(String encryptedExpiryYear) { + this.encryptedExpiryYear = encryptedExpiryYear; + return this; + } + + public String getEncryptedSecurityCode() { + return encryptedSecurityCode; + } + + public void setEncryptedSecurityCode(String encryptedSecurityCode) { + this.encryptedSecurityCode = encryptedSecurityCode; + } + + public DefaultPaymentMethodDetails encryptedSecurityCode(String encryptedSecurityCode) { + this.encryptedSecurityCode = encryptedSecurityCode; + return this; + } + + public String getRecurringDetailReference() { + return recurringDetailReference; + } + + public void setRecurringDetailReference(String recurringDetailReference) { + this.recurringDetailReference = recurringDetailReference; + } + + public DefaultPaymentMethodDetails recurringDetailReference(String recurringDetailReference) { + this.recurringDetailReference = recurringDetailReference; + return this; + } + + public Boolean getStoreDetails() { + return storeDetails; + } + + public void setStoreDetails(Boolean storeDetails) { + this.storeDetails = storeDetails; + } + + public DefaultPaymentMethodDetails storeDetails(Boolean storeDetails) { + this.storeDetails = storeDetails; + return this; + } + + public String getIdealIssuer() { + return idealIssuer; + } + + public void setIdealIssuer(String idealIssuer) { + this.idealIssuer = idealIssuer; + } + + public DefaultPaymentMethodDetails idealIssuer(String idealIssuer) { + this.idealIssuer = idealIssuer; + return this; + } + + @Override + public String toString() { + return "DefaultPaymentMethodDetails{" + + "type='" + + type + + '\'' + + ", expiryMonth='" + + expiryMonth + + '\'' + + ", expiryYear='" + + expiryYear + + '\'' + + ", holderName='" + + holderName + + '\'' + + ", installmentConfigurationKey='" + + installmentConfigurationKey + + '\'' + + ", personalDetails=" + + personalDetails + + ", billingAddress=" + + billingAddress + + ", deliveryAddress=" + + deliveryAddress + + ", encryptedExpiryMonth='" + + encryptedExpiryMonth + + '\'' + + ", encryptedExpiryYear='" + + encryptedExpiryYear + + '\'' + + ", recurringDetailReference='" + + recurringDetailReference + + '\'' + + ", storeDetails=" + + storeDetails + + ", idealIssuer=" + + idealIssuer + + '}'; + } +} + + + diff --git a/src/main/java/com/adyen/model/checkout/PaymentMethodDetails.java b/src/main/java/com/adyen/model/checkout/PaymentMethodDetails.java new file mode 100755 index 000000000..c371cf238 --- /dev/null +++ b/src/main/java/com/adyen/model/checkout/PaymentMethodDetails.java @@ -0,0 +1,26 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 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.checkout; + +public interface PaymentMethodDetails { + String getType(); + void setType(String type); +} diff --git a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java index 6e08e6c29..39e228516 100755 --- a/src/main/java/com/adyen/model/checkout/PaymentsRequest.java +++ b/src/main/java/com/adyen/model/checkout/PaymentsRequest.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -41,17 +40,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import static com.adyen.constants.ApiConstants.PaymentMethod.CVC; -import static com.adyen.constants.ApiConstants.PaymentMethod.ENCRYPTED_CARD_NUMBER; -import static com.adyen.constants.ApiConstants.PaymentMethod.ENCRYPTED_EXPIRY_MONTH; -import static com.adyen.constants.ApiConstants.PaymentMethod.ENCRYPTED_EXPIRY_YEAR; -import static com.adyen.constants.ApiConstants.PaymentMethod.ENCRYPTED_SECURITY_CODE; -import static com.adyen.constants.ApiConstants.PaymentMethod.EXPIRY_MONTH; -import static com.adyen.constants.ApiConstants.PaymentMethod.EXPIRY_YEAR; -import static com.adyen.constants.ApiConstants.PaymentMethod.HOLDER_NAME; -import static com.adyen.constants.ApiConstants.PaymentMethod.METHOD_TYPE; -import static com.adyen.constants.ApiConstants.PaymentMethod.NUMBER; -import static com.adyen.constants.ApiConstants.PaymentMethod.RECURRING_DETAIL_REFERENCE; import static com.adyen.constants.ApiConstants.PaymentMethodType.TYPE_SCHEME; /** @@ -109,7 +97,7 @@ public class PaymentsRequest { @SerializedName("orderReference") private String orderReference = null; @SerializedName("paymentMethod") - private Map paymentMethod = null; + private PaymentMethodDetails paymentMethod = null; @SerializedName("reference") private String reference = null; @SerializedName("returnUrl") @@ -136,6 +124,8 @@ public class PaymentsRequest { private String telephoneNumber = null; @SerializedName("browserInfo") private BrowserInfo browserInfo = null; + @SerializedName("deviceFingerprint") + private String deviceFingerprint = null; public PaymentsRequest additionalData(Map additionalData) { this.additionalData = additionalData; @@ -593,43 +583,31 @@ public void setOrderReference(String orderReference) { this.orderReference = orderReference; } - public PaymentsRequest paymentMethod(Map paymentMethod) { - this.paymentMethod = paymentMethod; - return this; - } - - public PaymentsRequest putPaymentMethodItem(String key, String paymentMethodItem) { - - this.paymentMethod.put(key, paymentMethodItem); - return this; + public PaymentMethodDetails getPaymentMethod() { + return paymentMethod; } - /** - * The collection that contains the type of the payment method and its specific information (e.g. `idealIssuer`). - * - * @return paymentMethod - **/ - public Map getPaymentMethod() { - return paymentMethod; + public void setPaymentMethod(PaymentMethodDetails paymentMethod) { + this.paymentMethod = paymentMethod; } - public void setPaymentMethod(Map paymentMethod) { + public PaymentsRequest paymentMethod(PaymentMethodDetails paymentMethod) { this.paymentMethod = paymentMethod; + return this; } public PaymentsRequest addEncryptedCardData(String encryptedCardNumber, String encryptedExpiryMonth, String encryptedExpiryYear, String encryptedSecurityCode, String holderName) { - this.paymentMethod = new HashMap<>(); - this.paymentMethod.put(METHOD_TYPE, TYPE_SCHEME); - this.paymentMethod.put(ENCRYPTED_CARD_NUMBER, encryptedCardNumber); - this.paymentMethod.put(ENCRYPTED_EXPIRY_MONTH, encryptedExpiryMonth); - this.paymentMethod.put(ENCRYPTED_EXPIRY_YEAR, encryptedExpiryYear); + DefaultPaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails(); + + paymentMethodDetails.type(TYPE_SCHEME).encryptedCardNumber(encryptedCardNumber).encryptedExpiryMonth(encryptedExpiryMonth).encryptedExpiryYear(encryptedExpiryYear); if (encryptedSecurityCode != null) { - this.paymentMethod.put(ENCRYPTED_SECURITY_CODE, encryptedSecurityCode); + paymentMethodDetails.setEncryptedSecurityCode(encryptedSecurityCode); } if (holderName != null) { - this.paymentMethod.put(HOLDER_NAME, holderName); + paymentMethodDetails.setHolderName(holderName); } + this.paymentMethod = paymentMethodDetails; return this; } @@ -639,26 +617,25 @@ public PaymentsRequest addEncryptedCardData(String encryptedCardNumber, String e * @return paymentMethod */ public PaymentsRequest addCardData(String cardNumber, String expiryMonth, String expiryYear, String securityCode, String holderName) { - this.paymentMethod = new HashMap<>(); - this.paymentMethod.put(METHOD_TYPE, TYPE_SCHEME); - this.paymentMethod.put(NUMBER, cardNumber); - this.paymentMethod.put(EXPIRY_MONTH, expiryMonth); - this.paymentMethod.put(EXPIRY_YEAR, expiryYear); + DefaultPaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails(); + paymentMethodDetails.type(TYPE_SCHEME).number(cardNumber).expiryMonth(expiryMonth).expiryYear(expiryYear); + if (securityCode != null) { - this.paymentMethod.put(CVC, securityCode); + paymentMethodDetails.setCvc(securityCode); } if (holderName != null) { - this.paymentMethod.put(HOLDER_NAME, holderName); + paymentMethodDetails.setHolderName(holderName); } + this.paymentMethod = paymentMethodDetails; return this; } public PaymentsRequest addOneClickData(String recurringDetailReference, String encryptedSecurityCode) { - this.paymentMethod = new HashMap<>(); - this.paymentMethod.put(METHOD_TYPE, TYPE_SCHEME); - this.paymentMethod.put(RECURRING_DETAIL_REFERENCE, recurringDetailReference); - this.paymentMethod.put(ENCRYPTED_SECURITY_CODE, encryptedSecurityCode); + DefaultPaymentMethodDetails paymentMethodDetails = new DefaultPaymentMethodDetails(); + paymentMethodDetails.type(TYPE_SCHEME).recurringDetailReference(recurringDetailReference).encryptedSecurityCode(encryptedSecurityCode); + + this.paymentMethod = paymentMethodDetails; return this; } @@ -907,6 +884,19 @@ public PaymentsRequest addBrowserInfoData(String userAgent, String acceptHeader) return this; } + public String getDeviceFingerprint() { + return deviceFingerprint; + } + + public void setDeviceFingerprint(String deviceFingerprint) { + this.deviceFingerprint = deviceFingerprint; + } + + public PaymentsRequest deviceFingerprint(String deviceFingerprint) { + this.deviceFingerprint = deviceFingerprint; + return this; + } + @Override public boolean equals(Object o) { if (this == o) { @@ -952,6 +942,7 @@ public boolean equals(Object o) { && Objects.equals(this.shopperReference, paymentsRequest.shopperReference) && Objects.equals(this.shopperStatement, paymentsRequest.shopperStatement) && Objects.equals(this.socialSecurityNumber, paymentsRequest.socialSecurityNumber) + && Objects.equals(this.deviceFingerprint, paymentsRequest.deviceFingerprint) && Objects.equals(this.telephoneNumber, paymentsRequest.telephoneNumber); } @@ -992,6 +983,7 @@ public int hashCode() { shopperReference, shopperStatement, socialSecurityNumber, + deviceFingerprint, telephoneNumber); } @@ -1035,6 +1027,7 @@ public String toString() { sb.append(" shopperReference: ").append(toIndentedString(shopperReference)).append("\n"); sb.append(" shopperStatement: ").append(toIndentedString(shopperStatement)).append("\n"); sb.append(" socialSecurityNumber: ").append(toIndentedString(socialSecurityNumber)).append("\n"); + sb.append(" deviceFingerprint: ").append(toIndentedString(deviceFingerprint)).append("\n"); sb.append(" telephoneNumber: ").append(toIndentedString(telephoneNumber)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/src/main/java/com/adyen/model/checkout/PersonalDetails.java b/src/main/java/com/adyen/model/checkout/PersonalDetails.java new file mode 100644 index 000000000..e6f475a5f --- /dev/null +++ b/src/main/java/com/adyen/model/checkout/PersonalDetails.java @@ -0,0 +1,138 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * + * Adyen Java API Library + * + * Copyright (c) 2017 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.checkout; + +import com.google.gson.annotations.SerializedName; + +public class PersonalDetails { + @SerializedName("firstName") + private String firstName; + @SerializedName("infix") + private String infix; + @SerializedName("lastName") + private String lastName; + @SerializedName("dateOfBirth") + private String dateOfBirth; + @SerializedName("telephoneNumber") + private String telephoneNumber; + @SerializedName("socialSecurityNumber") + private String socialSecurityNumber; + @SerializedName("shopperEmail") + private String shopperEmail; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public PersonalDetails firstName(String firstName) { + this.firstName = firstName; + return this; + } + + public String getInfix() { + return infix; + } + + public void setInfix(String infix) { + this.infix = infix; + } + + public PersonalDetails infix(String infix) { + this.infix = infix; + return this; + } + + public String getLastName() { + return lastName; + } + + public PersonalDetails lastName(String lastName) { + this.lastName = lastName; + return this; + } + + public String getDateOfBirth() { + return dateOfBirth; + } + + public PersonalDetails dateOfBirth(String dateOfBirth) { + this.dateOfBirth = dateOfBirth; + return this; + } + + public String getTelephoneNumber() { + return telephoneNumber; + } + + public PersonalDetails telephoneNumber(String telephoneNumber) { + this.telephoneNumber = telephoneNumber; + return this; + } + + public String getSocialSecurityNumber() { + return socialSecurityNumber; + } + + public PersonalDetails socialSecurityNumber(String socialSecurityNumber) { + this.socialSecurityNumber = socialSecurityNumber; + return this; + } + + public String getShopperEmail() { + return shopperEmail; + } + + public PersonalDetails shopperEmail(String shopperEmail) { + this.shopperEmail = shopperEmail; + return this; + } + + @Override + public String toString() { + return "PersonalDetails{" + + "firstName='" + + firstName + + '\'' + + ", infix='" + + infix + + '\'' + + ", lastName='" + + lastName + + '\'' + + ", dateOfBirth='" + + dateOfBirth + + '\'' + + ", telephoneNumber='" + + telephoneNumber + + '\'' + + ", socialSecurityNumber='" + + socialSecurityNumber + + '\'' + + ", shopperEmail='" + + shopperEmail + + '\'' + + '}'; + } +} diff --git a/src/main/java/com/adyen/service/Modification.java b/src/main/java/com/adyen/service/Modification.java index de2fd9662..c659a3cc9 100644 --- a/src/main/java/com/adyen/service/Modification.java +++ b/src/main/java/com/adyen/service/Modification.java @@ -1,19 +1,19 @@ -/** - * ###### - * ###### +/* + * ###### + * ###### * ############ ####( ###### #####. ###### ############ ############ * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### #####( ###### #####. ###### ##### ###### ##### ###### * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### * ###### ###### #####( ###### #####. ###### ##### ##### ###### * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - *

+ * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * * Adyen Java API Library - *

+ * * Copyright (c) 2017 Adyen B.V. * This file is open source and available under the MIT license. * See the LICENSE file for more info. diff --git a/src/test/java/com/adyen/CheckoutTest.java b/src/test/java/com/adyen/CheckoutTest.java index cf05ba674..d5c814d9b 100644 --- a/src/test/java/com/adyen/CheckoutTest.java +++ b/src/test/java/com/adyen/CheckoutTest.java @@ -20,13 +20,21 @@ */ package com.adyen; +import org.junit.Test; import com.adyen.model.Amount; -import com.adyen.model.checkout.*; +import com.adyen.model.checkout.PaymentMethodDetails; +import com.adyen.model.checkout.PaymentMethodsRequest; +import com.adyen.model.checkout.PaymentMethodsResponse; +import com.adyen.model.checkout.PaymentResultRequest; +import com.adyen.model.checkout.PaymentResultResponse; +import com.adyen.model.checkout.PaymentSessionRequest; +import com.adyen.model.checkout.PaymentSessionResponse; +import com.adyen.model.checkout.PaymentsDetailsRequest; +import com.adyen.model.checkout.PaymentsRequest; +import com.adyen.model.checkout.PaymentsResponse; import com.adyen.service.Checkout; -import org.junit.Test; - -import java.util.HashMap; - +import com.google.gson.annotations.SerializedName; +import static com.adyen.Service.GSON; import static com.adyen.enums.Environment.LIVE; import static junit.framework.TestCase.assertNull; import static org.junit.Assert.assertEquals; @@ -196,6 +204,25 @@ public void TestPaymentMethodsFailureMissingIdentifierOnLive() throws Exception } + @Test + public void TestPaymentMethodDetails() { + PaymentsRequest paymentsRequest = createPaymentsCheckoutRequest(); + String jsonRequest = GSON.toJson(paymentsRequest); + assertEquals( + "{\"amount\":{\"value\":1000,\"currency\":\"USD\"},\"merchantAccount\":\"MagentoMerchantTest\",\"paymentMethod\":{\"type\":\"scheme\",\"number\":\"4111111111111111\",\"expiryMonth\":\"10\",\"expiryYear\":\"2018\",\"holderName\":\"John Smith\",\"cvc\":\"737\"},\"reference\":\"Your order number\",\"returnUrl\":\"https://your-company.com/...\"}", + jsonRequest); + + TestPaymentMethodDetails testPaymentMethodDetails = new TestPaymentMethodDetails(); + testPaymentMethodDetails.setType("testType"); + testPaymentMethodDetails.setTestValue("testValue"); + paymentsRequest.setPaymentMethod(testPaymentMethodDetails); + + jsonRequest = GSON.toJson(paymentsRequest); + assertEquals( + "{\"amount\":{\"value\":1000,\"currency\":\"USD\"},\"merchantAccount\":\"MagentoMerchantTest\",\"paymentMethod\":{\"testKey\":\"testValue\",\"type\":\"testType\"},\"reference\":\"Your order number\",\"returnUrl\":\"https://your-company.com/...\"}", + jsonRequest); + } + /** * Returns a sample PaymentSessionRequest opbject with test data */ @@ -248,3 +275,29 @@ protected Amount createAmountObject(String currency, Long value) { return amount; } } + +class TestPaymentMethodDetails implements PaymentMethodDetails { + @SerializedName("testKey") + private String testValue; + + @SerializedName("type") + private String type; + + @Override + public String getType() { + return type; + } + + @Override + public void setType(String type) { + this.type = type; + } + + public String getTestValue() { + return testValue; + } + + public void setTestValue(String testValue) { + this.testValue = testValue; + } +} \ No newline at end of file