FeRR4L

cc chek

Feb 28th, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include("striplib/Stripe.php"); // Stripe.com PHP API library
  3.  
  4. Stripe::setApiKey(""); // Put here your stripe.com API key
  5.  
  6. function httpStatusCodes($code) {
  7.     switch($code) {
  8.         case 200:
  9.             $statusCode = "Everything worked as expected";
  10.             break;
  11.         case 400:
  12.             $statusCode = "Missing a required parameter";
  13.             break;
  14.         case 401:
  15.             $statusCode = "No valid API key provided";
  16.             break;
  17.         case 402:
  18.             $statusCode = "Parameters were valid but request failed";
  19.             break;
  20.         case 404:
  21.             $statusCode = "The requested item doesn't exist";
  22.             break;
  23.         case 500:
  24.         case 502:
  25.         case 503:
  26.         case 504:
  27.             $statusCode = "Something went wrong on Stripe's end";
  28.             break;
  29.         default:
  30.             $statusCode = "Unknown status code";
  31.             break;
  32.     }
  33.     return $statusCode;
  34. }
  35.  
  36. function stripErrorHandler($e) {
  37.     $returnArray = array();
  38.     $body = $e->getJsonBody();
  39.  
  40.     $returnArray["error"] = true;
  41.     $returnArray["statuscode"] = $e->getHttpStatus();
  42.     $returnArray["status"] = httpStatusCodes($e->getHttpStatus());
  43.  
  44.     if(isset($body["error"]["type"])) $returnArray["type"] = $body["error"]["type"];
  45.     if(isset($body["error"]["code"])) $returnArray["code"] = $body["error"]["code"];
  46.     if(isset($body["error"]["charge"])) $returnArray["charge"] = $body["error"]["charge"];
  47.    
  48.     $returnArray["message"] = $body["error"]["message"];
  49.     return $returnArray;
  50. }
  51.  
  52. function oneTimePayment($ccNum, $expMonth, $expYear, $cvc) {
  53.     $returnArray = array("error" => false);
  54.     try {
  55.         $cardDetails = array("number" => $ccNum, "exp_month" => $expMonth, "exp_year" => $expYear, "cvc" => $cvc);
  56.         $cu = Stripe_Charge::create(array("card" => $cardDetails, "amount" => 50, "currency" => "usd"));
  57.         $returnArray = json_decode($cu, true);
  58.     } catch (Stripe_Error $e) {
  59.         $returnArray = stripErrorHandler($e);
  60.     }
  61.     return $returnArray;
  62. }
  63.  
  64. if(isset($_GET["ccnum"]) AND isset($_GET["expmonth"]) AND isset($_GET["expyear"]) AND isset($_GET["cvv"])) {
  65.     $req = oneTimePayment($_GET["ccnum"], $_GET["expmonth"], $_GET["expyear"], $_GET["cvv"]);
  66.  
  67.     if(isset($req["error"])) {
  68.         echo "Card declined<br />\n";
  69.     } else {
  70.         echo "Everything seems O.K. from here<br />\n";
  71.     }
  72.  
  73.     echo "<br />\n<br />\nDebuging Info:<br />\n";
  74.  
  75.     echo "<pre>\n";
  76.     print_r($req);
  77.     echo "</pre>\n";
  78. } else {
  79.     echo "<pre>\n";
  80. ?>
  81.     -= Credit Card Checker =-
  82.  
  83.     This PHP script will try to make a $0.5 payment via stripe.com to check if the credit card is valid or not.
  84.  
  85.     Usage:      http://localhost/checker.php?ccnum={Credit Card Number}&expmonth={Expiration Month}&expyear={Expiration Year}&cvv={CVV/CVC etc}
  86.     Example:    http://localhost/checker.php?ccnum=4012888888881881&expmonth=12&expyear=16&cvv=123
  87.  
  88.     This is a testimonial for CCadmin: "Automatic Credit Card Checkout And Wire Transfer System"
  89.     Visit TCF/Evolution for more info.
  90.     By afsr
  91. <?php
  92.     echo "</pre>\n";
  93. }
  94. ?>
Add Comment
Please, Sign In to add comment