Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4095768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:56:35+00:00 2026-05-20T19:56:35+00:00

I am working on implementing a new payment module for Magento and want to

  • 0

I am working on implementing a new payment module for Magento and want to understand the core concept behind this logic. I know I have to extend from Mage_Payment_Model_Method_Abstract or any of its children classes, but my problem is when to use and how to use capture and authorize methods in my model.
For example if I split the whole process in steps like this:

  1. User comes to the shopping cart and choses lets say some payment method which is gateway.
  2. The system intercepts the request, collects all submitted data and sends the user to the gateway url.
  3. User places his order (or cancels) at the gateway site which sends information about it to my store.
  4. My store does some more modifications to the order with the received data and saves the order with status completed or canceled.

Where in these steps will I have to use authorize and capture methods ? I would appreciate if someone could explain to me what authorize and capture means?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:56:36+00:00Added an answer on May 20, 2026 at 7:56 pm

    Here’s the way I’ve always understood the concepts, and what you’ll need to know to implement a payment module in Magento. Answers to your specific "where does this happen" are bolded below, although it’s not quite as simple as you’re hoping for.

    Pre-internet, brick and mortar credit card transactions were a two stage process.

    At the time of a sale, when the merchant took a consumer’s credit card for a purchase they’d slide it through a point of sale device which would call into the credit card’s central office and ask "is this card authorized for this network, and is this particular consumer’s line of available credit large enough to allow this purchase".

    If the purchase was accepted (as opposed to declined), the charge was said to be authorized. The consumer would take their product, and the point of sale system/cash-register would note that the transaction was authorized. Then, at the end of a the day, or the end of the week, at some other predetermined regular schedule, or when the owner decided to stop drinking, the merchant would go though all their authorized receipts and send another request to the central office to capture the funds from the authorized transaction. Capturing the funds is what puts money in the merchant’s account.

    This is still the model in use by most gateways, and is the domain model that Magento Inc. chose to implement for their payment modules.

    The way things are supposed to run is, when a consumer reaches the final checkout steps in a system like Magento, Magento issues an authorization request to the gateway’s API. If the transaction is successful, the order is accepted into the system, and a unique ID from the authorization request is stored. Next, when the consumer’s goods ship, a store owner uses the Magento admin to create an invoice. The creation of this invoice issues a capture request (using a store id returned from the authorization request). This is where these method calls are issued in Magento.

    However, things get tricky because every payment gateway interprets these concepts a little differently, and every merchant interprets their "don’t capture until we’ve shipped" responsibilities differently. In addition to the scenario described above, payment modules have a system configuration value known as a Payment Action. This can be set to Authorize Only, which will implement the flow described above. It can also be set to Authorize and Capture, which will both authorize and capture a payment when the order is placed. It gets even more confusing because although the method is called Authorize and Capture, current versions of Magento will only issue the capture request when set in this mode (at least for Authorize.net), and Authorize.net will, internally, leave capture requests in an authorized but not captured state for most of the day. How Magento handles orders and payments and invoices is one area of the codebase that changes a lot from version to version.

    So, the idea behind the Magento payment module system is to shield you from the Cluster F— that is programming payment Gateway logic. In your authorize method you implement a call to your payment gateway’s authorize API (or perform whatever checks and logic you want to happen at this point). This method is passed a payment object and an amount. If you make you request/perform-your-logic and determine it’s invalid for whatever reason, you throw an Exception with

    Mage::throwException('...');
    

    This tells Magento the authorization failed, and it will act accordingly (show an error message, etc.). Otherwise, you set data members on the Payment object and issue a

    return $this;
    

    The data members are things you’ll need later, when capturing the payment. Which brings us to the capture method of your Payment module. This method is also sent a payment object and an amount. In this method you issue your capture request. The payment object will have cc_trans_id data member

    $payment->getCcTransId()
    

    which will allow you to issue a capture against your gateway. This is one of the data members you’re responsible for saving up in authorize. Again, if your code determines the capture has failed, you throw an exception. Otherwise, you return $this.

    The authorize.net payment module has good examples of how this is done.

    app/code/core/Mage/Paygate/Model/Authorizenet.php
    

    For example, consider this part of the capture method

    public function capture(Varien_Object $payment, $amount)
    {
        if ($payment->getCcTransId()) {
            $payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE);
        } else {
            $payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE);
        }   
        
        $payment->setAmount($amount);
        $request= $this->_buildRequest($payment);
        $result = $this->_postRequest($request);
        //...
        
    

    Here the capture method is checking if the payment has a cc_trans_id. Depending on the result, it sets anet_trans_type to either:

    self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE
    self::REQUEST_TYPE_AUTH_CAPTURE
    

    This value is then used by the API request object to send an API call for either

    1. Capturing a pre-authorized transaction
    2. Immediate capture
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on implementing bezier handles into my application. I have points and I
I am working on implementing Zend Framework within an existing project that has a
I'm currently working on a Google Maps project and am implementing a search function.
I'm working on a project for school, and I'm implementing a tool which can
Working on a project at the moment and we have to implement soft deletion
We're implementing a new solution in our classic ASP environment that's using COM interop
I am working on implementing a function that would execute another function a few
I am working on implementing tabs for my application. Everything is working well except
I'm working on implementing a reasonably simple XML serializer/deserializer (log file parser) application in
I'm working on a project in C# w/ XNA, and I want to reorganize

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.