Skip to content

Commit

Permalink
Merge branch 'master' into add-bizum-payment-method
Browse files Browse the repository at this point in the history
  • Loading branch information
mozcan authored Nov 26, 2024
2 parents 448f3d9 + 0016654 commit 570b579
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ Apache Maven:
<dependency>
<groupId>io.craftgate</groupId>
<artifactId>craftgate</artifactId>
<version>1.0.60</version>
<version>1.0.61</version>
</dependency>
```
Gradle Groovy DSL
```
implementation 'io.craftgate:craftgate:1.0.60'
implementation 'io.craftgate:craftgate:1.0.61'
```
Gradle Kotlin DSL
```
implementation("io.craftgate:craftgate:1.0.60")
implementation("io.craftgate:craftgate:1.0.61")
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/craftgate/adapter/BaseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static Map<String, String> createHttpHeaders(Object request, String path
headers.put(API_KEY_HEADER_NAME, options.getApiKey());
headers.put(RANDOM_HEADER_NAME, randomString);
headers.put(AUTH_VERSION_HEADER_NAME, API_VERSION_HEADER_VALUE);
headers.put(CLIENT_VERSION_HEADER_NAME, CLIENT_VERSION_HEADER_VALUE + ":1.0.60");
headers.put(CLIENT_VERSION_HEADER_NAME, CLIENT_VERSION_HEADER_VALUE + ":1.0.61");
headers.put(SIGNATURE_HEADER_NAME, prepareAuthorizationString(request, path, randomString, options));
if (Objects.nonNull(options.getLanguage())) {
headers.put(LANGUAGE_HEADER_NAME, options.getLanguage());
Expand Down
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 @@ -1616,6 +1616,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 570b579

Please sign in to comment.