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.
- Clone this repo
- Put it somewhere quicklisp can find it
- To use, require it from your ASD system or
(ql:quickload :cl-stripe)on the REPL.
All API functions (and data structure accessors) are exported from the
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.,
- All responses are returned as
stripe:sstructobjects, which are nicely-printing wrappers around st-json:jso (see below).
cardparameters 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
- A call's object is one of
listcalls use the plural for objects:
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.
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.
(let ((customers (list-customers))) (sstruct-get customers :data 4 :active-card))
- the "data" object from the reply object,
- then retrieves the 4th entry from that,
- 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).
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
Have fun with this library! I hope you can make something useful with it, and, most importantly, make some money!