Skip to content

Commit f4da864

Browse files
committed
Added PayPalAccounts endpoint
1 parent 8076823 commit f4da864

13 files changed

+757
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
0.3.0 (in progress)
55
-------------------
66

7+
- Added PayPal endpoint
78
- Added Transfer endpoint
89
- Added Payment Status Transitions endpoint
910
- Added Update Prepaid Card endpoint

src/main/java/com/hyperwallet/clientsdk/Hyperwallet.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,87 @@ public HyperwalletStatusTransition createTransferStatusTransition(String transfe
904904
return apiClient.post(url + "/transfers/" + transferToken + "/status-transitions", transition, HyperwalletStatusTransition.class);
905905
}
906906

907+
//--------------------------------------
908+
// PayPal Accounts
909+
//--------------------------------------
910+
911+
/**
912+
* Create PayPal Account Request
913+
*
914+
* @param payPalAccount HyperwalletPayPalAccount object to create
915+
* @return HyperwalletPayPalAccount created PayPal account for the specified user
916+
*/
917+
public HyperwalletPayPalAccount createPayPalAccount(HyperwalletPayPalAccount payPalAccount) {
918+
if (payPalAccount == null) {
919+
throw new HyperwalletException("PayPal Account is required");
920+
}
921+
if (StringUtils.isEmpty(payPalAccount.getUserToken())) {
922+
throw new HyperwalletException("User token is required");
923+
}
924+
if (StringUtils.isEmpty(payPalAccount.getTransferMethodCountry())) {
925+
throw new HyperwalletException("Transfer Method Country is required");
926+
}
927+
if (StringUtils.isEmpty(payPalAccount.getTransferMethodCurrency())) {
928+
throw new HyperwalletException("Transfer Method Currency is required");
929+
}
930+
if (StringUtils.isEmpty(payPalAccount.getEmail())) {
931+
throw new HyperwalletException("Email is required");
932+
}
933+
if (!StringUtils.isEmpty(payPalAccount.getToken())) {
934+
throw new HyperwalletException("PayPal Account token may not be present");
935+
}
936+
if (payPalAccount.getType() == null) {
937+
payPalAccount.setType(HyperwalletTransferMethod.Type.PAYPAL_ACCOUNT);
938+
}
939+
payPalAccount = copy(payPalAccount);
940+
payPalAccount.setStatus(null);
941+
payPalAccount.setCreatedOn(null);
942+
return apiClient.post(url + "/users/" + payPalAccount.getUserToken() + "/paypal-accounts", payPalAccount, HyperwalletPayPalAccount.class);
943+
}
944+
945+
/**
946+
* Get PayPal Account Request
947+
*
948+
* @param userToken User token assigned
949+
* @param payPalAccountToken PayPal Account token assigned
950+
* @return HyperwalletPayPalAccount PayPal Account
951+
*/
952+
public HyperwalletPayPalAccount getPayPalAccount(String userToken, String payPalAccountToken) {
953+
if (StringUtils.isEmpty(userToken)) {
954+
throw new HyperwalletException("User token is required");
955+
}
956+
if (StringUtils.isEmpty(payPalAccountToken)) {
957+
throw new HyperwalletException("PayPal Account token is required");
958+
}
959+
return apiClient.get(url + "/users/" + userToken + "/paypal-accounts/" + payPalAccountToken, HyperwalletPayPalAccount.class);
960+
}
961+
962+
/**
963+
* List PayPal Accounts
964+
*
965+
* @param userToken User token assigned
966+
* @param options List filter option
967+
* @return HyperwalletList of HyperwalletPayPalAccount
968+
*/
969+
public HyperwalletList<HyperwalletPayPalAccount> listPayPalAccounts(String userToken, HyperwalletPaginationOptions options) {
970+
if (StringUtils.isEmpty(userToken)) {
971+
throw new HyperwalletException("User token is required");
972+
}
973+
String url = paginate(this.url + "/users/" + userToken + "/paypal-accounts", options);
974+
return apiClient.get(url, new TypeReference<HyperwalletList<HyperwalletPayPalAccount>>() {
975+
});
976+
}
977+
978+
/**
979+
* List PayPal Accounts
980+
*
981+
* @param userToken User token assigned
982+
* @return HyperwalletList of HyperwalletPayPalAccount
983+
*/
984+
public HyperwalletList<HyperwalletPayPalAccount> listPayPalAccounts(String userToken) {
985+
return listPayPalAccounts(userToken, null);
986+
}
987+
907988
//--------------------------------------
908989
// Bank Accounts
909990
//--------------------------------------
@@ -1691,4 +1772,9 @@ private HyperwalletTransfer copy(HyperwalletTransfer transfer) {
16911772
return transfer;
16921773
}
16931774

