NAV Navbar
json javascript php


Introduction

The offered PumaPay PullPayment Protocol brings the solution to enable day-to-day payment scenarios, such as top-ups and subscriptions on the blockchain, thus adding convenience and usability to this revolutionary technology that can be integrated into your payment solution or paymebnt application.

With PumaPay's managed payment service, businesses can easily set up their account and start accepting cryptos immediately.

PullPayment models define how your customers will be billed for using your products. It’s like a billing/service plan. You can create one or multiple billing models.

Shown below are two sets of API’s which are required in order to utilize the recurring PullPayment Protocol.

Please note: in order to utilize these web services you must have a valid API key. The API key is obtained once you successfully onboard with the Business Console.

The API calls are subject to change in the future.

Business Console APIs - v2

Business Console - https://psp-backend.pumapay.io

All of the calls require the merchant API-key (pma-api-key). The API key authorises and identifies each merchant to retrieve their business data from the PumaPay servers.

Retrieve the list of products

Retrieves the list of the merchants products. Once the merchant creates a product(s) the call allows to retrieve all of the stored Products related to that merchant. It requires the businessID (the unique ID generated for the merchant during the registration process) and networkID (1 is for the mainnet, 3 is for the Ropsten testnet). The testnet is used to test the applications before submitting them on the mainnet where they can be revealed to the customers.

Method – GET

api/v2/api-key-auth/products/{businessID}/{networkID}

Body of the request

