From 285b68139289d327457458d633b4db610c1c1279 Mon Sep 17 00:00:00 2001 From: Onur Polattimur Date: Mon, 18 Mar 2024 15:20:59 +0300 Subject: [PATCH] Add GarantiPay v2 integration --- .../model/PosApmPaymentProvider.java | 3 +- .../io/craftgate/sample/PaymentSample.java | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/craftgate/model/PosApmPaymentProvider.java b/src/main/java/io/craftgate/model/PosApmPaymentProvider.java index 63a50d9d..12ea935e 100644 --- a/src/main/java/io/craftgate/model/PosApmPaymentProvider.java +++ b/src/main/java/io/craftgate/model/PosApmPaymentProvider.java @@ -3,6 +3,7 @@ public enum PosApmPaymentProvider { YKB_WORLD_PAY, + YKB_WORLD_PAY_SHOPPING_LOAN, GOOGLEPAY, - APPLEPAY + GARANTI_PAY, } diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index 9318a48c..2e019e93 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -1247,6 +1247,43 @@ void init_ykb_world_pay_pos_apm_payment() { assertEquals(AdditionalAction.SHOW_HTML_CONTENT, response.getAdditionalAction()); } + @Test + void init_garanti_pay_pos_apm_payment() { + List items = new ArrayList<>(); + + items.add(PaymentItem.builder() + .name("item 1") + .externalId(UUID.randomUUID().toString()) + .price(BigDecimal.valueOf(0.6)) + .build()); + + items.add(PaymentItem.builder() + .name("item 2") + .externalId(UUID.randomUUID().toString()) + .price(BigDecimal.valueOf(0.4)) + .build()); + + InitPosApmPaymentRequest request = InitPosApmPaymentRequest.builder() + .price(BigDecimal.ONE) + .paidPrice(BigDecimal.ONE) + .currency(Currency.TRY) + .paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION) + .conversationId("456d1297-908e-4bd6-a13b-4be31a6e47d5") + .paymentProvider(PosApmPaymentProvider.GARANTI_PAY) + .additionalParams(new HashMap() {{ + put("integrationType", "WEB2APP"); + }}) + .callbackUrl("https://www.your-website.com/craftgate-pos-apm-callback") + .items(items) + .build(); + + InitPosApmPaymentResponse response = craftgate.payment().initPosApmPayment(request); + assertNotNull(response.getPaymentId()); + assertNotNull(response.getAdditionalData().get("redirectUrl")); + assertEquals(PaymentStatus.WAITING, response.getPaymentStatus()); + assertEquals(AdditionalAction.REDIRECT_TO_URL, response.getAdditionalAction()); + } + @Test void complete_pos_apm_payment() { CompletePosApmPaymentRequest request = CompletePosApmPaymentRequest.builder()