Skip to content

Commit ba17015

Browse files
committed
deprecated start auth flow request method as opposed to breaking change
1 parent b4020b1 commit ba17015

File tree

3 files changed

+117
-4
lines changed

3 files changed

+117
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/).
77

8-
## [18.0.0] - 2025-x-x
8+
## [17.6.0] - 2025-x-x
99
### Added
10+
* New ProviderSelection builder method on the StartAuthorizationFlowRequest builder
1011
* New Icon object to ProviderSelection in authorization flow requests
1112
* New Consent type properties within the authorization flow request
1213

1314
### Changed
14-
* ⚠️ Breaking: replaced the `withProviderSelection()` flag on authorization flow request builder with a `providerSelection(...)` utility
15+
* ⚠️ Deprecated `withProviderSelection()` flag on authorization flow request builder with a `providerSelection(...)` utility
1516
that helps to set the provider icon object if needed
1617
* Various dependency updates
1718

src/main/java/com/truelayer/java/payments/entities/StartAuthorizationFlowRequest.java

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import lombok.*;
99

1010
@Getter
11-
@Builder
11+
@RequiredArgsConstructor
1212
@ToString
1313
@EqualsAndHashCode
1414
public class StartAuthorizationFlowRequest {
@@ -25,11 +25,84 @@ public class StartAuthorizationFlowRequest {
2525

2626
private final Map<String, String> userAccountSelection;
2727

28+
public static StartAuthorizationFlowRequestBuilder builder() {
29+
return new StartAuthorizationFlowRequestBuilder();
30+
}
31+
32+
public static class StartAuthorizationFlowRequestBuilder {
33+
private boolean withProviderSelection;
34+
35+
private ProviderSelection providerSelection;
36+
37+
private Map<String, String> schemeSelection;
38+
39+
private Redirect redirect;
40+
41+
private Consent consent;
42+
43+
private Form form;
44+
45+
private Map<String, String> userAccountSelection;
46+
47+
/**
48+
* Include an empty provider selection object in the request
49+
* @deprecated use providerSelection(ProviderSelection) instead
50+
* @return the builder object
51+
*/
52+
@Deprecated
53+
public StartAuthorizationFlowRequestBuilder withProviderSelection() {
54+
this.withProviderSelection = true;
55+
return this;
56+
}
57+
58+
public StartAuthorizationFlowRequestBuilder providerSelection(ProviderSelection providerSelection) {
59+
this.providerSelection = providerSelection;
60+
return this;
61+
}
62+
63+
public StartAuthorizationFlowRequestBuilder schemeSelection(Map<String, String> schemeSelection) {
64+
this.schemeSelection = schemeSelection;
65+
return this;
66+
}
67+
68+
public StartAuthorizationFlowRequestBuilder redirect(Redirect redirect) {
69+
this.redirect = redirect;
70+
return this;
71+
}
72+
73+
public StartAuthorizationFlowRequestBuilder consent(Consent consent) {
74+
this.consent = consent;
75+
return this;
76+
}
77+
78+
public StartAuthorizationFlowRequestBuilder form(Form form) {
79+
this.form = form;
80+
return this;
81+
}
82+
83+
public StartAuthorizationFlowRequestBuilder userAccountSelection(Map<String, String> userAccountSelection) {
84+
this.userAccountSelection = userAccountSelection;
85+
return this;
86+
}
87+
88+
public StartAuthorizationFlowRequest build() {
89+
if (withProviderSelection && providerSelection == null) {
90+
providerSelection = new ProviderSelection();
91+
}
92+
93+
return new StartAuthorizationFlowRequest(
94+
providerSelection, schemeSelection, redirect, consent, form, userAccountSelection);
95+
}
96+
}
97+
2898
@Builder
2999
@ToString
30100
@EqualsAndHashCode
101+
@AllArgsConstructor
31102
public static class ProviderSelection {
32-
private final Icon icon;
103+
private Icon icon;
104+
105+
public ProviderSelection() {}
33106

34107
@NoArgsConstructor
35108
@AllArgsConstructor

src/test/java/com/truelayer/java/acceptance/PaymentsAcceptanceTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,45 @@ public void shouldCompleteAnAuthorizationFlowForAPaymentWithPreselectedProvider(
448448
assertCanBrowseLink(bankPage);
449449
}
450450

451+
@SneakyThrows
452+
@Test
453+
@Deprecated
454+
@DisplayName(
455+
"It should complete an authorization flow for a payment with a preselected provider with deprecated provider selection method")
456+
public void shouldCompleteAnAuthorizationFlowForAPaymentWithPreselectedProviderDeprecatedProviderSelection() {
457+
// create payment
458+
CreatePaymentRequest paymentRequest =
459+
buildPaymentRequestWithProviderSelection(buildPreselectedProviderSelection(), CurrencyCode.GBP);
460+
461+
ApiResponse<CreatePaymentResponse> createPaymentResponse =
462+
tlClient.payments().createPayment(paymentRequest).get();
463+
464+
assertNotError(createPaymentResponse);
465+
assertTrue(createPaymentResponse.getData().isAuthorizationRequired());
466+
467+
// start the auth flow
468+
StartAuthorizationFlowRequest startAuthorizationFlowRequest = StartAuthorizationFlowRequest.builder()
469+
.redirect(Redirect.builder().returnUri(URI.create(RETURN_URI)).build())
470+
.withProviderSelection()
471+
.build();
472+
ApiResponse<AuthorizationFlowResponse> startAuthorizationFlowResponse = tlClient.payments()
473+
.startAuthorizationFlow(createPaymentResponse.getData().getId(), startAuthorizationFlowRequest)
474+
.get();
475+
476+
assertNotError(startAuthorizationFlowResponse);
477+
478+
// assert that the link returned is good to be browsed
479+
URI bankPage = startAuthorizationFlowResponse
480+
.getData()
481+
.asAuthorizing()
482+
.getAuthorizationFlow()
483+
.getActions()
484+
.getNext()
485+
.asRedirect()
486+
.getUri();
487+
assertCanBrowseLink(bankPage);
488+
}
489+
451490
@SneakyThrows
452491
@Test
453492
@DisplayName("It should complete an authorization flow for a payment with provider return")

0 commit comments

Comments
 (0)