**Body of the request**
Not required
function calljsonrpc(host_url, businessID, networkID, pma-api-key)
{
    URL_params = host_url + "api/v2/api-key-auth/products/" + businessID + "/" + networkID;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET",  URL_params, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("pma-api-key", pma-api-key);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function calljsonrpc($host_url, $businessID, $networkID, $pma_api_key)
  {
      //here you need to pass the host and the port of the server you are calling
      //as well as the network 3 for testnet and 1 for mainnet
      $url_params = "$host_url/api/v2/api-key-auth/products/$businessID/$networkID";

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pma_api_key;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url_params);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Parameters “businessID”: merchants unique ID generated at the merchants registeration

“networkID”: (1) for the mainnet, (3) for the testnet where apps can be tested

Header Parameters “pma-api-key”: merchants authorization API key, the unique key that identifies and authorises the merchant

Sample response

{

    "success": true,

    "status": 200,

    "message": "Successfully retrieved product details.",

    "data": [

        {

            "productID": "product_random_uid_generated_at_product_creation",

            "businessID": "business_random_uid_generated_at_registration",

            "categoryID": 15 //integer, represents a category,

            "tags": null //will be used for business search index in the future,

            "productName": "Name of the product",

            "productDescription": "Product Description",

            "creationTimestamp": "1554466395" //unix timestamp representing the date of the product creation,

            "lastUpdateTimestamp": "1554466395" // unix timestamp representing the date of the last product update,

            "productUrl": "www.example.com" //link to the product,

            "imageUrl": "www.imageURL.com" //link to the image,

            "verified": true //reflects if the product has been verified,

            "usdTotalEarnings": "61644" //total earnings in USD for this product,

            "eurTotalEarnings": "356084" //total earning in EUR for this product,

            "jpyTotalEarnings": "159658" total earning in JPY for this product,

            "gbpTotalEarnings": "0" //total earning in GBP for this product,

            "activeCustomers": 27 //number of active customers who are using this product/service,

            "numOfBilling": 28 //home manh times the billing has been made,

            "enabled": true //if the product is live,

            "totalEarnings": 10000 //the value in the base currency in cents of total earning for this product

        },

    ]

}

Retrieve billing models

Retrieves the list of all of the merchants billing models. Under each product the merchants will create billing models which identify the type of payment for their certain product/service categorised under the product(s)

Method – GET

api/v2/api-key-auth/pull-payment-models

Body of the request

**Body of the request**
Not required
function calljsonrpc(host_url, pma-api-key)
{
    URL_params = host_url + "api/v2/api-key-auth/pull-payment-models/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET",  URL_params, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("pma-api-key", pma-api-key);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function calljsonrpc($host_url, $pma_api_key)
  {
      //here you need to pass the host and the port of the server you are calling
      //as well as the network 3 for testnet and 1 for mainnet
      $url_params = "$host_url/api/v2/api-key-auth/pull-payment-models/";

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pma_api_key;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url_params);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Header Parameters

“pma-api-key”: merchants authorization API key

Sample Response

{

    "success": true,

    "status": 200,

    "message": "Successfully retrieved payment models.",

    "data": [

        {

            "id": "generated_id_of_the_billing_model",

            "productID": "ID of the product the billing model is related to",

            "title": "Payment Model Title",

            "description": "Payment Model Description",

            "amount": 2757 //base currency amount in cents,

            "initialPaymentAmount": 0 //the amount of the initial charge,

            "trialPeriod": 0 //unix timestamp value representing the duration of the trails period duration,

            "currency": "GBP" //base currency of the billing model repserented to the customer,

            "numberOfPayments": 39 //how many payments there will be in total,

                "frequency": 72726 //unix timestamp value representing the charge period, ex: weekly, monthly,

            "typeID": 2 //the type of the billing model,

            "networkID": 3 //1 for the mainnet, 3 for Ropsten testnetwork for application testing,

            "automatedCashOut": false //when set to true, it will automatically cash out merchants funds to the treasury,

            "cashOutFrequency": 1 //on which iteration will the funds be transferred to the treasury",

            "treasuryWallet": "0xD808D22F4f8b418faA3c4cC2D941eFCe8cB99" //the unique merchants wallet where the funds will be stored (treasury)"

        }

    ]

}

Retrieve PullPayments

Retrieves all of the pullpayments. Once the customers start paying the merchant, the new PullPayments will be created, this call allows to retrieve the list of the existing PullPayments and their details.

Method – GET

api/v2/api-key-auth/pull-payments/business/{businessID}?uniqueReferenceID={customeruniqueReferenceID}&page={page}&itemsPerPage={itemsPerPage}

Body of the request

**Body of the request**
Not required
function calljsonrpc(host_url, pma-api-key)
{
    URL_params = host_url + "api/v2/api-key-auth/pull-payments/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET",  URL_params, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("pma-api-key", pma-api-key);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function calljsonrpc($host_url, $pma_api_key)
  {
      //here you need to pass the host and the port of the server you are calling
      //as well as the network 3 for testnet and 1 for mainnet
      $url_params = "$host_url/api/v2/api-key-auth/pull-payments/";

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pma_api_key;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url_params);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Header Parameters

“pma-api-key”: merchants authorization API key

Sample response

{

    "success": true,

    "status": 200,

    "message": "Successfully retrieved all PullPayments",

    "data": [

        {

            "id": "payment_random_uid_generated0000",

            "title": "Payment Model Title",

            "productID": "product ID the PullPayment is related to",

            "description": "PullPayment Description",

            "amount": 8416 // PullPayment amount in cents in the base currency,

            "initialPaymentAmount": 0 //the initial PullPayment required amount,

            "initialNumberOfPayments": 57 //how many PullPayments there will be in total,

            "trialPeriod": 8856 //time in the unix timestamp format representing the duration of the trial period,

            "currency": "JPY" //PullPayments base currency,

            "hdWalletIndex": 0 //index of the HD wallet where the money will be transferred, 0 represents the first address, the treasury,

            "numberOfPayments": 55 //how many payments were made already,

            "frequency": 78517 //time in the unix timestamp format representing how often the recurring payment will be made,

            "type": "recurringWithTrial" //type of the PullPayment, in this case it is a recurring PullPayment with trial period,

            "status": "done" //status of the PullPayment, if all required payments were made,

            "networkID": 3 //mainnet or Ropsten testnet,

            "nextPaymentDate": "1554466395" //when is the next payment date,

            "lastPaymentDate": 454656 //when was the last date of the PullPayment, time in the unix timestamp format,

            "startTimestamp": "1554466395" //when the PullPayment was initialised,

            "customerAddress": "0xEA674fdDe714fd979de3EdF0F56AA9716B890000" //wallet address from which the PullPayments are made,

            "pullPaymentAddress": "0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8" //wallet address to which the payments are made,

            "automatedCashOut": false //specifies if the cashing out happens automaticall or manually,

            "cashOutFrequency": 1 //after each payment how often and on which iteration the cashing out happens,

            "treasuryWallet": "0xD80D21F4f86115b403faA3c4cC2D945eFCe6cB99" //address of the treasury wallet,

            "userID": dkeii45430402 //ID of the paying user

            }

        ]

    }

Retrieve all transactions

Retrieves all of the transactions for a business on a specified network. The merchant will provide their uniquely generated business ID and can select between the mainnet (1) or the Ropsten testnet (3) in case of testing the application.

Method – GET

api/v2/api-key-auth/transactions/all/{businessID}?page={page}&itemsPerPage={itemsPerPage}

**Body of the request**
Not required
function calljsonrpc(host_url, pma-api-key, businessID, networkID, productID, billingModelID, transactionStatuses, page, itemsPerPage)
{
    URL_params = host_url + "api/v2/api-key-auth/transactions/{businessID}/{networkID}";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET",  URL_params, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("pma-api-key", pma-api-key);
    if(productID){
        xmlhttp.setRequestHeader("productID", productID);
    }
    if(billingModelID){
        xmlhttp.setRequestHeader("billingModelID", billingModelID);
    }
    if(transactionStatuses){
        xmlhttp.setRequestHeader("transactionStatuses", transactionStatuses);
    }if(page){
        xmlhttp.setRequestHeader("page", page);
    }
    if(itemsPerPage){
        xmlhttp.setRequestHeader("itemsPerPage", itemsPerPage);
    }
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function calljsonrpc($host_url, $pma_api_key, $businessID, $networkID, $productID = null, $billingModelID = null, $transactionStatuses = null, $page = null, $itemsPerPage = null)
  {
      //here you need to pass the host and the port of the server you are calling
      //as well as the network 3 for testnet and 1 for mainnet
      $url_params = "$host_url/api/v2/api-key-auth/transactions/$businessID/$networkID";

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pma_api_key;
      if($productID){
        $request_headers[] = "productID: " . $productID;
      }
      if($billingModelID){
        $request_headers[] = "billingModelID: " . $billingModelID;
      }
      if($transactionStatuse){
        $request_headers[] = "transactionStatuses: " . $transactionStatuses;
      }
      if($page){
        $request_headers[] = "page: " . $page;
      }
      if($itemsPerPage){
        $request_headers[] = "itemsPerPage: " . $itemsPerPage;
      }

      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url_params);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Parameters

“businessID”: merchants unique business ID generated by the system at registration

“networkID”: (1) for the mainnet, (3) for the testnet in case of the application testing purposes

Query Parameters

“productID”: by specifying this parameter, the merchant can retrieve the list of the pullpayments for a specific product by its unique ID (not required)

“billingModelID”: by specifying this parameter, the merchant can retrieve the list of the pullpayments for a specific billing model by its unique ID (not required)

“transactionStatuses”: array of numbers [1 (pending), 2 (failed), 3 (success)], the merchant can retrieve only the transactions with a certain status. Needs to be passed as an array

“page”: pagination, which page number to load based on the itemsPerPage value (ex.: 100 records, 20 records per page, page 3 will display records 40-60, not required)

“itemsPerPage”: how many records to display on each page (not required)

Header Parameters

“pma-api-key”: merchants authorization API key

Sample response

{

    "success": true,

    "status": 200,

    "message": "Successfully retrieved transactions",

    "data": [

        {

            "execution_date": "1554465519" //time and date in the unix timestamp format representing when the transaction took place,

            "transaction_status": 2 //array of number representing statuses, 1 - pending, 2 - failed, 3 - success,

            "billing_model_name": "Payment Model Title",

            "tx_hash": "0xa31187efd73c666825da72ded11b99271a2975d9c47ec79e756fd77ba9104989" //unique transaction hash on the blockchain,

            "customer_address": "0xEA674fdDe714fd979de3EdF0F56AA9716B890498" //address from which the payment was made,

            "pma_balance": 0 //currenct balance of the wallet, ex.: after cashing out

        }

    ]

}

Wallet Core APIs - v2.1

Mainnet URL - https://wallet-api.pumapay.io/mainnet

Testnet (Ropsten) URL - https://wallet-api.pumapay.io/testnet

Wallet

Proxy JSON Rpc

Gets information about an Ethereum block

You need to specify block in params variable for the specific block or use latest for the latest block on the Ethereum network

Method – POST

/api/v2/wallet/json-rpc/{network}

Body of the request

{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByNumber",
  "params": [
    "latest",
    true
  ],
  "id": 1
}
function calljsonrpc(host_url, network, fcm_mobile_token)
{
    var ItemJSON;

    ItemJSON = [{
                    "jsonrpc": "2.0",
                    "method": "eth_getBlockByNumber",
                    "params": [
                        "latest",
                        true
                    ],
                    "id": 1
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    //as well as the network 3 for testnet and 1 for mainnet
    URL = host_url + "/api/v2/wallet/json-rpc/" + network

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function calljsonrpc($host_url, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      //as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/wallet/json-rpc/$network";

      $jsonrpc = "2.0";
      $method = "eth_getBlockByNumber";
      $params = ["latest", true];
      $id = 1;

      $post_data = array(
          'jsonrpc' => $jsonrpc,
          'method' => $method,
          'params' => $params,
          'id' => $id
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Parameters “jsonprc”: version of the JSON Rpc

“method”: method to call

“params”: take the number of the block to fetch the information for and it should be set to true

“id”: testnet (3) or mainnet (1)

Get provider by network

Retrieve the information about the current API provider for the connection to the Ethereum blockchain

Method – GET

/api/v2/wallet/provider/{network}

function getProvider(host_url, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/provider/" + network;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getProvider($host_url, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/provider/$network";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Create Wallet

Method to create a new wallet, return the mnemonic phrase and treasury address

Method - POST

/api/v2/wallet/create/

Body of the request

{
  "network": 3
}
function createWallet(host_url, network, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "network": network
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/create/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createWallet($host_url, $network, $fcm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/wallet/create/";

      $post_data = array(
          'network' => $network
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Decrption Treasury – the address at index 0 (address_0) generated from the mnemonic seed and index 0 the derivation path. It is used for storing the Ether for gas payments and PMA

Restore Wallet

Restores the HD wallet from a 12-word seed secret mnemonic phrase, and returns private and public keys for the address_0, which is the treasury/gas account.

Method - POST

/api/v2/wallet/restore/

Body of the request

{
  "mnemonic": "design carbon sudden humor position earn system early wrist rib enact strong",
  "network": 3
}
function restoreWallet(host_url, mnemonic, network, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "mnemonic": mnemonic,
                    "network": network
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/create/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function restoreWallet($host_url, $mnemonic, $network, $fcm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/wallet/create/";

      $post_data = array(
          'mnemonic' => $mnemonic,
          'network' => $network
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Parameters Mnemonic – 12-word seed secret mnemonic phrase used to generate all of the HD wallets addresses

network: Testnet (3) or Mainnet (1)

Load ERC Transfers from Chain

Retrieves the history for all of the transfers for an address. The results are split into pages by specified page index number based on records/itemsPerPage offset count.

Method – GET

/api/v2/wallet/transfers/{{customer_address}}?page={pageNumber}&itemsPerPage={itemsPerPage}

function loadErcTransfers(host_url, customer_address, page_offset, items_per_page, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/transfers/" + customer_address + "?page=" + page_offset + "&itemsPerPage=" + items_per_page;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function loadErcTransfers($host_url, $customer_address, $page_offset, $items_per_page, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/transfers/$customer_address?page=$page_offset&itemsPerPage=$items_per_page";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Parameters

customer_address: customer's address from where the transactions will be retreive

page: page index for page offset based on the number of total history records and items per page

itemsPerPage: number of records to display per page

Body of the request: is not required

Load Transactions from Chain

Retrieves the transaction history for a given address. The results are split into pages by specified page index number based on records/itemsPerPage offset count.

Method – GET

/api/v2/wallet/transactions/{{customer_address}}?page=0&itemsPerPage={itemsPerPage}

function getTransactionsFromChain(host_url, customer_address, page_offset, items_per_page, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/transactions/" + customer_address + "?page=" + page_offset + "&itemsPerPage=" + items_per_page;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getTransactionsFromChain($host_url, $customer_address, $page_offset, $items_per_page, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/transactions/$customer_address?page=$page_offset&itemsPerPage=$items_per_page";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Headers: “fcm-mobile-token”: firebase authorization token

Inline Parameters

customer_address: customer's address from where the transactions will be retreive

page: page index for page offset based on the number of total history records and items per page

itemsPerPage: number of records to display per page

Load All Transactions Transfers

Retrieves the transaction history and token transfers for a given address. The results are split into pages by the number of items specified per page.

Method – GET

/api/v2/wallet/transactions-transfers/{{customer_address}}?page={pageNumber}&itemsPerPage={itemsPerPage}

function getAllTransactionsTransfers(host_url, customer_address, page_offset, items_per_page, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/transactions-transfers/" + customer_address + "?page=" + page_offset + "&itemsPerPage=" + items_per_page;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getAllTransactionsTransfers($host_url, $customer_address, $page_offset, $items_per_page, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/transactions-transfers/$customer_address?page=$page_offset&itemsPerPage=$items_per_page";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers)
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Parameters

customer_address: customer's address from where the transactions will be retreive

page: page index for page offset based on the number of total history records and items per page

itemsPerPage: number of records to display per page

Get next N transactions

Gets the N number of the scheduled and upcoming transactions and payments for a given address

Method – GET

/api/v2/wallet/future-transactions/{{customer_address}}?count={recordCount}

function getNextTransactions(host_url, customer_address, recordCount, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/future-transactions/" + customer_address + "?count=" + recordCount;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getNextTransactions($host_url, $customer_address, $recordCount, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/future-transactions/$customer_address?count=$recordCount";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Parameters

customer_address: customer's address from where the transactions will be retreive

count: number of records to display per page, 10 in this case. The number can be custom abd you can return less or more future transactions

Get selected Rates with Balances

Populates the rates of the tokens values equivalent to the selected currency based on the exchange price of the ERC20 tokens for a given address.

Method – PUT

http://localhost:8081/api/v2/erc20/rates-balances/

Headers:

“fcm-mobile-token”: firebase authorization token

Body of the request

{
    "tokenAddresses": ["0xba265956aa7da6981be0d3387ae2d7c6a1f76108", "0x27babeadb7698d2a8da68c682b8c5875828abdf2"],
    "tokenSymbols": {
        "EOS": "0xba265956aa7da6981be0d3387ae2d7c6a1f76108",
        "TRX": "0x27babeadb7698d2a8da68c682b8c5875828abdf2"
    },
    "walletAddress": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
    "network": 1,
    "currency": "usd"
}
function getSelectedRatesWithBalance(host_url, network, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "tokenAddresses": ["0xba265956aa7da6981be0d3387ae2d7c6a1f76108", "0x27babeadb7698d2a8da68c682b8c5875828abdf2"],
                    "tokenSymbols": {
                        "EOS": "0xba265956aa7da6981be0d3387ae2d7c6a1f76108",
                        "TRX": "0x27babeadb7698d2a8da68c682b8c5875828abdf2"
                    },
                    "walletAddress": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
                    "network": network,
                    "currency": "usd"
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/rates-balances/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function getSelectedRatesWithBalance($host_url, $network, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/erc20/rates-balances/";

      $post_data = array(
          'network' => $network
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Parameters

tokenAddresses: the list of the ERC20 token addresses

tokenSymbols: token symbol or ticker, a shorthand of the tokens name on the market

walletAddress: address which holds the given tokens

network: testnet (3) or mainnet (1)

currency: currency to display the amount equivalent to the token value according to the exchanges information

Contract History

Retrieves transactions and executions history of the merchants contracts

Method – GET

/api/v2/wallet/contract-history/{{merchant_address}}

function getContractHistory(host_url, merchant_address, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "api/v2/wallet/contract-history/" + merchant_address;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getContractHistory($host_url, $merchant_address, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/contract-history/$merchant_address";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Parameters merchant_address: wallet adrdress of the merchant used for the specified smart contract

Description

contract: contract address to update

network: testnet (3) or mainnet (1)

Update Contract

Updates contracts values/parameters on a given network

Method – PUT

/api/v2/wallet/{contract}/{network}

function getContractHistory(host_url, contract, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "api/v2/wallet/" + contract + "/" + network;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getContractHistory($host_url, $contract, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/wallet/contract-history/$contract/$network";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_PUT, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Parameters

contract: contract address

network: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Get Tokens by Address

Retrieves the information about the ERC20 token from a given token address

Method – GET

/api/v2/erc20/token/{token_address}/{network}

function getTokensByAddress(host_url, token_address, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/token/" + token_address + "/" + network;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getTokensByAddress($host_url, $token_address, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/token/$token_address/$network";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Headers: fcm-mobile-token: firebase authorization token

Inline Parameters

token_address: address of the token on the blockchain

network: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Get ERC20 Tokens

Takes address or array of addresses and the network ID as the parameters and returns the rates for the tokens and/or Ethereum on the requested network

Method – GET

/api/v2/erc20/{address}/{networkID}

function getErc20Tokens(host_url, token_address, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/" + token_address + "/" + network + "/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getErc20Tokens($host_url, $token_address, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/$token_address/$network/";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

address: address or list of addresses of the token(s) to retrieve the rates for

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

ERC20 Rates

Fetches the rates from the exchange and updates the rates for all the tokens in the database

Method – PUT

/api/v2/erc20/rates/

function setErc20Rates(host_url, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/rates/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function setErc20Rates($host_url, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/rates/";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_PUT, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Token From a Contract

Retrieve the token details from the contract address

Method – GET

/api/v2/erc20/custom-token/{tokenAddress}/{network}

function getTokenFromContract(host_url, token_address, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/custom-token/" + token_address + "/" + network + "/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getTokenFromContract($host_url, $token_address, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/custom-token/$token_address/$network/";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

token_address: ERC20 address of the token

network: 1 for the Mainnet, 3 for the TestNet (Ropsten)

Add Custom Token

Adds the new token to the list of tokens

Method – POST

/api/v2/erc20/tokens/

Body of the request

{
  "address": "0x1234567890123456789912345678991234567899",
  "name": "test_token",
  "symbol": "TTN",
  "decimals": 6,
  "networkID": 1,
  "ico": "some icon"
}
function addCustomToken(host_url, token_address, token_name, token_symbol, decimals, ico, network, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "address": token_address,
                    "name":  token_name,
                    "symbol": token_symbol,
                    "decimals": decimals,
                    "networkID": network,
                    "ico": ico
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/tokens/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function addCustomToken($host_url, $token_address, $token_name, $token_symbol, $decimals, $ico, $network, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/erc20/tokens/";

      $post_data = array(
            "address" => $token_address,
            "name" => $token_name,
            "symbol" => $token_symbol,
            "decimals" => $decimals,
            "networkID" => $network,
            "ico" => $ico
      );

      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $fcm_mobile_token);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

address: address of a given token

name: name of the token

symbol: token ticker as represented on the market

decimals: decimal points after the whole number, the minimum divisible of a token

networkID: testnet (3) or mainnet (1)

ico: initial coin offering which originally introduced the token

Delete Custom ERC20 Token

Retrieves the ERC20 token address as a parameter and deletes it from the list of tokens

Method – DELETE

/api/v2/erc20/tokens/{tokenAddress}

function erc20Token(host_url, tokenAddress, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/api/v2/erc20/tokens/" + tokenAddress;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DELETE", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function erc20Token($host_url, $tokenAddress, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/tokens/$tokenAddress";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_DELETE, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params tokenAddress: address of the ERC20 token to delete from the database

ERC20 Balance

Fetches the list of available tokens for a given address and returns their balance in a given currency based on the exchange rates

Method – PUT

/api/v2/erc20/balances/

Body of the request

{
  "tokens": ["0xba265956aa7da6981be0d3387ae2d7c6a1f76108", "0x11c1e537801cc1c37ad6e1b7d0bdc0e00fcc6dc1", "0x"],
  "address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
    "network": 3,
    "currency": "usd"
}
function erc20Balanace(host_url, tokens, customer_address, currency, network, fcm_mobile_token)
{
    var ItemJSON;
    //token address can be an array with multiple token addresses
    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "tokens": tokens,
                    "address":  customer_address,
                    "network": network,
                    "currency": currency
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/balances/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function erc20Balanace($host_url, $tokens, $customer_address, $currency, $network, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/erc20/balances/";

      $post_data = array(
            "tokens" => $tokens,
            "address" => $customer_address,
            "network" => $network,
            "currency" => $currency
      );

      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_PUT, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $fcm_mobile_token);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

tokens: list of ERC20 tokens addresses

address: given address holding the tokens

network: testnet (3) or mainnet (1)

currency: currency which the rates should be displayed in

Get Rate

Retrieves the rate of ERC20 token from the exchange for the requested token

Method – GET

/api/v2/erc20/rate/?currency=USD&symbol=PMA&network=1

function getRate(host_url, currency, token_ticker, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/rate/?currency=" + currency + "&symbol=" + token_ticker + "&network=" + network;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getRate($host_url, $urrency, $token_ticker, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/rate/?currency=$currency&symbol=$token_ticker&network=$network";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

As the parameter uses currency, s*ymbol (token ticker)* and network ( 3 for testnet and 1 for mainnet)

Check for Updates

Checks for the update of the favorite ERC20 tokens status in the database

Method – GET

/api/v2/erc20/check-update/

function checkForTokenUpdate(host_url, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/check-update/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function checkForTokenUpdate($host_url, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/check-update/";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

ERC20 Supported Tokens

Retrieves the list of currently supported ERC20 tokens on a given network

Method – GET

/api/v2/erc20/tokens/supported/networkId

function erc20SupportedTokens(host_url, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/erc20/tokens/supported/" + network;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function erc20SupportedTokens($host_url, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/erc20/tokens/supported/$network";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

networkId: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Wallet - Changelly

Create Transaction

Converts/exchanges one coin/token into another

Method – POST

/api/v2/exchange/changelly/transaction/

function createTransaction(host_url, pair, address, amount, refundAddress, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "pair": "eth_pma",
                    "address": "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
                    "amount": 100,
                    "refundAddress": "0xb344ec617313d90331285E33cF4168DDb5C91B21"
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "api/v2/exchange/changelly/transaction" + merchant_address;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function createTransaction($host_url, $pair, $address, $amount, $refundAddress, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/exchange/changelly/transaction/$merchant_address";

      $post_data = array(
          'pair' => $pair,
          'address' => $address,
          'amount' => $amount,
          'refundAddress' => $refundAddress
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

pair: currency pair, for example "eth_pma"

address: address to receive the exchanged funds

amount: amount to be exchanged

refundAddress: address where the change will be sent

Retrieve Currencies

Retrieve the list of available currencies

Method – GET

/api/v2/exchange/changelly/currencies/

function getCurrenciesList(host_url, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/currencies/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getCurrenciesList($host_url, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/currencies/";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Retrieve Currencies Full

Retrieve the list of available currencies and additional details

Method – GET

/api/v2/exchange/changelly/currencies-full/

function getCurrenciesList(host_url, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/currencies-full/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getCurrenciesList($host_url, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/currencies-full/";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Minimum Exchange Amount

Retrieve the minimum amount for the exchanged pair Method – GET

/api/v2/exchange/changelly/min-amount/{pair}

Inline Params

pair: currency pair, for example "eth_pma"

function getCurrenciesList(host_url, pair, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/min-amount/:pair";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getCurrenciesList($host_url, $pair, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/min-amount/$pair";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

pair: currency pair, for example "eth_pma"

Exchange Amount for Pair

Returns estimated exchange amount for the pair Method – GET

/api/v2/exchange/changelly/exchange-amount/{currency_pair}/{rate}

function getCurrenciesList(host_url, pair, rate, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/exchange-amount/:pair/:rate";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getCurrenciesList($host_url, $pair, $rate, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/exchange-amount/$pair/$rate";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params currency_pair: currency pair, for example "eth_pma"

rate: the exchange rate

Validate Address

Verifies if the address is of a valid currency/token Method – GET

/api/v2/exchange/changelly/validate-address/{ticker}/{address}

function validateAddress(host_url, ticker, address, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/validate-address/:ticker/:address";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function vvalidateAddress($host_url, $ticker, $address, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/validate-address/$ticker/$address";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

ticker: currency ticker, for example "ETH" for Ethereum

address: address to be validated if of a given currency/token format

Transaction Status

Returns transactions status (for example, pending or completed)

Method – GET

/api/v2/exchange/changelly/status/{transaction_id}

function transactionStatus(host_url, transaction_id, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/status/:transaction_id";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}

Inline Params

transaction_id: currency pair, for example "eth_pma"

function transactionStatus($host_url, $transaction_id, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/status/$transaction_id";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

All Transactions

Retrieves the list of all the latest currenctly active/pending transactions

Method – GET

/api/v2/exchange/changelly/status/{transaction_id}

function allTransactions(host_url, transaction_id, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/exchange/changelly/status/:transaction_id";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function allTransactions($host_url, $transaction_id, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/exchange/changelly/status/$transaction_id";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

transaction_id: currency pair, for example "eth_pma"

Wallet - Blockchain

Get PMA Rate

Retrieves PMA rate against the given coin/token on a given network

Method – GET

/api/v2/pma-rate/blockchain/{network}/{ticker}

function getPmaRate(host_url, network, ticker, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/pma-rate/blockchain/:network/:ticker";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function getPmaRate($host_url, $network, $ticker, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/pma-rate/blockchain/$network/$ticker";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

network: 1 for the Mainnet, 3 for the Testnet (Ropsten)

ticker: currency/token ticker

All Transactions

Retrieves the list of all the latest pending transactions

Method – GET

/api/v2/pma-rate/blockchain/{network}/{ticker}

function allTransactions(host_url, network, ticker, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/pma-rate/blockchain/:network/:ticker";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function allTransactions($host_url, $network, $ticker, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/pma-rate/blockchain/$network/$ticker";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

network: 1 for the Mainnet, 3 for the Testnet (Ropsten)

ticker: currency/token ticker

Set PMA Rate

Updates PMA rate for the given currencies (USD, EUR, JPY, GBP)

Method – POST

/api/v2/pma-rate/set-rate-test/{network}/

function setPmaRate(host_url, network, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "api/v2/pma-rate/set-rate-test/:network" + merchant_address;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function setPmaRate($host_url, $network, $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/pma-rate/set-rate-test/$etwork";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

network: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Wallet - PullPayments

Create PullPayment

Executes new PullPayment

Method – POST

/api/v2/pull-payment

{
    "paymentID": "paymentID",
    "merchantID":  "$merchantID",
    "merchantAddress": "merchantAddress",
    "customerAddress": "customerAddress",
    "pullPaymentAddress": "pullPaymentAddress",
    "currency": "currency",
    "endTimeStamp": "endTimeStamp",
    "fiatAmountInCents": "fiatAmountInCents",
    "initialPaymentAmount": "initialPaymentAmount",
    "frequency": "frequency",
    "numberOfPayments": "numberOfPayments",
    "startTimestamp": "startTimestamp",
    "encryptedaPaymentsDetails": "encryptedPaymentsDetails", 
    "signature": "signature",
    "callbackURL": "callbackURL",
    "type": "type",
    "networkID": "networkID"
}
function createPullPayment(host_url, paymentID, merchantID, merchantAddress, customerAddress, pullPaymentAddress, currency, endTimeStamp, fiatAmountInCents, initialPaymentAmount, frequeny, numberOfPayments, startTimeStamp, encryptedPaymentDetails, signature, callbackURL, type, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    'paymentID': paymentID,
                    'merchantID': $merchantID,
                    'merchantAddress':merchantAddress,
                    'customerAddress': customerAddress,
                    'pullPaymentAddress': pullPaymentAddress,
                    'currency': currency,
                    'endTimeStamp': endTimeStamp,
                    'fiatAmountInCents': fiatAmountInCents,
                    'initialPaymentAmount': initialPaymentAmount,
                    'frequency': frequency,
                    'numberOfPayments': numberOfPayments,
                    'startTimestamp': startTimestamp,
                    'encryptedaPaymentsDetails': encryptedPaymentsDetails, 
                    'signature': signature,
                    'callbackURL': callbackURL,
                    'type': type,
                    'networkID': networkID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/pull-payment/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createPullPayment($host_url, $paymentID, $merchantID, $merchantAddress, $customerAddress, $pullPaymentAddress, $currency, $endTimeStamp, $fiatAmountInCents, $initialPaymentAmount, $frequeny, $numberOfPayments, $startTimeStamp, $encryptedPaymentDetails, $signature, $callbackURL, $type, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/pull-payment/";

      $post_data = array(
          'paymentID' => $paymentID,
          'merchantID' => $merchantID,
          'merchantAddress' => $merchantAddress,
          'customerAddress' => $customerAddress,
          'pullPaymentAddress' => $pullPaymentAddress,
          'currency' => $currency,
          'endTimeStamp' => $endTimeStamp,
          'fiatAmountInCents' => $fiatAmountInCents,
          'initialPaymentAmount' => $initialPaymentAmount,
          'frequency' => $frequency,
          'numberOfPayments' => $numberOfPayments,
          'startTimestamp' => $startTimestamp,
          'encryptedaPaymentsDetails' => $encryptedPaymentsDetails, 
          'signature' => $signature,
          'callbackURL' => $callbackURL,
          'type' => $type,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantID: merchants ID from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

pullPaymentAddress: address of the PullPayments contract

currency: basic currency specified in the billing model

endTimeStamp: unix timestamp of the final PullPayment excution

fiatAmountInCents: base currency amount in cents

initialPaymentAmount: payment on the first contract execution

frequency: unix timestamp defining the duration between the PullPayment executions

numberOfPayments: number of the total payments based on the billing model

startTimestamp: unix timestamp specifying the first PullPayment execution

encryptedaPaymentsDetails: encrypted data describing the PullPayment accessible to merchant and customer

signature: signature hash to sign the contract

callbackURL: the url called for retreiving the billing model details

type: type of the billing modle (1 to 6)

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Delete PullPayment

Deletes specific PullPayment

Method – DELETE

/api/v2/pull-payment

{
    "paymentID": "paymentID",
    "merchantAddress": "merchantAddress",
    "customerAddress": "customerAddress",
    "signature": "signature",
    "callbackURL": "callbackURL",
    "networkID": "networkID"
}
function deletePullPayment(host_url, paymentID, merchantAddress, customerAddress, signature, callbackURL, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    'paymentID': paymentID,
                    'merchantAddress':merchantAddress,
                    'customerAddress': customerAddress,
                    'signature': signature,
                    'callbackURL': callbackURL,
                    'networkID': networkID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/pull-payment/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DELETE", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function deletePullPayment($host_url, $paymentID, $merchantAddress, $customerAddress, $signature, $callbackURL, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/pull-payment/";

      $post_data = array(
          'paymentID' => $paymentID,
          'merchantAddress' => $merchantAddress,
          'customerAddress' => $customerAddress,
          'signature' => $signature,
          'callbackURL' => $callbackURL,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_DELETE, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

signature: signature hash to sign the contract

callbackURL: the url called for retreiving the billing model details

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Cancel PullPayment

Cancels a PullPayment

Method – POST

/api/v2/pull-payment/cancel

{
    "paymentID": "paymentID",
    "merchantAddress": "merchantAddress",
    "customerAddress": "customerAddress",
    "signature": "signature",
    "callbackURL": "callbackURL",
    "networkID": "networkID"
}
function cancelPullPayment(host_url, paymentID, merchantAddress, customerAddress, signature, callbackURL, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    'paymentID': paymentID,
                    'merchantAddress':merchantAddress,
                    'customerAddress': customerAddress,
                    'signature': signature,
                    'callbackURL': callbackURL,
                    'networkID': networkID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/pull-payment/cancel/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function cancelPullPayment($host_url, $paymentID, $merchantAddress, $customerAddress, $signature, $callbackURL, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/pull-payment/cancel/";

      $post_data = array(
          'paymentID' => $paymentID,
          'merchantAddress' => $merchantAddress,
          'customerAddress' => $customerAddress,
          'signature' => $signature,
          'callbackURL' => $callbackURL,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

signature: signature hash to sign the contract

callbackURL: the url called for retreiving the billing model details

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Sign Single PullPayment

Signs a PullPayment with the provided hash and transaction data Method – POST

/api/v2/tx-signature/registration-tx-single/

{
    "paymentID": "paymentID",
    "merchantID":  "$merchantID",
    "merchantAddress": "merchantAddress",
    "customerAddress": "customerAddress",
    "pullPaymentAddress": "pullPaymentAddress",
    "currency": "currency",
    "endTimeStamp": "endTimeStamp",
    "fiatAmountInCents": "fiatAmountInCents",
    "initialPaymentAmount": "initialPaymentAmount",
    "frequency": "frequency",
    "numberOfPayments": "numberOfPayments",
    "startTimestamp": "startTimestamp",
    "encryptedaPaymentsDetails": "encryptedPaymentsDetails", 
    "callbackURL": "callbackURL",
    "type": "type",
    "networkID": "networkID"
}
function signPullPayment(host_url, paymentID, merchantAddress, customerAddress, signature, callbackURL, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    'paymentID': paymentID,
                    'merchantID': $merchantID,
                    'merchantAddress':merchantAddress,
                    'customerAddress': customerAddress,
                    'pullPaymentAddress': pullPaymentAddress,
                    'currency': currency,
                    'endTimeStamp': endTimeStamp,
                    'fiatAmountInCents': fiatAmountInCents,
                    'initialPaymentAmount': initialPaymentAmount,
                    'frequency': frequency,
                    'numberOfPayments': numberOfPayments,
                    'startTimestamp': startTimestamp,
                    'encryptedaPaymentsDetails': encryptedPaymentsDetails, 
                    'callbackURL': callbackURL,
                    'type': type,
                    'networkID': networkID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/tx-signature/registration-tx-single/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DELETE", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function signPullPayment($host_url, $paymentID, $merchantID, $merchantAddress, $customerAddress, $pullPaymentAddress, $currency, $endTimeStamp, $fiatAmountInCents, $initialPaymentAmount, $frequeny, $numberOfPayments, $startTimeStamp, $encryptedPaymentDetails, $callbackURL, $type, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/tx-signature/registration-tx-single/";

      $post_data = array(
          'paymentID' => $paymentID,
          'merchantID' => $merchantID,
          'merchantAddress' => $merchantAddress,
          'customerAddress' => $customerAddress,
          'pullPaymentAddress' => $pullPaymentAddress,
          'currency' => $currency,
          'endTimeStamp' => $endTimeStamp,
          'fiatAmountInCents' => $fiatAmountInCents,
          'initialPaymentAmount' => $initialPaymentAmount,
          'frequency' => $frequency,
          'numberOfPayments' => $numberOfPayments,
          'startTimestamp' => $startTimestamp,
          'encryptedaPaymentsDetails' => $encryptedPaymentsDetails, 
          'callbackURL' => $callbackURL,
          'type' => $type,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_DELETE, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantID: merchants ID from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

pullPaymentAddress: address of the PullPayments contract

currency: basic currency specified in the billing model

endTimeStamp: unix timestamp of the final PullPayment excution

fiatAmountInCents: base currency amount in cents

initialPaymentAmount: payment on the first contract execution

frequency: unix timestamp defining the duration between the PullPayment executions

numberOfPayments: number of the total payments based on the billing model

startTimestamp: unix timestamp specifying the first PullPayment execution

encryptedaPaymentsDetails: encrypted data describing the PullPayment accessible to merchant and customer

callbackURL: the url called for retreiving the billing model details

type: type of the billing modle (1 to 6)

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

PullPayment Cancellation Signature

Signs a PullPayments cancellation Method – POST

/api/v2/tx-signature/cancellation-tx

{
    "paymentID": "paymentID",
    "merchantAddress": "merchantAddress",
    "networkID": "networkID"
}
function signPullPaymentCancellation(host_url, paymentID, merchantID, merchantAddress, customerAddress, pullPaymentAddress, currency, endTimeStamp, fiatAmountInCents, initialPaymentAmount, frequeny, numberOfPayments, startTimeStamp, encryptedPaymentDetails, callbackURL, type, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    'paymentID': paymentID,
                    'merchantAddress':merchantAddress,
                    'networkID': networkID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/tx-signature/cancellation-tx/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DELETE", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function signPullPaymentCancellation($host_url, $paymentID, $merchantAddress, $customerAddress, $signature, $callbackURL, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/tx-signature/cancellation-tx/";

      $post_data = array(
          'paymentID' => $paymentID,
          'merchantAddress' => $merchantAddress,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_DELETE, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantAddress: merchants wallet address used for the PullPayment registration

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Sign Recurring PullPayment Registration

Signs a Recurring PullPayment registration Method – POST

/api/v2/tx-signature/registration-tx-recurring/

{
    "paymentID": "paymentID",
    "merchantID":  "$merchantID",
    "merchantAddress": "merchantAddress",
    "customerAddress": "customerAddress",
    "pullPaymentAddress": "pullPaymentAddress",
    "currency": "currency",
    "endTimeStamp": "endTimeStamp",
    "fiatAmountInCents": "fiatAmountInCents",
    "initialPaymentAmount": "initialPaymentAmount",
    "frequency": "frequency",
    "numberOfPayments": "numberOfPayments",
    "startTimestamp": "startTimestamp",
    "callbackURL": "callbackURL",
    "type": "type",
    "networkID": "networkID"
}
function signRecurringPullPayment(host_url, paymentID, merchantID, merchantAddress, customerAddress, pullPaymentAddress, currency, endTimeStamp, fiatAmountInCents, initialPaymentAmount, frequeny, numberOfPayments, startTimeStamp, callbackURL, type, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    'paymentID': paymentID,
                    'merchantID': $merchantID,
                    'merchantAddress':merchantAddress,
                    'customerAddress': customerAddress,
                    'pullPaymentAddress': pullPaymentAddress,
                    'currency': currency,
                    'endTimeStamp': endTimeStamp,
                    'fiatAmountInCents': fiatAmountInCents,
                    'initialPaymentAmount': initialPaymentAmount,
                    'frequency': frequency,
                    'numberOfPayments': numberOfPayments,
                    'startTimestamp': startTimestamp,
                    'callbackURL': callbackURL,
                    'type': type,
                    'networkID': networkID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/tx-signature/registration-tx-recurring/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DELETE", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function signRecurringPullPayment($host_url, $paymentID, $merchantID, $merchantAddress, $customerAddress, $pullPaymentAddress, $currency, $endTimeStamp, $fiatAmountInCents, $initialPaymentAmount, $frequeny, $numberOfPayments, $startTimeStamp, $callbackURL, $type, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/tx-signature/registration-tx-recurring/";

      $post_data = array(
          'paymentID' => $paymentID,
          'merchantID' => $merchantID,
          'merchantAddress' => $merchantAddress,
          'customerAddress' => $customerAddress,
          'pullPaymentAddress' => $pullPaymentAddress,
          'currency' => $currency,
          'endTimeStamp' => $endTimeStamp,
          'fiatAmountInCents' => $fiatAmountInCents,
          'initialPaymentAmount' => $initialPaymentAmount,
          'frequency' => $frequency,
          'numberOfPayments' => $numberOfPayments,
          'startTimestamp' => $startTimestamp,
          'callbackURL' => $callbackURL,
          'type' => $type,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_DELETE, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantID: merchants ID from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

pullPaymentAddress: address of the PullPayments contract

currency: basic currency specified in the billing model

endTimeStamp: unix timestamp of the final PullPayment excution

fiatAmountInCents: base currency amount in cents

initialPaymentAmount: payment on the first contract execution

frequency: unix timestamp defining the duration between the PullPayment executions

numberOfPayments: number of the total payments based on the billing model

startTimestamp: unix timestamp specifying the first PullPayment execution

callbackURL: the url called for retreiving the billing model details

type: type of the billing modle (1 to 6)

networkID: 1 for the Mainnet, 3 for the Testnet (Ropsten)

Wallet - Mobile

Connect Mobile

Connect new mobile to the chain Method – POST

/api/v2/mobile/connect

{
    "token": "paymentID",
    "walletAddress": "merchantAddress",
    "networkID": "networkID",
    "currency": "currency",
    "initializeAppData": true
}
function connectMobile(host_url, paymentID, merchantID, merchantAddress, customerAddress, pullPaymentAddress, currency, endTimeStamp, fiatAmountInCents, initialPaymentAmount, frequeny, numberOfPayments, startTimeStamp, encryptedPaymentDetails, callbackURL, type, networkID, fcm_mobile_token)
{
    var ItemJSON;

    //network 3 for testnet and 1 for mainnet
    ItemJSON = [{
                    "token": paymentID,
                    "walletAddress": merchantAddress,
                    "networkID": networkID,
                    "currency": currency,
                    "initializeAppData": true
                }];
    ItemJSON = Json.stringify(ItemJSON);

    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/mobile/connect/";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DELETE", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);

}
function connectMobile($host_url, $paymentID, $merchantAddress, $customerAddress, $signature, $callbackURL, $networkID,  $fcm_mobile_token)
  {
      //here you need to pass the host and the port of the server you are calling
      $url = "$host_url/api/v2/mobile/connect/";

      $post_data = array(
                'token': $paymentID,
                'walletAddress': $merchantAddress,
                'networkID': $networkID,
                'currency': $currency,
                'initializeAppData': $initializeAppData // true of false
      );

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_DELETE, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Params

token: token for wallet/app authorization

wallet address: tresury/gas address with index [0] of the devices HD wallet

networkID: default network, 1 for the Mainnet, 3 for the Testnet (Ropsten)

currency: base currency to be used for the mobile

initializeAppData: boolean value, can be true of false

Wallet - Database

Contract History

Retrieves the history for the contract

Method – GET

/api/v2/wallet/contract-history/{walletAddress}

function allTransactions(host_url, walletAddress, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/contract-history/:walletAddress";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function allTransactions($host_url, $walletAddress, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/wallet/contract-history/$walletAddress";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

walletAddress: wallet address for which the contract history will be retrieved

Pull Contract History

Retrieves the history for the Pull contract

Method – GET

/api/v2/wallet/pull-contract/{walletAddress}

function allTransactions(host_url, walletAddress, fcm_mobile_token)
{
    //here you need to specify the host and the port of the server you are calling
    URL = host_url + "/api/v2/wallet/contract-history/:walletAddress";

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function allTransactions($host_url, $walletAddress, $cm_mobile_token)
  {
      // here you need to pass the host and the port of the server you are calling
      // as well as the network 3 for testnet and 1 for mainnet
      $url = "$host_url/api/v2/wallet/contract-history/$walletAddress";

      $request_headers = array();
      $request_headers[] = "fcm_mobile_token: " . $fcm_mobile_token;
      $request_headers[] = "Content-Type: application/json";
      $curl = curl_init($url);
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_HTTPHEADER, $request_headers);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

      $result_array = json_decode($result_json, $assoc = true);

      return $result_array;
  }

Inline Params

walletAddress: wallet address for which the Pull contract history will be retrieved

Errors

The PumaPay APIs use the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The API requested is hidden for administrators only.
404 Not Found -- The specified request could not be found.
405 Method Not Allowed -- You tried to access a API with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The API requested has been removed from our servers.
429 Too Many Requests -- Too many requests
500 Internal Server Error -- There was a problem with the server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.