Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A (toy) library for interfacing with stripe.com from Common Lisp
Common Lisp Ruby
branch: master
Failed to load latest commit information.
features Fix tests until the year 2020 (-:
.gitignore Add a few tests using clucumber and fix bugs exposed.
.ruby-version Bump ruby version used for tests
COPYING An (untested, toy) implementation of the cl-stripe API for Common Lisp.
Gemfile Add a few tests using clucumber and fix bugs exposed.
Gemfile.lock
README.md
cl-stripe.asd Add a :description to the .asd file.
cl-stripe.lisp Add a few tests using clucumber and fix bugs exposed.
package.lisp Some renamings: api keys and the "stripe" package.
sstruct.lisp Some renamings: api keys and the "stripe" package.
variables.lisp Some renamings: api keys and the "stripe" package.

README.md

An (experimental, toy) library for interfacing with Stripe

This library allows you to call the stripe.com API from Common Lisp and should nicely present results to you.

Installation

  1. Clone this repo
  2. Put it somewhere quicklisp can find it
  3. To use, require it from your ASD system or (ql:quickload :cl-stripe) on the REPL.

Conventions

All API functions (and data structure accessors) are exported from the stripe package.

The Stripe HTTP API has a few conventions, and so does Common Lisp. To get the two to talk and not cause inconvenience to you, I've implemented a few conventions on the cl-stripe side:

  • Underscores in the HTTP API (e.g., trial_end) become hyphens in the CL API (e.g., trial-end).
  • All responses are returned as stripe:sstruct objects, which are nicely-printing wrappers around st-json:jso (see below).
  • card parameters can be a string to specify a token or a plist containing the fields that specify the card details.
  • All API calls' function names have the form action-object.
  • A call's action is one of retrieve, list, create, update, delete, refund.
  • A call's object is one of charge, customer, token, subscription, plan, invoice, invoice-item.
  • list calls use the plural for objects: customer becomes customers. Other calls use the singular.

That's it. If you keep the Stripe HTTP API open, you should be able to use this library.

Data Structures

Stripe returns (not deeply) nested JSON objects. To make access to each field easier in the absence of a nice hash syntax, cl-stripe provides a function called sstruct-get. It allows you to specify fields that define a chain through the nested object.

For example:

(let ((customers (list-customers)))
  (sstruct-get customers :data 4 :active-card))

This retrieves:

  1. the "data" object from the reply object,
  2. then retrieves the 4th entry from that,
  3. then finally retrieves the "active_card" entry from that.

sstruct-get field names can be specified as keywords (which will be case-normalized to lower case, and hyphens replaced with underscores), or as strings (which will be used verbatim).

API Keys

Your stripe API key is a string you get from your dashboard in the web interface. Set it to either your live or testing key (but please don't blame me if anything goes wrong when you use your live key).

All cl-stripe api functions accept an :api-key keyword argument, which defaults to *default-api-key*. This variable can also be set using the set-default-api-key function.

That's it!

Have fun with this library! I hope you can make something useful with it, and, most importantly, make some money!

Something went wrong with that request. Please try again.