Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for refunding split payments #371

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Mollie.Api/Models/Refund/Request/RefundRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Mollie.Api.JsonConverters;
using System.Collections.Generic;
using Mollie.Api.JsonConverters;
using Newtonsoft.Json;

namespace Mollie.Api.Models.Refund.Request {
Expand Down Expand Up @@ -26,6 +27,20 @@ public record RefundRequest {
/// </summary>
public bool? Testmode { get; set; }

/// <summary>
/// If you wish to pull back the money that was sent to connected accounts within the creation of a partial
/// refund (namely a refund of less of the amount of the original payment), you can do so by setting the
/// routingReversals array in the request
/// </summary>
public IList<RoutingReversal>? RoutingReversals { get; set; }

/// <summary>
/// For a full reversal of the split that was specified during payment creation, simply set reverseRouting=true
/// when creating the refund, so that a full compensation is created for every route of the original payment.
/// This flag only works with full refunds, namely a refund of the same amount (or more) than the original payment.
/// </summary>
public bool? ReverseRouting { get; set; }

public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) {
Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Mollie.Api/Models/Refund/Response/RefundResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Mollie.Api.JsonConverters;
using Newtonsoft.Json;

Expand Down Expand Up @@ -55,6 +56,13 @@ public record RefundResponse {
/// </summary>
public required string PaymentId { get; set; }

/// <summary>
/// If you wish to pull back the money that was sent to connected accounts within the creation of a partial
/// refund (namely a refund of less of the amount of the original payment), you can do so by setting the
/// routingReversals array in the request
/// </summary>
public IList<RoutingReversal>? RoutingReversals { get; set; }

/// <summary>
/// Provide any data you like, for example a string or a JSON object. We will save the data alongside the refund. Whenever
/// you fetch the refund with our API, we’ll also include the metadata. You can use up to approximately 1kB.
Expand Down
15 changes: 15 additions & 0 deletions src/Mollie.Api/Models/Refund/RoutingReversal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Mollie.Api.Models.Payment;

namespace Mollie.Api.Models.Refund;

public record RoutingReversal {
/// <summary>
/// The amount to refund to the source
/// </summary>
public required Amount Amount { get; init; }

/// <summary>
/// The source to which the amount should be refunded
/// </summary>
public required RoutingDestination Source { get; init; }
}
Loading