From de3a0f7e98072de2449c84f27b8478f3cc5e35a8 Mon Sep 17 00:00:00 2001 From: Emre INAL Date: Thu, 21 Nov 2024 15:09:57 +0300 Subject: [PATCH 1/4] Adds refund transaction manual endpoint --- .../io/craftgate/adapter/PaymentAdapter.java | 6 ++++++ ...RefundPaymentTransactionManualRequest.java | 20 +++++++++++++++++++ .../io/craftgate/sample/PaymentSample.java | 13 +++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java diff --git a/src/main/java/io/craftgate/adapter/PaymentAdapter.java b/src/main/java/io/craftgate/adapter/PaymentAdapter.java index 0cc2260c..ceac85ad 100644 --- a/src/main/java/io/craftgate/adapter/PaymentAdapter.java +++ b/src/main/java/io/craftgate/adapter/PaymentAdapter.java @@ -142,6 +142,12 @@ public PaymentTransactionRefundResponse retrievePaymentTransactionRefund(Long id return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), PaymentTransactionRefundResponse.class); } + public PaymentTransactionRefundResponse refundPaymentTransactionManual(RefundPaymentTransactionManualRequest refundPaymentTransactionManualRequest) { + String path = "/payment/v1/refund-transactions/manual"; + return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(refundPaymentTransactionManualRequest, path, requestOptions), + refundPaymentTransactionManualRequest, PaymentTransactionRefundResponse.class); + } + public PaymentRefundResponse refundPayment(RefundPaymentRequest refundPaymentRequest) { String path = "/payment/v1/refunds"; return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(refundPaymentRequest, path, requestOptions), diff --git a/src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java b/src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java new file mode 100644 index 00000000..b77b8803 --- /dev/null +++ b/src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java @@ -0,0 +1,20 @@ +package io.craftgate.request; + +import io.craftgate.model.RefundDestinationType; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class RefundPaymentTransactionManualRequest { + + private Long paymentTransactionRefundId; + private String conversationId; + private String description; + + @Builder.Default + private RefundDestinationType refundDestinationType = RefundDestinationType.PROVIDER; + + @Builder.Default + private Boolean chargeFromMe = false; +} diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index e63561ed..fe6c6b05 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -915,7 +915,7 @@ void init_garanti_pay_payment() { .paymentGroup(PaymentGroup.LISTING_OR_SUBSCRIPTION) .items(items) .installments(installments) - .enabledInstallments(Arrays.asList(2,3)) + .enabledInstallments(Arrays.asList(2, 3)) .build(); InitGarantiPayPaymentResponse response = craftgate.payment().initGarantiPayPayment(request); @@ -1579,6 +1579,17 @@ void retrieve_payment_transaction_refund() { assertEquals(RefundStatus.SUCCESS, response.getStatus()); } + @Test + void refund_payment_transaction_manual() { + RefundPaymentTransactionManualRequest request = RefundPaymentTransactionManualRequest.builder() + .paymentTransactionRefundId(1L) + .build(); + + PaymentTransactionRefundResponse response = craftgate.payment().refundPaymentTransactionManual(request); + assertNotNull(response); + assertEquals(RefundStatus.SUCCESS, response.getStatus()); + } + @Test void store_card() { final StoreCardRequest storeCardRequest = StoreCardRequest.builder() From 2bf809ea4c1a7c463d3686a6b20b8521e532948c Mon Sep 17 00:00:00 2001 From: Emre INAL Date: Thu, 21 Nov 2024 15:58:26 +0300 Subject: [PATCH 2/4] added description --- src/test/java/io/craftgate/sample/PaymentSample.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index fe6c6b05..19766bfa 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -1583,6 +1583,7 @@ void retrieve_payment_transaction_refund() { void refund_payment_transaction_manual() { RefundPaymentTransactionManualRequest request = RefundPaymentTransactionManualRequest.builder() .paymentTransactionRefundId(1L) + .description("refunded manually") .build(); PaymentTransactionRefundResponse response = craftgate.payment().refundPaymentTransactionManual(request); From 06c60b63daae6971ea75abaf88ab20e94a3953fb Mon Sep 17 00:00:00 2001 From: Emre INAL Date: Thu, 21 Nov 2024 17:21:15 +0300 Subject: [PATCH 3/4] changed naming --- src/main/java/io/craftgate/adapter/PaymentAdapter.java | 6 +++--- ...a => RefundPaymentTransactionMarkAsRefundedRequest.java} | 2 +- src/test/java/io/craftgate/sample/PaymentSample.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/io/craftgate/request/{RefundPaymentTransactionManualRequest.java => RefundPaymentTransactionMarkAsRefundedRequest.java} (87%) diff --git a/src/main/java/io/craftgate/adapter/PaymentAdapter.java b/src/main/java/io/craftgate/adapter/PaymentAdapter.java index ceac85ad..2c034520 100644 --- a/src/main/java/io/craftgate/adapter/PaymentAdapter.java +++ b/src/main/java/io/craftgate/adapter/PaymentAdapter.java @@ -142,10 +142,10 @@ public PaymentTransactionRefundResponse retrievePaymentTransactionRefund(Long id return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), PaymentTransactionRefundResponse.class); } - public PaymentTransactionRefundResponse refundPaymentTransactionManual(RefundPaymentTransactionManualRequest refundPaymentTransactionManualRequest) { + public PaymentTransactionRefundResponse refundPaymentTransactionManual(RefundPaymentTransactionMarkAsRefundedRequest refundPaymentTransactionMarkAsRefundedRequest) { String path = "/payment/v1/refund-transactions/manual"; - return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(refundPaymentTransactionManualRequest, path, requestOptions), - refundPaymentTransactionManualRequest, PaymentTransactionRefundResponse.class); + return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(refundPaymentTransactionMarkAsRefundedRequest, path, requestOptions), + refundPaymentTransactionMarkAsRefundedRequest, PaymentTransactionRefundResponse.class); } public PaymentRefundResponse refundPayment(RefundPaymentRequest refundPaymentRequest) { diff --git a/src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java b/src/main/java/io/craftgate/request/RefundPaymentTransactionMarkAsRefundedRequest.java similarity index 87% rename from src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java rename to src/main/java/io/craftgate/request/RefundPaymentTransactionMarkAsRefundedRequest.java index b77b8803..4ee8d30b 100644 --- a/src/main/java/io/craftgate/request/RefundPaymentTransactionManualRequest.java +++ b/src/main/java/io/craftgate/request/RefundPaymentTransactionMarkAsRefundedRequest.java @@ -6,7 +6,7 @@ @Data @Builder -public class RefundPaymentTransactionManualRequest { +public class RefundPaymentTransactionMarkAsRefundedRequest { private Long paymentTransactionRefundId; private String conversationId; diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index 19766bfa..9b54447d 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -1580,10 +1580,10 @@ void retrieve_payment_transaction_refund() { } @Test - void refund_payment_transaction_manual() { - RefundPaymentTransactionManualRequest request = RefundPaymentTransactionManualRequest.builder() + void refund_payment_transaction_mark_as_refunded() { + RefundPaymentTransactionMarkAsRefundedRequest request = RefundPaymentTransactionMarkAsRefundedRequest.builder() .paymentTransactionRefundId(1L) - .description("refunded manually") + .description("marked as refunded") .build(); PaymentTransactionRefundResponse response = craftgate.payment().refundPaymentTransactionManual(request); From 2eaa0d3195b6fd89e990fad42d4bf6e13382ad31 Mon Sep 17 00:00:00 2001 From: Emre INAL Date: Thu, 21 Nov 2024 17:26:16 +0300 Subject: [PATCH 4/4] edit function name --- src/main/java/io/craftgate/adapter/PaymentAdapter.java | 2 +- src/test/java/io/craftgate/sample/PaymentSample.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/craftgate/adapter/PaymentAdapter.java b/src/main/java/io/craftgate/adapter/PaymentAdapter.java index 2c034520..932ef8c9 100644 --- a/src/main/java/io/craftgate/adapter/PaymentAdapter.java +++ b/src/main/java/io/craftgate/adapter/PaymentAdapter.java @@ -142,7 +142,7 @@ public PaymentTransactionRefundResponse retrievePaymentTransactionRefund(Long id return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), PaymentTransactionRefundResponse.class); } - public PaymentTransactionRefundResponse refundPaymentTransactionManual(RefundPaymentTransactionMarkAsRefundedRequest refundPaymentTransactionMarkAsRefundedRequest) { + public PaymentTransactionRefundResponse refundPaymentTransactionMarkAsRefunded(RefundPaymentTransactionMarkAsRefundedRequest refundPaymentTransactionMarkAsRefundedRequest) { String path = "/payment/v1/refund-transactions/manual"; return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(refundPaymentTransactionMarkAsRefundedRequest, path, requestOptions), refundPaymentTransactionMarkAsRefundedRequest, PaymentTransactionRefundResponse.class); diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index 9b54447d..f1681fea 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -1586,7 +1586,7 @@ void refund_payment_transaction_mark_as_refunded() { .description("marked as refunded") .build(); - PaymentTransactionRefundResponse response = craftgate.payment().refundPaymentTransactionManual(request); + PaymentTransactionRefundResponse response = craftgate.payment().refundPaymentTransactionMarkAsRefunded(request); assertNotNull(response); assertEquals(RefundStatus.SUCCESS, response.getStatus()); }