From 0def5f217bb18c2713c21d90faac1ed80f602a8f Mon Sep 17 00:00:00 2001 From: semihshn Date: Wed, 5 Jun 2024 13:12:20 +0300 Subject: [PATCH 1/2] Add retrieve migrated card method --- .../io/craftgate/adapter/PaymentAdapter.java | 6 +++++ .../request/RetrieveProviderCardRequest.java | 14 ++++++++++++ .../io/craftgate/response/CardResponse.java | 22 +++++++++++++++++++ .../io/craftgate/sample/PaymentSample.java | 14 ++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 src/main/java/io/craftgate/request/RetrieveProviderCardRequest.java create mode 100644 src/main/java/io/craftgate/response/CardResponse.java diff --git a/src/main/java/io/craftgate/adapter/PaymentAdapter.java b/src/main/java/io/craftgate/adapter/PaymentAdapter.java index 2ffd9bdd..ffb549dc 100644 --- a/src/main/java/io/craftgate/adapter/PaymentAdapter.java +++ b/src/main/java/io/craftgate/adapter/PaymentAdapter.java @@ -235,6 +235,12 @@ public MultiPaymentResponse retrieveMultiPayment(String token) { return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), MultiPaymentResponse.class); } + public CardResponse retrieveProviderCard(RetrieveProviderCardRequest retrieveProviderCardRequest) { + String query = RequestQueryParamsBuilder.buildQueryParam(retrieveProviderCardRequest); + String path = "/payment/v1/cards/provider-card-mappings" + query; + return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), CardResponse.class); + } + public boolean is3DSecureCallbackVerified(String threeDSecureCallbackKey, Map params) { String hash = params.get("hash"); String hashString = threeDSecureCallbackKey + diff --git a/src/main/java/io/craftgate/request/RetrieveProviderCardRequest.java b/src/main/java/io/craftgate/request/RetrieveProviderCardRequest.java new file mode 100644 index 00000000..96a4cf6c --- /dev/null +++ b/src/main/java/io/craftgate/request/RetrieveProviderCardRequest.java @@ -0,0 +1,14 @@ +package io.craftgate.request; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class RetrieveProviderCardRequest { + + private String providerCardToken; + private String externalId; + private String providerCardUserId; + +} diff --git a/src/main/java/io/craftgate/response/CardResponse.java b/src/main/java/io/craftgate/response/CardResponse.java new file mode 100644 index 00000000..3dd35360 --- /dev/null +++ b/src/main/java/io/craftgate/response/CardResponse.java @@ -0,0 +1,22 @@ +package io.craftgate.response; + +import io.craftgate.model.CardAssociation; +import io.craftgate.model.CardExpiryStatus; +import io.craftgate.model.CardType; +import lombok.Data; + +@Data +public class CardResponse { + + private String binNumber; + private String lastFourDigits; + private String cardUserKey; + private String cardToken; + private String cardAlias; + private CardType cardType; + private CardAssociation cardAssociation; + private String cardBrand; + private String cardBankName; + private Long cardBankId; + private CardExpiryStatus cardExpiryStatus; +} diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index dc184637..405365ed 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -1764,6 +1764,20 @@ void retrieve_multi_payment() { assertNotNull(response); } + @Test + void retrieve_provider_card() { + + RetrieveProviderCardRequest retrieveProviderCardRequest = RetrieveProviderCardRequest.builder() + .providerCardToken("45f12c74-3000-465c-96dc-876850e7dd7a") + .providerCardUserId("0309ac2d-c5a5-4b4f-a91f-5c444ba07b24") + .externalId("1001") + .build(); + + CardResponse response = craftgate.payment().retrieveProviderCard(retrieveProviderCardRequest); + + assertNotNull(response); + } + @Test void should_validate_3D_secure_callback_verified() { //given From 08d196ab892a77d125d31e1c68800844bc491df3 Mon Sep 17 00:00:00 2001 From: semihshn Date: Wed, 5 Jun 2024 16:38:08 +0300 Subject: [PATCH 2/2] Update --- .../io/craftgate/adapter/PaymentAdapter.java | 4 ++-- .../io/craftgate/response/CardResponse.java | 22 ------------------- .../io/craftgate/sample/PaymentSample.java | 2 +- 3 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 src/main/java/io/craftgate/response/CardResponse.java diff --git a/src/main/java/io/craftgate/adapter/PaymentAdapter.java b/src/main/java/io/craftgate/adapter/PaymentAdapter.java index ffb549dc..0cc2260c 100644 --- a/src/main/java/io/craftgate/adapter/PaymentAdapter.java +++ b/src/main/java/io/craftgate/adapter/PaymentAdapter.java @@ -235,10 +235,10 @@ public MultiPaymentResponse retrieveMultiPayment(String token) { return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), MultiPaymentResponse.class); } - public CardResponse retrieveProviderCard(RetrieveProviderCardRequest retrieveProviderCardRequest) { + public StoredCardResponse retrieveProviderCard(RetrieveProviderCardRequest retrieveProviderCardRequest) { String query = RequestQueryParamsBuilder.buildQueryParam(retrieveProviderCardRequest); String path = "/payment/v1/cards/provider-card-mappings" + query; - return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), CardResponse.class); + return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), StoredCardResponse.class); } public boolean is3DSecureCallbackVerified(String threeDSecureCallbackKey, Map params) { diff --git a/src/main/java/io/craftgate/response/CardResponse.java b/src/main/java/io/craftgate/response/CardResponse.java deleted file mode 100644 index 3dd35360..00000000 --- a/src/main/java/io/craftgate/response/CardResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.craftgate.response; - -import io.craftgate.model.CardAssociation; -import io.craftgate.model.CardExpiryStatus; -import io.craftgate.model.CardType; -import lombok.Data; - -@Data -public class CardResponse { - - private String binNumber; - private String lastFourDigits; - private String cardUserKey; - private String cardToken; - private String cardAlias; - private CardType cardType; - private CardAssociation cardAssociation; - private String cardBrand; - private String cardBankName; - private Long cardBankId; - private CardExpiryStatus cardExpiryStatus; -} diff --git a/src/test/java/io/craftgate/sample/PaymentSample.java b/src/test/java/io/craftgate/sample/PaymentSample.java index 405365ed..b6abd110 100644 --- a/src/test/java/io/craftgate/sample/PaymentSample.java +++ b/src/test/java/io/craftgate/sample/PaymentSample.java @@ -1773,7 +1773,7 @@ void retrieve_provider_card() { .externalId("1001") .build(); - CardResponse response = craftgate.payment().retrieveProviderCard(retrieveProviderCardRequest); + StoredCardResponse response = craftgate.payment().retrieveProviderCard(retrieveProviderCardRequest); assertNotNull(response); }