Skip to content

Commit ddb4126

Browse files
braintreepsDavid Johnson
andcommitted
3.45.0
Co-authored-by: David Johnson <djohnson14@paypal.com>
1 parent e7df716 commit ddb4126

24 files changed

Lines changed: 1490 additions & 48 deletions

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# Changelog
22

3-
## 3.45.0
4-
3+
## Unreleased
4+
5+
* Add Bank Account Instant Verification functionality
6+
* Add `BankAccountInstantVerificationGateway` for creating JWT tokens
7+
* Add `BankAccountInstantVerificationJwt` response object
8+
* Add `BankAccountInstantVerificationJwtRequest` for JWT creation
9+
* Add `achMandate` and `achMandateAcceptedAt` fields to `TransactionRequest`
10+
* Add `INSTANT_VERIFICATION` method to `UsBankAccountVerification.VerificationMethod`
11+
* Add `isDeviceToken` to `ApplePayCard` and `ApplePayDetails`
512
* Add `achRejectReason` to `Transaction`
613
* Add `rejectReason` to `AchReturnResponse`
714
* Add `sender` and `receiver` to `transfer` in `Transaction`

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.braintreepayments.gateway</groupId>
44
<artifactId>braintree-java</artifactId>
5-
<version>3.45.1-SNAPSHOT</version>
5+
<version>3.45.0-SNAPSHOT</version>
66
<description>Java Client Library for Braintree Payments Gateway</description>
77
<packaging>bundle</packaging>
88
<name>Braintree Gateway Java Client Library</name>
@@ -37,7 +37,7 @@
3737
<developerConnection>
3838
${scmConnection}
3939
</developerConnection>
40-
<tag>3.45.0</tag>
40+
<tag>3.45.0-SNAPSHOT</tag>
4141
</scm>
4242

4343
<developers>

