This library helps interact with Oriskami's API, a risk management intelligence to detect and manage transactions having a risk. Oriskami works by:
- fusioning your transaction data with external data providers;
- applying filters like whitelists, blacklists, rules, or risk scores trained with machine learning; and
- triggering notifications when a risk is detected (e-mail, slack, signed webhooks, etc.).
For a quick start see below, otherwise here are few links:
- Install the binding:
npm install --save oriskami
- Setup your access token:
var Oriskami = require("oriskami")
, oriskami = new Oriskami("YOUR_API_ACCESS_TOKEN", "API_VERSION")
- Bootstrap your account with historical data (
EventPast
; not analyzed):
oriskami.EventPast.create({
"parameters" :{
"id": 16646
, "email": "[email protected]"
, "names": "M Abc"
, "account_creation_time": "2017-05-17 21:50:00"
, "account_id": "10000"
, "account_n_fulfilled": "1"
, "account_total_since_created": "49.40"
, "account_total_cur": "EUR"
, "invoice_time": "2017-05-17 21:55:00"
, "invoice_address_country": "France"
, "invoice_address_place": "75008 Paris"
, "invoice_address_street1": "1 Av. des Champs-Élysées"
, "invoice_name": "M ABC"
, "invoice_phone1": "0123456789"
, "invoice_phone2": null
, "transport_date": "2017-05-18 08:00:00"
, "transport_type": "Delivery"
, "transport_mode": "TNT"
, "transport_weight": "9.000"
, "transport_unit": "kg"
, "transport_cur": "EUR"
, "delivery_address_country": "France"
, "delivery_address_place": "75008 Paris"
, "delivery_address_street1": "1 Av. des Champs-Élysées"
, "delivery_name": "M ABC"
, "delivery_phone1": "0123450689"
, "customer_ip_address": "1.2.3.4"
, "pmeth_origin": "FRA"
, "pmeth_validity": "0121"
, "pmeth_brand": "MC"
, "pmeth_bin": "510000"
, "pmeth_3ds": "-1"
, "cart_products": [ " Product ref #12345 ", " Product ref #45678 " ]
, "cart_details": [{
"name": "Product ref #12345"
, "pu": "10.00"
, "n": "1"
, "reimbursed": " 0"
, "available": "1"
, "amount": "10.00"
, "cur": "EUR"
}, {
"name": "Product ref #45678"
, "pu": "20.00"
, "n": "2"
, "reimbursed": " 0"
, "available": "1"
, "amount": "40.00"
, "cur": "EUR"
}]
, "cart_n": "15000"
, "order_payment_accepted": "2017-05-17 22:00:00"
, "amount_pmeth": "ABC Payment Service Provider"
, "amount_discounts": 0.00
, "amount_products": 20.00
, "amount_transport": 10.00
, "amount_total": 30.00
, "amount_cur": "EUR"
}
}, (err, res) => /* callback */)
- Label events for which the risk (
is_loss
) has materialized:
oriskami.EventLabel.update({
"id" : "1"
, "label": "is_loss"
, "value": "false"
}, (err, res) => /* process results */)
- Send live
Events
:
oriskami.events.create({ }, (err, res) => /* process results */)
Then you will get notified when a risk is detected.
Resource | C | R | U | D | L | Test Specs | |
---|---|---|---|---|---|---|---|
Event data | Event | {} |
123 |
123, {} |
123 |
{} |
See on github |
EventPast | {} |
{} |
See on github | ||||
EventLabel | 123 |
123, {} |
123 |
{} |
See on github | ||
EventLastId | {} |
See on github |
- C: Create
- R: Retrieve
- U: Update
- D: Delete
- L: List
123
: resource id{}
: JSON with query parameters
Oriskami signs its webhooks according to the Json Web Token standard www—here is how to parse incoming requests with express/restify:
var Oriskami = require("oriskami")
, oriskami = new Oriskami()
oriskami.getPublicKey((err) => { /* Retrieve public key (async) */
app.post("/webhook/oriskami" /* Endpoint defined as a notification */
, oriskami.webhook() /* Middleware that parses the Json Web Tokens */
, (req, res, next) => {
console.log(req.json)
})
}
A few code snippets:
Action | Code snippet |
---|---|
1. Change token | oriskami.set("auth", "your-api-token") |
2. Add new resource |
oriskami.extend("resourceName", "resourcePath") |
3. Change timeout | oriskami.set("timeout", 20000) // in ms |
4. To disable signing of JSON payloads on nodejs >= v5 |
oriskami.set("unsigned", true) |
Filters available for most resources (list
).
Filter | Default | Example | Description |
---|---|---|---|
limit |
10 |
{"limit":10} |
At most 10 returned results |
gt |
{"id":{"gt":10}} |
id greater than 10 |
|
gte |
{"id":{"gte":10}} |
id greater than or equal |
|
lt |
{"id":{"lt":10}} |
id less than |
|
lte |
{"id":{"lte":10}} |
id less than or equal |
To run the tests, you will need a Oriskami test API key (from your Oriskami dashboard)
export ORISKAMI_TEST_TOKEN="your-test-api-key"
npm install -g mocha
npm test
Note: on Windows, use SET
instead of export
for setting the ORISKAMI_TEST_TOKEN
environment variable.
- Inspired from stripe-node.
- Developed and maintained by Fabrice Colas for Oriskami.