NAV Navbar
json javascript php


Introduction

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

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

Our Pull Payment Protocol currently supports the following PullPayments:

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

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

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

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

PullPayment Models

CREATE

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

Method - POST

/api/v2/pull-payment-models/

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

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

    var ItemJSON;

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

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

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

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

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/');
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

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

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

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

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

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

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

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

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

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

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

typeID: type of the PullPayment model:

1. Single PushPayment

2. Single PullPayment

3. Recurring PullPayment

4. Recurring with trial

5. Recurring with initial payment

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

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

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

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

GET ALL

Fetch all of the merchants billing models.

Method - GET

/api/v2/pull-payment-models/

GET body of the request takes no parameters:

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

    var ItemJSON;

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

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

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

      return $result_array;
  }

GET BY ID

Fetch specific PullPayment model by its ID.

Method - GET

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

GET body of the request takes no parameters:

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

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

    var ItemJSON;

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

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

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

      return $result_array;
  }

UPDATE

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

Method - PUT

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

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

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

    var ItemJSON;

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

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

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

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

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/' . $ppID);
      curl_setopt($curl, CURLOPT_PUT, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

The params that need to be updated:

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

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

PARTIAL UPDATE

Update the existing PullPayment model by ID.

Method - PUT

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

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

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

    var ItemJSON;

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

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

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

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

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payment-models/' . $ppID);
      curl_setopt($curl, CURLOPT_PUT, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

PullPayments

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

CREATE

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

Method - POST

/api/v2/pull-payments/

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

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

    var ItemJSON;

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

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

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

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

      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payments/');
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

Parameters pullPaymentID: id of the PullPayment model created by the mercant

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

startTimestamp: time of the first contract execution and payment withdrawal

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

pullPaymentAddress: address where the funds will be transfered

userID: id of the user

GET ALL

Method - GET

Fetch all of the created PullPayments.

/api/v2/pull-payments/

GET body of the request takes no parameters:

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

    var ItemJSON;

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

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function getAllPullPayments()
  {
      $curl = curl_init('https://prembackend.pumapay.io/api/v2/pull-payments/');
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

GET BY ID

Method - GET

Fetch information about a specific PullPayment model by ID.

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

GET body of the request takes no parameters:

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

    var ItemJSON;

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

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

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

      return $result_array;
  }

CANCEL PULLPAYMENT

Cancel PullPayment

Method - POST

/api/v2/pull-payment/cancel/

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

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

    var ItemJSON;

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

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

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

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

      $curl = curl_init('https://wallet-api.pumapay.io/mainnet/api/v2/pull-payments/cancel/');
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

Params paymentID: ID of the PullPayment that needs will be cancelled

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

startcustomerAddressTimestamp: Unix timestamp when the PullPayment was created

callbackURL: url where the call will be made

userID: ID of the user who initialized the PullPayment

Blockchain Transactions

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

QR PAYLOAD

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

Method - GET

/api/v2/qr/{PullPaymentModelID}

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

{
  "code": 200,
  "success": true,
  "message": "Descriptive Success message",
  "data": {
    "paymentModelURL": "string",
    "paymentURL": "string",
    "transactionURL": "string"
  }
}
function retrieveQR(hostURL, pullPaymentModelID)
{
    var urlAPI = hostURL + "/api/v2/qr/" + pullPaymentModelID;

    var ItemJSON;

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

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("GET", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function retrieveQR($hostURL, $PullPaymentID)
  {
      $curl = curl_init("$hostURL/api/v2/qr/$PullPaymentModelID");
      curl_setopt($curl, CURLOPT_GET, 1);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

Scheduler

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

START

Start scheduler for a specific payment.

Method - POST

/api/v2/test/start-scheduler/

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

{
  "paymentID": "4a17335e-bf18-11e8-a355-000000fb1459"
}
function startScheduler(hostURL, paymentID)
{
    var ItemJSON;

    ItemJSON = [{
                    "paymentID": paymentID,
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = hostURL + "/api/v2/test/start-scheduler/";  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function cstartScheduler($hostURL, $paymentID)
  {
      paymentID: $paymentID;

      $post_data = array(
          'pullPaymentID' => $paymentID,
      );

      $curl = curl_init("$hostURL/api/v2/test/start-scheduler/");
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

STOP

Stops the scheduler for a specific payment

Method - POST

/api/v2/scheduler/stop

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

{
  "paymentID": "4a17335e-bf18-11e8-a355-000000fb1459"
}
function stopScheduler(hostURL, paymentID)
{
    var urlAPI = "pull-payments/";

    var ItemJSON;

    ItemJSON = [{
                    "paymentID": paymentID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = hostURL + "/api/v2/test/start-scheduler/" + paymentID;  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function stopScheduler($hostURL, $paymentID)
  {
      paymentID: $paymentID;

      $post_data = array(
          'pullPaymentID' => $paymentID
      );

      $curl = curl_init("$hostURL/api/v2/test/start-scheduler/$paymentID");
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

RESTART

POST /api/v2/scheduler/restart

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

{
  "paymentID": "4a17335e-bf18-11e8-a355-000000fb1459"
}
function restartScheduler(hostURL, paymentID)
{
    var urlAPI = "pull-payments/";

    var ItemJSON;

    ItemJSON = [{
                    "paymentID": paymentID
                }];
    ItemJSON = Json.stringify(ItemJSON);

    URL = hostURL + "/api/v2/scheduler/restart";  //Your API Call

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    xmlhttp.open("POST", URL, false);
    xmlhttp.setRequestHeader("Content-Type", "application/json");
    xmlhttp.onreadystatechange = callbackFunction(xmlhttp);
    promise = xmlhttp.send(ItemJSON);
}
function restartScheduler($hostURL, $paymentID)
  {
      paymentID: $paymentID;

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

      $curl = curl_init("$hostURL/api/v2/test/start-scheduler/$paymentID");
      curl_setopt($curl, CURLOPT_POST, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $result_json = curl_exec($curl);
      curl_close($curl);

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

      return $result_array;
  }

Wallet Core APIs

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

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

Wallet

Proxy JSON Rpc

Gets information about an Ethereum block

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

Method – POST

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

Body of the request

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

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

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

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

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

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

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

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

      return $result_array;
  }

Parameters “jsonprc”: version of the JSON Rpc

“method”: method to call

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

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

Get provider by network

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Create Wallet

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

Method - POST

/api/v2/wallet/create/

Body of the request

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

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

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

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

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

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

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

      return $result_array;
  }

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

Restore Wallet

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

Method - POST

/api/v2/wallet/restore/

Body of the request

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

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

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

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

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

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

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

      return $result_array;
  }

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

network: Testnet (3) or Mainnet (1)

Load ERC Transfers from Chain

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Parameters

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

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

itemsPerPage: number of records to display per page

Body of the request: is not required

Load Transactions from Chain

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

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

Inline Parameters

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

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

itemsPerPage: number of records to display per page

Load All Transactions Transfers

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Parameters

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

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

itemsPerPage: number of records to display per page

Get next N transactions

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Parameters

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

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

Get selected Rates with Balances

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

Method – PUT

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

Headers:

“fcm-mobile-token”: firebase authorization token

Body of the request

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

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

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

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

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

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

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

      return $result_array;
  }

Parameters

tokenAddresses: the list of the ERC20 token addresses

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

walletAddress: address which holds the given tokens

network: testnet (3) or mainnet (1)

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

Contract History

Retrieves transactions and executions history of the merchants contracts

Method – GET

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

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

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

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

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

      return $result_array;
  }

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

Description

contract: contract address to update

network: testnet (3) or mainnet (1)

Update Contract

Updates contracts values/parameters on a given network

Method – PUT

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

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

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

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

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

      return $result_array;
  }

Inline Parameters

contract: contract address

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

Get Tokens by Address

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Headers: fcm-mobile-token: firebase authorization token

Inline Parameters

token_address: address of the token on the blockchain

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

Get ERC20 Tokens

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

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

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

ERC20 Rates

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

Method – PUT

/api/v2/erc20/rates/

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

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

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

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

      return $result_array;
  }

Token From a Contract

Retrieve the token details from the contract address

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

token_address: ERC20 address of the token

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

Add Custom Token

Adds the new token to the list of tokens

Method – POST

/api/v2/erc20/tokens/

Body of the request

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

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

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

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

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

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

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

      return $result_array;
  }

Params

address: address of a given token

name: name of the token

symbol: token ticker as represented on the market

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

networkID: testnet (3) or mainnet (1)

ico: initial coin offering which originally introduced the token

Delete Custom ERC20 Token

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

Method – DELETE

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

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

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

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

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

      return $result_array;
  }

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

ERC20 Balance

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

Method – PUT

/api/v2/erc20/balances/

Body of the request

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

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

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

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

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

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

      return $result_array;
  }

Params

tokens: list of ERC20 tokens addresses

address: given address holding the tokens

network: testnet (3) or mainnet (1)

currency: currency which the rates should be displayed in

Get Rate

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

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

Check for Updates

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

Method – GET

/api/v2/erc20/check-update/

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

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

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

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

      return $result_array;
  }

ERC20 Supported Tokens

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Params

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

Wallet - Changelly

Create Transaction

Converts/exchanges one coin/token into another

Method – POST

/api/v2/exchange/changelly/transaction/

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

pair: currency pair, for example "eth_pma"

address: address to receive the exchanged funds

amount: amount to be exchanged

refundAddress: address where the change will be sent

Retrieve Currencies

Retrieve the list of available currencies

Method – GET

/api/v2/exchange/changelly/currencies/

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

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

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

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

      return $result_array;
  }

Retrieve Currencies Full

Retrieve the list of available currencies and additional details

Method – GET

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

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

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

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

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

      return $result_array;
  }

Minimum Exchange Amount

Retrieve the minimum amount for the exchanged pair Method – GET

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

Inline Params

pair: currency pair, for example "eth_pma"

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

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

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

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

      return $result_array;
  }

