magneto 2 failed payment cart cancelsCustom Payment Gateway IntegrationHow to integrate HDFC payment gateway in magento?Magento custom payment gateway Void invoicehow to repeat failed transaction - pay button, request payment etcHow to activate a “retry” in case of no payment status receive from Payment gateway to Magento?Prevent to empty cart after failed/canceled payments in magento 2Magento 1.9.2.1 Payment Module Form not appearingFailed Payment Redirect in Magento 2How to integrate new blockchain payment gateway?Magento 2 - Authorize.net payment failed in live mode

Why did my "seldom" get corrected?

Locked-up DOS computer beeped on keypress. What mechanism caused that?

How many opportunity attacks can you make per turn before becoming exhausted?

In this iconic lunar orbit rendezvous photo of John Houbolt, why do arrows #5 and #6 point the "wrong" way?

The most secure way to handle someone forgetting to verify their account?

Do pedestrians imitate auto traffic?

Company looks for long-term employees, but I know I won't be interested in staying long

How do I reproduce this layout and typography?

BritRail England Passes compared to return ticket for travel in England

Can error correction and detection be done without adding extra bits?

Should I have one hand on the throttle during engine ignition?

Why didn't Doctor Strange restore Tony Stark after he used the Stones?

Is it possible to invoke "super" with less ambiguous results?

Demographic consequences of closed loop reincarnation

What is the name for the average of the largest and the smallest values in a given data set?

Is encryption still applied if you ignore the SSL certificate warning for self-signed certs?

Is it possible to have a career in SciComp without contributing to arms research?

Applying for jobs with an obvious scar

Why do jet engines sound louder on the ground than inside the aircraft?

When will the last unambiguous evidence of mankind disappear?

Why is Google approaching my VPS machine?

What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?

I have found a mistake on someone's code published online: what is the protocol?

How important are the Author's mood and feelings for writing a story?



magneto 2 failed payment cart cancels


Custom Payment Gateway IntegrationHow to integrate HDFC payment gateway in magento?Magento custom payment gateway Void invoicehow to repeat failed transaction - pay button, request payment etcHow to activate a “retry” in case of no payment status receive from Payment gateway to Magento?Prevent to empty cart after failed/canceled payments in magento 2Magento 1.9.2.1 Payment Module Form not appearingFailed Payment Redirect in Magento 2How to integrate new blockchain payment gateway?Magento 2 - Authorize.net payment failed in live mode






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















When someone places an order on Magento 2 with viva wallet it cancels the order if the payment fails
can this code be changed so it doesnt cancels the order but redirect to payment failed but keeps the original cart so the customer can just change payment method or try a different card with out having to add the item back in the cart



<?php

namespace CedVivaPaymentsControllerViva;

use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoFrameworkAppActionAction as AppAction;
use Exception;

class Callback extends AppAction
{
/**
* @var CedVivaPaymentsModelPaymentMethod
*/
protected $_paymentMethod;

/**
* @var MagentoSalesModelOrder
*/
protected $_order;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var MagentoSalesModelOrderEmailSenderOrderSender
*/
protected $_orderSender;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;

private $_messageManager;


/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoSalesModelOrderFactory $orderFactory
* @param CedVivaPaymentsModelPaymentMethod $paymentMethod
* @param MagentoSalesModelOrderEmailSenderOrderSender $orderSender
* @param PsrLogLoggerInterface $logger
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelOrderFactory $orderFactory,
CedVivaPaymentsModelPaymentMethod $paymentMethod,
MagentoSalesModelOrderEmailSenderOrderSender $orderSender,
MagentoFrameworkMessageManagerInterface $messageManager,
PsrLogLoggerInterface $logger
)

$this->_paymentMethod = $paymentMethod;
$this->_orderFactory = $orderFactory;
$this->_client = $this->_paymentMethod->getClient();
$this->_orderSender = $orderSender;
$this->_messageManager = $messageManager;
$this->_logger = $logger;
parent::__construct($context);


public function execute()

try
$this->_success();
$this->paymentAction();

catch (Exception $e)
return $this->_failure();



public function getOrderId()
return $this->_objectManager->get('MagentoCheckoutModelSession')->getLastRealOrderId();


protected function paymentAction()

$payment_order = $this->getRequest()->getParam('s');
$transactionId = $this->getRequest()->getParam('t');

