modiying If I understand your question correctly, you can check if a payment was successful or not before adding the status to the order and marking the order as processed. Only orders marked as processed, and with statuses other than the cancelled order statuses
are successful. See how its done in the Stripe payment class.
This is an extract from Igniter\PayRegister\Payments\Stripe
class, processPaymentForm
method
if (!$response->isSuccessful()) {
$order->logPaymentAttempt('Payment error -> '.$response->getMessage(), 1, $fields, $response->getData());
throw new Exception($response->getMessage());
}
$order->logPaymentAttempt('Payment successful', 1, $fields, $response->getData());
$order->updateOrderStatus($host->order_status, ['notify' => FALSE]);
$order->markAsPaymentProcessed();