cancel
Showing results for 
Search instead for 
Did you mean: 

Invoice and Capture

Invoice and Capture

Hi to all!

I am trying to understand how Invoice creation and Capture works and would like to ask few questions.

I am working on custom payment module with following settings

 

protected $_canCapture = true;

protected $_canCapturePartial = true;

 

After the Order is created it is with Auth status and wait for Settle. So I go to Order Invoice menu and create Online Invoice.

I have two observers for the Invoice - Register and AfterSave. In Register I set the Invoice status to be Open. In AfterSave I do the real Online Settle process and get some response. My problem is when I got Decline Response. After the invoice is saved I have Capture Transaction and Invoice (Pending or Paid, depends of status I set into Register Observer)

And the question - can I go throw Invoice logic but stop Magento doing Capture and Invoice, I can try make them when get the response from the Online process?

At the moment I tried to delete the Transaction and the Invoice after Decline. I did it, but the Invoice menu is not visible anymore, looks like its visibility depends not only form the deleted Transaction and Invoice. If this approach is not wrong, what else I need to do so I can get Invoice menu back, so I can try Settle again?

 

Thanks and Regards!

1 REPLY 1

Re: Invoice and Capture

To prevent unwanted captures on the decline in your Magento invoice module:

  1. Control Capture Logic: Override capture() to process settlement first. Only create a capture transaction if approved.
  2. Disable Auto-Capture: Set $_canCapture = false and handle it manually.
  3. Keep Invoice Visible on Decline: Instead of deleting, set the invoice state to Pending using $invoice->setState(\Magento\Sales\Model\Order\Invoice:Smiley FrustratedTATE_OPEN)->save();.
  4. Enable Retry: Implement an admin action to retry settlement while keeping the invoice Open.