Inline Params

pair: currency pair, for example "eth_pma"

Exchange Amount for Pair

Returns estimated exchange amount for the pair Method – GET

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

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

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

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

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

      return $result_array;
  }

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

rate: the exchange rate

Validate Address

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

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

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

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

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

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

      return $result_array;
  }

Params

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

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

Transaction Status

Returns transactions status (for example, pending or completed)

Method – GET

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

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

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

Inline Params

transaction_id: currency pair, for example "eth_pma"

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

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

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

      return $result_array;
  }

All Transactions

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

transaction_id: currency pair, for example "eth_pma"

Wallet - Blockchain

Get PMA Rate

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

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

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

ticker: currency/token ticker

All Transactions

Retrieves the list of all the latest pending transactions

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

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

ticker: currency/token ticker

Set PMA Rate

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

Method – POST

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

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

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

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

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

      return $result_array;
  }

Inline Params

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

Wallet - PullPayments

Create PullPayment

Executes new PullPayment

Method – POST

/api/v2/pull-payment

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

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

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

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

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

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

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

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantID: merchants ID from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

pullPaymentAddress: address of the PullPayments contract

currency: basic currency specified in the billing model

endTimeStamp: unix timestamp of the final PullPayment excution

fiatAmountInCents: base currency amount in cents

