# Capturing a transaction Capturing converts part or all of an authorization's reserved funds into an actual charge. You can capture less than the full authorized amount, and you can capture multiple times against the same authorization (e.g. as a multi-shipment order goes out in parts) as long as the total captured never exceeds what was authorized. See the official documentation for [capturing a transaction](https://docs.ratepay.com/docs/developer/api_integration/payment_2.0/payment_api_2.0). ## Request `CaptureRequest` needs only the amount you're capturing now, item-level detail is optional and mainly useful for partial captures where you want Ratepay's records to reflect exactly what shipped. ```java Java import com.ratepay.sdk.CaptureOutcome; import com.ratepay.sdk.model.api.payment.CaptureRequest; import com.ratepay.sdk.model.api.payment.Item; import java.math.BigDecimal; import java.util.List; CaptureRequest request = new CaptureRequest( new BigDecimal("249.00"), // grossAmount, capturing the full authorized amount here List.of( new Item( new BigDecimal("249.00"), "Ergonomic Office Chair", BigDecimal.ONE, new BigDecimal("19"), "SKU-2050", null, null, null, null, null, null, null, null ) ), null, // partnerInvoiceId null, // partnerOperationId null, // partnerShopId null, // partnerTransactionId null, // shopTransactionId null, // specialItems null // vats ); CaptureOutcome outcome = client.capture(ratepayTransactionId, request, null); if (outcome.isAccepted()) { var accepted = (CaptureOutcome.Accepted) outcome; System.out.println("Captured " + accepted.getRatepayCaptureId()); } else { var declined = (CaptureOutcome.Declined) outcome; System.out.println("Capture declined: " + declined.getDecline().getCategory()); } ``` ```kotlin Kotlin import com.ratepay.sdk.CaptureOutcome import com.ratepay.sdk.model.api.payment.CaptureRequest import com.ratepay.sdk.model.api.payment.Item import java.math.BigDecimal val request = CaptureRequest( grossAmount = BigDecimal("249.00"), items = listOf( Item( grossUnitPrice = BigDecimal("249.00"), name = "Ergonomic Office Chair", taxRate = BigDecimal("19"), quantity = BigDecimal.ONE, articleNumber = "SKU-2050", ), ), ) when (val outcome = client.capture(ratepayTransactionId, request)) { is CaptureOutcome.Accepted -> println("Captured ${outcome.ratepayCaptureId}") is CaptureOutcome.Declined -> println("Capture declined: ${outcome.decline.category}") } ``` ## Outcome | Kind | Meaning | | --- | --- | | `ACCEPTED` | The capture succeeded; `ratepayCaptureId` identifies it for later shipping-information calls or refunds. | | `DECLINED` | The capture was rejected most commonly because the requested amount exceeds what's left to capture on the authorization. Inspect `Declined.decline`. | Every outcome type also offers `isAccepted()` / `isDeclined()` helpers (and `isOtpRequired()` on `AuthorizeOutcome`), handy in Java before Java 21 pattern matching. ## Exceptions | Exception | HTTP Status Code | | --- | --- | | `RatepayAuthException` | 401/403 | | `RatepayValidationException` | 400 | | `RatepayTransactionNotFoundException` | 404 | | `RatepayNetworkException` | 5xx/transport | ## Next - [Adding shipping information](/docs/developer/sdk/guides/adding-shipping-information) to a completed capture. - [Refunding a transaction](/docs/developer/sdk/guides/refunding-a-transaction) if you need to reverse a capture later.