X-Payments:Capturing payments when using X-Payments with Magento 2
Depending on the payment method settings, an order payment via X-Payments may be carried out in either the "Authorize" or the "Authorize and capture" mode.
In a workflow where an order payment is performed in the "Authorize" mode ("Initial transaction = Auth" in X-Payments and/or "Action = Authorize and capture" in Magento), it happens as a two-step process: at the time of order creation, you obtain an authorization for the order grand total amount; later you do a manual capture of the funds to initiate a transfer of the authorized amount from the buyer's account to your account. Note that you are guaranteed these funds only for a limited time (Typically, you have to capture a previously authorized amount within 30 days, but the time may vary by company, so you should check with your payment gateway).
In the "Authorize and capture" mode ("Initial transaction = Auth and capture" in the payment configuration settings in X-Payments and "Action = Authorize and capture" in the X-Payments connector payment method settings in Magento), an authorization and a capture are both performed at once at the time of order creation, so you do not need to worry about manually capturing the funds.
Below we discuss how to capture the funds for which an authorization has been obtained as a result of a buyer making a payment in the "Authorize" mode.
The recommended method to capture a previously authorized amount is based on creating an invoice. If required, multiple invoices can be created for a single order, each containing as many of the purchased items as you specify.
To perform a capture:
- In the Administrator panel, select Sales > Orders:
- In the Orders table, locate the order for which you want to perform a capture and click to open the order details.
- Choose to create a new invoice by clicking the Invoice button:
This opens a new invoice page:
- Scroll down to the Items to Invoice section.
This section provides a list of items you can invoice and their respective quantities. By default, the invoice will be created for the entire order. If you are going to invoice only some of the items and do a partial capture this time, update the quantities to invoice (specify the correct quantities in the Qty to invoice column and click the Update Qty's button).
The invoice totals will be re-calculated.Important: Before using partial capture, make sure your payment gateway supports this feature.
- Work through the invoicing process as usual: add a tracking number, create a packing slip, enter invoice comments as needed, specify whether a copy of the invoice needs to be emailed to the customer and whether your comments need to be appended to it.
- In the Amount field, select the payment action you require:
- Capture Online: Upon invoice submission, the invoice amount will be captured (a request to capture the specified amount will be sent through X-Payments to the payment gateway). After the capture, you will have the ability to create a credit memo should you require to issue a refund.
- Capture Offline: Upon invoice submission, the system will not capture the payment (no request to capture the payment will be sent). This option should be selected if the capture of funds is performed directly through the gateway or through the X-Payments back end. Note that after using the "Capture Offline" option you will no longer have the option to capture this payment through your Magento store. You will have the ability to create a credit memo.
- Not Capture: Upon invoice submission, the system will not capture the payment (no request to capture the payment will be sent). This option assumes that you will capture the payment at a later date. The completed invoice (you will be able to access it through Order View > Invoices) will have a Capture button allowing you to complete the task.
Before the payment is captured, you will able to cancel the invoice. After capturing you will be able to create a credit memo.Important: Do not select “Not Capture” unless you are certain that you are going to capture the payment through Magento at a later date. You will not be able to create a credit memo until the payment has been captured using the Capture button.
- Click the Submit Invoice button to process the invoice.
The invoice will be created. The selected payment action (Capture Online, Capture Offline or Not Capture) will be applied.
Now if you go back to the order details and click on the Invoices tab under the Order View menu, you should be able to see the new invoice added to the list of invoices pertaining to the order:
An invoice created with the "Capture Online" option or captured after it has been created with the "Not Capture" option will have the status Paid. The respective capture transaction will appear in the X-Payments back end with the status Charged.
An invoice created with the "Capture Offline" or "Not Capture" option will have the status Pending; no transaction will be reflected in X-Payments.