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 checkout token expire endpoint with new fields #134

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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