Skip to content

Commit

Permalink
Add support for the optional landing page option in the GetAuthorizat…
Browse files Browse the repository at this point in the history
…ionUrl method of the ConnectClient api (#349)
  • Loading branch information
Viincenttt authored Mar 29, 2024
1 parent e6e44ae commit 3b5652e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 42 deletions.
16 changes: 13 additions & 3 deletions src/Mollie.Api/Client/Abstract/IConnectClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using Mollie.Api.Models.Connect;

namespace Mollie.Api.Client.Abstract {
public interface IConnectClient : IDisposable {
public interface IConnectClient : IDisposable
{
/// <summary>
/// Constructs the Authorize URL for the Authorize endpoint from the parameters
/// </summary>
Expand All @@ -27,9 +28,18 @@ public interface IConnectClient : IDisposable {
/// You can provide any ISO 15897 locale, but the authorize flow currently only supports the following languages:
/// Possible values: en_US nl_NL nl_BE fr_FR fr_BE de_DE es_ES it_IT
/// </param>
/// <param name="landingPage">
/// Allows you to specify if Mollie should show the login or the signup page, when the merchant is not logged in at Mollie.
/// Defaults to the login page. Defaults to login.
/// </param>
/// <returns>The url to the mollie consent screen.</returns>
string GetAuthorizationUrl(string state, List<string> scopes, string redirectUri = null,
bool forceApprovalPrompt = false, string locale = null);
string GetAuthorizationUrl(
string state,
List<string> scopes,
string redirectUri = null,
bool forceApprovalPrompt = false,
string locale = null,
string landingPage = null);

/// <summary>
/// Exchange the auth code received at the Authorize endpoint for an actual access token, with which you can
Expand Down
10 changes: 9 additions & 1 deletion src/Mollie.Api/Client/ConnectClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ public ConnectClient(string clientId, string clientSecret, HttpClient httpClient
this._clientId = clientId;
}

public string GetAuthorizationUrl(string state, List<string> scopes, string redirectUri = null, bool forceApprovalPrompt = false, string locale = null) {
public string GetAuthorizationUrl(
string state,
List<string> scopes,
string redirectUri = null,
bool forceApprovalPrompt = false,
string locale = null,
string landingPage = null) {

var parameters = new Dictionary<string, string> {
{"client_id", this._clientId},
{"state", state},
Expand All @@ -38,6 +45,7 @@ public string GetAuthorizationUrl(string state, List<string> scopes, string redi
};
parameters.AddValueIfNotNullOrEmpty("redirect_uri", redirectUri);
parameters.AddValueIfNotNullOrEmpty("locale", locale);
parameters.AddValueIfNotNullOrEmpty("landing_page", landingPage);

return AuthorizeEndPoint + parameters.ToQueryString();
}
Expand Down
38 changes: 0 additions & 38 deletions src/Mollie.Api/Models/Connect/AuthorizeRequest.cs

This file was deleted.

0 comments on commit 3b5652e

Please sign in to comment.