Skip to content

Commit

Permalink
#368 Add integration test for payment with order line
Browse files Browse the repository at this point in the history
  • Loading branch information
Viincenttt committed Jun 13, 2024
1 parent 5a699af commit 0d38dff
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Mollie.Api/Models/Payment/PaymentLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public record PaymentLine {
/// <summary>
/// The type of product purchased. For example, a physical or a digital product.
/// Use the Mollie.Api.Models.Order.Request.OrderLineDetailsType class for a full list of known values.
/// </summary>
public required string Type { get; init; }

Expand All @@ -19,22 +20,22 @@ public record PaymentLine {
/// <summary>
/// The unit for the quantity. For example pcs, kg, or cm.
/// </summary>
public required string QuantityUnit { get; init; }
public string? QuantityUnit { get; init; }

/// <summary>
/// The price of a single item including VAT. The unit price can be zero in case of free items.
/// </summary>
public required Amount UnitPrice { get; init; }

/// <summary>
/// The total amount of the line, including VAT and discounts.
/// Any line-specific discounts, as a positive amount. Not relevant if the line itself is already a discount type.
/// </summary>
public required Amount TotalAmount { get; init; }
public Amount? DiscountAmount { get; set; }

/// <summary>
/// Any line-specific discounts, as a positive amount. Not relevant if the line itself is already a discount type.
/// The total amount of the line, including VAT and discounts.
/// </summary>
public Amount? DiscountAmount { get; set; }
public required Amount TotalAmount { get; init; }

/// <summary>
/// The VAT rate applied to the line, for example 21.00 for 21%. The vatRate should be passed as a string and not
Expand Down
33 changes: 33 additions & 0 deletions tests/Mollie.Tests.Integration/Api/PaymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Mollie.Api.Models.Customer.Response;
using Mollie.Api.Models.List.Response;
using Mollie.Api.Models.Mandate.Response;
using Mollie.Api.Models.Order.Request;
using Mollie.Api.Models.Payment.Request.PaymentSpecificParameters;
using Mollie.Api.Models.Payment.Response.PaymentSpecificParameters;
using Mollie.Api.Models.Terminal.Response;
Expand Down Expand Up @@ -360,6 +361,38 @@ public async Task CanCreatePaymentWithCustomMetaDataClass() {
metadataResponse.Description.Should().Be(metadataRequest.Description);
}

[DefaultRetryFact]
public async Task CanCreatePaymentWithLines() {
// Arrange
PaymentRequest paymentRequest = new PaymentRequest() {
Amount = new Amount(Currency.EUR, 90m),
Description = "Description",
RedirectUrl = DefaultRedirectUrl,
Lines = new List<PaymentLine>() {
new() {
Type = OrderLineDetailsType.Digital,
Description = "Star wars lego",
Quantity = 1,
QuantityUnit = "pcs",
UnitPrice = new Amount(Currency.EUR, 100m),
TotalAmount = new Amount(Currency.EUR, 90m),
DiscountAmount = new Amount(Currency.EUR, 10m),
ProductUrl = "http://www.lego.com/starwars",
ImageUrl = "http://www.lego.com/starwars.jpg",
Sku = "my-sku",
VatAmount = new Amount(Currency.EUR, 15.62m),
VatRate = "21.00"
}
}
};

// Act
PaymentResponse result = await _paymentClient.CreatePaymentAsync(paymentRequest);

// Assert
result.Lines.Should().BeEquivalentTo(paymentRequest.Lines);
}

[DefaultRetryFact]
public async Task CanCreatePaymentWithMandate() {
// When: We create a payment with a mandate id
Expand Down

0 comments on commit 0d38dff

Please sign in to comment.