Skip to main content

capture Method

Overview

The capture method finalizes an authorized payment by transferring the reserved funds from the customer's account to your merchant account. This completes the payment lifecycle after a successful authorization.

Business Use Case: An e-commerce order has shipped. The customer's payment was authorized at checkout, and now that the order is on its way, you capture the funds to complete the transaction.

Purpose

Why use capture?

ScenarioBenefit
E-commerce fulfillmentCharge customers only when orders ship
Hotel checkoutCapture final bill amount at check-out
Service completionBill after service is rendered
Partial shipmentsCapture only what was actually shipped

Key outcomes:

  • Funds transfer from customer to merchant
  • Payment reaches CAPTURED status
  • Transaction proceeds to settlement

Request Fields

FieldTypeRequiredDescription
merchant_transaction_idstringYesYour unique transaction reference
connector_transaction_idstringYesThe connector's transaction ID from authorize
amountMoneyNoAmount to capture (can be partial)
descriptionstringNoDescription for customer's statement
metadatadictNoAdditional data (max 20 keys)

Response Fields

FieldTypeDescription
merchant_transaction_idstringYour transaction reference (echoed back)
connector_transaction_idstringConnector's transaction ID
statusPaymentStatusCurrent status: CAPTURED, PENDING, FAILED
captured_amountint64Amount captured in minor units
errorErrorInfoError details if status is FAILED
status_codeintHTTP-style status code (200, 402, etc.)

Example

SDK Setup

from orchestratorx_prism import PaymentClient

payment_client = PaymentClient(
connector='stripe',
api_key='YOUR_API_KEY',
environment='SANDBOX'
)

Request

request = {
"merchant_transaction_id": "txn_order_001",
"connector_transaction_id": "pi_3Oxxx...",
"amount": {
"minor_amount": 1000,
"currency": "USD"
},
"description": "Order shipment #12345"
}

response = await payment_client.capture(request)

Response

{
"merchant_transaction_id": "txn_order_001",
"connector_transaction_id": "pi_3Oxxx...",
"status": "CAPTURED",
"captured_amount": 1000,
"status_code": 200
}

Common Patterns

Two-Step Payment Flow

sequenceDiagram
participant App as Your App
participant CS as Prism
participant PP as Payment Provider

Note over App: Customer places order
App->>CS: 1. authorize payment
CS->>PP: Reserve funds
PP-->>CS: Return: AUTHORIZED
CS-->>App: Confirm authorization
Note over App: Order ships
App->>CS: 2. capture payment
CS->>PP: Transfer funds
PP-->>CS: Return: CAPTURED
CS-->>App: Confirm capture

Flow Explanation:

  1. Authorize - Reserve funds at checkout to verify payment method.

  2. Fulfill - Process and ship the order.

  3. Capture - Transfer funds when order ships.

Partial Capture

Capture less than the authorized amount:

# Authorized for $100, capture only $75
request = {
"merchant_transaction_id": "txn_order_001",
"connector_transaction_id": "pi_3Oxxx...",
"amount": {
"minor_amount": 7500, # $75.00
"currency": "USD"
}
}

The remaining $25 is automatically released back to the customer.

Error Handling

Error CodeMeaningAction
402Capture failedAuthorization expired or insufficient funds
404Transaction not foundVerify connector_transaction_id
409Already capturedIdempotent - already captured successfully

Next Steps

  • authorize - Create initial authorization
  • void - Cancel authorization instead of capturing
  • refund - Return funds after capture