slipy Posted October 3, 2013 Share Posted October 3, 2013 Hi guys, First of all, sorry if i have English spelling mistakes or type errors. Well, this is the deal , we work with a CC gateway who dosnt have a module to WHMCS, so we started learning on how to integrate their redirect form into WHMCS. the CC gateway sent us their code to create the redirect to their cc process page. this is what we did: 1. we read the WHMCS guide 2. took the template gateway file and renamed it to our own gateway 3. changed the template to our gateway on functions ( gateway_config and gateway_link) 4. added necessary vars to gateway_config 5. we added the gateway redirect code where the template says "Enter redirect code here" 6. we added the gateway from the admin panel and simulated a purchase we got an error on a function that the redirect uses that its not defined. after hours of trying to use it without a function, but we failed to do so. basically this is our function gateway_config: function pelecard_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value"=>"Pelecard Gateway Module"), "userName" => array("FriendlyName" => "Login ID", "Type" => "text", "Size" => "20", ), "password" => array("FriendlyName" => "Password", "Type" => "text", "Size" => "20", ), "termNo" => array("FriendlyName" => "Terminal Number", "Type" => "text", "Size" => "20", ), "goodUrl" => array("FriendlyName" => "goodUrl", "Type" => "text", "Size" => "255", ), "errorUrl" => array("FriendlyName" => "errorUrl", "Type" => "text", "Size" => "255", ), //"transmethod" => array("FriendlyName" => "Transaction Method", "Type" => "dropdown", "Options" => "Option1,Value2,Method3", ), "instructions" => array("FriendlyName" => "Payment Instructions", "Type" => "textarea", "Rows" => "5", "Description" => "Do this then do that etc...", ), "testmode" => array("FriendlyName" => "Test Mode", "Type" => "yesno", "Description" => "Tick this to test", ), ); return $configarray; } this is our function gateway_link function ccprocess_link($params) { # Gateway Specific Variables $gatewayusername = $params['userName']; $gatewaypassword = $params['password']; $gatewayterminalid = $params['termNo']; $goodUrl = $params['goodUrl']; $errorUrl = $params['errorUrl']; $gatewaytestmode = $params['testmode']; # Invoice Variables $invoiceid = $params['invoiceid']; $description = $params["description"]; $amount = $params['amount']; # Format: ##.## $currency = $params['currency']; # Currency Code # Client Variables $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; # System Variables $companyname = $params['companyname']; $systemurl = $params['systemurl']; $currency = $params['currency']; $userName = "PeleTest"; $password = "Pelecard@Test"; $termNo = "0962210"; $password = str_replace("+", "`9`", $password); $password = str_replace("&", "`8`", $password); $password = str_replace("%", "`7`", $password); $data = array( 'userName' => $gatewayusername, 'password' => $gatewaypassword, 'termNo' => $gatewayterminalid, 'pageName' => 'ajaxPage', 'goodUrl' => $_POST['goodUrl'], 'errorUrl' => $_POST['errorUrl'], 'ValidateLink' => $_POST['goodUrl'], 'ErrorLink' => $_POST['errorUrl'], 'total' => $amount, 'currency' => '1', 'maxPayments' => '1', 'minPaymentsNo' => '1', 'creditTypeFrom' => '', 'logo' => $_POST['Logo'], 'smallLogo' => $_POST['smallLogo'], 'hidePciDssLogo' => $_POST['hidePciLogo'], 'hidePelecardLogo' => $_POST['hidePciLogo'], 'Theme' => $_POST['Theme'], 'Background' => $_POST['Background'], 'backgroundImage' => $_POST['backgroundImage'], 'topMargin' => $_POST['topMargin'], 'supportedCardTypes' => $_POST['supportedCardTypes'], 'parmx' => $_POST['Parmx'], 'hideParmx' => $_POST['hideParmx'], 'text1' => $_POST['text1'], 'text2' => $_POST['text2'], 'text3' => $_POST['text3'], 'text4' => $_POST['text4'], 'text5' => $_POST['text5'], 'cancelUrl' => $_POST['cancelUrl'], 'mustConfirm' => $_POST['mustConfirm'], 'confirmationText' => $_POST['confirmationText'], 'supportPhone' => $_POST['supportPhone'], 'errorText' => $_POST['errorText'], 'id' => $_POST['id'], 'cvv2' => $_POST['cvv2'], 'authNum' => $_POST['authNum'], 'shopNo' => $_POST['shopNo'], 'frmAction' => $_POST['frmAction'], 'TokenForTerminal' => $_POST['TokenForTerminal'], 'J5' => $_POST['J5'], 'keepSSL' => $_POST['keepSSL'] ## NO TRAILING COMMA ); list ($code2, $result) = do_post_request($data); ## Submit the data into gateway servers function do_post_request($data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => http_build_query($data) )); $url = 'https://gateway.ccprocess.co.il/'; if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); fpassthru($fp); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); } return array(substr(trim(strip_tags($response)),0,3), trim(strip_tags($response))); } $code = '<form id="form4" name="form4" action="https://gateway.ccprocess.co.il/" method="post"> <input type="hidden" name="noCheck" value="true" id="noCheck" /> </form> <script type="text/javascript"> function submitForm() { document.form4.submit();} submitForm(); </script>'; return $code; } } 0 Quote Link to comment Share on other sites More sharing options...
PowerChaos Posted October 21, 2013 Share Posted October 21, 2013 basicly there are some errors in it when do you provide a post value when you got no post value to start and how is the gateway module suposed to get a post value in first place ?? ( from the invoice that got generated and is suposed to post all the requested data you ask ? ) also check the gateway name ( ccprocess_link -> pelecard_link ) so in short change the post to the right value , as there is no post in first place here is some modified code that can work a bit better (not fully modified , but the function links are broken down so the function will not work , also again the post value is still in the script so remove/change them to the right value to get them working <?php function pelecard_config() { $configarray = array( "FriendlyName" => array("Type" => "System", "Value"=>"Pelecard Gateway Module"), "userName" => array("FriendlyName" => "Login ID", "Type" => "text", "Size" => "20", ), "password" => array("FriendlyName" => "Password", "Type" => "text", "Size" => "20", ), "termNo" => array("FriendlyName" => "Terminal Number", "Type" => "text", "Size" => "20", ), "goodUrl" => array("FriendlyName" => "goodUrl", "Type" => "text", "Size" => "255", ), "errorUrl" => array("FriendlyName" => "errorUrl", "Type" => "text", "Size" => "255", ), //"transmethod" => array("FriendlyName" => "Transaction Method", "Type" => "dropdown", "Options" => "Option1,Value2,Method3", ), // "instructions" => array("FriendlyName" => "Payment Instructions", "Type" => "textarea", "Rows" => "5", "Description" => "Do this then do that etc...", ), "testmode" => array("FriendlyName" => "Test Mode", "Type" => "yesno", "Description" => "Tick this to test", ), ); return $configarray; } function pelecard_link($params) { # Gateway Specific Variables $gatewayusername = $params['userName']; $gatewaypassword = $params['password']; $gatewayterminalid = $params['termNo']; $goodUrl = $params['goodUrl']; $errorUrl = $params['errorUrl']; $gatewaytestmode = $params['testmode']; # Invoice Variables $invoiceid = $params['invoiceid']; $description = $params["description"]; $amount = $params['amount']; # Format: ##.## $currency = $params['currency']; # Currency Code # Client Variables $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phonenumber']; # System Variables $companyname = $params['companyname']; $systemurl = $params['systemurl']; $currency = $params['currency']; //$userName = "PeleTest"; //$password = "Pelecard@Test"; //$termNo = "0962210"; $password = str_replace("+", "`9`", $password); $password = str_replace("&", "`8`", $password); $password = str_replace("%", "`7`", $password); $data = array( 'userName' => $gatewayusername, 'password' => $gatewaypassword, 'termNo' => $gatewayterminalid, 'pageName' => 'ajaxPage', 'goodUrl' => $goodUrl, 'errorUrl' => $errorUrl, 'ValidateLink' => $goodUrl, 'ErrorLink' => $errorUrl, 'total' => $amount, 'currency' => '1', 'maxPayments' => '1', 'minPaymentsNo' => '1', 'creditTypeFrom' => '', 'logo' => $_POST['Logo'], 'smallLogo' => $_POST['smallLogo'], 'hidePciDssLogo' => $_POST['hidePciLogo'], 'hidePelecardLogo' => $_POST['hidePciLogo'], 'Theme' => $_POST['Theme'], 'Background' => $_POST['Background'], 'backgroundImage' => $_POST['backgroundImage'], 'topMargin' => $_POST['topMargin'], 'supportedCardTypes' => $_POST['supportedCardTypes'], 'parmx' => $_POST['Parmx'], 'hideParmx' => $_POST['hideParmx'], 'text1' => $_POST['text1'], 'text2' => $_POST['text2'], 'text3' => $_POST['text3'], 'text4' => $_POST['text4'], 'text5' => $_POST['text5'], 'cancelUrl' => $_POST['cancelUrl'], 'mustConfirm' => $_POST['mustConfirm'], 'confirmationText' => $_POST['confirmationText'], 'supportPhone' => $_POST['supportPhone'], 'errorText' => $_POST['errorText'], 'id' => $_POST['id'], 'cvv2' => $_POST['cvv2'], 'authNum' => $_POST['authNum'], 'shopNo' => $_POST['shopNo'], 'frmAction' => $_POST['frmAction'], 'TokenForTerminal' => $_POST['TokenForTerminal'], 'J5' => $_POST['J5'], 'keepSSL' => $_POST['keepSSL'] ## NO TRAILING COMMA ); list ($code2, $result) = do_post_request($data); ## Submit the data into gateway servers function do_post_request($data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => http_build_query($data) )); $url = 'https://gateway.ccprocess.co.il/'; if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); fpassthru($fp); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); } return array(substr(trim(strip_tags($response)),0,3), trim(strip_tags($response))); } $code = '<form id="form4" name="form4" action="https://gateway.ccprocess.co.il/" method="post"> <input type="hidden" name="noCheck" value="true" id="noCheck" /> </form> <script type="text/javascript"> function submitForm() { document.form4.submit();} submitForm(); </script>'; return $code; } beside , this is "pelecard.php" Greetings From PowerChaos 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.