Capturing a payment

When the customer has authorized payment from their card, the final step is to capture the payment on the server. This involves making a request to a Payment Service Provider (PSP) to trigger the transfer of money from the customer's bank to yours.

Before you can capture a payment, you must first:

For Customer Initiated Transactions (CITs), you can send the invoice ID to the server for capture in a POST
after authorizing payment on it. For example, you could include the ID as a hidden field in a web form and submit the form to send its data to the server.

For Merchant Initiated Transactions (MITs), you must have access to a customer token to capture payment on the Invoice unless you already provided this during the optional authorization stage.

Server-side code

First, see the page about setting up your environment for details of how to install and access the Smart Router libraries
for your platform.

Assuming your handler has access to the payment source token and the associated invoice token, you can capture the payment with a call to Invoice.capture() as shown below:

curl -X POST https://api.processout.com/invoices/iv_lEZFFcQg5WwpKcolBrlzioeeFnnuPmyE/capture \
    -u test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x:key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB \
    -d source=card_Tpu6ZOCDu1tnDKp0kTnPOcVDMUbW7dTU
invoice.capture("card_1jSEVrx7oaRta1KEdxoMWbiGkK2MijrZ").then(
    function(transaction) {
        // 

    }, function(err) {
        // The invoice could not be captured
    });
transaction = invoice.capture("card_1jSEVrx7oaRta1KEdxoMWbiGkK2MijrZ")
transaction = invoice.capture("card_1jSEVrx7oaRta1KEdxoMWbiGkK2MijrZ")
$transaction = $invoice->capture("card_1jSEVrx7oaRta1KEdxoMWbiGkK2MijrZ");
tr, _ := iv.Capture("card_1jSEVrx7oaRta1KEdxoMWbiGkK2MijrZ")

Invoice.capture() returns a Transaction object if the payment is successful or an error code or null value if it is not. The Transaction has a status attribute that gives more detail about the exact stage it has reached. A successful payment will have a status value of completed but there are a number of other useful status indicators. See the Transaction section of the API reference for a list of all possible status codes.

Note that for an MIT, if you have previously authorized the payment on the server then you can just pass an empty string to Invoice.capture() instead of the token:

curl -X POST https://api.processout.com/invoices/iv_lEZFFcQg5WwpKcolBrlzioeeFnnuPmyE/capture \
    -u test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x:key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB \
    -H "Content-Type: application/x-www-form-urlencoded"
invoice.capture("").then(
    function(transaction) {
        // 

    }, function(err) {
        // The invoice could not be captured
    });
transaction = invoice.capture("")
transaction = invoice.capture("")
$transaction = $invoice->capture("");
tr, _ := iv.Capture("")

Invoice.capture can take a number of options, which are described in the table below. See the section about capture an invoice in the API reference for more details about the options.

ParameterDescription
capture_amountAmount of money to capture when partial captures are available.
capture_statement_descriptorText that will appear on the customer's bank statement for this payment.
invoice_detail_idsList of items from the invoice that were actually paid for with this capture.

Next steps

The order is often complete after you have captured the payment, but in some cases its status can still change after capture (for example, when there is a chargeback or a refund). We recommend that you stay updated about any status changes by using webhooks to respond to events