Clojure library for interacting with and creating OpenTransact assets.
This is under heavy development right now and does therefore not have a stable API yet.
Add the following dependency to your project.clj
file:
[opentransact "0.0.1"]
(use 'opentransact.core)
The Asset protocol contains the following 4 functions:
- asset-url return the OpenTransact Transaction URL for asset
- request creates a URL containing an OpenTransact Transfer Request
- authorize creates a URL containing an OpenTransact Transfer Authorization Request
- transfer! performs an actual OpenTransact Transfer
We have a RemoteAsset client which performs this over http.
However internal assets can be created adhearing to the same Asset protocol that can be wrapped in an OpenTransact Handler for Ring allowing you to create your own custom OpenTransact services.
Transfer directly:
(transfer asset {:to "AAAA" :amount 20M :note "For tomatos"})
=> {:xid "http://asset.com/transactions/123123123" :from "BBBB" :to "AAAA" :amount 20M :note "For tomatos"}
Create a Transfer Request for a html link or redirection:
(request asset {:to "AAAA" :amount 20M :note "For tomatos"})
=> "http://asset.com/usd?to=AAAA&amount=20¬e=For%20tomatos"
Create a Transfer Authorization Request for a html link or redirection:
(authorize asset {:to "AAAA" :amount 20M :note "For tomatos"})
=> "http://asset.com/usd?to=AAAA&amount=20¬e=For%20tomatos&client_id=abcdefg"
Create an OpenTransact RemoteAsset asset type:
(use 'opentransact.client)
(def asset (ot-asset "http://asset.com/usd" { :client-id "abcdefg" :client-secret "ssh" :token "my-oauth-token" :token-url "http://asset.com/token"}))
You create an asset handler by passing in an asset and a view handler to be displayed to the user for transfer-request and transfer-authorizations:
(opentransact.server/asset-handler asset auth-view)
This requires a backend that will implement the above transfer and authorize multimethods locally.
Copyright (C) 2012 Pelle Braendgaard and PicoMoney Company
Distributed under the Eclipse Public License, the same as Clojure.