{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars/sdk_sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["code-group"]},"type":"markdown"},"seo":{"title":"Capturing a transaction","description":"The specifications of Ratepay's APIs for easy payment transactions.","siteUrl":"https://docs.ratepay.com","keywords":"Ratepay developer portal, Ratepay api portal, Ratepay api reference docs","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"capturing-a-transaction","__idx":0},"children":["Capturing a transaction"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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"," ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://docs.ratepay.com/docs/developer/api_integration/payment_2.0/payment_api_2.0"},"children":["capturing a transaction"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"request","__idx":1},"children":["Request"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["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."]},{"$$mdtype":"Tag","name":"CodeGroup","attributes":{"mode":"tabs"},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","data-title":"Java","header":{"title":"Java","controls":{"copy":{}}},"source":"import com.ratepay.sdk.CaptureOutcome;\nimport com.ratepay.sdk.model.api.payment.CaptureRequest;\nimport com.ratepay.sdk.model.api.payment.Item;\nimport java.math.BigDecimal;\nimport java.util.List;\n\nCaptureRequest request = new CaptureRequest(\n    new BigDecimal(\"249.00\"), // grossAmount, capturing the full authorized amount here\n    List.of(\n        new Item(\n            new BigDecimal(\"249.00\"), \"Ergonomic Office Chair\", BigDecimal.ONE, new BigDecimal(\"19\"),\n            \"SKU-2050\", null, null, null, null, null, null, null, null\n        )\n    ),\n    null, // partnerInvoiceId\n    null, // partnerOperationId\n    null, // partnerShopId\n    null, // partnerTransactionId\n    null, // shopTransactionId\n    null, // specialItems\n    null  // vats\n);\n\nCaptureOutcome outcome = client.capture(ratepayTransactionId, request, null);\n\nif (outcome.isAccepted()) {\n    var accepted = (CaptureOutcome.Accepted) outcome;\n    System.out.println(\"Captured \" + accepted.getRatepayCaptureId());\n} else {\n    var declined = (CaptureOutcome.Declined) outcome;\n    System.out.println(\"Capture declined: \" + declined.getDecline().getCategory());\n}\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"kotlin","data-title":"Kotlin","header":{"title":"Kotlin","controls":{"copy":{}}},"source":"import com.ratepay.sdk.CaptureOutcome\nimport com.ratepay.sdk.model.api.payment.CaptureRequest\nimport com.ratepay.sdk.model.api.payment.Item\nimport java.math.BigDecimal\n\nval request = CaptureRequest(\n    grossAmount = BigDecimal(\"249.00\"),\n    items = listOf(\n        Item(\n            grossUnitPrice = BigDecimal(\"249.00\"),\n            name = \"Ergonomic Office Chair\",\n            taxRate = BigDecimal(\"19\"),\n            quantity = BigDecimal.ONE,\n            articleNumber = \"SKU-2050\",\n        ),\n    ),\n)\n\nwhen (val outcome = client.capture(ratepayTransactionId, request)) {\n    is CaptureOutcome.Accepted -> println(\"Captured ${outcome.ratepayCaptureId}\")\n    is CaptureOutcome.Declined -> println(\"Capture declined: ${outcome.decline.category}\")\n}\n","lang":"kotlin"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"outcome","__idx":2},"children":["Outcome"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Kind"},"children":["Kind"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Meaning"},"children":["Meaning"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ACCEPTED"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The capture succeeded; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ratepayCaptureId"]}," identifies it for later shipping-information calls or refunds."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DECLINED"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The capture was rejected most commonly because the requested amount exceeds what's left to capture on the authorization. Inspect ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Declined.decline"]},"."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every outcome type also offers ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isAccepted()"]}," / ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isDeclined()"]}," helpers (and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isOtpRequired()"]}," on ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AuthorizeOutcome"]},"), handy in Java before Java 21 pattern matching."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"exceptions","__idx":3},"children":["Exceptions"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Exception"},"children":["Exception"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"HTTP Status Code"},"children":["HTTP Status Code"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RatepayAuthException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["401/403"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RatepayValidationException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["400"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RatepayTransactionNotFoundException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["404"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RatepayNetworkException"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["5xx/transport"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next","__idx":4},"children":["Next"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/developer/sdk/guides/adding-shipping-information"},"children":["Adding shipping information"]}," to a completed capture."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/developer/sdk/guides/refunding-a-transaction"},"children":["Refunding a transaction"]}," if you need to reverse a capture later."]}]}]},"headings":[{"value":"Capturing a transaction","id":"capturing-a-transaction","depth":1},{"value":"Request","id":"request","depth":2},{"value":"Outcome","id":"outcome","depth":2},{"value":"Exceptions","id":"exceptions","depth":2},{"value":"Next","id":"next","depth":2}],"frontmatter":{"seo":{"title":"Capturing a transaction"}},"lastModified":"2026-11-04T12:17:22.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/developer/sdk/guides/capturing-a-transaction","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}