Authorize and then Capture programmatically using Authorize.Net in Magento

Authorize and then Capture programmatically using Authorize.Net in Magento

August 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Authorize and then Capture programmatically using Authorize.Net in Magento

Authorizing and Capturing Payments Separately with Authorize.Net and Magento

As an experienced e-commerce developer, I often receive queries from merchants who want to handle authorization and capture separately using Authorize.Net with their Magento stores. While many tutorials combine these steps, there’s a clear need for a guide that explains the process step-by-step.

Understanding the Separation of Authorization and Capture

In some business models, it’s necessary to pre-authorize payments without immediately capturing them. This is particularly useful in scenarios where you want to reserve funds but don’t want to settle the transaction until later. For example, hotels often use this approach for holding reservations.

The key difference lies in the timing of the settlement process. An authorization holds the funds from the customer’s account while a capture actually transfers those funds to your merchant account.

Setting Up Your Magento Store

Before we begin, ensure you have the Authorize.Net payment method configured correctly in your Magento admin panel:

  1. Navigate to System > Configuration > Sales > Payment Methods.
  2. Click on Add New Config.
  3. Select Authorize.Net as the payment method and save it.

You’ll need your API Login ID, Transaction Key, and whether you’re using a Sandbox or Production environment. You can generate these credentials from your Authorize.Net account manager page.

The Authorization Process

The authorization process involves creating a request to hold funds without settling them immediately. Here’s the basic PHP code required for an authorization:

$authorizeNet = new AuthorizeNetSIM_Client('Your_API_Login_ID', 'Your_Transaction_Key');

$response = $authorizeNet->createCustomerProfileTransaction(
    'AuthOnly',
    floatval($totalAmount),  // Total amount in USD
    'Authorization only: no capture.',
    $customerProfileId,
    '',
    array(
        'x_delim_data' => 'TRUE',
        'x_delim_char' => ',',
        'x_relay_response' => 'FALSE'
    )
);

if ($response->getResponseCode() == 1) {
    // Transaction was successful
    $transactionId = $response->getTransactionId();
} else {
    // Handle error
}

Replace Your_API_Login_ID and Your_Transaction_Key with your actual credentials. The $customerProfileId is the customer’s ID in Authorize.Net.

This code initiates an authorization request for a specific amount. It doesn’t actually settle the transaction; it merely holds the funds pending further action.

The Capture Process

Once you’re ready to finalize the transaction, you’ll need to perform the capture step. This involves using the same API but specifying the AuthCapture action instead of AuthOnly.

Here’s how to do it:

$response = $authorizeNet->createCustomerProfileTransaction(
    'AuthCapture',
    floatval($totalAmount),  // Total amount in USD
    'Authorization capture: settle funds.',
    $customerProfileId,
    '',
    array(
        'x_delim_data' => 'TRUE',
        'x_delim_char' => ',',
        'x_relay_response' => 'FALSE'
    )
);

The key difference is the AuthCapture action string. This tells the API to settle the transaction and transfer the funds.

Conclusion

Separating authorization and capture allows for greater flexibility in your payment processing workflows. By authorizing first, you can ensure that funds are reserved without immediately settling them. Then, when ready, you can perform a capture operation using the same transaction ID.

Remember, it’s crucial to handle these operations securely and within the constraints of Magento’s authorization and capture limits. Always test in a sandbox environment before deploying to production.

For more detailed information on Authorize.Net integration with Magento, I recommend checking out our comprehensive guide at Laravel Company.

Catalog API Admin Configuration

Our network