ktorp18 Posted August 10, 2008 Share Posted August 10, 2008 Hello PHPfreaks. This is my first post on here as I've hit my first bump in the road while teaching myself PHP and creating my own website. On my website I have a form to make a deposit by credit card through a credit card processing company and I'm having some trouble. It seems wherever I call this function to create "fingerprint" the code stops working. Everything before calling the function shows up on the page, but everything after it does not. The function causing the problem is the InsertFP function. Here is the code from the main form page (login IDs and passwords are replaced with asteriks): <form method="post" action="https://test.authorize.net/gateway/transact.dll"> <?php include ("simdata.php"); include ("simlib.php"); $password_length = 9; function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } srand(make_seed()); $alfa = "1234567890"; $token = ""; for($i = 0; $i < $password_length; $i ++) { $token .= $alfa[rand(0, strlen($alfa))]; } $loginid = "*********"; $x_tran_key = "***********"; $amount = 25; $sequence = $token; $currencycode = "USD"; $ret = InsertFP ($loginid, $x_tran_key, $amount, $sequence, $currencycode); ?> <input name="x_login" type="hidden" value="*********"> <input name="x_fp_sequence" type="hidden" value="<?php echo $token ?>"> <input name="x_fp_timestamp" type="hidden" value="<?php echo time() ?>"> Amount to Deposit (Minimum $20): <input name="x_amount" type="text" > <input name="x_tran_key" type="hidden" value="**********"> <input name="x_test_request" type="hidden" value="TRUE"> <input name="Submit1" type="submit" value="submit" > </form> And here is the code for simlib.php: function hmac ($key, $data) { return (bin2hex (mhash(MHASH_MD5, $data, $key))); } // Calculate and return fingerprint // Use when you need control on the HTML output function CalculateFP ($loginid, $x_tran_key, $amount, $sequence, $tstamp, $currency = "") { return (hmac ($x_tran_key, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency)); } // Inserts the hidden variables in the HTML FORM required for SIM // Invokes hmac function to calculate fingerprint. function InsertFP ($loginid, $x_tran_key, $amount, $sequence, $currency = "") { $tstamp = time (); $fingerprint = hmac ($x_tran_key, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency); echo ('<input type="hidden" name="x_fp_sequence" value="' . $sequence . '">' ); echo ('<input type="hidden" name="x_fp_timestamp" value="' . $tstamp . '">' ); echo ('<input type="hidden" name="x_fp_hash" value="' . $fingerprint . '">' ); return (0); } ?> and the other file...simdata.php <? // You may want to store this more securely in a DB or Registry or a Encrypted File $loginid = "***********"; $x_tran_key = "***********"; ?> Any help at all would be greatly appreciated. I've been trying to figure this one out for quite some time now. Thank you. PS - The credit card processing company is Authorize.net, but they don't give help for technical questions. Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/ Share on other sites More sharing options...
ktorp18 Posted August 10, 2008 Author Share Posted August 10, 2008 bump Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613093 Share on other sites More sharing options...
xtopolis Posted August 10, 2008 Share Posted August 10, 2008 I copy pastad your code, and it seemed to 'work' as far as I can tell. I see: Amount to Deposit (Minimum $20): [ ]Submit Silly question, but you do know all those <input>s with the "hidden" attribute aren't supposed to show right? My webdeveloper extension shows that they are created, but of course not visible.. Is there more code we're missing? Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613098 Share on other sites More sharing options...
ktorp18 Posted August 10, 2008 Author Share Posted August 10, 2008 the only code i left out was the main template stuff for my website. the credit card processing company says i have to have the mhash library on my php server for it to work. do you know how i can check to see if i have that? Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613124 Share on other sites More sharing options...
cooldude832 Posted August 10, 2008 Share Posted August 10, 2008 Silly question, but you do know all those <input>s with the "hidden" attribute aren't supposed to show right? My webdeveloper extension shows that they are created, but of course not visible.. Is there more code we're missing? hidden variables are very common in payment processors. They are account specific data the end user shouldn't alter but if they do no big deal Paypal uses these when sending payment from a site. Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613135 Share on other sites More sharing options...
xtopolis Posted August 10, 2008 Share Posted August 10, 2008 ktorp18, possibly if you do a <?php phpinfo(); ?> if might show if that exists. Another thing would be to put at the top of your page: <?php error_reporting(E_ALL); ?> which would probably tell you if it's calling a function that doesn't exist. cooldude832, I meant show as in be visible. He was commenting that nothing else 'showed' up after that code, which I was saying that from the code he gave us, nothing else would 'show' up [or be visible]. Yea.. anyway. Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613138 Share on other sites More sharing options...
ktorp18 Posted August 10, 2008 Author Share Posted August 10, 2008 I tried the error reporting thing and nothing else came up. When I did the php info the mhash thing didn't show up so maybe I don't have that on my php server. But then again, you said it worked for you, so I don't know. I'll try the alternative it has for people without the mhash library and then get back to you guys. BTW, thank you so much for all your help. Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613140 Share on other sites More sharing options...
ktorp18 Posted August 11, 2008 Author Share Posted August 11, 2008 I got it working now since I used the version where you don't need the mhash library. Thanks for the help guys. Link to comment https://forums.phpfreaks.com/topic/119048-help-with-credit-card-processing-function/#findComment-613144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.