1775+
private HyperwalletPayPalAccount copy(HyperwalletPayPalAccount payPalAccount) {
1776+
payPalAccount = HyperwalletJsonUtil.fromJson(HyperwalletJsonUtil.toJson(payPalAccount), HyperwalletPayPalAccount.class);
1777+
return payPalAccount;
1778+
}
1779+
16941780
}
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
package com.hyperwallet.clientsdk.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonFilter;
4+
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;
5+
6+
import java.util.Date;
7+
8+
import javax.xml.bind.annotation.XmlAccessType;
9+
import javax.xml.bind.annotation.XmlAccessorType;
10+
import javax.xml.bind.annotation.XmlRootElement;
11+
12+
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
13+
@XmlRootElement
14+
@XmlAccessorType(XmlAccessType.FIELD)
15+
public class HyperwalletPayPalAccount extends HyperwalletBaseMonitor {
16+
17+
private String token;
18+
private HyperwalletTransferMethod.Type type;
19+
private HyperwalletTransferMethod.Status status;
20+
private Date createdOn;
21+
private String transferMethodCountry;
22+
private String transferMethodCurrency;
23+
private Boolean isDefaultTransferMethod;
24+
private String email;
25+
private String userToken;
26+
27+
public String getToken() {
28+
return token;
29+
}
30+
31+
public void setToken(String token) {
32+
addField("token", token);
33+
this.token = token;
34+
}
35+
36+
public HyperwalletPayPalAccount token(String token) {
37+
addField("token", token);
38+
this.token = token;
39+
return this;
40+
}
41+
42+
public HyperwalletPayPalAccount clearToken() {
43+
clearField("token");
44+
this.token = null;
45+
return this;
46+
}
47+
48+
public HyperwalletTransferMethod.Type getType() {
49+
return type;
50+
}
51+
52+
public void setType(HyperwalletTransferMethod.Type type) {
53+
addField("type", type);
54+
this.type = type;
55+
}
56+
57+
public HyperwalletPayPalAccount type(HyperwalletTransferMethod.Type type) {
58+
addField("type", type);
59+
this.type = type;
60+
return this;
61+
}
62+
63+
public HyperwalletPayPalAccount clearType() {
64+
clearField("type");
65+
this.type = null;
66+
return this;
67+
}
68+
69+
public HyperwalletTransferMethod.Status getStatus() {
70+
return status;
71+
}
72+
73+
public void setStatus(HyperwalletTransferMethod.Status status) {
74+
addField("status", status);
75+
this.status = status;
76+
}
77+
78+
public HyperwalletPayPalAccount status(HyperwalletTransferMethod.Status status) {
79+
addField("status", status);
80+
this.status = status;
81+
return this;
82+
}
83+
84+
public HyperwalletPayPalAccount clearStatus() {
85+
clearField("status");
86+
this.status = null;
87+
return this;
88+
}
89+
90+
public Date getCreatedOn() {
91+
return createdOn;
92+
}
93+
94+
public void setCreatedOn(Date createdOn) {
95+
addField("createdOn", createdOn);
96+
this.createdOn = createdOn;
97+
}
98+
99+
public HyperwalletPayPalAccount createdOn(Date createdOn) {
100+
addField("createdOn", createdOn);
101+
this.createdOn = createdOn;
102+
return this;
103+
}
104+
105+
public HyperwalletPayPalAccount clearCreatedOn() {
106+
clearField("createdOn");
107+
this.createdOn = null;
108+
return this;
109+
}
110+
111+
public String getTransferMethodCountry() {
112+
return transferMethodCountry;
113+
}
114+
115+
public void setTransferMethodCountry(String transferMethodCountry) {
116+
addField("transferMethodCountry", transferMethodCountry);
117+
this.transferMethodCountry = transferMethodCountry;
118+
}
119+
120+
public HyperwalletPayPalAccount transferMethodCountry(String transferMethodCountry) {
121+
addField("transferMethodCountry", transferMethodCountry);
122+
this.transferMethodCountry = transferMethodCountry;
123+
return this;
124+
}
125+
126+
public HyperwalletPayPalAccount clearTransferMethodCountry() {
127+
clearField("transferMethodCountry");
128+
this.transferMethodCountry = null;
129+
return this;
130+
}
131+
132+
public String getTransferMethodCurrency() {
133+
return transferMethodCurrency;
134+
}
135+
136+
public void setTransferMethodCurrency(String transferMethodCurrency) {
137+
addField("transferMethodCurrency", transferMethodCurrency);
138+
this.transferMethodCurrency = transferMethodCurrency;
139+
}
140+
141+
public HyperwalletPayPalAccount transferMethodCurrency(String transferMethodCurrency) {
142+
addField("transferMethodCurrency", transferMethodCurrency);
143+
this.transferMethodCurrency = transferMethodCurrency;
144+
return this;
145+
}
146+
147+
public HyperwalletPayPalAccount clearTransferMethodCurrency() {
148+
clearField("transferMethodCurrency");
149+
this.transferMethodCurrency = null;
150+
return this;
151+
}
152+
153+
public Boolean getIsDefaultTransferMethod() {
154+
return isDefaultTransferMethod;
155+
}
156+
157+
public void setIsDefaultTransferMethod(Boolean isDefaultTransferMethod) {
158+
addField("isDefaultTransferMethod", isDefaultTransferMethod);
159+
this.isDefaultTransferMethod = isDefaultTransferMethod;
160+
}
161+
162+
public HyperwalletPayPalAccount isDefaultTransferMethod(Boolean isDefaultTransferMethod) {
163+
addField("isDefaultTransferMethod", isDefaultTransferMethod);
164+
this.isDefaultTransferMethod = isDefaultTransferMethod;
165+
return this;
166+
}
167+
168+
public HyperwalletPayPalAccount clearIsDefaultTransferMethod() {
169+
clearField("isDefaultTransferMethod");
170+
this.isDefaultTransferMethod = null;
171+
return this;
172+
}
173+
174+
public String getEmail() {
175+
return email;
176+
}
177+
178+
public void setEmail(String email) {
179+
addField("email", email);
180+
this.email = email;
181+
}
182+
183+
public HyperwalletPayPalAccount email(String email) {
184+
addField("email", email);
185+
this.email = email;
186+
return this;
187+
}
188+
189+
public HyperwalletPayPalAccount clearEmail() {
190+
clearField("email");
191+
this.email = null;
192+
return this;
193+
}
194+
195+
public String getUserToken() {
196+
return userToken;
197+
}
198+
199+
public void setUserToken(String userToken) {
200+
addField("userToken", userToken);
201+
this.userToken = userToken;
202+
}
203+
204+
public HyperwalletPayPalAccount userToken(String userToken) {
205+
addField("userToken", userToken);
206+
this.userToken = userToken;
207+
return this;
208+
}
209+
210+
public HyperwalletPayPalAccount clearUserToken() {
211+
clearField("userToken");
212+
this.userToken = null;
213+
return this;
214+
}
215+
}

src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
@XmlAccessorType(XmlAccessType.FIELD)
1414
public class HyperwalletTransferMethod extends HyperwalletBaseMonitor {
1515

16-
public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK}
16+
public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT}
1717

18-
public enum Status {ACTIVATED, INVALID, DE_ACTIVATED, PRE_ACTIVATED, SUSPENDED, LOST_OR_STOLEN, QUEUED, DECLINED, LOCKED, COMPLIANCE_HOLE, KYC_HOLD}
18+
public enum Status {ACTIVATED, INVALID, DE_ACTIVATED, PRE_ACTIVATED, SUSPENDED, LOST_OR_STOLEN, QUEUED, DECLINED, LOCKED, COMPLIANCE_HOLE, KYC_HOLD, VERIFIED}
1919

2020
public enum BankAccountRelationship {SELF, JOINT_ACCOUNT, SPOUSE, RELATIVE, BUSINESS_PARTNER, UPLINE, DOWNLINE, OTHER, OWN_COMPANY, BILL_PAYMENT}
2121

0 commit comments

Comments
 (0)