src/main/java/com/braintreegateway/ApplePayCard.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ApplePayCard implements PaymentMethod {
3232
private String healthcare;
3333
private String imageUrl;
3434
private boolean isDefault;
35+
private boolean isDeviceToken;
3536
private String issuingBank;
3637
private String last4;
3738
private String merchantTokenIdentifier;
@@ -66,6 +67,7 @@ public ApplePayCard(NodeWrapper node) {
6667
this.healthcare = node.findString("healthcare");
6768
this.imageUrl = node.findString("image-url");
6869
this.isDefault = node.findBoolean("default");
70+
this.isDeviceToken = node.findBoolean("is-device-token");
6971
this.issuingBank = node.findString("issuing-bank");
7072
this.last4 = node.findString("last-4");
7173
this.merchantTokenIdentifier = node.findString("merchant-token-identifier");
@@ -163,6 +165,10 @@ public String getImageUrl() {
163165
return imageUrl;
164166
}
165167

168+
public boolean getIsDeviceToken(){
169+
return isDeviceToken;
170+
}
171+
166172
public String getIssuingBank() {
167173
return issuingBank;
168174
}

src/main/java/com/braintreegateway/ApplePayDetails.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class ApplePayDetails {
2424
private String globalId;
2525
private String healthcare;
2626
private String imageUrl;
27+
private boolean isDeviceToken;
2728
private String issuingBank;
2829
private String last4;
2930
private String merchantTokenIdentifier;
@@ -53,6 +54,7 @@ public ApplePayDetails(NodeWrapper node) {
5354
globalId = node.findString("global-id");
5455
healthcare = node.findString("healthcare");
5556
imageUrl = node.findString("image-url");
57+
isDeviceToken = node.findBoolean("is-device-token");
5658
issuingBank = node.findString("issuing-bank");
5759
last4 = node.findString("last-4");
5860
merchantTokenIdentifier = node.findString("merchant-token-identifier");
@@ -131,6 +133,10 @@ public String getPayroll() {
131133
return payroll;
132134
}
133135

136+
public boolean getIsDeviceToken(){
137+
return isDeviceToken;
138+
}
139+
134140
public String getIssuingBank() {
135141
return issuingBank;
136142
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.braintreegateway;
2+
3+
import com.braintreegateway.exceptions.ServerException;
4+
import com.braintreegateway.util.GraphQLClient;
5+
import com.braintreegateway.util.Http;
6+
7+
import java.util.Map;
8+
9+
/**
10+
* Provides methods to interact with Bank Account Instant Verification functionality.
11+
*/
12+
public class BankAccountInstantVerificationGateway {
13+
14+
private final GraphQLClient graphQLClient;
15+
16+
private static final String CREATE_JWT_MUTATION =
17+
"mutation CreateBankAccountInstantVerificationJwt($input: CreateBankAccountInstantVerificationJwtInput!) { "
18+
+ "createBankAccountInstantVerificationJwt(input: $input) {"
19+
+ " jwt"
20+
+ " }"
21+
+ "}";
22+
23+
public BankAccountInstantVerificationGateway(BraintreeGateway gateway, Http http, Configuration configuration, GraphQLClient graphQLClient) {
24+
this.graphQLClient = graphQLClient;
25+
}
26+
27+
/**
28+
* Creates a Bank Account Instant Verification JWT for initiating the Open Banking flow.
29+
*
30+
* @param request the JWT creation request containing business name and redirect URLs
31+
* @return a {@link Result} containing the JWT
32+
*/
33+
public Result<BankAccountInstantVerificationJwt> createJwt(BankAccountInstantVerificationJwtRequest request) {
34+
Map<String, Object> response = graphQLClient.query(CREATE_JWT_MUTATION, request);
35+
ValidationErrors errors = GraphQLClient.getErrors(response);
36+
37+
if (errors != null) {
38+
return new Result<>(errors);
39+
}
40+
41+
try {
42+
Map<String, Object> data = (Map<String, Object>) response.get("data");
43+
Map<String, Object> result = (Map<String, Object>) data.get("createBankAccountInstantVerificationJwt");
44+
String jwt = (String) result.get("jwt");
45+
46+
BankAccountInstantVerificationJwt jwtObject = new BankAccountInstantVerificationJwt(jwt);
47+
return new Result<>(jwtObject);
48+
49+
} catch (ClassCastException | NullPointerException e) {
50+
throw new ServerException("Couldn't parse response: " + e.getMessage());
51+
}
52+
}
53+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.braintreegateway;
2+
3+
/**
4+
* Represents a Bank Account Instant Verification JWT.
5+
*/
6+
public class BankAccountInstantVerificationJwt {
7+
private final String jwt;
8+
9+
public BankAccountInstantVerificationJwt(String jwt) {
10+
this.jwt = jwt;
11+
}
12+
13+
/**
14+
* Returns the JWT for Bank Account Instant Verification.
15+
*
16+
* @return the JWT as a string
17+
*/
18+
public String getJwt() {
19+
return jwt;
20+
}
21+
22+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.braintreegateway;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
/**
7+
* Provides a fluent interface to build requests for creating Bank Account Instant Verification JWTs.
8+
*/
9+
public class BankAccountInstantVerificationJwtRequest extends Request {
10+
private String businessName;
11+
private String returnUrl;
12+
private String cancelUrl;
13+
14+
/**
15+
* Sets the officially registered business name for the merchant.
16+
*
17+
* @param businessName the business name
18+
* @return the BankAccountInstantVerificationJwtRequest
19+
*/
20+
public BankAccountInstantVerificationJwtRequest businessName(String businessName) {
21+
this.businessName = businessName;
22+
return this;
23+
}
24+
25+
/**
26+
* Sets the URL to redirect the consumer after successful account selection.
27+
*
28+
* @param returnUrl the return URL
29+
* @return the BankAccountInstantVerificationJwtRequest
30+
*/
31+
public BankAccountInstantVerificationJwtRequest returnUrl(String returnUrl) {
32+
this.returnUrl = returnUrl;
33+
return this;
34+
}
35+
36+
/**
37+
* Sets the URL to redirect the consumer upon cancellation of the Open Banking flow.
38+
*
39+
* @param cancelUrl the cancel URL
40+
* @return the BankAccountInstantVerificationJwtRequest
41+
*/
42+
public BankAccountInstantVerificationJwtRequest cancelUrl(String cancelUrl) {
43+
this.cancelUrl = cancelUrl;
44+
return this;
45+
}
46+
47+
48+
public String getBusinessName() {
49+
return businessName;
50+
}
51+
52+
public String getReturnUrl() {
53+
return returnUrl;
54+
}
55+
56+
public String getCancelUrl() {
57+
return cancelUrl;
58+
}
59+
60+
61+
@Override
62+
public Map<String, Object> toGraphQLVariables() {
63+
Map<String, Object> variables = new HashMap<>();
64+
Map<String, Object> input = new HashMap<>();
65+
66+
if (businessName != null) {
67+
input.put("businessName", businessName);
68+
}
69+
if (returnUrl != null) {
70+
input.put("returnUrl", returnUrl);
71+
}
72+
if (cancelUrl != null) {
73+
input.put("cancelUrl", cancelUrl);
74+
}
75+
76+
variables.put("input", input);
77+
return variables;
78+
}
79+
}

src/main/java/com/braintreegateway/BraintreeGateway.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,14 @@ public ReportGateway report() {
303303
public ExchangeRateQuoteGateway exchangeRateQuote() {
304304
return new ExchangeRateQuoteGateway(http, graphQLClient, configuration);
305305
}
306+
307+
/**
308+
* Returns a {@link BankAccountInstantVerificationGateway} for interacting with
309+
* Bank Account Instant Verification functionality.
310+
*
311+
* @return a {@link BankAccountInstantVerificationGateway}.
312+
*/
313+
public BankAccountInstantVerificationGateway bankAccountInstantVerification() {
314+
return new BankAccountInstantVerificationGateway(this, http, configuration, graphQLClient);
315+
}
306316
}

src/main/java/com/braintreegateway/PaymentMethodRequest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class PaymentMethodRequest extends Request {
2323
private String threeDSecureAuthenticationId;
2424
private String venmoSdkPaymentMethodCode;
2525
private PaymentMethodThreeDSecurePassThruRequest threeDSecurePassThruRequest;
26+
private PaymentMethodUsBankAccountRequest usBankAccountRequest;
2627

2728
public PaymentMethodRequest() {
2829
}
@@ -144,6 +145,11 @@ public PaymentMethodThreeDSecurePassThruRequest threeDSecurePassThruRequest() {
144145
return threeDSecurePassThruRequest;
145146
}
146147

148+
public PaymentMethodUsBankAccountRequest usBankAccount() {
149+
this.usBankAccountRequest = new PaymentMethodUsBankAccountRequest(this);
150+
return usBankAccountRequest;
151+
}
152+
147153
@Override
148154
public String toXML() {
149155
return buildRequest("payment-method").toXML();
@@ -171,7 +177,8 @@ protected RequestBuilder buildRequest(String root) {
171177
.addElement("paymentMethodNonce", paymentMethodNonce)
172178
.addElement("paypalRefreshToken", paypalRefreshToken)
173179
.addElement("threeDSecureAuthenticationId", threeDSecureAuthenticationId)
174-
.addElement("venmoSdkPaymentMethodCode", venmoSdkPaymentMethodCode);
180+
.addElement("venmoSdkPaymentMethodCode", venmoSdkPaymentMethodCode)
181+
.addElement("usBankAccount", usBankAccountRequest);
175182

176183
return builder;
177184
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.braintreegateway;
2+
3+
import java.util.Calendar;
4+
5+
/**
6+
* A request builder for US Bank Account data used in payment method requests.
7+
*/
8+
public class PaymentMethodUsBankAccountRequest extends Request {
9+
private String achMandateText;
10+
private Calendar achMandateAcceptedAt;
11+
private PaymentMethodRequest parent;
12+
13+
public PaymentMethodUsBankAccountRequest(PaymentMethodRequest parent) {
14+
this.parent = parent;
15+
}
16+
17+
/**
18+
* Sets the ACH mandate text for authorization.
19+
*
20+
* @param achMandateText the ACH mandate text
21+
* @return the PaymentMethodUsBankAccountRequest
22+
*/
23+
public PaymentMethodUsBankAccountRequest achMandateText(String achMandateText) {
24+
this.achMandateText = achMandateText;
25+
return this;
26+
}
27+
28+
/**
29+
* Sets the timestamp when the ACH mandate was accepted.
30+
*
31+
* @param achMandateAcceptedAt the timestamp when the mandate was accepted
32+
* @return the PaymentMethodUsBankAccountRequest
33+
*/
34+
public PaymentMethodUsBankAccountRequest achMandateAcceptedAt(Calendar achMandateAcceptedAt) {
35+
this.achMandateAcceptedAt = achMandateAcceptedAt;
36+
return this;
37+
}
38+
39+
/**
40+
* Returns to the parent PaymentMethodRequest.
41+
*
42+
* @return the PaymentMethodRequest
43+
*/
44+
public PaymentMethodRequest done() {
45+
return parent;
46+
}
47+
48+
public String getAchMandateText() {
49+
return achMandateText;
50+
}
51+
52+
public Calendar getAchMandateAcceptedAt() {
53+
return achMandateAcceptedAt;
54+
}
55+
56+
@Override
57+
public String toXML() {
58+
return buildRequest("usBankAccount").toXML();
59+
}
60+
61+
public RequestBuilder buildRequest(String root) {
62+
return new RequestBuilder(root)
63+
.addElement("achMandateText", achMandateText)
64+
.addElement("achMandateAcceptedAt", achMandateAcceptedAt);
65+
}
66+
}

0 commit comments

Comments
 (0)