Credit Card Verification


/ Published in: PHP
Save to your folder(s)

Credit Card Verification


Copy this code and paste it in your HTML
  1. function object_2_array($result){
  2. $array = array();
  3. foreach ($result as $key=>$value)
  4. {
  5. # if $value is an object then
  6. if (is_object($value))
  7. {
  8. #run the $value through the function again.
  9. $array[$key]=object_2_array($value);
  10. }
  11. # if $value is an array then
  12. if (is_array($value))
  13. {
  14. #run the $value through the function again??????
  15. $array[$key]=object_2_array($value);
  16. }
  17. # if $value is not an array then (it also includes objects)
  18. else
  19. {
  20. $array[$key]=$value;
  21. }
  22. }
  23. return $array;
  24. }
  25.  
  26.  
  27.  
  28. function checkcreditcardValidity( $cardno = 0){
  29.  
  30. $client = new soapClient('http://ws.cdyne.com/creditcardverify/luhnchecker.asmx?wsdl');
  31.  
  32. $result = $client->CheckCC(array("CardNumber" => $cardno));
  33. $arr = object_2_array($result);
  34. $arr1 = object_2_array($arr['CheckCCResult']);
  35.  
  36. //$arr1['CardType'];
  37. if( $arr1['CardValid'] != '1' ){
  38. return false;
  39. }
  40. return true;
  41. }
  42.  
  43. /*----------------------------------------------------------------------------*/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.