diff --git a/src/main/java/io/craftgate/model/ApmType.java b/src/main/java/io/craftgate/model/ApmType.java index 67ddf42f..acc8ed0d 100644 --- a/src/main/java/io/craftgate/model/ApmType.java +++ b/src/main/java/io/craftgate/model/ApmType.java @@ -14,6 +14,7 @@ public enum ApmType { TOMPAY, MASLAK, ALFABANK, + TOM_FINANCE, FUND_TRANSFER, CASH_ON_DELIVERY } diff --git a/src/test/java/io/craftgate/sample/BnplPaymentSample.java b/src/test/java/io/craftgate/sample/BnplPaymentSample.java index 13906902..4e4cd473 100644 --- a/src/test/java/io/craftgate/sample/BnplPaymentSample.java +++ b/src/test/java/io/craftgate/sample/BnplPaymentSample.java @@ -15,9 +15,7 @@ import org.junit.jupiter.api.Test; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -112,6 +110,49 @@ void init_bnpl_payment() { assertNotNull(response.getRedirectUrl()); } + @Test + void init_tom_finance_bnpl_payment() { + BigDecimal price = new BigDecimal("100"); + + Map additionalParams = new HashMap<>(); + additionalParams.put("buyerName", "John Doe"); + additionalParams.put("buyerPhoneNumber", "5551112233"); + + List paymentItemRequests = new ArrayList<>(); + paymentItemRequests.add(PaymentItem.builder() + .name("item-1") + .externalId("externalId") + .price(new BigDecimal("100")) + .build()); + + List items = new ArrayList<>(); + items.add(BnplPaymentCartItem.builder() + .id("26020874") + .name("Item 1") + .brandName("26010303") + .type(BnplCartItemType.OTHER) + .unitPrice(new BigDecimal("100")) + .quantity(1) + .build()); + InitBnplPaymentRequest request = InitBnplPaymentRequest.builder() + .price(price) + .paidPrice(price) + .currency(Currency.TRY) + .apmType(ApmType.TOM_FINANCE) + .apmOrderId(UUID.randomUUID().toString()) + .paymentGroup(PaymentGroup.PRODUCT) + .conversationId("conversationId") + .externalId("externalId") + .callbackUrl("https://www.your-website.com/bnpl-callback") + .items(paymentItemRequests) + .cartItems(items) + .additionalParams(additionalParams) + .build(); + + InitBnplPaymentResponse response = craftgate.payment().initBnplPayment(request); + assertNotNull(response.getRedirectUrl()); + } + @Test void approve_bnpl_payment() {