function returnAfterPayment() { // Check for request forgeries //JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN')); // token cannot be check as return data will be different for different gateways make impossible. $app = JFactory::getApplication(); $rawDataPost = $app->input->post->getArray(); $rawDataGet = $app->input->get->getArray(); $data = array_merge($rawDataGet, $rawDataPost); $gwayName = $app->input->get('gateway', '', 'string'); $isValid = false; if (!empty($gwayName)) { $payconfig = JblanceHelper::getPaymodeInfo($gwayName); //get the payment config of the gateway require_once JPATH_SITE . '/components/com_jblance/gateways/class.' . $gwayName . '.php'; $className = $gwayName . '_class'; if (class_exists($className)) { $object = new $className($payconfig, null); $functionName = $gwayName . 'Return'; $result = $object->{$functionName}($data); //call the payment function to submit the form $isValid = $result['success']; if ($isValid) { $invoice_num = $result['invoice_num']; // based on the invoice number, identify if it is deposit or plan if ($invoice_num) { $result = JblanceHelper::identifyDepositOrPlan($invoice_num); //if invoice number is not found if ($result) { if ($result['type'] == 'plan') { $row = JblanceHelper::approveSubscription($result['id']); } elseif ($result['type'] == 'deposit') { $row = JblanceHelper::approveFundDeposit($result['id']); } //set the result type and id for redirection $app->input->set('buy', $result['type']); $app->input->set('oid', $result['id']); } else { $isValid = false; $data['jblance_failure_reason'] = JText::_('COM_JBLANCE_INVOICE_NUMBER_NOT_FOUND_PLAN_DEPOSIT_RECORDS'); } } else { $isValid = false; $data['jblance_failure_reason'] = JText::_('COM_JBLANCE_INVOICE_NUMBER_EMPTY_OR_INVALID'); } $oid = $app->input->get('oid', 0, 'int'); $buy = $app->input->get('buy', '', 'string'); //either buy deposit or plan } else { $data['jblance_failure_reason'] = JText::_('COM_JBLANCE_PAYMENT_VERIFICATION_FAILED'); } if ($isValid) { $msg = JText::sprintf('COM_JBLANCE_PAYMENT_SUCCESSFUL', ucfirst($gwayName)); $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=thankpayment&oid=' . $oid . '&buy=' . $buy, false); } else { $msg = JText::_('COM_JBLANCE_PAYMENT_ERROR') . ' : ' . $data['jblance_failure_reason']; $link = JRoute::_('index.php?option=com_jblance&view=membership&layout=thankpayment&type=cancel', false); } $this->setRedirect($link, $msg); } //end of class name } //end of gateway }