Hello,
As I wrote, the bank system (we can't change its behaviour) manages the both results (OK and DOUBT), always as at the same "success" case but with different $post value (OK or DOUBT), so I defined a new method in register.php to be able to manage the different cases.
function complete_bps_pagopa()
{
global $xhtml_url, $Itemid;
$post = JFactory::getApplication()->input->post->getArray();
if($post['esito'] == 'OK') {
// PAGAMENTO EFFETTUATO CORRETTAMENTE
$mainframe = JFactory::getApplication();
GatewayFactory::setpostback();
// imposto il valore del transactionId visto che prima di chiamare il portale BPS no n l'ho fatto
// perchè lo script termina con un die()
$session = JFactory::getSession();
$joomartpay = $session->get('joomartpay', false);
//$joomartpay['transaction_id'] = $post['id_transazione'];
$joomartpay['transaction_id'] = $post['numero_avviso'];
$session->set('joomartpay', $joomartpay);
// --------------------- FINE aggiornamento sessione
$this->success();
$mainframe->redirect("index.php?option=com_dtregister&task=payment.success&Itemid=$Itemid");
exit;
die();
} elseif ($post['esito'] == 'KO') {
$msg = '<div class="alert alert-danger text-center" role="alert"><h3>' . JText::_('DT_PAYMENT_BPS_ESITO_KO') . '</h3></div>';
echo $msg . '<a href="' . JRoute::_('index.php', $xhtml_url) . '">' . JText::_('RETURN_TO_SITE') . '</a>';
} elseif ($post['esito'] == 'DOUBT') {
// PAGAMENTO DUBBIO
$mainframe = JFactory::getApplication();
GatewayFactory::setpostback();
// imposto il valore del transactionId visto che prima di chiamare il portale BPS no n l'ho fatto
// perchè lo script termina con un die()
$session = JFactory::getSession();
$joomartpay = $session->get('joomartpay', false);
//$joomartpay['transaction_id'] = $post['id_transazione'];
$joomartpay['transaction_id'] = $post['numero_avviso'];
$session->set('joomartpay', $joomartpay);
// --------------------- FINE aggiornamento sessione
$this->success(true);
//*** HERE I MUST INSERT THE CODE TO STORE THE PAYMENT AS PENDING ***//
$msg = '<div class="alert alert-warning text-center" role="alert"><h3>' . JText::_('DT_PAYMENT_BPS_ESITO_DIFFERITO') . '</h3></div>';
echo $msg . '<a href="' . JRoute::_('index.php', $xhtml_url) . '">' . JText::_('RETURN_TO_SITE') . '</a>';
}
}
Do you think it could be a good idea to manage the DOUBT case like the OK and then after $this->success(true) line, load the user model (getModel('user')) and update some fields in different tables?
regards,
Matt