NAV
JavaScript PHP

Nash Link API Documentation

Welcome to the Nash Link API!

This REST API is highly compatible with BitPay and BTCPay. It allows developers to interact with Nash Link securely for creating invoices as a merchant and retrieving invoices as a user.

Introduction

Payment sequence

Click to enlarge:

SDKs

Creating an invoice with our SDK:

import { NashLinkApi } from '@neon-exchange/nash-link'

const api = new NashLinkApi('sandbox', `<YOUR_API_KEY>`, `<YOUR_API_SECRET_KEY>`)
const invoiceResponse = await api.createInvoice({
  price: 10
  currency: 'EUR'
})
<?php
require_once 'NashLinkApi.php';

use Nash\Link\NashLinkApi;

$api = new NashLinkApi('sandbox', '<YOUR_API_KEY>', '<YOUR_API_SECRET_KEY>');
$invoice_data = array("price" => 10, "currency" => "EUR");

// create the invoice
$response = $api->createInvoice($invoice_data);

// check for errors
if ($response['error'] == true) {
  print $response['message'];
  print $response['status_code'];
  return;
}

// created invoice data
var_dump($response['data'])

Getting an invoice data with our SDK:

import { NashLinkApi } from '@neon-exchange/nash-link'

const api = new NashLinkApi('sandbox', `<YOUR_API_KEY>`, `<YOUR_API_SECRET_KEY>`)
const invoiceResponse = await api.getInvoice('<INVOICE_ID>')
<?php
require_once 'NashLinkApi.php';

use Nash\Link\NashLinkApi;

$api = new NashLinkApi('sandbox', '<YOUR_API_KEY>', '<YOUR_API_SECRET_KEY>');

// get the invoice
$response = $api->getInvoice('<INVOICE_ID>');

// check for errors
if ($response['error'] == true) {
  print $response['message'];
  print $response['status_code'];
  return;
}

// invoice data
var_dump($response['data'])

We provide well-maintained SDKs for several programming languages. These are a slim layer to simplify API access (in particular, request signing):

Making requests

API URLs

The Nash Link API base URLs are:

Note: You need to use an API key created for the specific environment.

Request headers

All authenticated requests need to include the following HTTP headers:

Signing requests

You can use our SDK to create the signature:

import { signRequest } from '@neon-exchange/nash-link'

const url = "https://link.nash.io/api/v1/sandbox/invoices"
const body = { price: 40, currency: "EUR" }
const signingResult = signRequest({ url, body, secretKey: `<YOUR_API_SECRET_KEY>` })

Authenticated requests need to be signed with the API secret key. You need to concatenate the URL with the request body, create a HMAC-SHA256 signature, then send this as the x-signature header.

For example, say you wish to send a request to https://link.nash.io/api/v1/sandbox/invoices with this payload:

{ "price": 40, "currency": "EUR" }

You’d concatenate the URL and request body like this:

https://link.nash.io/api/v1/sandbox/invoices{"price":40,"currency":"EUR"}

This string is then signed using HMAC-SHA256 and the API secret key.

The resulting signature needs to be sent in the x-signature HTTP header.

If you want to implement the signing yourself, take a look at our example code.

Invoice API

The invoice is the main data structure for payments. When a user wants to pay with Nash Link, the merchant creates an invoice for the specified amount and can optionally include further fields, such as internal order ID, redirect URL and many others.

Create an invoice

POST /invoices

POST /invoices

{
    "price": 40,
    "currency": "EUR"
}

Response:

<InvoiceObject>

See also: Invoice object documentation

Request headers

Request body (JSON)

Mandatory fields

Name Type Description
price number Amount in fiat
currency string Fiat currency, in ISO 4217 3-character currency code. Must be EUR currently.

Optional fields

Name Type Description
orderId string Merchant order reference ID
itemDesc string Description of the purchase
posData string Passthru variable for Merchant internal use
notificationEmail string Email address of the merchant to receive notifications about invoice status changes
notificationURL string URL of the merchant backend to receive webhooks relating to invoice status changes
redirectURL string URL to redirect the user to after a successful purchase

Response

An Invoice object as described in the Invoice object documentation.

Get an invoice

GET /invoices/<invoiceId>

GET /invoices/JDBtJCFV

Response:

<InvoiceObject>

see also: Invoice object documentation

Request headers

Response

Invoice object as described in the Invoice object documentation

Resources

This section describes all the data structures used by the Nash Link API in detail.

Invoice