$OrderCode = $payment_order;
$Lang = $this->getRequest()->getParam('lang');
$order_id = $this->getOrderId();
$update_order = $this->_objectManager->create('CedVivaPaymentsModelVivaPayments')->load($OrderCode, 'ordercode');
$this->_loadOrder($order_id);

$MerchantID = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantid');

$APIKey = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantpass');

$request = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/transaction_url');

$getargs = '?ordercode='.urlencode($OrderCode);

$session = curl_init($request);

curl_setopt($session, CURLOPT_HTTPGET, true);
curl_setopt($session, CURLOPT_URL, $request . $getargs);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_USERPWD, $MerchantID.':'.$APIKey);
$curlversion = curl_version();
if(!preg_match("/NSS/" , $curlversion['ssl_version']))
curl_setopt($session, CURLOPT_SSL_CIPHER_LIST, "TLSv1");


$response = curl_exec($session);
curl_close($session);
try

if(is_object(json_decode($response)))
$resultObj=json_decode($response);

catch( Exception $e )
echo $e->getMessage();


if ($resultObj->ErrorCode==0)
if(sizeof($resultObj->Transactions) > 0)
foreach ($resultObj->Transactions as $t)
$TransactionId = $t->TransactionId;
$Amount = $t->Amount;
$StatusId = $t->StatusId;
$CustomerTrns = $t->CustomerTrns ;
$message = "Transactions completed Successfully";
$update_order->setOrderState('paid')->save();

else
$update_order->setOrderState('failed')->save();
$message = 'No transactions found. Make sure the order code exists and is created by your account.';

else
$update_order->setOrderState('failed')->save();
$message = 'The following error occured: <strong>' . $resultObj->ErrorCode . '</strong>, ' . $resultObj->ErrorText;


if(isset($StatusId) && strtoupper($StatusId) == 'F')

else


$this->_createVivaPaymentsComment($message);
$this->_order->cancel()->save();
$this->_messageManager->addError("<strong>Error: </strong>" .__('Your transaction failed or has been cancelled! Please Try an alternative payment card.'). "<br/>");
$this->_redirect('checkout/cart');





protected function _registerPaymentCapture($transactionId, $amount, $message)

$payment = $this->_order->getPayment();


$payment->setTransactionId($transactionId)
->setPreparedMessage($this->_createVivaPaymentsComment($message))
->setShouldCloseParentTransaction(false)
->setIsTransactionClosed(0)
->registerCaptureNotification(
$amount,
true
);

$this->_order->save();

$invoice = $payment->getCreatedInvoice();
if ($invoice && !$this->_order->getEmailSent())
$this->_orderSender->send($this->_order);
$this->_order->addStatusHistoryComment(
__('You notified customer about invoice #%1.', $invoice->getIncrementId())
)->setIsCustomerNotified(
true
)->save();



protected function _loadOrder($order_id)

$this->_order = $this->_orderFactory->create()->loadByIncrementId($order_id);

if (!$this->_order && $this->_order->getId())
throw new Exception('Could not find Magento order with id $order_id');



protected function _success()

$this->getResponse()
->setStatusHeader(200);


protected function _failure()

$this->getResponse()
->setStatusHeader(400);


protected function _createVivaPaymentsComment($message = '')

if ($message != '')

$message = $this->_order->addStatusHistoryComment($message);
$message->setIsCustomerNotified(null);

return $message;










share|improve this question
























  • okay cool. and what is your question? we can not provide support for Ced_VivaPayments. ask the developer for support

    – Philipp Sander
    Jul 10 at 14:58











  • Well well @PhilippSander You didnt get this. Developer himself asking question ;)

    – Vivek
    Jul 11 at 9:01

















0















When someone places an order on Magento 2 with viva wallet it cancels the order if the payment fails
can this code be changed so it doesnt cancels the order but redirect to payment failed but keeps the original cart so the customer can just change payment method or try a different card with out having to add the item back in the cart



<?php

namespace CedVivaPaymentsControllerViva;

use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoFrameworkAppActionAction as AppAction;
use Exception;

