Clojure library for the Paymill API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/clj_paymill
test/clj_paymill/test
.gitignore
README.md
project.clj

README.md

clj-paymill

Clojure library for the Paymill API.

Installation

clj-paymill is up on Clojars:

[clj-paymill "0.1.4-SNAPSHOT"]

Testing

If you haven't got a Paymill account set up but want to experiment, you can peruse the tests, wherein we somewhat filthily scrape the Paymill site to retrieve a test key. This obviously isn't guaranteed to work forever, and leaves some crud on their server, so don't overdo it.

Usage

Only very limited functionality is offered at this stage (i.e. just what I need). There are two namespaces, clj-paymill.net which is a thin wrapper around clj-http to talk to the Paymill REST API and spit JSON back out, and clj-paymill.client which is in turn a thin wrapper around that.

(ns paymill-test
  (:require [clj-paymill.net :refer :all]
            [clj-paymill.client :refer :all]))
        
;; get a private key for testing 
(def key (generate-test-key))

;; create a client
(create-client! key "example@example.org" "Test Testerson")

;; find them again
(get-client key (:id client))
(list-clients key {:email "example@example.org"})

;; update them
(update-client! (:id client) "new-email@example.org" "New Name")

;; create a payment (token taken from Paymill Bridge)
(create-payment! key token client)

;; create an offer
(create-offer! key "Test offer" 10 "GBP" "month")

;; list offers
(list-offers key)

;; create a subscription
(subscribe! key client payment offer)

;; check its current status
(subscription-details key (:id subscription))

;; cancel it
(cancel-subscription! key (:id subscription) true)

;; talk to other parts of the API
(paymill-request key :post "preauthorizations" {...})
(paymill-request key :get ["preauthorizations" (:id preauthorization)])