-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(io-20): implemented StartAuthorizationFlow endpoint
- Added CreatePayment tests with auth flow
- Loading branch information
1 parent
69d6806
commit 661362e
Showing
6 changed files
with
207 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/TrueLayer/Payments/Model/AuthorizationFlow/AuthorizationFlowAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using TrueLayer.Serialization; | ||
using OneOf; | ||
|
||
namespace TrueLayer.Payments.Model.AuthorizationFlow; | ||
|
||
using AuthorizationFlowActionUnion = OneOf< | ||
Models.AuthorizationFlowAction.ProviderSelection, | ||
AuthorizationFlowAction.Consent, | ||
Models.AuthorizationFlowAction.Form, | ||
Models.AuthorizationFlowAction.WaitForOutcome, | ||
Models.AuthorizationFlowAction.Redirect | ||
>; | ||
|
||
/// <summary> | ||
/// Contains information regarding the next action to be taken in the authorization flow. | ||
/// </summary> | ||
/// <param name="Next">The next action that can be performed.</param> | ||
public record Actions(AuthorizationFlowActionUnion Next); | ||
|
||
/// <summary> | ||
/// Contains information regarding the nature and the state of the authorization flow. | ||
/// </summary> | ||
/// <param name="Actions">Contains the next action to be taken in the authorization flow.</param> | ||
public record AuthorizationFlow(Actions Actions); | ||
|
||
/// <summary> | ||
/// This static class contains the different types of actions that can be taken during the authorization flow. | ||
/// It contains only the actions/types that are for the payments flow and not already defined in the <see cref="TrueLayer.Models.AuthorizationFlowAction"/> class. | ||
/// </summary> | ||
public static class AuthorizationFlowAction | ||
{ | ||
public enum SubsequentActionHint { Redirect = 0, Form = 1, Wait = 2 }; | ||
|
||
[JsonDiscriminator("consent")] | ||
public record Consent( | ||
string Type, | ||
ConsentRequirements Requirements, | ||
SubsequentActionHint SubsequentActionHint) : IDiscriminated; | ||
|
||
public record ConsentAisRequirement( | ||
List<ConsentAisScopes> RequiredScopes, | ||
List<ConsentAisScopes> OptionalScopes); | ||
|
||
public record ConsentRequirements(ConsentPisRequirement Pis, ConsentAisRequirement Ais); | ||
|
||
public record AdjacentConsent(ConsentRequirements Requirements); | ||
|
||
public record AdjacentAction(AdjacentConsent Consent); | ||
|
||
[JsonDiscriminator("user_account_selection")] | ||
public record UserAccountSelection( | ||
string Type, | ||
Models.Provider Provider, | ||
string MaskedAccountIdentifier, | ||
DateTime LastUsedAt) : IDiscriminated; | ||
|
||
[JsonDiscriminator("scheme_selection")] | ||
public record SchemeSelection( | ||
string Type, | ||
List<Scheme> Schemes) : IDiscriminated; | ||
|
||
public record Scheme( | ||
string Id, | ||
bool Recommended, | ||
Fee Fee); | ||
|
||
public record Fee(int AmountInMinor, string Currency); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/TrueLayer/Payments/Model/AuthorizationFlow/AuthorizationFlowResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using TrueLayer.Serialization; | ||
|
||
namespace TrueLayer.Payments.Model.AuthorizationFlow | ||
{ | ||
public static class AuthorizationFlowResponse | ||
{ | ||
/// <summary> | ||
/// Mandate Authorization Flow | ||
/// </summary> | ||
/// <param name="Status">authorizing</param> | ||
/// <param name="AuthorizationFlow">Contains information regarding the nature and the state of the authorization flow.</param> | ||
[JsonDiscriminator("authorizing")] | ||
public record AuthorizationFlowAuthorizing(string Status, AuthorizationFlow AuthorizationFlow); | ||
|
||
/// <summary> | ||
/// Mandate Authorization Flow | ||
/// </summary> | ||
/// <param name="Status">failed</param> | ||
/// <param name="FailureStage">The status the mandate was in when it failed./param> | ||
/// <param name="FailureReason">A readable detail for why the mandate failed.</param> | ||
[JsonDiscriminator("failed")] | ||
public record AuthorizationFlowAuthorizationFailed(string Status, string FailureStage, string FailureReason); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters