Skip to content

AdGoji/mollie

Repository files navigation

Mollie API for Clojure

Clojure client implementation for Mollie API.


Clojars Project cljdoc badge

Requirements

  • Java 11
  • Clojure 1.11

Quick start

Include the library to your project

See the clojars page for the latest version.

Add require

(require '[com.adgoji.mollie.api :as mollie.api]

Create a new client

(def mollie-client
  (mollie.api/new-client {:api-key "your-api-key"}))

Explore available functions

All functions are available in the com.adgoji.mollie.api namespace:

(mollie.api/create-payment mollie-client
                           {:amount
                            {:value    100.00M
                             :currency "EUR"}
                            :description  "Buying some good stuff"
                            :redirect-url "https://example.com"})
;; => {:com.adgoji.mollie.payment/status :open,
;;     :com.adgoji.mollie.payment/redirect-url "https://example.com",
;;     :com.adgoji.mollie.payment/resource "payment",
;;     :com.adgoji.mollie.payment/id "tr_oXHpf8Rk8w",
;;     :com.adgoji.mollie.payment/amount
;;     #:com.adgoji.mollie.amount{:value 100.00M, :currency "EUR"},
;;     :com.adgoji.mollie.payment/description "Buying some good stuff",
;;     :com.adgoji.mollie.payment/created-at
;;     #object[java.time.Instant 0x6e7855d9 "2023-06-29T20:36:32Z"],
;;     :com.adgoji.mollie.link/self
;;     #:com.adgoji.mollie.link{:href "https://api.mollie.com/v2/payments/tr_oXHpf8Rk8w",
;;                              :type "application/hal+json"},
;;     :com.adgoji.mollie.payment/expires-at
;;     #object[java.time.Instant 0x25f9a736 "2023-06-29T20:51:32Z"],
;;     :com.adgoji.mollie.link/dashboard
;;     #:com.adgoji.mollie.link{:href "https://my.mollie.com/dashboard/org_17446479/payments/tr_oXHpf8Rk8w",
;;                              :type "text/html"},
;;     :com.adgoji.mollie.payment/mode :test,
;;     :com.adgoji.mollie.link/documentation
;;     #:com.adgoji.mollie.link{:href "https://docs.mollie.com/reference/v2/payments-api/create-payment",
;;                              :type "text/html"},
;;     :com.adgoji.mollie.payment/profile-id "pfl_25emLDBma5",
;;     :com.adgoji.mollie.payment/method nil,
;;     :com.adgoji.mollie.link/checkout
;;     #:com.adgoji.mollie.link{:href "https://www.mollie.com/checkout/select-method/oXHpf8Rk8w",
;;                              :type "text/html"},
;;     :com.adgoji.mollie.payment/details nil,
;;     :com.adgoji.mollie.payment/sequence-type :oneoff}

(require '[com.adgoji.mollie.payment :as payment])

(::payment/id *1)
;; => "tr_oXHpf8Rk8w"

(mollie.api/get-payment-by-id client "tr_oXHpf8Rk8w")

Usage notes

Specs

All functions in the com.adgoji.mollie.api namespace are covered by spec. If your editor supports spec (like CIDER), it's a very convenient way to explore the library:

spec screencast

Response format

All responses are returned as hash maps with fully qualified keywords as keys. Please browse specs for more details.

Client options

  • :base-url (string: optional, default https://api.mollie.com) - redefine Mollie API base URL.
  • :api-key (string: required)
  • :check-response? (boolean: optional, default false) - additionally check if response conforms to spec. This is disabled by default, so if response is changed on the Mollie side, client will continue working (although results may be unpredictable).
  • :throw-exceptions? (boolean: optional, default true) - throw exceptions on faulty HTTP statuses (>=400) from Mollie API.

Pagination

All functions that return list of entities support pagination parameters - from and limit. Both parameters are optional:

  • if both parameters are omitted - return all entities from all pages.
  • if only from parameter is provided - return all entities from all pages starting from the provided entity ID.
  • if only limit parameter is provided - return only requested number of entities starting from the first entity.
  • if both parameters are provided - return only requested number of entities starting from the provided entity ID.

Features

  • API key authentication
  • Customers
    • Create customer
    • Update customer
    • Delete customer
    • Fetch customer by ID
    • Get list of customers
    • Create customer payment
    • Get list of customer payments
  • Payments
    • Create payment
    • Get payment by ID
    • Cancel payment by ID
    • Update payment by ID
    • Get list of payments
  • Mandates
    • Create mandate
    • Get mandate by ID
    • Revoke mandate by ID
    • Get list of mandates
  • Subscriptions
    • Create subscription
    • Get subscription by ID
    • Update subscription by ID
    • Delete subscription by ID
    • Get list of subscriptions
  • Methods
  • Refunds
  • Chargebacks
  • Captures
  • Orders
  • Shipments
  • Settlements
  • Organizations
  • Permissions
  • Invoices
  • Mollie connect