Skip to content

Commit

Permalink
feat(acl-21-103-154-94): add support to missing fields (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-mauro-franchi authored Aug 12, 2024
1 parent 6d687c6 commit fdfcbc0
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/TrueLayer/Payments/Model/Beneficiary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace TrueLayer.Payments.Model
{
using AccountIdentifierUnion = OneOf<SortCodeAccountNumber, Iban, Bban, Nrb>;
using VerificationUnion = OneOf<Verification.Automated>;

public static class Beneficiary
{
Expand Down Expand Up @@ -43,6 +44,11 @@ public MerchantAccount(string merchantAccountId)
/// Gets or inits A reference for the payment. Not visible to the remitter.
/// </summary>
public string? Reference { get; init; }

/// <summary>
/// Gets or inits verification information for the payment.
/// </summary>
public VerificationUnion? Verification { get; init; }
}

/// <summary>
Expand Down
19 changes: 18 additions & 1 deletion src/TrueLayer/Payments/Model/CreatePaymentRequest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using OneOf;
using TrueLayer.Payments.Model.AuthorizationFlow;
using static TrueLayer.Payments.Model.PaymentMethod;
Expand All @@ -21,20 +22,26 @@ public class CreatePaymentRequest
/// <param name="relatedProducts">Related products</param>
/// <param name="authorizationFlow">The authorization flow parameter.
/// If provided, the start authorization flow endpoint does not need to be called</param>
/// <param name="metadata">Add to the payment a list of custom key-value pairs as metadata</param>
/// <param name="riskAssessment">The risk assessment and the payment_creditable webhook configuration.</param>
public CreatePaymentRequest(
long amountInMinor,
string currency,
PaymentMethodUnion paymentMethod,
PaymentUserRequest? user = null,
RelatedProducts? relatedProducts = null,
StartAuthorizationFlowRequest? authorizationFlow = null)
StartAuthorizationFlowRequest? authorizationFlow = null,
Dictionary<string, string>? metadata = null,
RiskAssessment? riskAssessment = null)
{
AmountInMinor = amountInMinor.GreaterThan(0, nameof(amountInMinor));
Currency = currency.NotNullOrWhiteSpace(nameof(currency));
PaymentMethod = paymentMethod;
User = user;
RelatedProducts = relatedProducts;
AuthorizationFlow = authorizationFlow;
Metadata = metadata;
RiskAssessment = riskAssessment;
}

/// <summary>
Expand Down Expand Up @@ -67,5 +74,15 @@ public CreatePaymentRequest(
/// Gets the payments authorization flow request
/// </summary>
public StartAuthorizationFlowRequest? AuthorizationFlow { get; }

/// <summary>
/// Gets the metadata for the payment
/// </summary>
public Dictionary<string, string>? Metadata { get; }

/// <summary>
/// Gets the risk assessment configuration
/// </summary>
public RiskAssessment? RiskAssessment { get; }
}
}
6 changes: 6 additions & 0 deletions src/TrueLayer/Payments/Model/GetPaymentResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using OneOf;
using TrueLayer.Serialization;
using static TrueLayer.Payments.Model.PaymentMethod;
Expand Down Expand Up @@ -54,6 +55,11 @@ public abstract record PaymentDetails
/// Gets the end user details
/// </summary>
public PaymentUser User { get; init; } = null!;

/// <summary>
/// Gets the metadata added to the payment.
/// </summary>
public Dictionary<string, string>? Metadata { get; init; } = null;
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/TrueLayer/Payments/Model/RiskAssessment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace TrueLayer.Payments.Model;

public record RiskAssessment(string? Segment = null);
22 changes: 22 additions & 0 deletions src/TrueLayer/Payments/Model/Verification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using TrueLayer.Serialization;

namespace TrueLayer.Payments.Model;

public static class Verification
{
[JsonDiscriminator("automated")]
public sealed record Automated: IDiscriminated
{
public string Type => "automated";

/// <summary>
/// Enable or disable the verification of the remitter name.
/// </summary>
public bool RemitterName { get; init; }

/// <summary>
/// Enable or disable the verification of the remitter date of birth.
/// </summary>
public bool RemitterDateOfBirth { get; init; }
}
}
6 changes: 6 additions & 0 deletions test/TrueLayer.AcceptanceTests/MerchantAccountsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using OneOf;
using Shouldly;
using TrueLayer.Common;
using TrueLayer.MerchantAccounts.Model;
Expand Down Expand Up @@ -99,6 +100,11 @@ private static CreatePaymentRequest CreatePaymentRequest(string merchantId)
new Beneficiary.MerchantAccount(merchantId)
{
Reference = "Test payment",
Verification = new Verification.Automated
{
RemitterName = false,
RemitterDateOfBirth = false
}
}),
new PaymentUserRequest(
name: "Jane Doe",
Expand Down
8 changes: 7 additions & 1 deletion test/TrueLayer.AcceptanceTests/PaymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ private static CreatePaymentRequest CreateTestPaymentRequest(
dateOfBirth: new DateTime(1999, 1, 1),
address: new Address("London", "England", "EC1R 4RB", "GB", "1 Hardwick St")),
relatedProducts,
authorizationFlow
authorizationFlow,
metadata: new Dictionary<string, string>
{
["test-key-1"] = "test-value-1",
["test-key-2"] = "test-value-2",
},
riskAssessment: new RiskAssessment("test")
);
}

Expand Down

0 comments on commit fdfcbc0

Please sign in to comment.