Skip to content

Commit

Permalink
Adds refund transaction mark as refunded endpoint (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
reywyn authored Nov 21, 2024
1 parent 9da262b commit 9358ccc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/java/io/craftgate/adapter/PaymentAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 13 additions & 1 deletion src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9358ccc

Please sign in to comment.