Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/adyen/model/checkout/AfterpayDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public enum TypeEnum {

AFTERPAYTOUCH(String.valueOf("afterpaytouch")),

AFTERPAYTOUCH_US(String.valueOf("afterpaytouch_US")),

AFTERPAY_B2B(String.valueOf("afterpay_b2b")),

CLEARPAY(String.valueOf("clearpay"));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/adyen/model/checkout/CardDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public enum FundingSourceEnum {

DEBIT(String.valueOf("debit")),

PREPAID(String.valueOf("prepaid"));
PREPAID(String.valueOf("prepaid")),

DEFFERED_DEBIT(String.valueOf("DEFFERED_DEBIT"));

private static final Logger LOG = Logger.getLogger(FundingSourceEnum.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,7 @@ public CheckoutPaymentMethod(ZipDetails o) {
mappings.put("afterpay_directdebit", OpenInvoiceDetails.class);
mappings.put("afterpaytouch", AfterpayDetails.class);
mappings.put("afterpaytouch_pos", AfterpayDetails.class);
mappings.put("afterpaytouch_US", AfterpayDetails.class);
mappings.put("alipay", PaymentDetails.class);
mappings.put("alipay_hk", PaymentDetails.class);
mappings.put("alipay_hk_wap", PaymentDetails.class);
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/com/adyen/serializer/ModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.adyen.model.checkout.AfterpayDetails;
import com.adyen.model.checkout.CardDetails;
import com.adyen.model.checkout.CheckoutPaymentMethod;
import com.adyen.model.checkout.CreateCheckoutSessionResponse;
Expand All @@ -19,6 +20,7 @@
import com.adyen.model.tapi.SaleData;
import com.adyen.model.tapi.TransactionIDType;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.time.Month;
import java.time.OffsetDateTime;
import java.time.ZoneId;
Expand Down Expand Up @@ -370,4 +372,34 @@ public void testToJsonFlagTrueButFieldNotSet() throws JsonProcessingException {
public void testTapiEnumFromValueNull() {
assertNull(Result.fromValue(null));
}

@Test
public void testCardDetailsFundingSourceEnumSupportsDefferedDebit() {
// Adyen POS terminals can return additionalData.fundingSource = "DEFFERED_DEBIT",
// which was previously missing from this enum (issue #1878).
assertEquals(
CardDetails.FundingSourceEnum.DEFFERED_DEBIT,
CardDetails.FundingSourceEnum.fromValue("DEFFERED_DEBIT"));
}

@Test
public void testAfterpayDetailsTypeEnumSupportsAfterpaytouchUS() {
// The /paymentMethods endpoint can return type "afterpaytouch_US" for
// Afterpay/Cash App Afterpay in the US, which was previously missing (issue #1953).
assertEquals(
AfterpayDetails.TypeEnum.AFTERPAYTOUCH_US,
AfterpayDetails.TypeEnum.fromValue("afterpaytouch_US"));
}

@Test
public void testCheckoutPaymentMethodDeserializesAfterpaytouchUS() throws IOException {
String json = "{\"type\": \"afterpaytouch_US\"}";

CheckoutPaymentMethod paymentMethod = CheckoutPaymentMethod.fromJson(json);

assertTrue(paymentMethod.getActualInstance() instanceof AfterpayDetails);
assertEquals(
AfterpayDetails.TypeEnum.AFTERPAYTOUCH_US,
((AfterpayDetails) paymentMethod.getActualInstance()).getType());
}
}