Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("striplib/Stripe.php"); // Stripe.com PHP API library
- Stripe::setApiKey(""); // Put here your stripe.com API key
- function httpStatusCodes($code) {
- switch($code) {
- case 200:
- $statusCode = "Everything worked as expected";
- break;
- case 400:
- $statusCode = "Missing a required parameter";
- break;
- case 401:
- $statusCode = "No valid API key provided";
- break;
- case 402:
- $statusCode = "Parameters were valid but request failed";
- break;
- case 404:
- $statusCode = "The requested item doesn't exist";
- break;
- case 500:
- case 502:
- case 503:
- case 504:
- $statusCode = "Something went wrong on Stripe's end";
- break;
- default:
- $statusCode = "Unknown status code";
- break;
- }
- return $statusCode;
- }
- function stripErrorHandler($e) {
- $returnArray = array();
- $body = $e->getJsonBody();
- $returnArray["error"] = true;
- $returnArray["statuscode"] = $e->getHttpStatus();
- $returnArray["status"] = httpStatusCodes($e->getHttpStatus());
- if(isset($body["error"]["type"])) $returnArray["type"] = $body["error"]["type"];
- if(isset($body["error"]["code"])) $returnArray["code"] = $body["error"]["code"];
- if(isset($body["error"]["charge"])) $returnArray["charge"] = $body["error"]["charge"];
- $returnArray["message"] = $body["error"]["message"];
- return $returnArray;
- }
- function oneTimePayment($ccNum, $expMonth, $expYear, $cvc) {
- $returnArray = array("error" => false);
- try {
- $cardDetails = array("number" => $ccNum, "exp_month" => $expMonth, "exp_year" => $expYear, "cvc" => $cvc);
- $cu = Stripe_Charge::create(array("card" => $cardDetails, "amount" => 50, "currency" => "usd"));
- $returnArray = json_decode($cu, true);
- } catch (Stripe_Error $e) {
- $returnArray = stripErrorHandler($e);
- }
- return $returnArray;
- }
- if(isset($_GET["ccnum"]) AND isset($_GET["expmonth"]) AND isset($_GET["expyear"]) AND isset($_GET["cvv"])) {
- $req = oneTimePayment($_GET["ccnum"], $_GET["expmonth"], $_GET["expyear"], $_GET["cvv"]);
- if(isset($req["error"])) {
- echo "Card declined<br />\n";
- } else {
- echo "Everything seems O.K. from here<br />\n";
- }
- echo "<br />\n<br />\nDebuging Info:<br />\n";
- echo "<pre>\n";
- print_r($req);
- echo "</pre>\n";
- } else {
- echo "<pre>\n";
- ?>
- -= Credit Card Checker =-
- This PHP script will try to make a $0.5 payment via stripe.com to check if the credit card is valid or not.
- Usage: http://localhost/checker.php?ccnum={Credit Card Number}&expmonth={Expiration Month}&expyear={Expiration Year}&cvv={CVV/CVC etc}
- Example: http://localhost/checker.php?ccnum=4012888888881881&expmonth=12&expyear=16&cvv=123
- This is a testimonial for CCadmin: "Automatic Credit Card Checkout And Wire Transfer System"
- Visit TCF/Evolution for more info.
- By afsr
- <?php
- echo "</pre>\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement