Capture Session
The capture_payment_session endpoint should be called after create_payment_session
has been called with kind of authorization as outlined in Manual/Delayed Capture.
The failure or success status is communicated to the partner via a payment_session_complete
webhook as before.
Request Notes
total_amount(Required) - The amount in cents to charge, including any tax and fees you’re collecting. Captures together can’t exceed the session’stotal_amount; to collect more, void and create a new session.item_details(Required) - The units in this capture, each referencing anitem_idfrom the session’sorder_items.- Without multi-capture, an item keeps the same per-unit cost (
total / quantity) in every capture, andtotal_amountmust equal the sum of thetotalvalues, except on a single capture of the whole order, the only capture that may also carry order-level shipping, fees and discounts.
- Without multi-capture, an item keeps the same per-unit cost (
final(Optional, defaults totrue) -falsekeeps the rest of the authorization for a later capture. It requiresmulticapture_availableto betrueon the authorizedpayment_session_completewebhook; otherwise the request fails withValidationError.- A final capture releases whatever it doesn’t collect.
- To close without collecting more, send
total_amount: 0with emptyitem_detailsafter at least one earlier capture, or void the session.
amount_detailsanditem_details[].amount_details(Optional, multi-capture only) - The charges and discounts this capture carries, in the same shape as at session creation. Other sessions reject them withInvalidItemizedData.
Multi-capture sessions
Multi-capture must be enabled for your integration by Truemed Support. See Capturing in multiple parts for setup and integration guidance.
After authorization, split a session only when multicapture_available is true on the payment_session_complete webhook. When it’s false, a final: false capture is rejected and a final capture releases whatever it doesn’t collect.
Each capture may include any remaining quantity of an order item, down to a single unit, and items may be captured in any order. Across all captures, the total quantity for an item_id cannot exceed its quantity in the original order.
Send final: false when more captures will follow. final: true closes the session and releases any uncollected amount. A capture also closes the session if it collects the entire remaining balance.
Without amount_details, Truemed infers the order-level part:
total_amountcan be up to these units’ session totals plus the net order-level money still owed on the session (order_level_charges_remaininglessorder_level_discounts_remaining).- Below the units’ totals, the session’s order-level discounts are applied: up to these items’ share on a non-final capture, up to all that remain on a final. Anything lower is money you chose not to collect, and it can’t be captured later.
With amount_details, you declare it. If a session’s first capture sends no amount_details, later captures can’t send them either; a final capture without amount_details collects what’s left. A session whose first capture declares can mix declared and inferred captures.
amount_detailscan be declared at the top level of the capture or per item.- At the item level, the unit price ×
quantity, plus its charges, minus its discounts, must equal itstotal. A discount declared on an item belongs to that item. - At the capture level, the items’ totals plus its charges minus its discounts must equal
total_amount. - In a capture that declares
amount_detailsat either level, an item that omitsamount_detailsor sendsamount_details: {}uses the item-level charges and discounts provided tocreate_payment_session. Itstotalmust equal the unit price ×quantity, plus the captured units’ share of those charges, minus their share of those discounts. At the capture level, omittingamount_detailsor sendingamount_details: {}declares no order-level charges or discounts. - Declared charges must fit within
order_level_charges_remaining, and declared discounts must fit withinorder_level_discounts_remaining; the two are checked separately. An item’s discount beyond what’s left is money you chose not to collect on that item; a capture-level one is rejected.
Partial quantities: the cumulative limit is the captured units’ proportional share of max_capture_amount, rounded half up, plus up to one cent per captured unit, and never more than max_capture_amount. For example, when max_capture_amount is 1000 and quantity is 3, the item’s captures may total up to 334 after one unit, 669 after two, and 1000 after all three. See Partial quantities: why a rounding rule, and which one.
Card minimum: no card is charged less than $0.50 in one capture, so a capture under $0.50 in total is rejected.
Response Notes
Success Case
HTTP Status: 200
id- The ID of the payment session that was captured, the same value thatcreate_payment_sessionreturned.capture_id- The ID of this capture. Pass it ascapture_idto Create Refund to refund against this capture. The same ID is returned if the endpoint is called again with the sameidempotency_key. It is omitted for a zero-amount final capture, which only releases the uncaptured remainder.
Bad Request
HTTP Status: 400
If a field is missing or the request otherwise can’t be processed, we’ll return a 400 with the following fields:
error- can be one of:MissingField: One of the required fields is not present in the request.TotalAmountInvalid: The amount can’t be accepted: more than these items and the order-level money still owed allow, more than is still authorized, negative, under $0.50, a zero amount where it isn’t allowed, or declared amounts that don’t add up tototal_amountor don’t fit the order-level charges or discounts still unused. On a multi-capture session themessageexplains what to change. A rejected capture records nothing.PaymentSessionDoesNotExist: Thepayment_session_iddoes not exist.ServerError: There was an internal server error. Requests can be retried as long as theidempotency_keyis the same.SessionVoided: The session has already been voided via a call to/payment_session/{payment_session_id}/void.SessionExpired: The auth hold has expired and we were unable to recharge the customer for the amount requested.SessionPending: The user hasn’t completed the Truemed checkout flow (survey, CC entry form).SessionCaptured: You’re attempting to capture a payment_session that has already been captured. This error will never be returned if reissuing a capture call with the same idempotency key - the return value will be the same as the first call.ImmediateCapture: The payment session wasn’t created withkind=authorization.InvalidItemizedData: Anitem_detailsentry is invalid (a bad quantity or total, or more than is left of the item), an item’s declaredamount_detailsdon’t add up to itstotal,amount_detailson a session without multi-capture, or, on a multi-capture session, the sameitem_idsent twice, oramount_detailson a capture after the session’s first capture declared none. Themessagenames the item and the value.ValidationError:final: falseon a session without multi-capture.InvalidRequestParameter:amount_detailsis malformed, for exampletotal_discountswithoutdiscounts_details.
message- Indication of which field was missing, details on how the total amount was invalid, or details on voided sessions.
Authentication
Sales channel API key for merchant server-to-server authentication
Path parameters
The UUID of the payment session returned by create_payment_session.
Request
The total amount in cents to charge the user, inclusive of taxes and fees being collected by the partner. Must be less than or equal to the total_amount passed in when creating the payment session. If an amount more than the initial authorization should be captured, void the initial auth hold and create a new one.
Order-level charges and discounts this capture carries beyond its items, in the session-creation shape. The items’ totals plus charges minus discounts must equal total_amount. To declare no charges or discounts, send a zero total with an empty details list. Multi-capture sessions only, and only when the session’s first capture declared amounts: once a capture sends none, later captures are rejected if they do.
Defaults to true, which releases whatever this capture doesn’t collect. false keeps the rest authorized for a later capture; it needs multi-capture (see multicapture_available).
Response
The ID of the payment session that was captured, the same value returned by create_payment_session. Use capture_id to identify this capture.
The ID of this capture. Pass it as capture_id to the refund endpoint to refund against this capture. The same ID is returned if the endpoint is called again with the same idempotency_key. Omitted for a zero-amount final capture, which only releases the uncaptured remainder and cannot be refunded.