class Callback extends AppAction
{
/**
* @var CedVivaPaymentsModelPaymentMethod
*/
protected $_paymentMethod;

/**
* @var MagentoSalesModelOrder
*/
protected $_order;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var MagentoSalesModelOrderEmailSenderOrderSender
*/
protected $_orderSender;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;

private $_messageManager;


/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoSalesModelOrderFactory $orderFactory
* @param CedVivaPaymentsModelPaymentMethod $paymentMethod
* @param MagentoSalesModelOrderEmailSenderOrderSender $orderSender
* @param PsrLogLoggerInterface $logger
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelOrderFactory $orderFactory,
CedVivaPaymentsModelPaymentMethod $paymentMethod,
MagentoSalesModelOrderEmailSenderOrderSender $orderSender,
MagentoFrameworkMessageManagerInterface $messageManager,
PsrLogLoggerInterface $logger
)

$this->_paymentMethod = $paymentMethod;
$this->_orderFactory = $orderFactory;
$this->_client = $this->_paymentMethod->getClient();
$this->_orderSender = $orderSender;
$this->_messageManager = $messageManager;
$this->_logger = $logger;
parent::__construct($context);


public function execute()

try
$this->_success();
$this->paymentAction();

catch (Exception $e)
return $this->_failure();



public function getOrderId()
return $this->_objectManager->get('MagentoCheckoutModelSession')->getLastRealOrderId();


protected function paymentAction()

$payment_order = $this->getRequest()->getParam('s');
$transactionId = $this->getRequest()->getParam('t');

$OrderCode = $payment_order;
$Lang = $this->getRequest()->getParam('lang');
$order_id = $this->getOrderId();
$update_order = $this->_objectManager->create('CedVivaPaymentsModelVivaPayments')->load($OrderCode, 'ordercode');
$this->_loadOrder($order_id);

$MerchantID = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantid');

$APIKey = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantpass');

$request = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/transaction_url');

$getargs = '?ordercode='.urlencode($OrderCode);

$session = curl_init($request);

curl_setopt($session, CURLOPT_HTTPGET, true);
curl_setopt($session, CURLOPT_URL, $request . $getargs);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_USERPWD, $MerchantID.':'.$APIKey);
$curlversion = curl_version();
if(!preg_match("/NSS/" , $curlversion['ssl_version']))
curl_setopt($session, CURLOPT_SSL_CIPHER_LIST, "TLSv1");


$response = curl_exec($session);
curl_close($session);
try

if(is_object(json_decode($response)))
$resultObj=json_decode($response);

catch( Exception $e )
echo $e->getMessage();


if ($resultObj->ErrorCode==0)
if(sizeof($resultObj->Transactions) > 0)
foreach ($resultObj->Transactions as $t)
$TransactionId = $t->TransactionId;
$Amount = $t->Amount;
$StatusId = $t->StatusId;
$CustomerTrns = $t->CustomerTrns ;
$message = "Transactions completed Successfully";
$update_order->setOrderState('paid')->save();

else
$update_order->setOrderState('failed')->save();
$message = 'No transactions found. Make sure the order code exists and is created by your account.';

else
$update_order->setOrderState('failed')->save();
$message = 'The following error occured: <strong>' . $resultObj->ErrorCode . '</strong>, ' . $resultObj->ErrorText;


if(isset($StatusId) && strtoupper($StatusId) == 'F')

else


$this->_createVivaPaymentsComment($message);
$this->_order->cancel()->save();
$this->_messageManager->addError("<strong>Error: </strong>" .__('Your transaction failed or has been cancelled! Please Try an alternative payment card.'). "<br/>");
$this->_redirect('checkout/cart');





protected function _registerPaymentCapture($transactionId, $amount, $message)

$payment = $this->_order->getPayment();


$payment->setTransactionId($transactionId)
->setPreparedMessage($this->_createVivaPaymentsComment($message))
->setShouldCloseParentTransaction(false)
->setIsTransactionClosed(0)
->registerCaptureNotification(
$amount,
true
);

$this->_order->save();

$invoice = $payment->getCreatedInvoice();
if ($invoice && !$this->_order->getEmailSent())
$this->_orderSender->send($this->_order);
$this->_order->addStatusHistoryComment(
__('You notified customer about invoice #%1.', $invoice->getIncrementId())
)->setIsCustomerNotified(
true
)->save();



protected function _loadOrder($order_id)

$this->_order = $this->_orderFactory->create()->loadByIncrementId($order_id);

if (!$this->_order && $this->_order->getId())
throw new Exception('Could not find Magento order with id $order_id');



protected function _success()

$this->getResponse()
->setStatusHeader(200);


