nairteashop.org

Ramblings from a tech and music enthusiast

Getting started with Stripe – part 2

05/19/2014

This is a follow-up to my introductory post on Stripe. I covered Stripe’s merchant and marketplace products in the first post, and in this one we’ll try building some basic web apps that use Stripe Checkout and Stripe.js.

Note that to keep the focus on the API I kept things as minimal as possible, which meant omitting most error checking, so do not use any of the code from this post as-is in production. At the very least, you need to add comprehensive error handling and use HTTPS for both the frontend and the backend.

Backend: Node.js + Express

We’ll use a common node.js + Express backend for all the examples, so let’s cover that first.

Making a charge against a credit/debit card using the Stripe API requires a surprisingly small amount of code. The following is a fully-functional Node.js/Express app that will make a $10 charge against a card token supplied in an HTTP POST request to http://<server>:3000/charge, and respond with either an HTTP 204 OK or an HTTP 500 error depending on whether the card was successfully charged or not.

To test, save the above code into a file called index.js, replacing sk_MY_SECRET_KEY with your Stripe secret key (if you don’t have one, sign up for an account with Stripe). Then setup and run it like you would any Express application, i.e.:

Your backend is now running at http://localhost:3000

This backend can accept a Stripe card token and make a $10 charge against it. Sweet! We now need to build a frontend that accepts card information, converts that into a card token, and sends it to the backend.
Read More

Getting started with Stripe – part 1

05/15/2014

stripeOnline payments is probably one of the hottest fields in tech right now. After a long period of quiet since PayPal debut over 15 years ago, there’s now a renaissance in this space with the rise of startups like StripeBalancedWePay, DwollaBrainTree and many others.

I recently spent some time trying to understand the offerings by Stripe, one of the leaders in this new batch of companies, and thought I’d share what I’d learned in a blog post.

Stripe

Stripe is an online and mobile payments company; its products enable anyone who sells products on a website or in a mobile app to easily accept credit and debit card payments from customers.

Stripe processes and charges the cards, and automatically transfers the collected amount to the seller’s bank account. The transfers are made daily (albeit with a 7 day delay from when the payments were originally made). Card verification and fraud prevention mechanisms come built-in, and a dashboard provides an easy way to deal with things like refunds and chargebacks (i.e. disputed charges). Nice!

Stripe also lets the merchant sidestep what’s called “PCI compliance“. To process any major credit or debit card you must be compliant with the Data Security Standards (DSS) as laid out by the Payment Card Industry (PCI) – a consortium founded by AmEx, Discover, JCB, MasterCard, and Visa. The standards were created to protect cardholder information and to prevent credit card fraud, and certainly has admirable goals, but let me tell you something from years of working in retail: achieving and maintaining PCI compliance is unbelievably painful. With Stripe, you can achieve PCI compliance by following a few simple guidelines; Stripe does most of the heavy lifting for you.

Stripe is currently available in the U.S. and Canada, several Western European countries and Australia.
Read More

Big O in plain english

12/11/2013

This answer on stack overflow is one of the nicest explanations I’ve seen of the Big O notation used in software engineering. However, this other answer easily wins for best example; using various activities you’d perform on a phone book to explain different complexities is genius.

(Quick recap: Big O notation is used to capture the upper bound of the complexity of an algorithm, Big Ω is used for lower bound, and Big Θ for upper and lower, or “tight”, bound. For Big-O complexities of common algorithms used in computer science, check out the fantastic Big-O cheat sheet.)

I’ve paraphrased the phone book example below since I liked it so much. Note that the input “n” here is the number of pages in the phone book.

O(1): Given a person’s name and the page that the person is listed on, find their phone number. This is a constant-time operation, since flipping to a specified page and then scanning that page for a name both take a roughly constant amount of time no matter how many pages the book has. Read More

Playing with acoustics

12/08/2013

Ever wonder how much room acoustics affect sound? Julien Audigier shows us, using just a simple two piece set and natural reverb.

Ishkur’s guide to electronic music

12/08/2013

If you’re a fan of electronic music, you probably already know of Ishkur’s guide. If not, you need to go check it out. Like right now. (Don’t let the 90s interface and sound effects scare you away!)

Ishkur’s guide is like wikipedia for the hundreds of sub-genres that constitute electronic music. Each genre comes with snarky commentary, representative song samples, links to the parent genre it was inspired from, and the child genres that it in turn inspired.

I spent at least a couple of days on this the first time I discovered it. Totally worth it.

Older Posts