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.1

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.

Generate API Key

Generates the PumaPay Merchants API Key. It is used to authorise all of the merchants actions with the PumaPay Console APIs. Merchant needs to be registered/onboarded through the PumaPay Business Console in order to get verified and to retreive his businessID.

Method – GET

api/v2/console-auth/api-keys/generate/{business_id}

**Body of the request**
Not required
function generateApiKey(host_url, xAccessToken, businessID)
{
    URL_params = host_url + "api/v2/console-auth/api-keys/generate/" + businessID;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET",  URL_params, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("x-access-token", xAccessToken);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function generate_api_key($host_url, $x_access_token, $businessID)
{
    //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/console-auth/api-keys/generate/$businessID;

    $request_headers = array();
    $request_headers[] = "x-access-token: " . $x_access_token;
    $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;
}

Query Parameters “businessID”: merchants unique business ID in the system

Header Parameters “x-access-token”: the token generated after the Business Console login and will be used for the session validation

Successfull response

{

    "success": true,

    "status": 200,

    "message": "Successfully generated the API key. You can now retrieve it",

    "data": {

            "pma-api-key": "generated API key",

       }

}

Retrieve the API Key

Once the API key has been generated, you can retrieve it from your account for further server-side validations.

Method – GET

api/v2/console-auth/api-keys/{business_id}

**Body of the request**
Not required
function retrieveApiKey(host_url, xAccessToken, businessID)
{
    URL_params = host_url + "api/v2/console-auth/api-keys/" + businessID;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET",  URL_params, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("x-access-token", xAccessToken);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function retrieve_api_key($host_url, $x_access_token, $businessID)
{
    //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/console-auth/api-keys/$businessID;

    $request_headers = array();
    $request_headers[] = "x-access-token: " . $x_access_token;
    $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;
}

Query Parameters “businessID”: merchants unique business ID in the system

Header Parameters “x-access-token”: the token generated after the Business Console login and will be used for the session validation

Successfull response

{

    "success": true,

    "status": 200,

    "message": "Successfully generated the API key. You can now retrieve it",

    "data": {

            "pma-api-key": "generated API key",

      }

}

Get the business details

Retrieve the business details by the business ID.

Method – GET

api/v2/api-key-auth/business/{business_id}

**Body of the request**
Not required
function retrieveBusinessDetails(host_url, pmaApiKey, businessID)
{
    URL_params = host_url + "api/v2/api-key-auth/business/" + businessID;

    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", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function retrieve_business_details($host_url, $pmaApiKey, $businessID)
{
    //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/business/$businessID;

    $request_headers = array();
    $request_headers[] = "pma-api-key: " . $pmaApiKey;
    $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;
}

Query Parameters “businessID”: merchants unique business ID in the system

Header Parameters “pma-api-key”: the token generated after the Business Console login and will be used for the session validation

Sample response

{

    "success": true,

    "status": 200,

    "message": "Successfully retrieved the business details.",

    "data": {

            "businessID": "business_random_uid_generated_at_registration",

            "businessName": "name of your business",

            "businessType": "business type/category (from the list in the Business Console)",

            "description": "description of your business/services",

            "kycTierID": "what KYC tier you have passed",

            "countryID": "the country of your business (from the list in the Business Console)",

            "state": "state/area",

            "city": "city",

            "zipCode": "ZIP code",

            "streetAddress1": "business address line 1",

            "streetAddress2": "business address line 2",

            "industry1": "your business industry 1 (from the list in the Business Console)",

            "industry2": "your business industry 2 (from the list in the Business Console)",

            "url": "link to your business website",

            "registrationDate": "date when the business was registered",

            "updateDate": "date when the business details were updated",

            "firstName": "Owners first name",

            "lastName": "Owners last name",

            "phoneNumber": "contact phone number",

            "jobTitle": "owners job title",

            "countries": [

                    {

                         "countryID": "generated_country1_id",

                         "countryName": "country1_name"

                    },

                    {

                         "countryID": "generated_country_id",

                        "countryName": "country2_name"

                    },

                      . . .

              ],

            "industries": [

                    {

                         "id": "generated_industry1_id",

                         "industryName": "industry1_name"

                    },

                    {

                         "id": "generated_industry2_id",

                        "industryName": "industry2_name"

                    },

                      . . .

              ],

            "businessTypes": [

                    {

                         "id": "1",

                         "businessType": "Corporation"

                    },

                    {

                         "id": "2",

                        "businessType": "Sole Proprietor or single member LLC"

                    },

                      . . .

              ]

}

Get the business status

Retrieve the business status.

Method – GET

api/v2/api-key-auth/business-control/status/{business_id}

**Body of the request**
Not required
function retrieveBusinessStatus(host_url, pmaApiKey, businessID)
{
    URL_params = host_url + "api/v2/api-key-auth/business-control/status/" + businessID;

    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", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function retrieve_business_status($host_url, $pmaApiKey, $businessID)
{
    //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/business-control/status/$businessID";

    $request_headers = array();
    $request_headers[] = "pma-api-key: " . $pmaApiKey;
    $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;
}

Query Parameters “businessID”: merchants unique business ID in the system

Header Parameters “pma-api-key”: the token generated after the Business Console login and will be used for the session validation

Sample response

{

    "success": true,

    "status": 200,

    "message": "Successfully retrieved the business control.",

    "data": {

            "businessID": "business_random_uid_generated_at_registration",

            "businessDetailsSubmitted": true,

            "businessDetailsApproved": true,

            "kycSubmitted": true,

            "kycApproved": true,

            "kycRequested": true,

            "kycRejected": false,

            "treasuryWalletAddressSubmitted": true,

            "treasuryWalletAddressApproved": true,

            "prideAccessRequested": false,

            "prideAccessApproved": false,

            "gasWalletAssigned": true,

            "businessKycFlowCompleted": true,

            "onBoardingCompleted": false

      }

}

Create new product

Method – POST

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

Create the new product identifying your goods/services you will be creating the billing models for. You may have multiple products and each product can have multiple billing models.

{
    "categoryID": 1,
    "tags": ["1", "tag1", "tag2", "tag3"],
    "byte64Image": "/9j/4AAQSkZJRgABAQEAYABgAAD/4QUpRXhpZgAASUkqAAgAAA...longstring",
    "productName": "Name of the product",
    "productDescription": "descritpion",
    "productUrl": "www.product-url.com",
    "networkID": 1
}
function createProduct(host_url, pmaApiKey, businessID, mode, categoryID, tags, byte64image, imageUrl = null, currency = null, productName, productDescription, productUrl, networkID = null)
{
    var ItemJSON;

    ItemJSON = [{
                    "jsonrpc": "2.0",
                    "mode": mode,
                    "categoryID": categoryID,
                    "tags": tags,
                    "byte64Image": byte64Image,
                    "imageUrl": imageUrl,
                    "currency": currency,
                    "productName": productName,
                    "productDescription": productDescription,
                    "productUrl": productUrl,
                    "networkID": networkID
                }];

    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/api-key-auth/products/" + businessID;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("pma-api-key", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createProduct($host_url, $pmaApiKey, $mode, $businessID, $categoryID, $tags, $byte64image, $imageUrl = null, $currency = null, $productName, $productDescription, $productUrl, $networkID = 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 = "$host_url/api/v2/api-key-auth/products/$businessID";

      $post_data = array(
          'jsonrpc' => $jsonrpc,
          'mode' => $mode,
          'categoryID' => $categoryID,
          'tags' => $tags,
          'byte64Image' => $byte64Image,
          'imageUrl' => $imageUrl,
          'currency' => $currency,
          'productName' => $productName,
          'productDescription' => $productDescription,
          'productUrl' => $productUrl,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pmaApiKey;
      $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;
  }

Query Parameters

“businessID”: your unique business ID in the system (string)

Body Request Parameters

"categoryID": product category ID (ingeger)

"tags": name of your product (string | number)

"byte64Image": name of your product (string)

"productName": name of your product (string)

"productDescription": name of your product (string)

"productUrl": name of your product (string)

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

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

Successfull response

{

    "success": true,

    "status": 200,

    "message": "Product record created"

}

Retrieve the list of all 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/all/{{business_id}}/{{network_id}}

**Body of the request**
Not required
function getProducts(host_url, pmaApiKey, businessID, networkID, categoryID, currency, verified, page, itemsPerPage, orderBy, orderType)
{
    URL_params = host_url + "api/v2/api-key-auth/products/" + businessID + "/" + baseCurrency + "/" + 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.setRequestHeader("baseCurrency", baseCurrency);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function get_products($host_url, $pma_api_key, $businessID, $networkID, $categoryID, $currency, $verified, $page, $itemsPerPage, $orderBy, $orderType)
{
    //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?categoryID=$categoryID&currency=$currency&verified=$verified&page=$page&itemsPerPage=$itemsPerPage&orderBy=$orderBy&orderType=$orderType";

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

Query Parameters “businessID”: merchants unique business ID in the system

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

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

"categoryID": the product category (numeric value)

"currency": base currency for the product

"verified": if the product has been verified

"page": number of the search results page based on the total number of search results and items per page dislpayed (pagination)

"itemsPerPage": how many item will be displayed per page in the search results

"orderBy": order by filter (ex.: date, price)

"orderType": ascending or descending (ASC/DESC)

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,

            "currency": "USD" //string, base currency used for the product,

            "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 // total earning in base currency in cents

        },

    ]

}

Create new PullPayment Model

Method – POST

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

Create the new PullPayment Model under a product.

{
    "productID": "random_product_generated_id",
    "businessID": "business_random_uid_generated",
    "title": "title of the PullPayment Model",
    "description": "additional description",
    "amount": 100, // the payment amount in cents in a base currency
    "initialPaymentAmount": 0, // how much the customer has to pay right away
    "currency": "EUR", // base currency of the product
    "numberOfPayments": 3, // how many recurring payments there will be
    "typeID": 3, // category of the PullPayment model
    "frequency": 1800, // how often the customer will be charged in Unix timestamp format
    "networkID": 3, // 1 for the mainnet, 3 for the Ropsten testnet
    "trialPeriod": 0 // if the billing model has a trial period, in Unix timestamp format
}
function createPullPaymentModel(host_url, pmaApiKey, productID, businessID, title, description, amount, initialPaymentAmount, currency, numberOfPayments, typeID, frequency, networkID, trialPeriod)
{
    var ItemJSON;

    ItemJSON = [{
                    "productID": productID,
                    "businessID": businessID,
                    "title": title,
                    "description": description,
                    "amount": amount,
                    "initialPaymentAmount": initialPaymentAmount,
                    "currency": currency,
                    "numberOfPayments": numberOfPayments,
                    "typeID": typeID,
                    "frequency": frequency,
                    "networkID": networkID,
                    "trialPeriod": trialPeriod
                }];

    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/api-key-auth/products/" + businessID;

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.setRequestHeader("pma-api-key", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function createPullPaymentModel($host_url, $pmaApiKey, $productID, $businessID, $title, $description, $amount, $initialPaymentAmount, $currency, $numberOfPayments, $typeID, $frequency, $networkID, $trialPeriod)
  {
      //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/api-key-auth/products/$businessID";

    $url = "$host_url/api/v2/api-key-auth/products/$businessID";

      $post_data = array(
          'jsonrpc' => $jsonrpc,
          'mode' => $mode,
          'categoryID' => $categoryID,
          'tags' => $tags,
          'byte64Image' => $byte64Image,
          'imageUrl' => $imageUrl,
          'currency' => $currency,
          'productName' => $productName,
          'productDescription' => $productDescription,
          'productUrl' => $productUrl,
          'networkID' => $networkID
      );

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pmaApiKey;
      $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;
      $post_data = array(
            "productID" => $productID,
            "businessID" => $businessID,
            "title" => $title,
            "description" => $description,
            "amount" => $amount,
            "initialPaymentAmount" => $initialPaymentAmount,
            "currency" => $currency,
            "numberOfPayments" => $numberOfPayments,
            "typeID" => $typeID,
            "frequency" => $frequency,
            "networkID" => $networkID,
            "trialPeriod" => $trialPeriod
      );

      $request_headers = array();
      $request_headers[] = "pma-api-key: " . $pmaApiKey;
      $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;
  }

Body Request Parameters

"productID": the unique generated ID of the product (string)

"businessID": ID of the registered business (string)

"title": title of the PullPayment Model (string)

"description": PullPayment Model description (string)

"amount": payment amount in base currency in cents(string)

"initialPaymentAmount": name of your product (string)

"currency": name of your product (string)

"numberOfPayments": name of your product (string)

typeID: type of the PullPayment Model (single, recurring, etc.)

"frequency": how often the PullPayment is executed in Unix timestamp (ex.: recurring PullPayment once a month)

"networkID": (1) for the mainnet, (3) for the Ropsten testnet (integer)

"trialPeriod": PullPayment trial period in Unix timestamp (ingeger)

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

Successfull response

{

    "success": true,

    "status": 200,

    "message": "PullPayment model record created"

}

Get billing models

Retrieves the list of all of the merchants billing models for a product. Under each product the merchants will create billing models which repserent the payment model for their certain product/service

Method – GET

Main Call

api/v2/api-key-auth/pull-payment-models/all/{businessID}/{networkID}/{productID}

Additional Filters

api/v2/api-key-auth/pull-payment-models/all/{businessID}/{networkID}/{productID}?typeID={typeID}&currency={currency}&estimateGas={estimateGas}&currencyEstimateGas={currencyEstimateGas}&page={page}&itemsPerPage={itemsPerPage}&orderBy={orderBy}&orderType={orderType}

**Body of the request**
Not required
function getBillingModels(hostUrl, pmaApiKey, businessID, networkID, productID, typeID, currency, estimateGas, currencyEstimateGas, page, itemsPerPage, orderBy, orderType)
{
    URL_params = host_url + "api/v2/api-key-auth/pull-payment-models/all/" + businessID + "/" + networkID + "/" + productID;

    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", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function get_billing_models($host_url, $pma_api_key, $businessID, $networkID, $productID, $typeID, $currency, $estimateGas, $currencyEstimateGas, $page, $itemsPerPage, $orderBy, $orderType)
  {
      //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/all/$businessID/$networkID/$productID/";

      $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

In-Query Parameters

"networkID": 1 for the mainnet, 3 for the Ropsten testnet

“businessID”: merchants unique business ID in the system

"productID": the product generated ID after its creation

"typeID": ID of your business in the system

"currency": 1 of the 4 base currencies (USD, EUR, JPY, GBP)

"estimateGas": whether to estimate the gas for the transaction or not (True/False)

"currencyEstimateGas": displaying the the gas transaction amount in base currency

"page": number of the search results page based on the total number of search results and items per page dislpayed (pagination)

"itemsPerPage": how many item will be displayed per page in the search results

"orderBy": search results sort parameter

"orderType": order by ascending or descending (ASC/DESC)

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 All 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**
Not required
function getPullPayments(host_url, pmaApiKey, baseCurrency, uniqueReferenceID, page, itemsPerPage)
{
    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 get_pullpayments($host_url, $pma_api_key, $baseCurrency, $uniqueReferenceID, $page, $itemsPerPage)
  {
      //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

In-Query Parameters

“businessID”: merchants unique business ID in the system

"uniqueReferenceID": unique reference ID of the customer fetched from the merchants/psps' system uniquely identifying the user

"page": number of the search results page based on the total number of search results and items per page dislpayed (pagination)

"itemsPerPage": how many item will be displayed per page in the search results

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 PullPayments by Business ID

Retrieves all the PullPayments for a given business.

Method – GET

api/v2/api-key-auth/pull-payments/business/{businessID}

Additional Filters

api/v2/api-key-auth/pull-payment-models/all/{businessID}?page={page}&itemsPerPage={itemsPerPage}&uniqueReferenceID={uniqueReferenceID}

**Body of the request**
Not required
function getPullPaymentsByBusiness(host_url, pmaApiKey, businessID, page, itemsPerPage, uniqueReferenceID)
{
    URL_params = host_url + "api/v2/api-key-auth/pull-payments/business/" + businessID + "?page=" + page + "&itemsPerPage" + itemsPerPage + "&uniqueReferenceID=" + uniqueReferenceID;

    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", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function get_pullpayments_by_business($host_url, $pma_api_key, $businessID, $page, $itemsPerPage, $uniqueReferenceID)
  {
      //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/business/$businessID?page=$page&itemsPerPage=$itemsPerPage&uniqueReferenceID=$uniqueReferenceID";

      $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

In-Query Parameters

pullPaymentID: merchants unique business ID in the system

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,

            "uniqueReferenceID": dkeii45430402 //unique ID of the customer in the merchants system

            }

        ]

    

}

Retrieve PullPayments by PullPaymentID

Retrieves the pullpayment by its ID.

Method – GET

api/v2/api-key-auth/pull-payments/{pull_payment_id}

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

    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", pmaApiKey);
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function get_pullpayment_by_pullpayment_id($host_url, $pma_api_key, $pullPaymentID)
  {
      //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/$pullPaymentID";

      $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

In-Query Parameters

“businessID”: merchants unique business ID in the system

"uniqueReferenceID": unique reference ID of the customer fetched from the merchants/psps' system uniquely identifying the user

"page": number of the search results page based on the total number of search results and items per page dislpayed (pagination)

"itemsPerPage": how many item will be displayed per page in the search results

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 businessID and can select between the mainnet (1) for the history of the payments received or the Ropsten testnet (3) which is used for the testing purposes.

Method – GET

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

**Body of the request**
Not required
function getTransactions(host_url, pma-api-key, businessID, networkID, page, itemsPerPage, uniqueReferenceID)
{
    URL_params = host_url + "api/v2/api-key-auth/transactions/all/" + businessID + "/" + networkID + "?page=" + page + "&itemsPerPage=" + itemsPerPage + "&uniqueReferenceID=" + uniqueReferenceID;

    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);
    try{
        xmlhttp.setRequestHeader("businessID", businessID);
    }
    catch (error) {
        return (error)
    }

    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function get_transactions($host_url, $pma_api_key, $businessID, $networkID, $page = null, $itemsPerPage = null, $uniqueReferenceID = 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

      //additional parameters can be passed with in-query variables for additional filtering
      $url_params = "$host_url/api/v2/api-key-auth/transactions/all/$businessID/$networkID?page=$page&itemsPerPage=$itemsPerPage&uniqueReferenceID=$uniqueReferenceID";

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

Get transaction by hash

Retrieve a single transaction data by the transaction hash.

Method – GET

api/v2/api-key-auth/transactions/{transaction_hash}

**Body of the request**
Not required
function transactionByHash(host_url, pmaApiKey, transactionHash)
{
    URL_params = host_url + "api/v2/api-key-auth/transactions/" + transactionHahs;

    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", pmaApiKey);

    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function transaction_by_hash($host_url, $pma_api_key, $transaction_hash)
  {
      $url_params = "$host_url/api/v2/api-key-auth/transactions/$transaction_hash;

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

Query Parameters

transactionHash: unique hash of the transaction

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 //PMA amount of the transaction

        }

    ]

}

Get transaction by PullPayment

Retrieve a single transaction data by the transaction hash.

Method – GET

api/v2/api-key-auth/transactions/pull-payment/{pull_payment_id}

**Body of the request**
Not required
function transactionByPullPayment(host_url, pmaApiKey, pullPyamentID)
{
    URL_params = host_url + "api/v2/api-key-auth/transactions/" + pullPaymentID;

    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", pmaApiKey);

    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function transaction_by_pullpayment($host_url, $pma_api_key, $pullpayment_id)
  {
      $url_params = "$host_url/api/v2/api-key-auth/transactions/$pullpayment_id;

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

Query Parameters

pullPaymentID: ID of the PullPayment

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 //PMA amount of the transaction

        }

    ]

}

Get transaction by business

Retrieve transactions for a business (merchant) data by the business ID.

Method – GET

api/v2/api-key-auth/transactions/all/{business_id}/{network_id}?transactionStatuses=[1,2]&page=0&itemsPerPage=2&uniqueReferenceID=123

**Body of the request**
Not required
function transactionByBusiness(host_url, pmaApiKey, businessID, networkID, transactionStatuses, page, itemsPerPage, uniqueReferenceID)
{
    URL_params = host_url + "api/v2/api-key-auth/transactions/all/" + business_id + "/" + network_id + "?transactionStatuses=" + transactinsStatuses + "&page=" +page + "&itemsPerPage=" + itemsPerPage + "&uniqueReferenceID=" + uniqueReferenceID;

    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", pmaApiKey);

    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
}
function transaction_by_business($host_url, $pma_api_key, $businessID, $networkID, $transactionStatuses, $page, $itemsPerPage, $uniqueReferenceID)
{
    $url_params = "$host_url/api/v2/api-key-auth/transactions/all/$businessID/$networkID?transactionStatuses=$transactinsStatuses&page=$page&itemsPerPage=$itemsPerPage&uniqueReferenceID=$uniqueReferenceID";

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

Query Parameters

“businessID”: merchants unique business ID in the system

“networkID”: 1 (mainnnet) or 3 (ropsten testnet)

transactionStatuses: array of numbers, can be a single element, 1 - pending, 2 - failed, 3 - success

"page": number of the search results page based on the total number of search results and items per page dislpayed (pagination)

"itemsPerPage": how many item will be displayed per page in the search results

"uniqueReferenceID": unique reference ID of the customer fetched from the merchants/psps' system uniquely identifying the user

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 //PMA amount of the transaction

        }

    ]

}

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}

{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByNumber",
  "params": [
    "latest",
    true
  ],
  "id": 1
}

123456 ```javascript 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, $jsonrpc, $method, $params, $id)
  {
      //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";

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

{
  "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/

{
  "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

{
    "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/

{
  "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/

{
  "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.