Model/Payment.php
public function void(InfoInterface $payment)
    {
        try {
            $transactionId = $payment->getAdditionalInformation('real_transaction_id');

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

            //Get transaction data
            $transactionData = ['transaction_id' => $transactionId];
            $apiKey = $this->configHelper->getApiKey();

            //Request Data
            $requestData = $this->dataObjectFactory->create();
            $requestData->setApiData($transactionData);
            $requestData->setDynamicApiUrl(ApiHelper::API_VOID_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 void response from boltpay')
                );
            }

            if (@$response->status != 'cancelled') {
                throw new LocalizedException(__('Payment void error.'));
            }

            $order = $payment->getOrder();

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

            return $this;
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }
public function void(InfoInterface $payment)
    {
        try {
            $transactionId = $payment->getAdditionalInformation('real_transaction_id');

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

            //Get transaction data
            $transactionData = ['transaction_id' => $transactionId];
            $apiKey = $this->configHelper->getApiKey();

            //Request Data
            $requestData = $this->dataObjectFactory->create();
            $requestData->setApiData($transactionData);
            $requestData->setDynamicApiUrl(ApiHelper::API_VOID_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 void response from boltpay')
                );
            }

            if (@$response->status != 'cancelled') {
                throw new LocalizedException(__('Payment void error.'));
            }

            $order = $payment->getOrder();

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

            return $this;
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }
public function void ( InfoInterface $ payment ) { try { $ transactionId = $ payment -> getAdditionalInformation ( 'real_transaction_id' ) ; if ( empty ( $ transactionId ) ) { throw new LocalizedException ( __ ( 'Please wait while transaction gets updated from Bolt.' ) ) ; } //Get transaction data $ transactionData = [ 'transaction_id' => $ transactionId ] ; $ apiKey = $ this -> configHelper -> getApiKey ( ) ; //Request Data $ requestData = $ this -> dataObjectFactory -> create ( ) ; $ requestData -> setApiData ( $ transactionData ) ; $ requestData -> setDynamicApiUrl ( ApiHelper :: API_VOID_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 void response from boltpay' ) ) ; } if ( @ $ response -> status != 'cancelled' ) { throw new LocalizedException ( __ ( 'Payment void error.' ) ) ; } $ order = $ payment -> getOrder ( ) ; $ this -> orderHelper -> updateOrderPayment ( $ order , null , $ response -> reference ) ; return $ this ; } catch ( \ Exception $ e ) { $ this -> bugsnag -> notifyException ( $ e ) ; throw $ e ; } }
Void the payment through gateway

@param DataObject|InfoInterface $payment

@return $this
@throws \Exception
Void the payment through gateway