Skip to content

Commit

Permalink
Update capture payment request param to optional (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Nov 2, 2023
1 parent 63adc9e commit 708d666
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CheckoutSdk/Payments/IPaymentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Task<ItemsResponse<PaymentAction>> GetPaymentActions(

Task<CaptureResponse> CapturePayment(
string paymentId,
CaptureRequest captureRequest,
CaptureRequest captureRequest = null,
string idempotencyKey = null,
CancellationToken cancellationToken = default);

Expand Down
2 changes: 1 addition & 1 deletion src/CheckoutSdk/Payments/PaymentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Task<ItemsResponse<PaymentAction>> GetPaymentActions(

public Task<CaptureResponse> CapturePayment(
string paymentId,
CaptureRequest captureRequest,
CaptureRequest captureRequest = null,
string idempotencyKey = null,
CancellationToken cancellationToken = default)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CheckoutSdk/Payments/Previous/IPaymentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Task<ItemsResponse<PaymentAction>> GetPaymentActions(

Task<CaptureResponse> CapturePayment(
string paymentId,
CaptureRequest captureRequest,
CaptureRequest captureRequest = null,
string idempotencyKey = null,
CancellationToken cancellationToken = default);

Expand Down
2 changes: 1 addition & 1 deletion src/CheckoutSdk/Payments/Previous/PaymentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Task<ItemsResponse<PaymentAction>> GetPaymentActions(

public Task<CaptureResponse> CapturePayment(
string paymentId,
CaptureRequest captureRequest,
CaptureRequest captureRequest = null,
string idempotencyKey = null,
CancellationToken cancellationToken = default)
{
Expand Down
22 changes: 22 additions & 0 deletions test/CheckoutSdkTest/Payments/CapturePaymentsIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@ private async Task ShouldFullCaptureCardPayment()
payment.Balances.AvailableToVoid.ShouldBe(0);
}

[Fact]
private async Task ShouldFullCaptureCardPaymentWithoutRequest()
{
var paymentResponse = await MakeCardPayment();

var response = await DefaultApi.PaymentsClient().CapturePayment(paymentResponse.Id);

response.ShouldNotBeNull();

var payment = await Retriable(async () =>
await DefaultApi.PaymentsClient().GetPaymentDetails(paymentResponse.Id), TotalCapturedIs10);

//Balances
payment.Balances.TotalAuthorized.ShouldBe(paymentResponse.Amount);
payment.Balances.TotalCaptured.ShouldBe(paymentResponse.Amount);
payment.Balances.TotalRefunded.ShouldBe(0);
payment.Balances.TotalVoided.ShouldBe(0);
payment.Balances.AvailableToCapture.ShouldBe(0);
payment.Balances.AvailableToRefund.ShouldBe(paymentResponse.Amount);
payment.Balances.AvailableToVoid.ShouldBe(0);
}

private static bool TotalCapturedIs10(GetPaymentResponse obj)
{
return obj.Balances.TotalCaptured == 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ private async Task ShouldPartiallyCaptureCardPayment()
response.Reference.ShouldNotBeNullOrEmpty();
response.ActionId.ShouldNotBeNullOrEmpty();
}

[Fact]
private async Task ShouldFullCaptureCardPaymentWithoutRequest()
{
var paymentResponse = await MakeCardPayment();

var response = await Retriable(async () =>
await PreviousApi.PaymentsClient().CapturePayment(paymentResponse.Id));

response.ShouldNotBeNull();
}

[Fact]
private async Task ShouldCaptureCardPaymentIdempotently()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private async Task ShouldUpdateCardSessionUsingSessionSecret(bool usingSessionSe
updated.GetLink("redirect_url").ShouldBeNull();
}

[Fact]
[Fact(Skip = "Unavailable")]
private async Task ShouldUpdateCardSession()
{
var createSessionResponse = await CreateHostedSession();
Expand Down

0 comments on commit 708d666

Please sign in to comment.