Getting started with Stripe: Do it so it won’t scale

So you want to create a startup product that you want people to pay for? A great way to integrate payment is with Stripe. They make it super easy to accept credit card payments and their API is incredibly simple to use.

When I setup Email It In, the simple way to email files to Google Drive, Skydrive or Dropbox, I knew from the outset I wanted a way to monetize the service. So Stripe seemed like the obvious solution and so far I’m very happy with it.

But when thinking about payments anyone who understands credit cards and recurring payments knows that there’s a bunch of things you need to consider:

  • What happens when a payment is revoked? (called a “chargeback” in the credit card world)
  • What happens when a credit card expires?
  • What happens when a credit card is cancelled because of fraud against the owner?
  • What are the events I don’t understand because I don’t know all the details about payments – that’s not my business because I am just a nerd with a good idea?
  • How do I let someone cancel and get a refund?

What I know in life I know from experience, so how can you get experience of all of these things with Stripe without being super-human? We build it so that dealing with these issues is at first a manual problem, but so it gives us enough information in the system to make it automated in the future.

So what’s the secret? The trick is in Stripe’s hooks.

They send you HTTP events when most of these things happen. The trick is to email yourself when you receive these events. The code for this in Node.js is simple:

app.post("/_stripe_hook", function (req, res) {
    console.log("Stripe hook called: ", req.body);
        from: "Email It In <stripe@emailitin.com>",
        to: "Matt Sergeant <helpme@gmail.com>",
        subject: "Stripe Hook Called",
        text: util.inspect(req.body, { depth: null }),
    }, function (err, response) {
        if (err) console.log(err);
        else console.log("Message Sent: " + response.message);

        return res.send(200);

Now the downside is that I see everything. For every initial credit card transaction I get 6 or 7 emails. But that visibility into the process is hugely useful. You get to see everything that happens and can deal with things you haven’t seen before very quickly. Yes you have to be able to understand JSON, but that’s fairly trivial even for non-developers.

Some day soon I’ll replace much of this with automation. But I’ll do that when the number of emails becomes too much. And that will frankly be considered a good day.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s