Skip to content

Server API

BizApp(options)

Return new instance of BizApp. BizApp() is the top level function exported by bizapp module.

Parameter Description Default Required
options.appId The wallet address of the BizApp, set to DEV for developer mode DEV False

Example:

var BizApp = require("bizapp");
var biz = BizApp({
    appId: "yewLaSjEiziHhqgRwmyTomMNfiQm9h4SNM"
});

biz.Express(options, callback)

Return an event handler for Express.JS

Parameter Description Default Required
callback Callback when user passed/failed the challenge True

Example:

var express = require("express");
var bodyParser = require("body-parser"); // Required to parse POST data

var app = express();
app.use(bodyParser.urlencoded({ extended: true }));

app.post("/api/login", biz.Express({}, (result, response) => {
  if (result.err) {
    console.log(result.err);
  }

  var userData = {
    id: 10,
    name: "John Doe"
  };
  var address = result.address; // Authenticated wallet address
  response.send(userData);
}));

Notes:

  • Make sure body-parser middleware is enabled
  • Anything sent via response.send() will be passed to login callback in client side

biz.verify(options, callback)

Callback will return true as the result if the transaction is valid by verifying the transaction with the blockchain, false otherwise

Parameter Description Default Required
options.trxId The transaction ID to be verified True
options.toAddress The recipient address of the transaction True
options.amount The expected amount of the transaction True
options.minConfirmations The minimum confirmation required for a transaction to be consider valid 6 False
options.testnet If set to true, verify from testnet chain false False
options.identifier The identifier that attached with the transaction on the client side False
callback Callback with the result of the verification True

Example:

var options = {
  trxId: "de224c99af5e1b7ec368f126c1c255344d58477c6f366ff0e60502b439807b69",
  toAddress: "TWpWX8BozztxYMc8AEPtXfLtADGUzf7xiG",
  amount: 900000276,
  minConfirmations: 6
};

biz.verify(options, (error, result) => {
  if (!error && result) {
    console.log("Valid payment");
  } else {
    console.log("Invalid payment");
  }
});