Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds refund transaction mark as refunded endpoint #209

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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),
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 RefundPaymentTransactionManualRequest {

private Long paymentTransactionRefundId;
private String conversationId;
private String description;

@Builder.Default
private RefundDestinationType refundDestinationType = RefundDestinationType.PROVIDER;

@Builder.Default
private Boolean chargeFromMe = false;
}
13 changes: 12 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,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()
Expand Down
Loading