NAV Navbar
json javascript php


Introduction

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.

This documentation shows how you can create payment models powered by PumaPay PullPayment Protocol.

Our Pull Payment Protocol currently supports the following PullPayments:

Single Pull Payment - Example: One time payment of $5.00

Recurring Pull Payment (Fixed amount) - Example: Monthly subscription of $12.99

Recurring Pull Payment with trial period - Example: Free trial of 15 days and monthly subscription of $20.00

Recurring Pull Payment with initial payment - Example: $3.00 for 3 days and weekly subscription of $10.00

PullPayment Models

CREATE

Create new billing model with several configuration parameters and it will be used for the PullPayment.

Method - POST

/api/v2/pull-payment-models/

Example of the parameters to use in the body of the request:

{
  "merchantID": "4a17335e-bf18-11e8-a355-000000fb1459",
  "title": "National Cryptographic Gold Mebmership",
  "description": "Access to all gold articles",
  "amount": 1099,
  "initialPaymentAmount": 199,
  "trialPeriod": 86400,
  "currency": "USD",
  "numberOfPayments": 12,
  "typeID": 2,
  "frequency": 604800,
  "networkID": 3,
  "automatedCashOut": true,
  "cashOutFrequency": 1
}
function createPullPaymentModel()
{
    var urlAPI = "pull-payment-models/";

    var ItemJSON;

    ItemJSON = [{
                    "merchantID": "4a17335e-bf18-11e8-a355-000000fb1459",
                    "title": "National Cryptographic Gold Mebmership",
                    "description": "Access to all gold articles",
                    "amount": 1099,
                    "initialPaymentAmount": 199,
                    "trialPeriod": 86400,
                    "currency": "USD",
                    "numberOfPayments": 12,
                    "typeID": 2,
                    "frequency": 604800,
                    "networkID": 3,
                    "automatedCashOut": true,
                    "cashOutFrequency": 1  
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createPullPaymentModel()
  {
      $merchantID = "4a17335e-bf18-11e8-a355-000000fb1459";
      $title = "National Cryptographic Gold Mebmership";
      $description = "Access to all gold articles";
      $amount = 1099;
      $initialPaymentAmount = 199;
      $trialPeriod = 86400;
      $currency = "USD";
      $numberOfPayments = 12;
      $typeID = 2;
      $frequency = 604800;
      $networkID = 3;
      $automatedCashOut = true;
      $cashOutFrequency = 1;

      $post_data = array(
          'merchantID' => $merchanID,
          'title' => $title,
          'description' => $description,
          'amount' => $amount,
          'initialPaymentAmount' => $initialPaymentAmount,
          'trialPeriod' => $trialPeriod,
          'currency' => $currency,
          'numberOfPayments' => $numberOfPayments,
          'typeID' => $typeID,
          'frequency' => $frequency,
          'networkID' => $networkID,
          'automatedCashOut' => $automatedCashOut,
          'cashOutFrequency' => $cashOutFrequency  
      );

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/');
      curl_setopt($curl, CURLOPT_POST, 1);
      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;
  }

When creating the new PullPayment model, you must specify the parameters that will be passed to the server and stored as the new billing model in the PostgreSQL database on the Merchant Backend.

There are a few parameters that define the billing model in the body of the request:

merchantID : (your merchant ID, will become deprecated with the release of the Merchant Portal)

title: the name of your PullPaymentr model as it will be presented to the consumer

description: a short description of the PullPayment model as it will be presented to the consumer for more informnation

amount: the amount of the subscription/payment that will be paid by the consumer for single/each recurring payme t

initialPaymentAmount: the amount the consumer needs to pay at the beginning of the subscription, which may refer to the trial period payment or dicsount

trialPeriod: specifies the duration of the trial period in unix timestamp

currency: currency for the payment/subscription that the merchant specified (USD, EUR, GPB, JPY)

numberOfPayments: total number of payments/executions for the same service/subscription (example: 1 time for single payment, 3 months subscription, 12 months etc.)

typeID: type of the PullPayment model:

1. Single PushPayment

2. Single PullPayment

3. Recurring PullPayment

4. Recurring with trial

5. Recurring with initial payment

frequency: time length between the payment executions in unix format in seconds (for example: 604800 is 1 month)

networkID: 1 is the Mainnet for the production, 3 is the Testnet for development and testing on the Ropsten network

automaticCashOut: if the payment will be automatically cashed out to the treasury or false if the merchant prefers to cash out manually

cashOutFrequency: how often after the payment the funds will be transferred from the address executing the contract to the treasury. Default is 1, meaning that it will be done after every execution

GET ALL

Fetch all of the merchants billing models.

Method - GET

/api/v2/pull-payment-models/

GET body of the request takes no parameters:

function getAllPullPaymentModels()
{
    var urlAPI = "pull-payment-models/";

    var ItemJSON;

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function getAllPullPaymentModels()
  {
      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/');
      curl_setopt($curl, CURLOPT_GET, 1);
      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;
  }

GET BY ID

Fetch specific PullPayment model by its ID.

Method - GET

api/v2/pull-payment-models/{PullPaymentModelID}

GET body of the request takes no parameters:

PullPaymentModelID is the ID of the billing model created by the merchant.

function getAllPullPaymentModelsByID(var ppID)
{
    var urlAPI = "pull-payment-models/" +  ppID;

    var ItemJSON;

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function getAllPullPaymentModelsByID($ppID)
  {
      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/' . $ppID);
      curl_setopt($curl, CURLOPT_GET, 1);
      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;
  }

UPDATE

Update the existing PullPayment models parameters for automatic cashout and cashout frequency, by the model ID.

Method - PUT

/api/v2/pull-payment-models/{PullPaymentModelID}

Example of the parameters to use in the body of the request:

{
  "title": "National Cryptographic Gold Mebmership",
  "description": "Access to all gold articles",
  "amount": 1099,
  "initialPaymentAmount": 199,
  "trialPeriod": 86400,
  "currency": "USD",
  "numberOfPayments": 12,
  "typeID": 2,
  "frequency": 604800,
  "networkID": 3,
  "automatedCashOut": true,
  "cashOutFrequency": 1
}
function updatePullPaymentModel(var ppID)
{
    var urlAPI = "pull-payment-models/" + ppID;

    var ItemJSON;

    ItemJSON = [{
                    "title": "National Cryptographic Gold Mebmership",
                    "description": "Access to all gold articles",
                    "amount": 1099,
                    "initialPaymentAmount": 199,
                    "trialPeriod": 86400,
                    "currency": "USD",
                    "numberOfPayments": 12,
                    "typeID": 2,
                    "frequency": 604800,
                    "networkID": 3,
                    "automatedCashOut": true,
                    "cashOutFrequency": 1  
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PUT", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function updatePullPaymentModel($ppID)
  {
      $title = "National Cryptographic Gold Mebmership";
      $description = "Access to all gold articles";
      $amount = 1099;
      $initialPaymentAmount = 199;
      $trialPeriod = 86400;
      $currency = "USD";
      $numberOfPayments = 12;
      $typeID = 2;
      $frequency = 604800;
      $networkID = 3;
      $automatedCashOut = true;
      $cashOutFrequency = 1;

      $post_data = array(
          'title' => $title,
          'description' => $description,
          'amount' => $amount,
          'initialPaymentAmount' => $initialPaymentAmount,
          'trialPeriod' => $trialPeriod,
          'currency' => $currency,
          'numberOfPayments' => $numberOfPayments,
          'typeID' => $typeID,
          'frequency' => $frequency,
          'networkID' => $networkID,
          'automatedCashOut' => $automatedCashOut,
          'cashOutFrequency' => $cashOutFrequency  
      );

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/' . $ppID);
      curl_setopt($curl, CURLOPT_PUT, 1);
      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;
  }

The params that need to be updated:

automaticCashOut: if the payment will be automatically treasured to the treasury or false if the merchant prefers to cash out manualoy

cashOutFrequency: how often after the payment the funds will be transferred from the address executing the contract to the treasury. Default is 1, meaning that it will be done after every execution

PARTIAL UPDATE

Update the existing PullPayment model by ID.

Method - PUT

/api/v2/pull-payment-models/{PullPaymentModelID}

Example of the parameters to use in the body of the request:

{
  "automatedCashOut": true,
  "cashOutFrequency": 1
}
function updatePullPaymentModel(var ppID)
{
    var urlAPI = "pull-payment-models/" + ppID;

    var ItemJSON;

    ItemJSON = [{
                    "automatedCashOut": true,
                    "cashOutFrequency": 1  
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("PATCH", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function updatePullPaymentModel($ppID)
  {
      $automatedCashOut = true;
      $cashOutFrequency = 1;

      $post_data = array(
          'automatedCashOut' => $automatedCashOut,
          'cashOutFrequency' => $cashOutFrequency  
      );

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/' . $ppID);
      curl_setopt($curl, CURLOPT_PATCH, 1);
      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;
  }

PullPayments

PullPayments are single transactions which are executed on the Ehtereum blockchain. They belong to certain Billing models and are made according to the rules you’ve set to create the latter. “Pull” stands for pulling funds from a customer’s wallet after he or she agrees to the conditions. Each PullPayment is created automatically after the customer accepts a payment, has an Ethereum address and can be seen in the database.

CREATE

Initialize the PullPayment and execute smart contract between the customer and merchant over the blockchain.

Method - POST

/api/v2/pull-payments/

Example of the parameters to use in the body of the request:

{
  "pullPaymentModelID": "4a17335e-bf18-11e8-a355-fb1459",
  "numberOfPayments": 12,
  "startTimestamp": 1537401600,
  "customerAddress": "0x0000000000000000000000000000000000011111",
  "pullPaymentAddress": "0x0000000000000000000000000000000000033333",
  "userID": "userIdOnMerchantsSystem"
}
function createPullPayment()
{
    var urlAPI = "pull-payments/";

    var ItemJSON;

    ItemJSON = [{
                    "pullPaymentModelID": "4a17335e-bf18-11e8-a355-fb1459",
                    "numberOfPayments": 12,
                    "startTimestamp": 1537401600,
                    "customerAddress": "0x0000000000000000000000000000000000011111",
                    "pullPaymentAddress": "0x0000000000000000000000000000000000033333",
                    "userID": "userIdOnMerchantsSystem"
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createPullPayment()
  {
      $pullPaymentID = "4a17335e-bf18-11e8-a355-fb1459";
      $numberOfPayments = 12;
      $startTimestamp = 1537401600;
      $customerAddress = "0x0000000000000000000000000000000000011111";
      $pullPaymentAddress = "0x0000000000000000000000000000000000033333";
      $userID = t"userIdOnMerchantsSystem";

      $post_data = array(
          'pullPaymentID' => $pullPaymentID,
          'numberOfPayments' => $numberOfPayments,
          'startTimestamp' => $startTimestamp,
          'customerAddress' => $customerAddress,
          'pullPaymentAddress' => $pullPaymentAddress,
          'userID' => $userID 
      );

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payments/');
      curl_setopt($curl, CURLOPT_POST, 1);
      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;
  }

pullPaymentID: id of the PullPayment model created by the mercant

numberOfPayments: how many times the payment will be executed (for example: once a month, weekly ertc.)

startTimestamp: time of the first contract execution and payment withdrawal

customerAddress: address from which the funds will be "pulled" by the merchant

pullPaymentAddress: address where the funds will be transfered

userID: id of the user

GET ALL

Method - GET

Fetch all of the created PullPayments.

/api/v2/pull-payments/

GET body of the request takes no parameters:

function getAllPullPayments()
{
    var urlAPI = "pull-payments/";

    var ItemJSON;

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function getAllPullPayments()
  {
      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payments/');
      curl_setopt($curl, CURLOPT_GET, 1);
      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;
  }

GET BY ID

Method - GET

Fetch information about a specific PullPayment model by ID.

/api/v2/pull-payments/{PullPaymentID}

GET body of the request takes no parameters:

function getPullPaymentByID(var PullPaymentID)
{
    var urlAPI = "pull-payments/" + PullPaymentID;

    var ItemJSON;

    URL = "https://prembackend.pumapay.io/api/v2/" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function getAllPullPaymentByID($PullPaymentID)
  {
      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payments/' . $PullPaymentID);
      curl_setopt($curl, CURLOPT_GET, 1);
      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;
  }

CANCEL PULLPAYMENT

Method - POST

Cancel PullPayment

/api/v2/pull-payment/cancel/

Example of the parameters to use in the body of the request:

{
  "paymentID": "4a17335e-bf18-11e8-a355-fb1459",
  "merchantAddress": "0x9622daed76056ebbdde284ba6aa7d8c3571cd0d9",
  "startcustomerAddressTimestamp": "0x7660C532633fF7b82632f369d45F57fD2AD9B2Ff",
  "signature": "4a17335ebb1459",
  "callbackURL": "wallet-api.pumapay.io/mainnet/infura/",
  "userID": "a366-dg1459"
}
function createPullPayment()
{
    var urlAPI = "pull-payments/";

    var ItemJSON;

    ItemJSON = [{
                    "paymentID": "4a17335e-bf18-11e8-a355-fb1459",
                    "merchantAddress": "0x9622daed76056ebbdde284ba6aa7d8c3571cd0d9",
                    "startcustomerAddressTimestamp": "0x7660C532633fF7b82632f369d45F57fD2AD9B2Ff",
                    "signature": "4a17335ebb1459",
                    "callbackURL": "wallet-api.pumapay.io/mainnet/infura/",
                    "userID": "a366-dg1459"
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = "https://pwallet-api.pumapay.io/mainnet/api/v2/pull-payment/cancel" + urlAPI;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createPullPayment()
  {
      paymentID: "4a17335e-bf18-11e8-a355-fb1459",
      merchantAddress: "0x9622daed76056ebbdde284ba6aa7d8c3571cd0d9",
      startcustomerAddressTimestamp: "0x7660C532633fF7b82632f369d45F57fD2AD9B2Ff",
      signature: "4a17335ebb1459",
      callbackURL: "wallet-api.pumapay.io/mainnet/infura/",
      userID: "a366-dg1459"

      $post_data = array(
          'pullPaymentID' => $pullPaymentID,
          'numberOfPayments' => $numberOfPayments,
          'startTimestamp' => $startTimestamp,
          'customerAddress' => $customerAddress,
          'pullPaymentAddress' => $pullPaymentAddress,
          'userID' => $userID 
      );

      $curl = curl_init('https://wallet-api.pumapay.io/mainnet/api/v2/pull-payments/cancel/');
      curl_setopt($curl, CURLOPT_POST, 1);
      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;
  }

The params that need to be updated:

paymentID: ID of the PullPayment that needs will be cancelled

merchantID: ID of the merchant whos billing model was used for creating the PullPayment

startcustomerAddressTimestamp: Unix timestamp when the PullPayment was created

callbackURL: url where the call will be made

userID: ID of the user who initialized the PullPayment

Blockchain Transactions

QR Payload provides merchants with the necessary data bases on their billing model, which allow the merchants to easily generate the QR code for the clients, so they can make a single payment, or subscribe to the recurring payment.

QR PAYLOAD

Returns data based on the billing model that will be used for generating the QR code used for the PullPayment.

Method - GET

/api/v2/qr/{PullPaymentModelID}

Example of the returned data to be used for QR code generation with pluging or web service:

{
  "code": 200,
  "success": true,
  "message": "Descriptive Success message",
  "data": {
    "paymentModelURL": "string",
    "paymentURL": "string",
    "transactionURL": "string"
  }
}

Scheduler

Scheduler allows to autoexecute a PullPayment and initialize transactions from consumer to merchant based on the billing model. If the user wants to restart the scheduler after a long period of time, all the payments (even the missing payments) will start again.

START

Start scheduler for a specific payment.

Method - POST

/api/v2/test/start-scheduler/

POST request is used in the API call to start the scheduler on a specific PullPayment model.

{
  "paymentID": "4a17335e-bf18-11e8-a355-000000fb1459"
}

STOP

Stops the scheduler for a specific payment

POST /api/v2/scheduler/stop

POST request is used in the API call to stop the scheduler on a specific PullPayment model.

{
  "paymentID": "4a17335e-bf18-11e8-a355-000000fb1459"
}

RESTART

POST /api/v2/scheduler/restart

POST request is used in the API call to restart the scheduler on a specific PullPayment model.

{
  "paymentID": "4a17335e-bf18-11e8-a355-000000fb1459"
}

Wallet APIs

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

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

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/3

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;
  }

“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

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

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;
  }

“network”: Testnet (3) or Mainnet (1)

Load ERC Transfers from Chain

Retrieves all of the transfers that happened to and from the address including person-to-person and token transfers after the contract execution. The results are split into pages by number of items per page and navigated sequentially by page number.

Method – GET

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

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;
  }

Headers

page: is the number of page you wish to return

itemsPerPage: how many records will be returned per page

Body of the request: is not required

Load Transactions from Chain

Load the history of all transactions related to an execution of a smart contract and gas payment for a given address (consumers address). The results are split into pages by number of items per page and navigated sequentially by the page number.

Method – GET

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

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

Parameters

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

page: offset based on the number of transactions and items to display per page

itemsPerPage: number of records to display per page

Load All Transactions Transfers

Retrieves the history of token transfers related to all the transactions that happened over the Ethereum network for a given address. The results are split into pages by number of items per page and navigated sequentially by the page number.

Method – GET

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

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;
  }

Parameters

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

page: offset based on the number of transactions and items to display per page

itemsPerPage: number of records to display per page

Get last N transactions

Retrieves last N number of transactions in Ethereum and ERC20 tokens for a given address.

Method – GET

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

function getLastTransactions(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 getLastTransactions($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;
  }

Parameters

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

page: offset based on the number of transactions and items to display per page

itemsPerPage: number of records to display per page, 10 in this case

Get next N transactions

Gets the next N number of scheduled transactions for the upcoming payment for a given address

Method – GET

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

function getNextTransactions(host_url, customer_address, count, 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=" + count;

    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, $count, $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=$count";

      $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;
  }

Description

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

Get Tokens by Address

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

Method – GET

/api/v2/erc20/token/0x818fc6c2ec5986bc6e2cbf00939d90556ab12ce5/1

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

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;
  }

Params

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

"networkID": testnet (3) or mainnet (1)

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;
  }

Get Token From a Contract Address

Get the token details from the contract address

Method – GET

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

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;
  }

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;
  }

Description

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 – DEL

/api/v2/erc20/tokens/tokenAddress

function erc20Token(host_url, token_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/erc20/api/v2/erc20/tokens/" + tokenAddress;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("DEL", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("fcm_mobile_token", fcm_mobile_token);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function erc20Token($host_url, $token_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/erc20/tokens/$token_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_DEL, 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("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 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_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;
  }

Description

“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

Gets the rate of ERC20 token from the exchange based on the price specified for the provided token

As the parameter takes currency, symbol (token ticker) and network ( 3 for testnet and 1 for mainnet)

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;
  }

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: testnet (3) or mainnet (1)

Get Contract History

Retrieves transactions and executions history of the merchants contracts Accepts merchant_address as the parameter

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;
  }

Changelly

Create Transaction

Converts/exchanges one coin/token into another

Method – POST

/api/v2/exchange/changelly/transaction/

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;
  }

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.