diff --git a/src/Mollie.Api/Models/Payment/PaymentLine.cs b/src/Mollie.Api/Models/Payment/PaymentLine.cs index 3b9932aa..247a0428 100644 --- a/src/Mollie.Api/Models/Payment/PaymentLine.cs +++ b/src/Mollie.Api/Models/Payment/PaymentLine.cs @@ -3,6 +3,7 @@ public record PaymentLine { /// /// 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. /// public required string Type { get; init; } @@ -19,7 +20,7 @@ public record PaymentLine { /// /// The unit for the quantity. For example pcs, kg, or cm. /// - public required string QuantityUnit { get; init; } + public string? QuantityUnit { get; init; } /// /// The price of a single item including VAT. The unit price can be zero in case of free items. @@ -27,14 +28,14 @@ public record PaymentLine { public required Amount UnitPrice { get; init; } /// - /// 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. /// - public required Amount TotalAmount { get; init; } + public Amount? DiscountAmount { get; set; } /// - /// 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. /// - public Amount? DiscountAmount { get; set; } + public required Amount TotalAmount { get; init; } /// /// The VAT rate applied to the line, for example 21.00 for 21%. The vatRate should be passed as a string and not diff --git a/tests/Mollie.Tests.Integration/Api/PaymentTests.cs b/tests/Mollie.Tests.Integration/Api/PaymentTests.cs index db4e45d9..6aab326c 100644 --- a/tests/Mollie.Tests.Integration/Api/PaymentTests.cs +++ b/tests/Mollie.Tests.Integration/Api/PaymentTests.cs @@ -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; @@ -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() { + 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