header

Magento 1.x Software Support Notice

For Magento Commerce 1, Magento is providing software support through June 2020. Depending on your Magento Commerce 1 version, software support may include both quality fixes and security patches. Please review our Magento Software Lifecycle Policy to see how your version of Magento Commerce 1 is supported.

For Magento Open Source 1.5 to 1.9, Magento is providing software security patches through June 2020 to ensure those sites remain secure and compliant. Visit our information page for more details about our software maintenance policy and other considerations for your business.

Invoice Capture

Edit this page on GitHub

Module: Mage_Sales

Resource: sales_order_invoice

Aliases:

Method:

Allows you to capture the required invoice. Note that not all order invoices can be captured. Only some payment methods support capturing the order invoice (e.g., PayPal Pro).

Aliases:

Arguments:

Type Name Description
string sessionId Session ID
string invoiceIncrementId
Invoice increment ID

Returns:

Type Description
boolean\int True (1) if the order invoice is captured.

Notes:

You should check the invoice to see if it can be captured before attempting to capture the invoice. Otherwise, the API call will generate an error.

Invoices have states as defined in the model Mage_Sales_Model_Order_Invoice:

Also note that there is a method call in the model that checks this for you - canCapture(). And it also verifies that the payment can be captured, so the invoice state might not be the only condition that is required to allow it to be captured.

Examples

Request Example SOAP V1
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$orderIncrementId = '100000016';

//Create invoice for order
$invoiceIncrementId = $proxy->call(
    $session,
    'sales_order_invoice.create',
    array(
        'orderIncrementId' => $orderIncrementId,
        array('order_item_id' => '15', 'qty' => '1')
    )
);

//Capture invoice amount
$result = $proxy->call(
    $session,
    'sales_order_invoice.capture',
    $invoiceIncrementId
);
Request Example SOAP V2
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionID = $proxy->login('apiUser', 'apiKey');

$orderIncrementId = '100000016';

//Create invoice for order
$qty = array(
    array('order_item_id' => '15', 'qty' => '1')
);
$invoiceIncrementId = $proxy->salesOrderInvoiceCreate(
     $sessionID,
     $orderIncrementId,
     $qty);

//Capture invoice amount
$result = $proxy->salesOrderInvoiceCapture(
     $sessionID,
     $invoiceIncrementId
);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->salesOrderInvoiceCapture((object)array('sessionId' => $sessionId->result, 'invoiceIncrementId' => '100000016'));   

var_dump($result->result);