protected function _failure()

$this->getResponse()
->setStatusHeader(400);


protected function _createVivaPaymentsComment($message = '')

if ($message != '')

$message = $this->_order->addStatusHistoryComment($message);
$message->setIsCustomerNotified(null);

return $message;










share|improve this question
























  • okay cool. and what is your question? we can not provide support for Ced_VivaPayments. ask the developer for support

    – Philipp Sander
    Jul 10 at 14:58











  • Well well @PhilippSander You didnt get this. Developer himself asking question ;)

    – Vivek
    Jul 11 at 9:01













0












0








0








When someone places an order on Magento 2 with viva wallet it cancels the order if the payment fails
can this code be changed so it doesnt cancels the order but redirect to payment failed but keeps the original cart so the customer can just change payment method or try a different card with out having to add the item back in the cart



<?php

namespace CedVivaPaymentsControllerViva;

use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoFrameworkAppActionAction as AppAction;
use Exception;

class Callback extends AppAction
{
/**
* @var CedVivaPaymentsModelPaymentMethod
*/
protected $_paymentMethod;

/**
* @var MagentoSalesModelOrder
*/
protected $_order;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var MagentoSalesModelOrderEmailSenderOrderSender
*/
protected $_orderSender;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;

private $_messageManager;


/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoSalesModelOrderFactory $orderFactory
* @param CedVivaPaymentsModelPaymentMethod $paymentMethod
* @param MagentoSalesModelOrderEmailSenderOrderSender $orderSender
* @param PsrLogLoggerInterface $logger
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelOrderFactory $orderFactory,
CedVivaPaymentsModelPaymentMethod $paymentMethod,
MagentoSalesModelOrderEmailSenderOrderSender $orderSender,
MagentoFrameworkMessageManagerInterface $messageManager,
PsrLogLoggerInterface $logger
)

$this->_paymentMethod = $paymentMethod;
$this->_orderFactory = $orderFactory;
$this->_client = $this->_paymentMethod->getClient();
$this->_orderSender = $orderSender;
$this->_messageManager = $messageManager;
$this->_logger = $logger;
parent::__construct($context);


public function execute()

try
$this->_success();
$this->paymentAction();

catch (Exception $e)
return $this->_failure();



public function getOrderId()
return $this->_objectManager->get('MagentoCheckoutModelSession')->getLastRealOrderId();


protected function paymentAction()

$payment_order = $this->getRequest()->getParam('s');
$transactionId = $this->getRequest()->getParam('t');

$OrderCode = $payment_order;
$Lang = $this->getRequest()->getParam('lang');
$order_id = $this->getOrderId();
$update_order = $this->_objectManager->create('CedVivaPaymentsModelVivaPayments')->load($OrderCode, 'ordercode');
$this->_loadOrder($order_id);

$MerchantID = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantid');

$APIKey = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantpass');

$request = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/transaction_url');

$getargs = '?ordercode='.urlencode($OrderCode);

$session = curl_init($request);

curl_setopt($session, CURLOPT_HTTPGET, true);
curl_setopt($session, CURLOPT_URL, $request . $getargs);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_USERPWD, $MerchantID.':'.$APIKey);
$curlversion = curl_version();
if(!preg_match("/NSS/" , $curlversion['ssl_version']))
curl_setopt($session, CURLOPT_SSL_CIPHER_LIST, "TLSv1");


$response = curl_exec($session);
curl_close($session);
try

if(is_object(json_decode($response)))
$resultObj=json_decode($response);

catch( Exception $e )
echo $e->getMessage();


if ($resultObj->ErrorCode==0)
if(sizeof($resultObj->Transactions) > 0)
foreach ($resultObj->Transactions as $t)
$TransactionId = $t->TransactionId;
$Amount = $t->Amount;
$StatusId = $t->StatusId;
$CustomerTrns = $t->CustomerTrns ;
$message = "Transactions completed Successfully";
$update_order->setOrderState('paid')->save();

else
$update_order->setOrderState('failed')->save();
$message = 'No transactions found. Make sure the order code exists and is created by your account.';

else
$update_order->setOrderState('failed')->save();
$message = 'The following error occured: <strong>' . $resultObj->ErrorCode . '</strong>, ' . $resultObj->ErrorText;


if(isset($StatusId) && strtoupper($StatusId) == 'F')

else


