src/TransactionService.php
public function cancel(Transaction $transaction)
    {
        $cancelResult = $this->process($transaction, Operation::CANCEL);

        if ($transaction instanceof CreditCardTransaction
            && $cancelResult->getStatusCollection()->hasStatusCodes(['500.1057'])
        ) {
            return $this->process($transaction, Operation::REFUND);
        }

        return $cancelResult;
    }
public function cancel(Transaction $transaction)
    {
        $cancelResult = $this->process($transaction, Operation::CANCEL);

        if ($transaction instanceof CreditCardTransaction
            && $cancelResult->getStatusCollection()->hasStatusCodes(['500.1057'])
        ) {
            return $this->process($transaction, Operation::REFUND);
        }

        return $cancelResult;
    }
public function cancel ( Transaction $ transaction ) { $ cancelResult = $ this -> process ( $ transaction , Operation :: CANCEL ) ; if ( $ transaction instanceof CreditCardTransaction && $ cancelResult -> getStatusCollection ( ) -> hasStatusCodes ( [ '500.1057' ] ) ) { return $ this -> process ( $ transaction , Operation :: REFUND ) ; } return $ cancelResult ; }
If a failureResponse returns from the cancel process call
with a specific status code which declares that the credit card amount has already been settled,
we try a refund process call.

@param Transaction $transaction
@throws MalformedResponseException
@throws UnconfiguredPaymentMethodException
@throws \RuntimeException
@throws \InvalidArgumentException
@throws MandatoryFieldMissingException
@return FailureResponse|InteractionResponse|Response|SuccessResponse
If a failureResponse returns from the cancel process call with a specific status code which declares that the credit card amount has already been settled we try a refund process call .