array( 'label' => '', 'type' => 'custom', 'html' => '', ), 'merchantid' => array( 'label' => 'Merchant ID', 'type' => 'text', ), 'testmode' => array( 'label' => 'Test Mode', 'type' => 'select', 'options' => array('Yes', 'No'), ), ); } /** * Class constructor. * * @param array $order The order info array. * @param array $params The payment configuration. These fields are the * same of the getAdminParameters() function. */ public function __construct($order, $params = array()) { $this->order_info = $order; $this->params = $params; } /** * This method is invoked every time a user visits the page of a reservation with PENDING Status. * * @return void */ public function showPayment() { $merchant_id = $this->params['merchantid']; $action_url = "https://yourbankgateway.com/"; if ($this->params['testmode'] == 'Yes') { $action_url = "https://test.yourbankgateway.com/"; } $form = '
'; // put here all the required fields of your gateway $form .= ''; $form .= ''; $form .= ''; $form .= ''; // print a button to submit the payment form $form .= ''; $form .= '
'; echo $form; } /** * Validate the transaction details sent from the bank. * This method is invoked by the system every time the Notify URL * is visited (the one used in the showPayment() method). * * @return array The array result, which MUST contain the "verified" key (1 or 0). */ public function validatePayment() { $array_result = array(); $array_result['verified'] = 0; $array_result['tot_paid'] = ''; /** This value will be stored in the DB */ /** In case of error the log will be sent via email to the admin */ $status = $_POST['status']; /** Process your gateway response here */ if ($status == 'success') { $array_result['verified'] = 1; /** Set a value for $array_result['tot_paid'] */ $array_result['tot_paid'] = $_POST['amount']; } else { $array_result['log'] = "Transaction Error!\n".$_POST['error_msg']; } /** Return the array to VikRestaurants */ return $array_result; } /** * This function is called once the payment has been validated for redirect actions. * * @param boolean $esit The esit of the transaction. * * @return void */ public function afterValidation($esit = 0) { $app = JFactory::getApplication(); if ($esit < 1) { $app->enqueueMessage('The payment was not verified, please try again.', 'error'); $app->redirect($this->order_info['error_url']); } else { $app->enqueueMessage('Thank you! The payment was verified successfully.'); $app->redirect($this->order_info['return_url']); } exit; } }