Skip to content

Commit

Permalink
adds checkout token expire endpoint with new fields (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
reywyn authored Aug 29, 2023
1 parent 712a1bf commit 11bea86
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/io/craftgate/adapter/PaymentAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public PaymentResponse retrieveCheckoutPayment(String token) {
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), PaymentResponse.class);
}

public void expireCheckoutPayment(String token) {
String path = "/payment/v1/checkout-payments/" + token;
HttpClient.delete(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions));
}

public DepositPaymentResponse createDepositPayment(CreateDepositPaymentRequest createDepositPaymentRequest) {
String path = "/payment/v1/deposits";
return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(createDepositPaymentRequest, path, requestOptions),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class InitCheckoutPaymentRequest {
protected boolean allowInstallmentOnlyCommercialCards;
protected boolean forceThreeDS;
protected boolean forceAuthForNonCreditCards;
protected Long ttl;
protected List<CustomInstallment> customInstallments;
protected List<PaymentItem> items;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import lombok.Data;

import java.time.LocalDateTime;

@Data
public class InitCheckoutPaymentResponse {

protected String token;
protected String pageUrl;
protected LocalDateTime tokenExpireDate;
}
8 changes: 8 additions & 0 deletions src/test/java/io/craftgate/sample/PaymentSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ void init_checkout_payment() {
assertNotNull(response);
assertNotNull(response.getPageUrl());
assertNotNull(response.getToken());
assertNotNull(response.getTokenExpireDate());
}

@Test
Expand All @@ -741,6 +742,13 @@ void retrieve_checkout_payment() {
assertNotNull(response);
}

@Test
void expire_checkout_payment() {
String token = "456d1297-908e-4bd6-a13b-4be31a6e47d5";

craftgate.payment().expireCheckoutPayment(token);
}

@Test
void create_deposit_payment() {
CreateDepositPaymentRequest request = CreateDepositPaymentRequest.builder()
Expand Down

0 comments on commit 11bea86

Please sign in to comment.