GithubHelp home page GithubHelp logo

tlongren / money-collector Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 12.0 963 KB

Simple interface for accepting credit card payments on any PHP enabled server. Built with Stripe.

Home Page: https://pay.longren.io

License: MIT License

JavaScript 20.55% PHP 53.44% CSS 26.00%

money-collector's Introduction

money-collector's People

Contributors

tlongren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

money-collector's Issues

file not works

1, 'errorMessage' => $message); echo json_encode($a); } // Load stripe-php require_once('vendor/autoload.php'); $privateTestKey = "sk_test_CuNBMPPupmDc1eyKFjpeBi7c"; // These are the SECRET keys! $privateLiveKey = "ENTER YOUR PRIVATE LIVE KEY HERE"; \Stripe\Stripe::setApiKey($privateTestKey); // Switch to change between live and test environments // Get all the values from the form $token = $_POST['stripeToken']; $cardNumber = $_POST['cardNumber']; $cardCVC = $_POST['cardCVC']; $expirationMonth = $_POST['expirationMonth']; $expirationYear = $_POST['expirationYear']; $price = $_POST['price']; $name = $_POST['name']; $email = $_POST['email']; $priceInCents = $price \* 100; // Stripe requires the amount to be expressed in cents try { // We must have all of this information to proceed. If it's missing, balk. if (!isset($token)) throw new Exception("Website Error: The Stripe token was not generated correctly or passed to the payment handler script. Your credit card was NOT charged. Please report this problem to the webmaster."); if (!isset($cardNumber)) throw new Exception("Website Error: Bad card number Your credit card was NOT charged. Please report this problem to the webmaster."); if (!isset($cardCVC)) throw new Exception("Website Error: Invalid security code (CVC). Your credit card was NOT charged. Please report this problem to the webmaster."); if (!isset($expirationMonth)) throw new Exception("Website Error: Expiration month was not set. Your credit card was NOT charged. Please report this problem to the webmaster."); if (!isset($expirationYear)) throw new Exception("Website Error: Expiration year was not set. Your credit card was NOT charged. Please report this problem to the webmaster."); if (!isset($price)) throw new Exception("Website Error: Gotta enter a value to pay. Your credit card was NOT charged. Please report this problem to the webmaster."); try { // create the charge on Stripe's servers. THIS WILL CHARGE THE CARD! $charge = \Stripe\Charge::create(array( "amount" => $priceInCents, "currency" => "usd", "card" => $token, "description" => $email) ); ``` // If no exception was thrown, the charge was successful! // Here, you might record the user's info in a database, email a receipt, etc. // Return a result code of '0' and whatever other information you'd like. // This is accessible to the jQuery Ajax call return-handler in "buy-controller.js" $array = array('result' => 0, 'email' => $email, 'price' => $price, 'message' => 'Thank you; your transaction was successful!'); echo json_encode($array); } catch (Stripe_Error $e) { // The charge failed for some reason. Stripe's message will explain why. $message = $e->getMessage(); returnErrorWithMessage($message); } ``` } catch (Exception $e) { // One or more variables was NULL $message = $e->getMessage(); returnErrorWithMessage($message); } ?>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.