Hello, I'm completely new to Magento and I was trying to create a custom payment option for version 2.3, but I haven't been able to achieve what is described in the title. My goal was to create a custom method for CC and, depending on the result on the CC Provider, deny the transaction directly and redirect the user to the fail page rather than the success page.
The plugin is accessible in both the backend and the frontend, however no matter what I do it always redirects to the success page and the order status ends up as processing. Payment model is extending directly from
\Magento\Payment\Model\Method\Cc
I've tried to change the payment status from the authorize method, using the below code:
if(isset($response['tid'])) { // Successful auth request.
// Set the transaction id on the payment so the capture request knows auth has happened.
$payment->setTransactionId($response['tid']);
$payment->setParentTransactionId($response['tid']);
}
//directly deny transaction
$payment->setIsTransactionPending(false);
$payment->setIsTransactionDenied(1);
//processing is not done yet.
$payment->setIsTransactionClosed(0);
return $this;
however the transaction still goes back to the success page and it shows as processing in the status.
How can I achieve this, what am I missing? Any help is highly appreciated, thank you very much.