Skip to content

Commit

Permalink
#400 Fix: Move testmode parameter from query string to request body o…
Browse files Browse the repository at this point in the history
…n CaptureClient.CreateCapture
  • Loading branch information
Viincenttt committed Oct 8, 2024
1 parent 6e94641 commit 24d3270
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Mollie.Api/Client/Abstract/ICaptureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public interface ICaptureClient : IBaseMollieClient {
Task<CaptureResponse> GetCaptureAsync(UrlObjectLink<CaptureResponse> url);
Task<ListResponse<CaptureResponse>> GetCaptureListAsync(string paymentId, bool testmode = false);
Task<ListResponse<CaptureResponse>> GetCaptureListAsync(UrlObjectLink<ListResponse<CaptureResponse>> url);
Task<CaptureResponse> CreateCapture(string paymentId, CaptureRequest captureRequest, bool testmode = false);
Task<CaptureResponse> CreateCapture(string paymentId, CaptureRequest captureRequest);
}
}
5 changes: 2 additions & 3 deletions src/Mollie.Api/Client/CaptureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ public async Task<ListResponse<CaptureResponse>> GetCaptureListAsync(UrlObjectLi
return await GetAsync(url).ConfigureAwait(false);
}

public async Task<CaptureResponse> CreateCapture(string paymentId, CaptureRequest captureRequest, bool testmode = false) {
public async Task<CaptureResponse> CreateCapture(string paymentId, CaptureRequest captureRequest) {
ValidateRequiredUrlParameter(nameof(paymentId), paymentId);
var queryParameters = BuildQueryParameters(testmode);
return await PostAsync<CaptureResponse>($"payments/{paymentId}/captures{queryParameters.ToQueryString()}", captureRequest)
return await PostAsync<CaptureResponse>($"payments/{paymentId}/captures", captureRequest)
.ConfigureAwait(false);
}

Expand Down
11 changes: 8 additions & 3 deletions src/Mollie.Api/Models/Capture/Request/CaptureRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ public record CaptureRequest {
/// </summary>
[JsonConverter(typeof(RawJsonConverter))]
public string? Metadata { get; set; }


/// <summary>
/// Oauth only - Optional – Set this to true to make this capture for a test payment
/// </summary>
public bool? Testmode { get; set; }

public void SetMetadata(object metadataObj, JsonSerializerSettings? jsonSerializerSettings = null) {
Metadata = JsonConvert.SerializeObject(metadataObj, jsonSerializerSettings);
}

public override string ToString() {
return $"Amount: {Amount} Description: {Description}";
}
}
}
}

0 comments on commit 24d3270

Please sign in to comment.