diff --git a/src/main/java/io/craftgate/adapter/PaymentAdapter.java b/src/main/java/io/craftgate/adapter/PaymentAdapter.java index 0cc2260c..932ef8c9 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 refundPaymentTransactionMarkAsRefunded(RefundPaymentTransactionMarkAsRefundedRequest refundPaymentTransactionMarkAsRefundedRequest) { + String path = "/payment/v1/refund-transactions/manual"; + return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(refundPaymentTransactionMarkAsRefundedRequest, path, requestOptions), + refundPaymentTransactionMarkAsRefundedRequest, 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/RefundPaymentTransactionMarkAsRefundedRequest.java b/src/main/java/io/craftgate/request/RefundPaymentTransactionMarkAsRefundedRequest.java new file mode 100644 index 00000000..4ee8d30b --- /dev/null +++ b/src/main/java/io/craftgate/request/RefundPaymentTransactionMarkAsRefundedRequest.java @@ -0,0 +1,20 @@ +package io.craftgate.request; + +import io.craftgate.model.RefundDestinationType; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class RefundPaymentTransactionMarkAsRefundedRequest { + + 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..f1681fea 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,18 @@ void retrieve_payment_transaction_refund() { assertEquals(RefundStatus.SUCCESS, response.getStatus()); } + @Test + void refund_payment_transaction_mark_as_refunded() { + RefundPaymentTransactionMarkAsRefundedRequest request = RefundPaymentTransactionMarkAsRefundedRequest.builder() + .paymentTransactionRefundId(1L) + .description("marked as refunded") + .build(); + + PaymentTransactionRefundResponse response = craftgate.payment().refundPaymentTransactionMarkAsRefunded(request); + assertNotNull(response); + assertEquals(RefundStatus.SUCCESS, response.getStatus()); + } + @Test void store_card() { final StoreCardRequest storeCardRequest = StoreCardRequest.builder()