How do I capture a payment in my payment driver?

If the gateway provides the option to defer capturing the payment (authorising and capturing are performed at different times), the capture method should be implemented. This captured amount may be equal to or less than the authorised amount, and is always passed to the method in the lowest form of currency (pennies, cents, etc.).

The capture method should return a Aero\Payment\Responses\PaymentResponse instance.

public function capture(int $amount, Payment $payment)
    $response = new \Aero\Payment\Responses\PaymentResponse();

    // request to capture the transaction using the 3rd party API
    $capture = AcmePaymentsInc::captureTransaction($payment->reference, $amount);

    // check if the transaction status is "captured"
    if ($capture->status !== AcmePaymentsInc::STATUS_CAPTURED) {
        // update the status of the aero payment to "failed"
            'state' => \Aero\Payment\Models\Payment::FAILED,

        // set an error on the response
        $response->setError('The transaction failed to be captured.');

        return $response;

    // internally capture the amount for the payment
        'amount' => $amount,

    // mark the response as successful

    return $response;


Aero will attempt to auto-capture any authorised payments against an order when the order is marked as dispatched.

Articles in this section

Was this article helpful?
0 out of 0 found this helpful