Skip to content

Commit

Permalink
Add support for voucher related fields in PaymentRequest (#410)
Browse files Browse the repository at this point in the history
* Add support for voucher related fields in PaymentRequest

* Remove failing test
  • Loading branch information
Viincenttt authored Jan 17, 2025
1 parent 426e757 commit eed1b62
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.

This file was deleted.

10 changes: 9 additions & 1 deletion src/Mollie.Api/Models/Payment/PaymentLine.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Mollie.Api.Models.Payment;
using System.Collections.Generic;

namespace Mollie.Api.Models.Payment;

public record PaymentLine {
/// <summary>
Expand Down Expand Up @@ -49,6 +51,12 @@ public record PaymentLine {
/// </summary>
public Amount? VatAmount { get; set; }

/// <summary>
/// An array with the voucher categories, in case of a line eligible for a voucher. See the Integrating
/// Vouchers guide for more information. Use the Mollie.Api.Models.VoucherCategory class for a full list of known values.
/// </summary>
public IEnumerable<string>? Categories { get; set; }

/// <summary>
/// The SKU, EAN, ISBN or UPC of the product sold.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/Mollie.Api/Models/Payment/PaymentMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ public static class PaymentMethod {
public const string BacsDirectDebit = "bacs";
public const string Alma = "alma";
public const string GooglePay = "googlepay";
public const string Voucher = "voucher";
}
}
7 changes: 7 additions & 0 deletions src/Mollie.Api/Models/Payment/Request/PaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public string? Method {
}
}

/// <summary>
/// Only relevant for iDEAL, KBC/CBC, gift card, and voucher payments.
/// Some payment methods are a network of connected banks or card issuers. In these cases, after selecting the payment method,
/// the customer may still need to select the appropriate issuer before the payment can proceed.
/// </summary>
public string? Issuer { get; set; }

/// <summary>
/// Normally, a payment method screen is shown. However, when using this parameter, you can choose a specific payment method
/// and your customer will skip the selection screen and is sent directly to the chosen payment method. The parameter
Expand Down
8 changes: 8 additions & 0 deletions src/Mollie.Api/Models/VoucherCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Mollie.Api.Models;

public static class VoucherCategory {
public const string Gift = "gift";
public const string Eco = "eco";
public const string Meal = "meal";
public const string SportCulture = "sport_culture";
}
6 changes: 3 additions & 3 deletions tests/Mollie.Tests.Integration/Api/OrderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public async Task ManageOrderLinesAsync_AddOperation_OrderLineIsAdded() {
ManageOrderLinesAddOperationData newOrderLineRequest = new ManageOrderLinesAddOperationData {
Name = "LEGO Batman mobile",
Type = OrderLineDetailsType.Physical,
Category = OrderLineDetailsCategory.Gift,
Category = VoucherCategory.Gift,
Quantity = 1,
UnitPrice = new Amount(Currency.EUR, 100.00m),
TotalAmount = new Amount(Currency.EUR, 100.00m),
Expand Down Expand Up @@ -434,10 +434,10 @@ private OrderRequest CreateOrder() {
Amount = new Amount(Currency.EUR, "100.00"),
OrderNumber = "16738",
Lines = new List<OrderLineRequest>() {
new OrderLineRequest() {
new() {
Name = "A box of chocolates",
Type = OrderLineDetailsType.Physical,
Category = OrderLineDetailsCategory.Gift,
Category = VoucherCategory.Gift,
Quantity = 1,
UnitPrice = new Amount(Currency.EUR, "100.00"),
TotalAmount = new Amount(Currency.EUR, "100.00"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class PaymentResponseFactoryTests {
[InlineData(PaymentMethod.BacsDirectDebit, typeof(PaymentResponse))]
[InlineData(PaymentMethod.Alma, typeof(PaymentResponse))]
[InlineData(PaymentMethod.GooglePay, typeof(PaymentResponse))]
[InlineData(PaymentMethod.Voucher, typeof(PaymentResponse))]
[InlineData("UnknownPaymentMethod", typeof(PaymentResponse))]
public void Create_CreatesTypeBasedOnPaymentMethod(string paymentMethod, Type expectedType) {
// Given
Expand Down

0 comments on commit eed1b62

Please sign in to comment.