initialPaymentAmount: payment on the first contract execution

frequency: unix timestamp defining the duration between the PullPayment executions

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

startTimestamp: unix timestamp specifying the first PullPayment execution

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

signature: signature hash to sign the contract

callbackURL: the url called for retreiving the billing model details

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

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

Delete PullPayment

Deletes specific PullPayment

Method – DELETE

/api/v2/pull-payment

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

signature: signature hash to sign the contract

callbackURL: the url called for retreiving the billing model details

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

Cancel PullPayment

Cancels a PullPayment

Method – POST

/api/v2/pull-payment/cancel

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

signature: signature hash to sign the contract

callbackURL: the url called for retreiving the billing model details

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

Sign Single PullPayment

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

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

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantID: merchants ID from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

pullPaymentAddress: address of the PullPayments contract

currency: basic currency specified in the billing model

endTimeStamp: unix timestamp of the final PullPayment excution

fiatAmountInCents: base currency amount in cents

initialPaymentAmount: payment on the first contract execution

frequency: unix timestamp defining the duration between the PullPayment executions

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

startTimestamp: unix timestamp specifying the first PullPayment execution

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

callbackURL: the url called for retreiving the billing model details

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

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

PullPayment Cancellation Signature

Signs a PullPayments cancellation Method – POST

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

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantAddress: merchants wallet address used for the PullPayment registration

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

Sign Recurring PullPayment Registration

Signs a Recurring PullPayment registration Method – POST

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

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

paymentID: payment ID requested from the database

merchantID: merchants ID from the database

merchantAddress: merchants wallet address used for the PullPayment registration

customerAddress: customers wallet address used for the PullPayment registration

pullPaymentAddress: address of the PullPayments contract

currency: basic currency specified in the billing model

endTimeStamp: unix timestamp of the final PullPayment excution

fiatAmountInCents: base currency amount in cents

initialPaymentAmount: payment on the first contract execution

frequency: unix timestamp defining the duration between the PullPayment executions

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

startTimestamp: unix timestamp specifying the first PullPayment execution

callbackURL: the url called for retreiving the billing model details

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

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

Wallet - Mobile

Connect Mobile

Connect new mobile to the chain Method – POST

/api/v2/mobile/connect

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

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

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

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

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

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

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

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

      return $result_array;
  }

Params

token: token for wallet/app authorization

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

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

currency: base currency to be used for the mobile

initializeAppData: boolean value, can be true of false

Wallet - Database

Contract History

Retrieves the history for the contract

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

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

Pull Contract History

Retrieves the history for the Pull contract

Method – GET

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

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

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

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

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

      return $result_array;
  }

Inline Params

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

Errors

The PumaPay APIs use the following error codes:

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