To start off, please forgive me if i sound like an idiot as i have limited coding capabilities. Having said that, i've been having trouble setting up a custom payment gateway.
The payment gateway requires that i specify a redirection URL for each transaction status: success, fail and cancelled.
The issue is that i have no idea what URL to specify for successful transactions so that the order is successfully processed and recorded into the database.
I've basically just adapted from one of the existing merchant files and came up with the following:
class Merchant_enets extends Merchant_driver { const PROCESS_URL = 'https://www.enets.sg/enets2/enps.do'; public function default_settings() { return array( 'user_id' => '', 'test_mode' => FALSE, ); } public function purchase() { $request = $this->_build_purchase(); $this->post_redirect($this->_process_url(), $request); } private function _build_purchase() { $request = array(); $request['mid'] = $this->setting('user_id'); $request['amount'] = $this->param('amount'); $request['txnRef'] = $this->param('transaction_id'); $request['umapiType'] = 'lite'; return $request; } public function purchase_return() { $result = $this->CI->input->get_post('result'); if (empty($result)) { return new Merchant_response(Merchant_response::FAILED, lang('merchant_invalid_response')); } // validate response $request = new SimpleXMLElement(''); $request->Response = $result; $response = $this->post_request(self::PROCESS_URL, $request->asXML()); $xml = simplexml_load_string($response); if ((string)$xml->Success == '1') { if ((string)$xml->status == 'succ') { return new Merchant_response(Merchant_response::AUTHORIZED, (string)$xml->ResponseText, (string)$xml->txnRef); } } return new Merchant_response(Merchant_response::FAILED, (string)$xml->ResponseText, (string)$xml->txnRef); } protected function _process_url() { return $this->setting('test_mode') ? self::PROCESS_URL_TEST : self::PROCESS_URL; } }
Please help!
I'm using EE 2.7 and Store 1.6.5