$this->_createVivaPaymentsComment($message);
$this->_order->cancel()->save();
$this->_messageManager->addError("<strong>Error: </strong>" .__('Your transaction failed or has been cancelled! Please Try an alternative payment card.'). "<br/>");
$this->_redirect('checkout/cart');





protected function _registerPaymentCapture($transactionId, $amount, $message)

$payment = $this->_order->getPayment();


$payment->setTransactionId($transactionId)
->setPreparedMessage($this->_createVivaPaymentsComment($message))
->setShouldCloseParentTransaction(false)
->setIsTransactionClosed(0)
->registerCaptureNotification(
$amount,
true
);

$this->_order->save();

$invoice = $payment->getCreatedInvoice();
if ($invoice && !$this->_order->getEmailSent())
$this->_orderSender->send($this->_order);
$this->_order->addStatusHistoryComment(
__('You notified customer about invoice #%1.', $invoice->getIncrementId())
)->setIsCustomerNotified(
true
)->save();



protected function _loadOrder($order_id)

$this->_order = $this->_orderFactory->create()->loadByIncrementId($order_id);

if (!$this->_order && $this->_order->getId())
throw new Exception('Could not find Magento order with id $order_id');



protected function _success()

$this->getResponse()
->setStatusHeader(200);


protected function _failure()

$this->getResponse()
->setStatusHeader(400);


protected function _createVivaPaymentsComment($message = '')

if ($message != '')

$message = $this->_order->addStatusHistoryComment($message);
$message->setIsCustomerNotified(null);

return $message;










share|improve this question
















When someone places an order on Magento 2 with viva wallet it cancels the order if the payment fails
can this code be changed so it doesnt cancels the order but redirect to payment failed but keeps the original cart so the customer can just change payment method or try a different card with out having to add the item back in the cart



<?php

namespace CedVivaPaymentsControllerViva;

use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoFrameworkAppActionAction as AppAction;
use Exception;