{
  "facade": "merchant/invoice",
  "data": {
    "id": "JDBtJCFV",
    "status": "complete",
    "price": 9,
    "currency": "EUR",
    "itemDesc": "Item XYZ",
    "orderId": "10118",
    "posData": "tx46523",
    "invoiceTime": 1588318118648,
    "expirationTime": 1588319018648,
    "currentTime": 1588325917427,
    "paidOn": 1588319018644,
    "notificationEmail": "[email protected]",
    "notificationURL": "https://yourredirecturl.com",
    "redirectURL": "https://yourwebsite.com/checkout/10118",
    "url": "https://link.nash.io/widget?invoiceId=JDBtJCFV",
    "transactionCurrency": "BTC",
    "amountPaid": 92313,
    "displayAmountPaid": "0.00092313",
    "exchangeRates": {
      "BTC": {
        "EUR": 9749.44
      }
    },
    "supportedTransactionCurrencies": {
      "BTC": {
        "enabled": true
      }
    },
    "paymentWalletAddress": "bc1qx2qyua0kjzyhza5y4x9lj7mghu39sm4d0sl226",
    "paymentWalletBlockchain": "BTC",
    "paymentCodes": {
      "BTC": {
        "BIP21": "bitcoin:bc1qx2qyua0kjzyhza5y4x9lj7mghu39sm4d0sl226?value=0.00092313"
      }
    },
  }
}

Data fields

Name Type Description
id string ID of this specific invoice
status string new / paid / complete / expired
price number Fiat amount of the invoice
currency string Fiat currency of the invoice
itemDesc string Merchant-provided reference text about the items in this invoice
orderId string Merchant-provided reference ID
posData string Passthru variable for Merchant internal use
invoiceTime number Timestamp of when the invoice was created
expirationTime number Timestamp of when the invoice will expire
currentTime number Timestamp of the API call retrieving this invoice
paidOn number Timestamp of when the invoice was paid
notificationEmail string Email address of the merchant to receive notifications about invoice status changes
notificationURL string URL of the merchant backend to receive webhooks relating to invoice status changes
redirectURL string Merchant-provided URL to redirect the user after a successful payment
url string Web address of the invoice
transactionCurrency string Symbol of cryptocurrency the user paid with
amountPaid number Amount the user paid, in smallest unit of the cryptocurrency (initially 0)
displayAmountPaid string Amount the user paid, in full unit of the cryptocurrency (initially '0')
exchangeRates object Exchange rates for this invoice
supportedTransactionCurrencies object Supported cryptocurrencies to pay this invoice
paymentWalletAddress string Wallet address for payment
paymentWalletBlockchain string Wallet blockchain
paymentCodes object URI for sending a transaction to the invoice

See also:

Errors

The Nash Link API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request sucks
401 Unauthorized – Your API key is incorrect
404 Not Found – The specified resource could not be found
500 Internal Server Error – We had a problem with our server – try again later
503 Service Unavailable – We’re temporarially offline for maintanance – try again later

E-Commerce Plugins

This section describes the installation of our payment plugin in various e-commerce solutions.

Magento 2

Download Nashlink plugins and sdks zip pack.

You need access to your magento instance for ssh and/or ftp.

As first step you need to copy Nashlink/ plugin directory to magento code path. Most common ways are via FTP or SSH.

After that, connect via ssh or machine console to run magento install commands.

Copy Magento 2 plugin over FTP

Access your magento instance via ftp and copy Nashlink/ plugin directory to <MAGENTO_BASE_PATH>/app/code/

Copy Magento 2 plugin over SSH

$ scp -r Nashlink <your_user>@<your_magento_ip>:<MAGENTO_BASE_PATH>/app/code/

Install Magento 2 plugin

Get terminal access to your magento instance via ssh:

$ ssh <your_user>@<your_magento_ip>

After login, run the following commands inside magento instance:

$ bin/magento setup:upgrade

$ bin/magento module:enable Nashlink_NPCheckout

$ bin/magento setup:static-content:deploy -f

$ bin/magento cache:flush

Active Magento 2 plugin

You can now activate Nashlink checkout plugin inside admin interface via Stores -> Configuration -> Sales-> Payment Methods

Follow the instructions on plugin configuration interface to get your store ready for Nashlink.

WooCommerce

Download Nashlink plugins and sdks zip pack.

You need access to your woocommerce wordpress instance for ssh and/or ftp.

Manual Install

It requires you first installs and configure WooCommerce plugin on your wordpress instance.

After get WooCommerce up and running you are able to install nashlink checkout.

Download the latest nashlink woocomerce checkout distribution here nashlink woocommerce checkout

Log in on you woocommerce instance as admin. Go to Plugins -> Add New -> Browse -> woocommerce-nashlink.zip

After that, you can enable the plugin on admin interface(wordpress plugin and woocomerce payment choice).

You can use the same process to update to newer versions.