Skip to content

Commit 0db9abe

Browse files
authored
Add bnpl verify endpoint (#239)
1 parent d1a8b96 commit 0db9abe

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

src/main/java/io/craftgate/adapter/PaymentAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ public PaymentResponse approveBnplPayment(Long paymentId) {
236236
return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), PaymentResponse.class);
237237
}
238238

239+
public BnplPaymentVerifyResponse verifyBnplPayment(Long paymentId) {
240+
String path = "/payment/v1/bnpl-payments/" + paymentId + "/verify";
241+
return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), BnplPaymentVerifyResponse.class);
242+
}
243+
239244
public InstantTransferBanksResponse retrieveActiveBanks() {
240245
String path = "/payment/v1/instant-transfer-banks";
241246
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions),

src/main/java/io/craftgate/request/InitBnplPaymentRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.craftgate.request;
22

33
import io.craftgate.request.dto.BnplPaymentCartItem;
4-
import lombok.Builder;
54
import lombok.Data;
65
import lombok.EqualsAndHashCode;
76
import lombok.experimental.SuperBuilder;
7+
88
import java.util.List;
99

1010
@Data
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.craftgate.response;
2+
3+
import io.craftgate.model.ApmAdditionalAction;
4+
import io.craftgate.model.PaymentStatus;
5+
import io.craftgate.response.dto.PaymentError;
6+
import lombok.Data;
7+
8+
@Data
9+
public class BnplPaymentVerifyResponse {
10+
11+
private PaymentStatus paymentStatus;
12+
private ApmAdditionalAction additionalAction;
13+
private PaymentError paymentError;
14+
}

src/main/java/io/craftgate/response/dto/PaymentError.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
@Data
66
public class PaymentError {
7+
78
private String errorCode;
89
private String errorDescription;
910
private String errorGroup;

src/test/java/io/craftgate/sample/BnplPaymentSample.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import io.craftgate.request.dto.BnplPaymentCartItem;
1111
import io.craftgate.request.dto.PaymentItem;
1212
import io.craftgate.response.BnplPaymentOfferResponse;
13+
import io.craftgate.response.BnplPaymentVerifyResponse;
1314
import io.craftgate.response.InitBnplPaymentResponse;
15+
import io.craftgate.response.PaymentResponse;
1416
import io.craftgate.response.dto.BnplBankOffer;
1517
import org.junit.jupiter.api.Test;
1618

@@ -153,10 +155,17 @@ void init_tom_finance_bnpl_payment() {
153155
assertNotNull(response.getRedirectUrl());
154156
}
155157

156-
157158
@Test
158159
void approve_bnpl_payment() {
159160
Long paymentId = 1L;
160-
craftgate.payment().approveBnplPayment(paymentId);
161+
PaymentResponse response = craftgate.payment().approveBnplPayment(paymentId);
162+
assertNotNull(response.getId());
163+
}
164+
165+
@Test
166+
void verify_bnpl_payment() {
167+
Long paymentId = 1L;
168+
BnplPaymentVerifyResponse response = craftgate.payment().verifyBnplPayment(paymentId);
169+
assertNotNull(response.getPaymentStatus());
161170
}
162171
}

0 commit comments

Comments
 (0)