I'm developing a custom payment method, so far I managed to send the form to the gateway and everything works fine. When I conclude the payment I get a link to come back to the shop(contao) I've set the link to be :
But I dont know how should I get all the data that I got back so I can finish my order and get the payment confirmation in contao. Also when I link back first I get an error, Invalid request token!. I imagine that I'm not getting the right token when linking back to contao, and thus I can't get any data from the form that was sent back to contao.Code:$this->Environment->base.$this->addToUrl('step=complete').'?uid='.$objOrder->uniqid
Here is my Payment class:
So is there any idea what am I doing wrong, or not doing?Code:class PaymentTelecash extends IsotopePayment{ protected $arrLanguages = array('en_us'=>'en_US', 'en_uk'=>'en_UK', 'fr'=>'fr_FR', 'de'=>'de_DE', 'it_IT'=>6); protected $arrCurrencies = array('AUD'=>036, 'CAD'=>124, 'DKK'=>208, 'HKD'=>344, 'ISK'=>352, 'JPY'=>392, 'MXN'=>484, 'NZD'=>554, 'NOK'=>578, 'SGD'=>702, 'ZAR'=>710, 'SEK'=>752, 'CHF'=>756, 'THB'=>764, 'GBP'=>826, 'USD'=>840, 'TRY'=>949, 'EUR'=>978, 'PLN'=>985); public function __get($strKey){ switch( $strKey ){ case 'available': if (!array_key_exists($this->Isotope->Config->currency, $this->arrCurrencies)){ return false; } return parent::__get($strKey); default: return parent::__get($strKey); } } public function statusOptions(){ return array('pending', 'processing', 'complete', 'on_hold'); } protected function getDateTime(){ $dateTime = date("Y:m:d-H:i:s"); return $dateTime; } protected function createHash($chargetotal, $currency) { $stringToHash = $this->telecash_storeID . $this->getDateTime() . $chargetotal . $currency . $this->telecash_secretkey; $ascii = bin2hex($stringToHash); return sha1($ascii); } public function processPayment(){ $objOrder = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE cart_id=?")->limit(1)->executeUncached($this->Isotope->Cart->id); $intTotal = $this->Isotope->Cart->grandTotal * 100; // Check basic order data if ($this->Input->get('orderid') == $objOrder->id && $this->Input->get('cur') == $this->arrCurrencies[$this->Isotope->Config->currency] && $this->Input->get('amount') == $intTotal){ return true; } global $objPage; } public function checkoutForm(){ global $objPage; $objOrder = $this->Database->prepare("SELECT * FROM tl_iso_orders WHERE cart_id=?")->limit(1)->executeUncached($this->Isotope->Cart->id); $intTotal = $this->Isotope->Cart->grandTotal; return ' <h2>' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0] . '</h2> <p class="message">' . $GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1] . '</p> <form method="post" id="telecash_payment" action="https://test.ipg-online.com/connect/gateway/processing"> <input type="hidden" name="txntype" value="sale"> <input type="hidden" name="mode" value="fullpay"/> <input type="hidden" name="language" value="'.(array_key_exists($GLOBALS['TL_LANGUAGE'], $this->arrLanguages) ? $this->arrLanguages[$GLOBALS['TL_LANGUAGE']] : 'de_DE').'"/> <input type="hidden" name="timezone" value="CET"/> <input type="hidden" name="txndatetime" value="'.$this->getDateTime().'"/> <input type="hidden" name="hash" value="'.$this->createHash($intTotal,$this->arrCurrencies[$this->Isotope->Config->currency]).'"/> <input type="hidden" name="storename" value="'.$this->telecash_storeID.'"/> <input type="hidden" name="chargetotal" value="'.$intTotal.'"/> <input type="hidden" name="currency" value="'.$this->arrCurrencies[$this->Isotope->Config->currency].'"/> <input type="hidden" name="responseSuccessURL" value="'.$this->Environment->base.$this->addToUrl('step=complete').'?uid='.$objOrder->uniqid.'"/> <input type="hidden" name="notify_url" value="' . $this->Environment->base . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id . '"/> <input type="submit" class="process_submit" value="'.$GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2].'"> </form> <script type="text/javascript"> <![CDATA[//><!-- window.addEvent( \'domready\' , function() { $(\'telecash_payment\').submit(); }); //--><!]]> </script>'; } }
Thanks!


Reply With Quote
Bookmarks