class Callback extends AppAction
{
/**
* @var CedVivaPaymentsModelPaymentMethod
*/
protected $_paymentMethod;

/**
* @var MagentoSalesModelOrder
*/
protected $_order;

/**
* @var MagentoSalesModelOrderFactory
*/
protected $_orderFactory;

/**
* @var MagentoSalesModelOrderEmailSenderOrderSender
*/
protected $_orderSender;

/**
* @var PsrLogLoggerInterface
*/
protected $_logger;

private $_messageManager;


/**
* @param MagentoFrameworkAppActionContext $context
* @param MagentoSalesModelOrderFactory $orderFactory
* @param CedVivaPaymentsModelPaymentMethod $paymentMethod
* @param MagentoSalesModelOrderEmailSenderOrderSender $orderSender
* @param PsrLogLoggerInterface $logger
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelOrderFactory $orderFactory,
CedVivaPaymentsModelPaymentMethod $paymentMethod,
MagentoSalesModelOrderEmailSenderOrderSender $orderSender,
MagentoFrameworkMessageManagerInterface $messageManager,
PsrLogLoggerInterface $logger
)

$this->_paymentMethod = $paymentMethod;
$this->_orderFactory = $orderFactory;
$this->_client = $this->_paymentMethod->getClient();
$this->_orderSender = $orderSender;
$this->_messageManager = $messageManager;
$this->_logger = $logger;
parent::__construct($context);


public function execute()

try
$this->_success();
$this->paymentAction();

catch (Exception $e)
return $this->_failure();



public function getOrderId()
return $this->_objectManager->get('MagentoCheckoutModelSession')->getLastRealOrderId();


protected function paymentAction()

$payment_order = $this->getRequest()->getParam('s');
$transactionId = $this->getRequest()->getParam('t');

$OrderCode = $payment_order;
$Lang = $this->getRequest()->getParam('lang');
$order_id = $this->getOrderId();
$update_order = $this->_objectManager->create('CedVivaPaymentsModelVivaPayments')->load($OrderCode, 'ordercode');
$this->_loadOrder($order_id);

$MerchantID = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantid');

$APIKey = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/merchantpass');

$request = $this->_objectManager->create('MagentoFrameworkAppConfigScopeConfigInterface')->getValue('payment/paymentmethod/transaction_url');

$getargs = '?ordercode='.urlencode($OrderCode);

$session = curl_init($request);

curl_setopt($session, CURLOPT_HTTPGET, true);
curl_setopt($session, CURLOPT_URL, $request . $getargs);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_USERPWD, $MerchantID.':'.$APIKey);
$curlversion = curl_version();
if(!preg_match("/NSS/" , $curlversion['ssl_version']))
curl_setopt($session, CURLOPT_SSL_CIPHER_LIST, "TLSv1");


$response = curl_exec($session);
curl_close($session);
try

if(is_object(json_decode($response)))
$resultObj=json_decode($response);

catch( Exception $e )
echo $e->getMessage();


if ($resultObj->ErrorCode==0)
if(sizeof($resultObj->Transactions) > 0)
foreach ($resultObj->Transactions as $t)
$TransactionId = $t->TransactionId;
$Amount = $t->Amount;
$StatusId = $t->StatusId;
$CustomerTrns = $t->CustomerTrns ;
$message = "Transactions completed Successfully";
$update_order->setOrderState('paid')->save();

else
$update_order->setOrderState('failed')->save();
$message = 'No transactions found. Make sure the order code exists and is created by your account.';

else
$update_order->setOrderState('failed')->save();
$message = 'The following error occured: <strong>' . $resultObj->ErrorCode . '</strong>, ' . $resultObj->ErrorText;


if(isset($StatusId) && strtoupper($StatusId) == 'F')

else


$this->_createVivaPaymentsComment($message);
$this->_order->cancel()->save();
$this->_messageManager->addError("<strong>Error: </strong>" .__('Your transaction failed or has been cancelled! Please Try an alternative payment card.'). "<br/>");
$this->_redirect('checkout/cart');





protected function _registerPaymentCapture($transactionId, $amount, $message)

$payment = $this->_order->getPayment();


$payment->setTransactionId($transactionId)
->setPreparedMessage($this->_createVivaPaymentsComment($message))
->setShouldCloseParentTransaction(false)
->setIsTransactionClosed(0)
->registerCaptureNotification(
$amount,
true
);

$this->_order->save();

$invoice = $payment->getCreatedInvoice();
if ($invoice && !$this->_order->getEmailSent())
$this->_orderSender->send($this->_order);
$this->_order->addStatusHistoryComment(
__('You notified customer about invoice #%1.', $invoice->getIncrementId())
)->setIsCustomerNotified(
true
)->save();



protected function _loadOrder($order_id)

$this->_order = $this->_orderFactory->create()->loadByIncrementId($order_id);

if (!$this->_order && $this->_order->getId())
throw new Exception('Could not find Magento order with id $order_id');



protected function _success()

$this->getResponse()
->setStatusHeader(200);


protected function _failure()

$this->getResponse()
->setStatusHeader(400);


protected function _createVivaPaymentsComment($message = '')

if ($message != '')

$message = $this->_order->addStatusHistoryComment($message);
$message->setIsCustomerNotified(null);

return $message;







payment-gateway






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 10 at 14:53









Raj Mohan R

1,6213 silver badges13 bronze badges




1,6213 silver badges13 bronze badges










asked Jul 10 at 13:31









Alex BeckAlex Beck

1




1












  • okay cool. and what is your question? we can not provide support for Ced_VivaPayments. ask the developer for support

    – Philipp Sander
    Jul 10 at 14:58











  • Well well @PhilippSander You didnt get this. Developer himself asking question ;)

    – Vivek
    Jul 11 at 9:01

















  • okay cool. and what is your question? we can not provide support for Ced_VivaPayments. ask the developer for support

    – Philipp Sander
    Jul 10 at 14:58











  • Well well @PhilippSander You didnt get this. Developer himself asking question ;)

    – Vivek
    Jul 11 at 9:01
















okay cool. and what is your question? we can not provide support for Ced_VivaPayments. ask the developer for support

– Philipp Sander
Jul 10 at 14:58





okay cool. and what is your question? we can not provide support for Ced_VivaPayments. ask the developer for support

– Philipp Sander
Jul 10 at 14:58













Well well @PhilippSander You didnt get this. Developer himself asking question ;)

– Vivek
Jul 11 at 9:01





Well well @PhilippSander You didnt get this. Developer himself asking question ;)

– Vivek
Jul 11 at 9:01










0






active

oldest

votes














Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f281580%2fmagneto-2-failed-payment-cart-cancels%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f281580%2fmagneto-2-failed-payment-cart-cancels%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form