• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interesting problem! I will leave the business if I cant get this solved =/

#1
[eluser]cehennem[/eluser]
Hey there,

I'm developing an e-commerce web page nowadays. Today I have faced a very interesting problem-bug or whatever bullshit it is.

There is a function in a model file that draw money from user's credit card information.

Code:
function draw_money() {

$bank = new Posnet();

  $example_card['ccno']  = '4553591000148024';  # example valid ccno
  $example_card['expdate'] = '1303';
  $example_card['cvc']  = '000';
  $example_card['orderid'] = rand(100000,999999);
  $example_card['amount']  = '3500';
  $example_card['currencycode'] = 'YT';
  $example_card['instnumber'] = '00';

  $bank->DoSaleTran(
       $example_card['ccno'],
       $example_card['expdate'],
       $example_card['cvc'],
       $example_card['orderid'],
       $example_card['amount'],
       $example_card['currencycode'],
       $example_card['instnumber']
       );
}

the function above takes about 10 secs to complete the process. its all ok so far. but now, there is also another function in this model that formats the card data to be valid for the draw-money process. when I use this function in draw_money() function, the page gives Timeout message with page title of "500 Internal Server Error". Read comments to see differences.

Code:
function format_card_data($vars) {
   $vars['ccno'] = str_replace('-', '', $vars['ccno']);
   return $vars;
}



function draw_money() {

$bank = new Posnet();

  $example_card['ccno']  = '4553-5910-0014-8024'; # example invalid ccno
  $example_card['expdate'] = '1303';
  $example_card['cvc']  = '000';
  $example_card['orderid'] = rand(100000,999999);
  $example_card['amount']  = '3500';
  $example_card['currencycode'] = 'YT';
  $example_card['instnumber'] = '00';
        
# strip non-numeric chars. from ccno
$example_card = $this->format_card_data($example_card); # <<<------------

  $bank->DoSaleTran(
       $example_card['ccno'],
       $example_card['expdate'],
       $example_card['cvc'],
       $example_card['orderid'],
       $example_card['amount'],
       $example_card['currencycode'],
       $example_card['instnumber']
       );
}


The error message:

Quote:Request Timeout

This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout'.

that because the timeout of the script execution is defined 30 sec in the conf file.

Thats very intersting I got this message just because of I used a simple function to strip "-" character in the credit card.

#2
[eluser]InsiteFX[/eluser]
Why are you passing the whole array to the function? Just pass the ccno, thats all you are stripping - out of.
Code:
# strip non-numeric chars. from ccno
$example_card['ccno'] = $this->format_card_data($example_card['ccno']); # <<<------------

#3
[eluser]cehennem[/eluser]
[quote author="InsiteFX" date="1342263662"]Why are you passing the whole array to the function? Just pass the ccno, thats all you are stripping - out of.
Code:
# strip non-numeric chars. from ccno
$example_card['ccno'] = $this->format_card_data($example_card['ccno']); # <<<------------
[/quote]

thanks you've got a point, but I will format other values too once I get the problem solved. Wink

#4
[eluser]InsiteFX[/eluser]
Once you have it working for the ccno it should work with anything you pass to it.

If you are going to use it for other data then I would just assign it to a variable pass it to the function then assign the return value to your variable or array.

#5
[eluser]InsiteFX[/eluser]
Code:
$example = '4553591000148024';  # example valid ccno

function format_card_data($vars)
{
   return str_replace('-', '', $vars);
}

$example_card['ccno'] = $this->format_card_data($example);

#6
[eluser]solid9[/eluser]
Have you also tried reading the error_log?
Perhaps it show a different error message.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.