Liking cljdoc? Tell your friends :D

clj-comgate

A client for Comgate Payments API.

CircleCI Dependencies Status License

Leiningen/Boot

[clj-comgate "0.2.0"]

Documentation

All functions are designed to return errors instead of throwing exceptions.

All API calls return a tuple within following structure: [keyword response http-response] wherekeyword can be:

  • :ok when a response is a success and parsed
  • :error when a response is parsed but it's an error response
  • :error-unmarshalling when a response is not a well formated

A response is a parsed body of an original HTTP response.

To be able to run examples this line is needed:

(require '[clj-comgate.core :as comgate])

create-payment

Creates a new payment within opts.

(comgate/create-payment {:merchant "asdf", :secret "qwerty", :price 10000, ...})
;; [:ok
;;  {:code 0, :message "OK", :redirect "https://payments.comgate.cz/...
;;  {:request-time 386, ...

To see all possible options see https://platebnibrana.comgate.cz/cz/protokol-api

Example of an error response:

(comgate/create-payment {:merchant "asdf", :secret "qwerty", :price 10000, ...})
;; [:error
;;  {:code 1400, :message "Access from unauthorized location [127.0.0.1]!"
;;  {:request-time 386, ...

get-status

Returns a status of requested payment by opts.

(comgate/get-status {:merchant "asdf", :secret "qwerty", :transId "AAAA-BBBB-CCCC"})
;; [:ok
;;  {:code 0, :label "Test label", :message "OK", ...
;;  {:request-time 386, ...

payment-result-response->map

In case you want to handle the push payment result you can use payment-result-response->map to parse a request body:

(:body request) ;; a Ring request "merchant=merchant_com&test=false&price=10000...
(comgate/payment-result-response->map (:body request)) ;; {:merchant "merchant_com", ...

When accepting the push request Comgate expects OK response, thus you can use comgate/payment-result-success-response for it (it's a Ring's response).

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close