Skip to content

Commit 5d87394

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

File tree

3 files changed

+118
-5
lines changed

3 files changed

+118
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +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-
that helps to set the provider icon object if needed
15+
* ⚠️ Deprecated `withProviderSelection()` flag on authorization flow request builder
1616
* Various dependency updates
1717

1818
## [17.5.1] - 2025-10-31

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

Lines changed: 76 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,85 @@ public class StartAuthorizationFlowRequest {
2525

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

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

34108
@NoArgsConstructor
35109
@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)