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

Update capture payment request param #341

Merged
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
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
Loading