Skip to content

Commit

Permalink
Adds tom finance (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalikci authored Nov 27, 2023
1 parent 7895d97 commit fdf6dee
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/craftgate/model/ApmType.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum ApmType {
TOMPAY,
MASLAK,
ALFABANK,
TOM_FINANCE,
FUND_TRANSFER,
CASH_ON_DELIVERY
}
47 changes: 44 additions & 3 deletions src/test/java/io/craftgate/sample/BnplPaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -112,6 +110,49 @@ void init_bnpl_payment() {
assertNotNull(response.getRedirectUrl());
}

@Test
void init_tom_finance_bnpl_payment() {
BigDecimal price = new BigDecimal("100");

Map<String, String> additionalParams = new HashMap<>();
additionalParams.put("buyerName", "John Doe");
additionalParams.put("buyerPhoneNumber", "5551112233");

List<PaymentItem> paymentItemRequests = new ArrayList<>();
paymentItemRequests.add(PaymentItem.builder()
.name("item-1")
.externalId("externalId")
.price(new BigDecimal("100"))
.build());

List<BnplPaymentCartItem> 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() {
Expand Down

0 comments on commit fdf6dee

Please sign in to comment.