Model/Payment.php
public function capture(InfoInterface $payment, $amount)
    {
        try {
            $order = $payment->getOrder();

            if ($amount <= 0) {
                throw new LocalizedException(__('Invalid amount for capture.'));
            }

            $realTransactionId = $payment->getAdditionalInformation('real_transaction_id');

            if (empty($realTransactionId)) {
                throw new LocalizedException(
                    __('Please wait while transaction get updated from Bolt.')
                );
            }

            $captureAmount = $amount * 100;

            //Get capture data
            $capturedData = [
                'transaction_id' => $realTransactionId,
                'amount'         => $captureAmount,
                'currency'       => $order->getOrderCurrencyCode()
            ];

            $apiKey = $this->configHelper->getApiKey();

            //Request Data
            $requestData = $this->dataObjectFactory->create();
            $requestData->setApiData($capturedData);
            $requestData->setDynamicApiUrl(ApiHelper::API_CAPTURE_TRANSACTION);
            $requestData->setApiKey($apiKey);

            //Build Request
            $request = $this->apiHelper->buildRequest($requestData);
            $result = $this->apiHelper->sendRequest($request);
            $response = $result->getResponse();

            if (empty($response)) {
                throw new LocalizedException(
                    __('Bad capture response from boltpay')
                );
            }

            if (!in_array(@$response->status, [self::TRANSACTION_AUTHORIZED, self::TRANSACTION_COMPLETED])) {
                throw new LocalizedException(__('Payment capture error.'));
            }

            $this->orderHelper->updateOrderPayment($order, null, $response->reference);

            return $this;
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }
public function capture(InfoInterface $payment, $amount)
    {
        try {
            $order = $payment->getOrder();

            if ($amount <= 0) {
                throw new LocalizedException(__('Invalid amount for capture.'));
            }

            $realTransactionId = $payment->getAdditionalInformation('real_transaction_id');

            if (empty($realTransactionId)) {
                throw new LocalizedException(
                    __('Please wait while transaction get updated from Bolt.')
                );
            }

            $captureAmount = $amount * 100;

            //Get capture data
            $capturedData = [
                'transaction_id' => $realTransactionId,
                'amount'         => $captureAmount,
                'currency'       => $order->getOrderCurrencyCode()
            ];

            $apiKey = $this->configHelper->getApiKey();

            //Request Data
            $requestData = $this->dataObjectFactory->create();
            $requestData->setApiData($capturedData);
            $requestData->setDynamicApiUrl(ApiHelper::API_CAPTURE_TRANSACTION);
            $requestData->setApiKey($apiKey);

            //Build Request
            $request = $this->apiHelper->buildRequest($requestData);
            $result = $this->apiHelper->sendRequest($request);
            $response = $result->getResponse();

            if (empty($response)) {
                throw new LocalizedException(
                    __('Bad capture response from boltpay')
                );
            }

            if (!in_array(@$response->status, [self::TRANSACTION_AUTHORIZED, self::TRANSACTION_COMPLETED])) {
                throw new LocalizedException(__('Payment capture error.'));
            }

            $this->orderHelper->updateOrderPayment($order, null, $response->reference);

            return $this;
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }
public function capture ( InfoInterface $ payment , $ amount ) { try { $ order = $ payment -> getOrder ( ) ; if ( $ amount <= 0 ) { throw new LocalizedException ( __ ( 'Invalid amount for capture.' ) ) ; } $ realTransactionId = $ payment -> getAdditionalInformation ( 'real_transaction_id' ) ; if ( empty ( $ realTransactionId ) ) { throw new LocalizedException ( __ ( 'Please wait while transaction get updated from Bolt.' ) ) ; } $ captureAmount = $ amount * 100 ; //Get capture data $ capturedData = [ 'transaction_id' => $ realTransactionId , 'amount' => $ captureAmount , 'currency' => $ order -> getOrderCurrencyCode ( ) ] ; $ apiKey = $ this -> configHelper -> getApiKey ( ) ; //Request Data $ requestData = $ this -> dataObjectFactory -> create ( ) ; $ requestData -> setApiData ( $ capturedData ) ; $ requestData -> setDynamicApiUrl ( ApiHelper :: API_CAPTURE_TRANSACTION ) ; $ requestData -> setApiKey ( $ apiKey ) ; //Build Request $ request = $ this -> apiHelper -> buildRequest ( $ requestData ) ; $ result = $ this -> apiHelper -> sendRequest ( $ request ) ; $ response = $ result -> getResponse ( ) ; if ( empty ( $ response ) ) { throw new LocalizedException ( __ ( 'Bad capture response from boltpay' ) ) ; } if ( ! in_array ( @ $ response -> status , [ self :: TRANSACTION_AUTHORIZED , self :: TRANSACTION_COMPLETED ] ) ) { throw new LocalizedException ( __ ( 'Payment capture error.' ) ) ; } $ this -> orderHelper -> updateOrderPayment ( $ order , null , $ response -> reference ) ; return $ this ; } catch ( \ Exception $ e ) { $ this -> bugsnag -> notifyException ( $ e ) ; throw $ e ; } }
Capture the authorized transaction through the gateway

@param InfoInterface $payment
@param float $amount

@return $this
@throws \Exception
Capture the authorized transaction through the gateway