From 477feee8c3ec65c975fd3fed694e119c6831aef4 Mon Sep 17 00:00:00 2001 From: akswaminathan-pp-dev Date: Thu, 1 Dec 2022 11:27:00 +0530 Subject: [PATCH 1/4] DTPAYETWO-759- Added field accountId for Paypal Accounts --- .../hyperwallet/clientsdk/Hyperwallet.java | 4 +- .../model/HyperwalletPayPalAccount.java | 22 +++++ .../hyperwallet/clientsdk/HyperwalletIT.java | 87 +++++++++++++++++++ .../clientsdk/HyperwalletTest.java | 42 ++++++++- ...eatePayPalAccountWithAccountId-request.txt | 11 +++ ...tePayPalAccountWithAccountId-response.json | 17 ++++ .../createVenmoAccountWithEmail-request.txt | 10 +++ .../createVenmoAccountWithEmail-response.json | 17 ++++ 8 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/integration/createPayPalAccountWithAccountId-request.txt create mode 100644 src/test/resources/integration/createPayPalAccountWithAccountId-response.json create mode 100644 src/test/resources/integration/createVenmoAccountWithEmail-request.txt create mode 100644 src/test/resources/integration/createVenmoAccountWithEmail-response.json diff --git a/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java b/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java index ae9cf26ed..08d72bbc9 100644 --- a/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java +++ b/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java @@ -1527,8 +1527,8 @@ public HyperwalletPayPalAccount createPayPalAccount(HyperwalletPayPalAccount pay if (StringUtils.isEmpty(payPalAccount.getTransferMethodCurrency())) { throw new HyperwalletException("Transfer Method Currency is required"); } - if (StringUtils.isEmpty(payPalAccount.getEmail())) { - throw new HyperwalletException("Email is required"); + if (StringUtils.isEmpty(payPalAccount.getEmail()) && StringUtils.isEmpty(payPalAccount.getAccountId())) { + throw new HyperwalletException("Email/AccountId is required"); } if (!StringUtils.isEmpty(payPalAccount.getToken())) { throw new HyperwalletException("PayPal Account token may not be present"); diff --git a/src/main/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccount.java b/src/main/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccount.java index 52bf5cfd3..9801229a5 100644 --- a/src/main/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccount.java +++ b/src/main/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccount.java @@ -27,6 +27,7 @@ public enum Type {PAYPAL_ACCOUNT} private Boolean isDefaultTransferMethod; private String email; private String userToken; + private String accountId; private List links; public String getToken() { @@ -197,6 +198,27 @@ public HyperwalletPayPalAccount clearEmail() { return this; } + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + addField("accountId", accountId); + this.accountId = accountId; + } + + public HyperwalletPayPalAccount accountId(String accountId) { + addField("accountId", accountId); + this.accountId = accountId; + return this; + } + + public HyperwalletPayPalAccount clearAccountId() { + clearField("accountId"); + this.accountId = null; + return this; + } + public String getUserToken() { return userToken; } diff --git a/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java b/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java index d76b67cb9..e1b2ab475 100644 --- a/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java +++ b/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java @@ -3323,6 +3323,93 @@ public void testCreateAuthenticationToken() throws Exception { ".eyJzdWIiOiJ1c3ItMmQyZGNlYWMtNDlmNi00YWQwLTk0N2YtMTIwOTIzNzhhMmQyIiwiaWF0IjoxNTQ0ODI5ODA2LCJleHAiOjE1NDQ4MzA0MDYsImF1ZCI6InBndS03YTEyMzJlOC0xNDc5LTQzNzAtOWY1NC03ODc1ZjdiMTg2NmMiLCJpc3MiOiJwcmctY2NhODAyNWUtODVhMy0xMWU2LTg2MGEtNThhZDVlY2NlNjFkIiwicmVzdC11cmkiOiJodHRwczovL3FhbWFzdGVyLWh5cGVyd2FsbGV0LmF3cy5wYXlsdXRpb24ubmV0L3Jlc3QvdjMvIiwiZ3JhcGhxbC11cmkiOiJodHRwczovL3FhbWFzdGVyLWh5cGVyd2FsbGV0LmF3cy5wYXlsdXRpb24ubmV0L2dyYXBocWwifQ.pGOdbYermGhiON5IFKSnXZd6Zj hktMd3WEDOMplYyAeiqVeZGck04eVpsBaXEqYp78NJIs7J5kMX-rPgFYxHpw"))); } + @Test + public void createPayPalAccountWithAccountId() throws Exception { + String functionality = "createPayPalAccountWithAccountId"; + initMockServer(functionality); + + HyperwalletPayPalAccount payPalAccount = new HyperwalletPayPalAccount() + .userToken("usr-e7b61829-a73a-45dc-930e-afa8a56b924c") + .transferMethodCountry("US") + .transferMethodCurrency("USD") + .type(HyperwalletPayPalAccount.Type.PAYPAL_ACCOUNT) + .accountId("K8QRQHMYWETL9"); + + HyperwalletPayPalAccount returnValue; + try { + returnValue = client.createPayPalAccount(payPalAccount); + } catch (Exception e) { + mockServer.verify(parseRequest(functionality)); + throw e; + } + List hyperwalletLinks = new ArrayList<>(); + HyperwalletLink hyperwalletLink = new HyperwalletLink(); + hyperwalletLink.setHref( + "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-e7b61829-a73a-45dc-930e-afa8a56b924c/paypal-accounts/trm-54b0db9c-5565-47f7" + + "-aee6-685e713595f4"); + Map mapParams = new HashMap<>(); + mapParams.put("rel", "self"); + hyperwalletLink.setParams(mapParams); + hyperwalletLinks.add(hyperwalletLink); + + assertThat(returnValue.getToken(), is(equalTo("trm-54b0db9c-5565-47f7-aee6-afa8a56b924c"))); + assertThat(returnValue.getStatus(), is(equalTo(HyperwalletPayPalAccount.Status.ACTIVATED))); + assertThat(returnValue.getType(), is(equalTo(HyperwalletPayPalAccount.Type.PAYPAL_ACCOUNT))); + assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2022-11-11T00:00:00 UTC")))); + assertThat(returnValue.getTransferMethodCountry(), is(equalTo("US"))); + assertThat(returnValue.getTransferMethodCurrency(), is(equalTo("USD"))); + assertThat(returnValue.getAccountId(), is(equalTo("K8QRQHMYWETL9"))); + if (returnValue.getLinks() != null) { + HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0); + HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0); + assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref()))); + assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams()); + } + } + + @Test + public void createVenmoAccountWithEmail() throws Exception { + String functionality = "createVenmoAccountWithEmail"; + initMockServer(functionality); + + HyperwalletVenmoAccount venmoAccount = new HyperwalletVenmoAccount() + .userToken("usr-c4292f1a-866f-4310-a289-b916853939ef") + .transferMethodCountry("US") + .transferMethodCurrency("USD") + .type(HyperwalletVenmoAccount.Type.VENMO_ACCOUNT) + .accountId("user@domain.com"); + + HyperwalletVenmoAccount returnValue; + try { + returnValue = client.createVenmoAccount(venmoAccount); + } catch (Exception e) { + mockServer.verify(parseRequest(functionality)); + throw e; + } + List hyperwalletLinks = new ArrayList<>(); + HyperwalletLink hyperwalletLink = new HyperwalletLink(); + hyperwalletLink.setHref( + "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939ef/venmo-accounts/trm-ac5727ac-8fe7-42fb" + + "-b69d-977ebdd7b49c"); + Map mapParams = new HashMap<>(); + mapParams.put("rel", "self"); + hyperwalletLink.setParams(mapParams); + hyperwalletLinks.add(hyperwalletLink); + assertThat(returnValue.getToken(), is(equalTo("trm-ac5727ac-8fe7-42fb-b69d-977ebdd7b49c"))); + assertThat(returnValue.getStatus(), is(equalTo(HyperwalletVenmoAccount.Status.ACTIVATED))); + assertThat(returnValue.getType(), is(equalTo(HyperwalletVenmoAccount.Type.VENMO_ACCOUNT))); + assertThat(returnValue.getCreatedOn(), is(equalTo(dateFormat.parse("2022-11-11T22:50:14 UTC")))); + assertThat(returnValue.getTransferMethodCountry(), is(equalTo("US"))); + assertThat(returnValue.getTransferMethodCurrency(), is(equalTo("USD"))); + assertThat(returnValue.getAccountId(), is(equalTo("user@domain.com"))); + if (returnValue.getLinks() != null) { + HyperwalletLink actualHyperwalletLink = returnValue.getLinks().get(0); + HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0); + assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref()))); + assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams()); + } + } + private void initMockServerWithErrorResponse(String functionality) throws IOException { mockServer.reset(); diff --git a/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java b/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java index e3551de33..c58c699a6 100644 --- a/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java +++ b/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java @@ -3656,8 +3656,8 @@ public void testCreatePayPalAccount_noEmail() { } catch (HyperwalletException e) { assertThat(e.getErrorCode(), is(nullValue())); assertThat(e.getResponse(), is(nullValue())); - assertThat(e.getErrorMessage(), is(equalTo("Email is required"))); - assertThat(e.getMessage(), is(equalTo("Email is required"))); + assertThat(e.getErrorMessage(), is(equalTo("Email/AccountId is required"))); + assertThat(e.getMessage(), is(equalTo("Email/AccountId is required"))); assertThat(e.getHyperwalletErrors(), is(nullValue())); assertThat(e.getRelatedResources(), is(nullValue())); } @@ -8866,4 +8866,42 @@ public void testListTransferRefunds_noTransferToken() { } } + @Test + public void createPayPalAccountWithAccountId() throws Exception { + HyperwalletPayPalAccount payPalAccount = new HyperwalletPayPalAccount(); + payPalAccount.setUserToken("test-user-token"); + payPalAccount.setTransferMethodCountry("test-transfer-method-country"); + payPalAccount.setTransferMethodCurrency("test-transfer-method-currency"); + payPalAccount.setAccountId("test-accountId"); + payPalAccount.setStatus(HyperwalletPayPalAccount.Status.ACTIVATED); + payPalAccount.setCreatedOn(new Date()); + + HyperwalletPayPalAccount payPalAccountResponse = new HyperwalletPayPalAccount(); + + Hyperwallet client = new Hyperwallet("test-username", "test-password"); + HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client); + + Mockito.when(mockApiClient.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyObject(), ArgumentMatchers.any(Class.class))) + .thenReturn(payPalAccountResponse); + + HyperwalletPayPalAccount resp = client.createPayPalAccount(payPalAccount); + assertThat(resp, is(equalTo(payPalAccountResponse))); + + ArgumentCaptor argument = ArgumentCaptor.forClass(HyperwalletPayPalAccount.class); + Mockito.verify(mockApiClient) + .post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/paypal-accounts"), argument.capture(), + ArgumentMatchers.eq(payPalAccount.getClass())); + + HyperwalletPayPalAccount apiPayPalAccount = argument.getValue(); + assertThat(apiPayPalAccount, is(notNullValue())); + assertThat(apiPayPalAccount.getUserToken(), is(equalTo("test-user-token"))); + assertThat(apiPayPalAccount.getTransferMethodCountry(), is(equalTo("test-transfer-method-country"))); + assertThat(apiPayPalAccount.getTransferMethodCurrency(), is(equalTo("test-transfer-method-currency"))); + assertThat(apiPayPalAccount.getAccountId(), is(equalTo("test-accountId"))); + assertThat(apiPayPalAccount.getStatus(), is(nullValue())); + assertThat(apiPayPalAccount.getCreatedOn(), is(nullValue())); + assertThat(apiPayPalAccount.getType(), is(HyperwalletPayPalAccount.Type.PAYPAL_ACCOUNT)); + } + + } diff --git a/src/test/resources/integration/createPayPalAccountWithAccountId-request.txt b/src/test/resources/integration/createPayPalAccountWithAccountId-request.txt new file mode 100644 index 000000000..2cec54ff5 --- /dev/null +++ b/src/test/resources/integration/createPayPalAccountWithAccountId-request.txt @@ -0,0 +1,11 @@ +curl -X "POST" "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-e7b61829-a73a-45dc-930e-afa8a56b924c/paypal-accounts" \ +-u testuser@12345678:myAccPassw0rd \ +-H "Content-Type: application/json" \ +-H "Accept: application/json" \ +-d "{ + "type": "PAYPAL_ACCOUNT", + "transferMethodCountry": "US", + "transferMethodCurrency": "USD", + "accountId": "K8QRQHMYWETL9", + "userToken": "usr-e7b61829-a73a-45dc-930e-afa8a56b924c" +}" diff --git a/src/test/resources/integration/createPayPalAccountWithAccountId-response.json b/src/test/resources/integration/createPayPalAccountWithAccountId-response.json new file mode 100644 index 000000000..c06370c8e --- /dev/null +++ b/src/test/resources/integration/createPayPalAccountWithAccountId-response.json @@ -0,0 +1,17 @@ +{ + "token": "trm-54b0db9c-5565-47f7-aee6-afa8a56b924c", + "type": "PAYPAL_ACCOUNT", + "status": "ACTIVATED", + "createdOn": "2022-11-11T00:00:00", + "transferMethodCountry": "US", + "transferMethodCurrency": "USD", + "accountId": "K8QRQHMYWETL9", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-e7b61829-a73a-45dc-930e-afa8a56b924c/paypal-accounts/trm-54b0db9c-5565-47f7-aee6-685e713595f4" + } + ] +} diff --git a/src/test/resources/integration/createVenmoAccountWithEmail-request.txt b/src/test/resources/integration/createVenmoAccountWithEmail-request.txt new file mode 100644 index 000000000..5ae0a8d62 --- /dev/null +++ b/src/test/resources/integration/createVenmoAccountWithEmail-request.txt @@ -0,0 +1,10 @@ +curl -X "POST" "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939ef/venmo-accounts" \ +-u testuser@12345678:myAccPassw0rd \ +-H "Content-Type: application/json" \ +-H "Accept: application/json" \ +-d "{ + "type": "VENMO_ACCOUNT", + "transferMethodCountry": "US", + "transferMethodCurrency": "USD", + "accountId": "user@domain.com" +}" diff --git a/src/test/resources/integration/createVenmoAccountWithEmail-response.json b/src/test/resources/integration/createVenmoAccountWithEmail-response.json new file mode 100644 index 000000000..aa4ac8b13 --- /dev/null +++ b/src/test/resources/integration/createVenmoAccountWithEmail-response.json @@ -0,0 +1,17 @@ +{ + "token": "trm-ac5727ac-8fe7-42fb-b69d-977ebdd7b49c", + "type": "VENMO_ACCOUNT", + "status": "ACTIVATED", + "createdOn": "2022-11-11T22:50:14", + "transferMethodCountry": "US", + "transferMethodCurrency": "USD", + "accountId": "user@domain.com", + "links": [ + { + "params": { + "rel": "self" + }, + "href": "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-c4292f1a-866f-4310-a289-b916853939ef/venmo-accounts/trm-ac5727ac-8fe7-42fb-b69d-977ebdd7b49c" + } + ] +} From 688a305c5b7e8d3718dc5fb1c3b8033424f9fabe Mon Sep 17 00:00:00 2001 From: akswaminathan-pp-dev Date: Thu, 1 Dec 2022 11:51:19 +0530 Subject: [PATCH 2/4] DTPAYETWO-759- Updated error message when accountId or email is missing for paypal accounts --- CHANGELOG.md | 5 +++++ src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java | 2 +- src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4135723..bf1479c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ Changelog ========= +2.4.4 +------------------- +- Added field 'accountId' to PayPal. +- PayPal account creation allowed using field 'accountId' which accepts Email, Phone Number, PayPal PayerID. +- Venmo account creation allowed using field 'accountId' which accepts Email, Phone Number, Venmo Handle, Venmo External ID. 2.4.3 ----------------- diff --git a/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java b/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java index 08d72bbc9..01ee08011 100644 --- a/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java +++ b/src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java @@ -1528,7 +1528,7 @@ public HyperwalletPayPalAccount createPayPalAccount(HyperwalletPayPalAccount pay throw new HyperwalletException("Transfer Method Currency is required"); } if (StringUtils.isEmpty(payPalAccount.getEmail()) && StringUtils.isEmpty(payPalAccount.getAccountId())) { - throw new HyperwalletException("Email/AccountId is required"); + throw new HyperwalletException("Email or AccountId is required"); } if (!StringUtils.isEmpty(payPalAccount.getToken())) { throw new HyperwalletException("PayPal Account token may not be present"); diff --git a/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java b/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java index c58c699a6..5e4b8ec5e 100644 --- a/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java +++ b/src/test/java/com/hyperwallet/clientsdk/HyperwalletTest.java @@ -3656,8 +3656,8 @@ public void testCreatePayPalAccount_noEmail() { } catch (HyperwalletException e) { assertThat(e.getErrorCode(), is(nullValue())); assertThat(e.getResponse(), is(nullValue())); - assertThat(e.getErrorMessage(), is(equalTo("Email/AccountId is required"))); - assertThat(e.getMessage(), is(equalTo("Email/AccountId is required"))); + assertThat(e.getErrorMessage(), is(equalTo("Email or AccountId is required"))); + assertThat(e.getMessage(), is(equalTo("Email or AccountId is required"))); assertThat(e.getHyperwalletErrors(), is(nullValue())); assertThat(e.getRelatedResources(), is(nullValue())); } From e0c31eac810db2587d4bb3d02c3984447873ed9e Mon Sep 17 00:00:00 2001 From: akswaminathan-pp-dev Date: Mon, 7 Aug 2023 08:56:07 +0530 Subject: [PATCH 3/4] DTPAYETWO-759- Resolving merge issues --- .../hyperwallet/clientsdk/HyperwalletIT.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java b/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java index b51ca0532..d0e7a3a4c 100644 --- a/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java +++ b/src/test/java/com/hyperwallet/clientsdk/HyperwalletIT.java @@ -3377,8 +3377,41 @@ public void testGetPayPalAccountDefaultTransfer() throws Exception { String functionality = "getPayPalAccountDefaultTransfer"; initMockServer(functionality); + HyperwalletPayPalAccount paypalAccount; + try { + paypalAccount = client.getPayPalAccount("usr-e7b61829-a73a-45dc-930e-afa8a56b923c", "trm-54b0db9c-5565-47f7-aee6-685e713595f4"); + } catch (Exception e) { + mockServer.verify(parseRequest(functionality)); + throw e; + } + List hyperwalletLinks = new ArrayList<>(); + HyperwalletLink hyperwalletLink = new HyperwalletLink(); + hyperwalletLink.setHref( + "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-e7b61829-a73a-45dc-930e-afa8a56b923c/paypal-accounts/trm-54b0db9c-5565-47f7" + + "-aee6-685e713595f4"); + Map mapParams = new HashMap<>(); + mapParams.put("rel", "self"); + hyperwalletLink.setParams(mapParams); + hyperwalletLinks.add(hyperwalletLink); + + assertThat(paypalAccount.getToken(), is(equalTo("trm-54b0db9c-5565-47f7-aee6-685e713595f4"))); + assertThat(paypalAccount.getStatus(), is(equalTo(HyperwalletPayPalAccount.Status.ACTIVATED))); + assertThat(paypalAccount.getType(), is(equalTo(HyperwalletPayPalAccount.Type.PAYPAL_ACCOUNT))); + assertThat(paypalAccount.getCreatedOn(), is(equalTo(dateFormat.parse("2022-05-01T00:00:00 UTC")))); + assertThat(paypalAccount.getTransferMethodCountry(), is(equalTo("US"))); + assertThat(paypalAccount.getTransferMethodCurrency(), is(equalTo("USD"))); + assertThat(paypalAccount.getEmail(), is(equalTo("user@domain.com"))); + assertThat(paypalAccount.getIsDefaultTransferMethod(), is(equalTo(Boolean.TRUE))); + if (paypalAccount.getLinks() != null) { + HyperwalletLink actualHyperwalletLink = paypalAccount.getLinks().get(0); + HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0); + assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref()))); + assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams()); + } + } + @Test - public void createPayPalAccountWithAccountId() throws Exception { + public void testCreatePayPalAccountWithAccountId() throws Exception { String functionality = "createPayPalAccountWithAccountId"; initMockServer(functionality); @@ -3422,7 +3455,7 @@ public void createPayPalAccountWithAccountId() throws Exception { } @Test - public void createVenmoAccountWithEmail() throws Exception { + public void testCreateVenmoAccountWithEmail() throws Exception { String functionality = "createVenmoAccountWithEmail"; initMockServer(functionality); @@ -3464,39 +3497,6 @@ public void createVenmoAccountWithEmail() throws Exception { } } - HyperwalletPayPalAccount paypalAccount; - try { - paypalAccount = client.getPayPalAccount("usr-e7b61829-a73a-45dc-930e-afa8a56b923c", "trm-54b0db9c-5565-47f7-aee6-685e713595f4"); - } catch (Exception e) { - mockServer.verify(parseRequest(functionality)); - throw e; - } - List hyperwalletLinks = new ArrayList<>(); - HyperwalletLink hyperwalletLink = new HyperwalletLink(); - hyperwalletLink.setHref( - "https://api.sandbox.hyperwallet.com/rest/v4/users/usr-e7b61829-a73a-45dc-930e-afa8a56b923c/paypal-accounts/trm-54b0db9c-5565-47f7" - + "-aee6-685e713595f4"); - Map mapParams = new HashMap<>(); - mapParams.put("rel", "self"); - hyperwalletLink.setParams(mapParams); - hyperwalletLinks.add(hyperwalletLink); - - assertThat(paypalAccount.getToken(), is(equalTo("trm-54b0db9c-5565-47f7-aee6-685e713595f4"))); - assertThat(paypalAccount.getStatus(), is(equalTo(HyperwalletPayPalAccount.Status.ACTIVATED))); - assertThat(paypalAccount.getType(), is(equalTo(HyperwalletPayPalAccount.Type.PAYPAL_ACCOUNT))); - assertThat(paypalAccount.getCreatedOn(), is(equalTo(dateFormat.parse("2022-05-01T00:00:00 UTC")))); - assertThat(paypalAccount.getTransferMethodCountry(), is(equalTo("US"))); - assertThat(paypalAccount.getTransferMethodCurrency(), is(equalTo("USD"))); - assertThat(paypalAccount.getEmail(), is(equalTo("user@domain.com"))); - assertThat(paypalAccount.getIsDefaultTransferMethod(), is(equalTo(Boolean.TRUE))); - if (paypalAccount.getLinks() != null) { - HyperwalletLink actualHyperwalletLink = paypalAccount.getLinks().get(0); - HyperwalletLink expectedHyperwalletLink = hyperwalletLinks.get(0); - assertThat(actualHyperwalletLink.getHref(), is(equalTo(expectedHyperwalletLink.getHref()))); - assertEquals(actualHyperwalletLink.getParams(), expectedHyperwalletLink.getParams()); - } - } - private void initMockServerWithErrorResponse(String functionality) throws IOException { mockServer.reset(); mockServer From 71023b6bd7a5dae4e1b815f87acf4bac445542fe Mon Sep 17 00:00:00 2001 From: akswaminathan-pp-dev Date: Mon, 7 Aug 2023 10:19:28 +0530 Subject: [PATCH 4/4] DTPAYETWO-759- Adding accountId to fix test failures --- .../clientsdk/model/HyperwalletPayPalAccountTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccountTest.java b/src/test/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccountTest.java index a7101bd46..dab91bac6 100644 --- a/src/test/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccountTest.java +++ b/src/test/java/com/hyperwallet/clientsdk/model/HyperwalletPayPalAccountTest.java @@ -20,6 +20,7 @@ protected HyperwalletPayPalAccount createBaseModel() { .transferMethodCurrency("test-transfer-method-currency") .isDefaultTransferMethod(Boolean.FALSE) .email("test-user-email") + .accountId("test-user-accountId") .links(hyperwalletLinkList) .userToken("test-user-token"); return payPalAccount;