Socket
Socket
Sign inDemoInstall

ubivar

Package Overview
Dependencies
1
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3-beta11 to 0.1.3-beta12

1

lib/Ubivar/index.js

@@ -13,2 +13,3 @@ var path = require("path")

, "status"
, "geoip"
, "fx"

@@ -15,0 +16,0 @@ , "bins"

2

package.json
{
"name": "ubivar",
"version": "0.1.3-beta11",
"version": "0.1.3-beta12",
"description": "API wrapper to Ubivar",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -5,31 +5,22 @@ # Ubivar node.js bindings

Ubivar is an API that takes over the hassle of automatically screening
e-payment for frauds on e-commerce websites.
e-payment for frauds.
Ubivar's purpose is to route e-commerce transactions given their estimated
risk. By default, the three possible routing outcomes are a suggested
rejection, a recommended manual verification, and a proposed acceptance of the
transaction. Ubivar does not need all the business events (aka `resources`),
however the more it has contextual information about the transactions, the
better its accuracy. The two required resources are the `transactions` and the
`labels` that categorize the `transactions` like fraud, not fraud. The API is
simple: you provide Ubivar your request `token` and the bindings provide the
hooks to send and receive resources to the API.
Ubivar routes e-commerce transactions given their risk. By default the three
routing outcomes are rejection, manual verification, and acceptance and the two
elementary resources are the `transactions` and the `labels`. `Transactions`
are online sales pushed to your payment gateway and `labels` define the *a
posteriori* truth about each `transaction`, i.e. {`fraud`, `non-fraud`}.
# Install
Using Ubivar simply requires an access `token`. Then the bindings provide the
hooks to send and receive resources to the API. For each `transaction` that
Ubivar receives, it calculates a routing. Later, as you review manually some of
the `transactions` or as you receive fraud notifications, you `label`
those `transactions` as `fraud`.
`npm install ubivar`
## Quick Start
# Documentation
### A. Install and initialize
Documentation is available at [https://ubivar.com/docs/nodejs](https://ubivar.com/docs/nodejs)
`npm install ubivar`
# API Overview
Every resource is accessed via your `ubivar` instance and accepts an optional
callback as the last argument. The sample code below retrieves your account
information (as json) and updates the primary phone with a random value.
## Quick Start
### A. Init
```js

@@ -40,19 +31,19 @@ var Ubivar = require("ubivar")

### B. Send an e-commerce transaction
### B. Send transactions
```js
ubivar.transactions.create({
"user_id" : "test_phahr3Eit3_123" // the id of your client
, "user_email" : "test_phahr3Eit3@gmail-123.com" // the email of your client
, "type" : "sale" // the type of transaction
, "status" : "success" // whether the transaction was authorized
"user_id" : "test_phahr3Eit3_123" // your client's id
, "user_email" : "test_phahr3Eit3@gmail-123.com" // your client email
, "type" : "sale" // the transaction type
, "status" : "success" // the transaction status
, "order_id" : "test_iiquoozeiroogi_123" // the shopping cart id
, "tx_id" : "client_tx_id_123" // the transaction id of this transaction
, "amount" : "43210" // the amount of the transaction in cents
, "tx_id" : "client_tx_id_123" // the transaction id
, "amount" : "43210" // the amount in cents
, "payment_method":{
"bin" :"123456" // the bank identification number of the card
"bin" :"123456" // the BIN of the card
, "brand" :"Mastercard" // the brand of the card
, "funding" :"credit" // the type of card
, "country" :"US" // the iso country code of the card
, "name" :"M Man" // the name of the card holder
, "cvc_check":"pass" // whether the card passed the cvc check
, "country" :"US" // the card country code
, "name" :"M Man" // the card holder's name
, "cvc_check" :"pass" // the cvc check result
},"billing_address":{

@@ -76,3 +67,3 @@ "line1" :"123 Market Street" // the billing address

### C. Retrieve its status
### C. Retrieve routing and label
```js

@@ -89,58 +80,45 @@ ubivar.labels.retrieve(txId, function(err, res){

## All resources and methods
## Resources, actions, and arguments
Every resource is accessed via your `ubivar` instance and accepts an optional
callback as the last argument. In the matrix below we list the resources
(rows), the actions (columns) and the arguments (cells). The full documentation
is available at
[https://ubivar.com/docs/nodejs](https://ubivar.com/docs/nodejs).
+ [Me](https://www.ubivar.com/docs/nodejs#me)
+ [retrieve()](https://www.ubivar.com/docs/nodejs#retrieve_your_information)
+ [update(params)](https://www.ubivar.com/docs/nodejs#update_your_information)
+ [Account](https://www.ubivar.com/docs/nodejs#accounts)
+ [create(params)](https://www.ubivar.com/docs/nodejs#create_an_account)
+ [retrieve(id)](https://www.ubivar.com/docs/nodejs#retrieve_an_account)
+ [update(id, params)](https://www.ubivar.com/docs/nodejs#update_an_account)
+ [del(id)](https://www.ubivar.com/docs/nodejs#delete_an_account)
+ [list()](https://www.ubivar.com/docs/nodejs#list_accounts)
+ [Transaction](https://www.ubivar.com/docs/nodejs#transactions)
+ [create(params)](https://www.ubivar.com/docs/nodejs#create_a_transaction)
+ [retrieve(id)](https://www.ubivar.com/docs/nodejs#retrieve_a_transaction)
+ [update(id, params)](https://www.ubivar.com/docs/nodejs#update_a_transaction)
+ [del(id)](https://www.ubivar.com/docs/nodejs#delete_a_transaction)
+ [list()](https://www.ubivar.com/docs/nodejs#list_transactions)
+ [Login](https://www.ubivar.com/docs/nodejs#login)
+ [create(params)](https://www.ubivar.com/docs/nodejs#create_login_event)
+ [retrieve(id)](https://www.ubivar.com/docs/nodejs#retrieve_login_event)
+ [del(id)](https://www.ubivar.com/docs/nodejs#delete_login_event)
+ [list()](https://www.ubivar.com/docs/nodejs#list_login_events)
+ [Logout](https://www.ubivar.com/docs/nodejs#logout)
+ [create(params)](https://www.ubivar.com/docs/nodejs#create_logout_event)
+ [retrieve(id)](https://www.ubivar.com/docs/nodejs#retrieve_logout_event)
+ [del(id)](https://www.ubivar.com/docs/nodejs#delete_logout_event)
+ [list()](https://www.ubivar.com/docs/nodejs#list_logout_events)
+ [Item](https://www.ubivar.com/docs/nodejs#items)
+ [create(params)](https://www.ubivar.com/docs/nodejs#create_item)
+ [retrieve(id)](https://www.ubivar.com/docs/nodejs#retrieve_item)
+ [update(id, params)](https://www.ubivar.com/docs/nodejs#update_item)
+ [del(id)](https://www.ubivar.com/docs/nodejs#delete_item)
+ [list(params)](https://www.ubivar.com/docs/nodejs#list_items)
+ [Label](https://www.ubivar.com/docs/nodejs#labels)
+ [create(params)](https://www.ubivar.com/docs/nodejs#create_label)
+ [retrieve(id)](https://www.ubivar.com/docs/nodejs#retrieve_label)
+ [update(id, params)](https://www.ubivar.com/docs/nodejs#update_label)
+ [del(id)](https://www.ubivar.com/docs/nodejs#delete_label)
+ [list(params)](https://www.ubivar.com/docs/nodejs#list_labels)
+ [Fx](https://www.ubivar.com/docs/nodejs#fx)
+ [list(params)](https://www.ubivar.com/docs/nodejs#list_fx)
+ [BINs](https://www.ubivar.com/docs/nodejs#bin)
+ [list(params)](https://www.ubivar.com/docs/nodejs#list_bin)
+ [Status](https://www.ubivar.com/docs/nodejs#status)
+ [list(params)](https://www.ubivar.com/docs/nodejs#list_status)
| Resource | Create | Retrieve | Update | Delete | List |
| ------------- |:------:|:--------:|:------:|:------:|:------:|
| Me | |<a href="https://ubivar.com/docs/nodejs#retrieve_your_information">_</a> |<a href="https://ubivar.com/docs/nodejs#retrieve_your_information">param</a>| | |
| Accounts |<a href="https://ubivar.com/docs/nodejs#create_an_account">object</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_an_account">id</a> |<a href="https://ubivar.com/docs/nodejs#update_an_account">id, params</a>|<a href="https://ubivar.com/docs/nodejs#delete_an_account">id</a>|<a href="https://ubivar.com/docs/nodejs#list_accounts">params</a>|
| Transactions |<a href="https://ubivar.com/docs/nodejs#create_a_transaction">object</a>| <a href="https://ubivar.com/docs/nodejs#retrieve_a_transaction">id</a> |<a href="https://ubivar.com/docs/nodejs#update_a_transaction">id, params</a>|<a href="https://ubivar.com/docs/nodejs#delete_a_transaction">id</a>|<a href="https://ubivar.com/docs/nodejs#list_transactions">params</a>|
| Login |<a href="https://ubivar.com/docs/nodejs#create_login_event">object</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_login_event">id</a> | |<a href="https://ubivar.com/docs/nodejs#delete_login_event">id</a>|<a href="https://ubivar.com/docs/nodejs#list_login_events">params</a>|
| Logout |<a href="https://ubivar.com/docs/nodejs#create_logout_event">object</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_logout_event">id</a> | |<a href="https://ubivar.com/docs/nodejs#delete_logout_event">id</a>|<a href="https://ubivar.com/docs/nodejs#list_logout_events">params</a>|
| Items |<a href="https://ubivar.com/docs/nodejs#create_item">object</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_item">id</a> |<a href="https://ubivar.com/docs/nodejs#update_item">id, params</a>|<a href="https://ubivar.com/docs/nodejs#delete_item">id</a>|<a href="https://ubivar.com/docs/nodejs#list_items">params</a>|
| Labels |<a href="https://ubivar.com/docs/nodejs#create_label">object</a>|<a href="https://ubivar.com/docs/nodejs#retrieve_label">id</a> |<a href="https://ubivar.com/docs/nodejs#update_label">id, params</a>|<a href="https://ubivar.com/docs/nodejs#delete_label">id</a>|<a href="https://ubivar.com/docs/nodejs#list_labels">params</a>|
| Fx | | | | |<a href="https://ubivar.com/docs/nodejs#list_fx">params</a>|
| Bins | | | | |<a href="https://ubivar.com/docs/nodejs#list_bin">params</a>|
| Status | | | | |<a href="https://ubivar.com/docs/nodejs#list_status">params</a>|
| Geoip | | | | |<a href="https://ubivar.com/docs/nodejs#list_geoip">`{"ip":ip}`</a>|
## Filter parameters
| Filter | Default | Example | Description |
| ------------- |:-------:|:--------------------|:------------------------------|
| `start_after` | | `{"start_after":10}`| `id` after the one specified |
| `end_before` | | `{"end_before":10}` | `id` before the one specified |
| `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 |
## Configuration
+ `ubivar.set("auth", "your-api-token")`
+ `ubivar.setTimeout(20000) // in ms`, node's default is `120000ms`
+ `ubivar.set("timeout", 20000) // in ms`, node's default is `120000ms`
# More information / wikis
## Issues and feature requests
+ [In-depth documentation](https://www.ubivar.com/docs/nodejs)
+ [Report issues and feature requests](https://github.com/ubivar/ubivar-node/issues)
# Development
## Development

@@ -156,4 +134,4 @@ To run the tests, you will need a Ubivar test API key (from your [Ubivar dashboard](https://my.ubivar.com))

# Author
## Author
Originally inspired from [stripe-node](https://github.com/stripe/stripe-node). Developed by [Fabrice Colas](https://fabricecolas.me) ([fabrice.colas@gmail.com](mailto:fabrice.colas@gmail.com)). Maintained by Ubivar.

@@ -8,2 +8,4 @@ "use strict"

ubivar.set("timeout", 20000)
describe("Resources", function() {

@@ -14,3 +16,3 @@ var rootProps = ["log","_api"]

, allResources = ubivar.get("resources")
, specialResources = ["me", "fx", "bins", "status"]
, specialResources = ["me", "fx", "bins", "geoip", "status"]
, genericResources = _.difference(allResources, specialResources)

@@ -49,10 +51,8 @@

var message = "Should be " + (isAuthorized?" ":"un") + "authorized "
if(!!token){
message += "'"+ token.slice(0,5) +"...'"
} else {
message += "'" + token + "'"
}
message += !!token ? ("'"+token.slice(0,5)+"...'") : ("'"+token+"'")
it(message, function(done){
var ubivar = require("../../lib")(token, "latest")
ubivar.set("timeout", 20000)
ubivar.me.retrieve(function(gotError, res){

@@ -94,3 +94,3 @@ if( isAuthorized && gotError) done((new Error(message)))

} else {
done(new Error("Should not return any deleted resource"))
done(new Error("Should fail to delete 'me'!"))
}

@@ -185,3 +185,2 @@ })

})
})

@@ -294,2 +293,24 @@

describe("Geoip", function(){
it("Should return a valid geoip resource", function(done){
ubivar.geoip.list({"ip":"207.97.227.239"}, function(err, res){
var result = !err && res.data.length > 0 ? res.data[0] : null
, fields = ["ip","start_ip","end_ip","block_length","country","region","city","latitude","longitude"]
if(err){ return done(err)
} else if(res.data.length === 0){
return done(new Error("Did not return results" ))
}
_.each(fields, function(field){
if(!_.has(result, field)){
return done(new Error("Should have a '" + field + "'"))
}
})
done()
})
})
})
_.each(genericResources, function(resource){

@@ -296,0 +317,0 @@ describe(resource[0].toUpperCase() + resource.slice(1)

@@ -34,6 +34,2 @@ "use strict"

describe("Timeout", function(){
it("Should default to the one of node", function(){
expect(ubivar.get('timeout')).to.equal(require('http').createServer().timeout)
})
it("Should allow to change default value", function(){

@@ -40,0 +36,0 @@ ubivar.set("timeout", 900);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc