Cryptocurrency API Hashbon

Initial setup.

In order to start accepting payments, you need to prepare your account:

  1. Log into your account.

  2. In the Business tab go to Settings.

  3. Enable payment online shop.

    img
  4. Enter Shop Name, Shop URL, Status URL, Success URL, Error URL.

    Field

    R/O

    Description

    Example

    Shop Name

    Required

    Shop Name. Will be displayed on the payment form.

    Schnappi Online Store

    Shop URL

    Required

    Shop website

    https://schnappi.com

    Status URL

    Optional

    This URL will receive notifications about changes in the account status (paid, canceled, etc.)

    https://schnappi.com/invoicestatus.php

    Success URL

    Optional

    After successful payment, the user will be redirected to this URL. If not specified - go to Shop URL

    https://schnappi.com/thankyou.php

    Error URL

    Optional

    If errors occurred during the payment, the user will be redirected to this URL. If not specified - go to Shop URL

    https://schnappi.com/error.php

    Additional commission / bonus

    Optional

    Set an additional fee that is taken from the client in your favor. if you set a negative value it becomes a bonus for the client. The value is given as a percentage. min: -15%, max: 15%

    10

    Volatility risk

    Optional

    false - risk on the merchant, true - risk on the client

    true/false

Excellent! You can accept payments on your website.

Create an invoice for payment.

To accept a payment you need to create an invoice. There are two options for this.

  1. Create an invoice manually.

  2. Create an invoice via API.

Create an invoice manually.

  1. Go to BusinessInvoices.

  2. Click the Create Invoice button.

  3. Enter all the required information.

  4. Click the Create button.

  5. Copy the link to the invoice and send it to the buyer.

  6. Keep track of the invoice status in the list of Invoices.

Create an invoice via API.

Simplified mechanism.

This mechanism is suitable for merchants who need a simple and fast payment integration.

To create an invoice for payment, you need to create a special link and provide it to the user.

The Hashbon platform will do the rest.

  1. Create a link that will contain the following parameters:

    Parameter

    R/O

    Description

    Example

    shopId

    required

    Unique Shop ID. It is specified in the section BusinessSettings

    shopId=123

    shopInvoiceId

    optional

    Unique invoice ID in the shop system. It is not possible to create two invoices with the same shopInvoiceId. If an invoice with the specified shopInvoiceId has already been created, the system will return either the form of payment (if the invoice has not been paid) or indicate the status of the invoice

    shopInvoiceId=529kd34tm

    amount

    required

    Payment amount

    amount=99.95

    invoiceCurrency

    optional

    Invoice currency. By default - EUR. You can choose any currency from the list ...

    invoiceCurrency=USD

    receiveCurrency

    optional

    The currency that will be credited to the merchant`s account. By default: EURT You can select the option: asis - then the merchant will receive the same currency that a customer paid with You can choose any currency from the list ... When exchanging currencies, the exchange fee will be applied: hashbon.com/fees

    receiveCurrency=asis

    You should get a link:

    
    https://hashbon.com/api/v1/invoices/create/fromlink?shopId=123&shopInvoiceId=529kd34tm&invoiceCurrency=EUR&amount=99.95&receiveCurrency=BTC
    
    

    This link indicates that the invoice is 99.95 EUR (invoiceCurrency is not specified, therefore the value is taken by default). The client himself chooses the cryptocurrency, which he will pay with, and after payment the amount will be exchanged for bitcoin, bitcoins will be credited to the merchant’s account. The invoice was issued on behalf of the 123 shop.

  2. Provide this link to your buyer. The buyer will be able to choose the cryptocurrency that is more convenient for him to pay and will make the payment.

  3. There are three ways to track your invoice status.

    1. Manually in the list of invoices.

    2. If you specified the Status URL in the shop settings, we will send a notification about the invoice status as soon as it changes.

    3. Via API (see the Invoice Verification tab).

  4. As soon as the invoice receives the status succeeded, it means that it is fully paid and confirmed.

Great! You have received your first payment.

Standard mechanism.

This mechanism is suitable for large merchants who need deep integration with a payment gateway.

  1. To create an account, send a post-request to the address:

    
      {
        shopInvoiceId:"", //required
        amount:	"", //required
        invoiceCurrency:	"", //optional
        receiveCurrency: 	"", // optional
        receipt:  [
          {
            item: "MacBook Pro 27",
            descr: "bla-bla-bla",
            num: 1,
            price: 995,
          },
          {
            item: "iPhone 13",
            descr: "bla-bla-bla",
            num: 1,
            price: 1500,
          },
        ]
      }
    
    

    Data «shopId» and «sign» are sent in the request headers sign is formed as a hash of the concatenation of three strings: JSON, request address and Shop Secret Key (specified in the Business SettingsDevelopers tab). Sha256 is used.

    In response to the request, json will be returned containing the address of the payment form:

    
      {
        ….
        invoiceURL: "https://hashbon.com/payments/invoiceURL/xxxxxxxxxxxx",
      }
    
    

    Request example:

    
      curl --location --request POST
      'https://hashbon.com/api/v1/invoices/create/fromdata'
      --header 'Sign: e366ae8dc226c1660c74dcb4ec6848638e7dd85a4c1a1aa0cacd4d979a06f113'
      --header 'Shop-id: 44'
      --header 'Content-Type: application/json'
      --header 'Cookie: pc_r=X191bmRlZmluZWRfXw%3D%3D'
      --data-raw: {
        shopInvoiceId: "1", 
        amount: 1.05, 
        invoiceCurrency: "BTC", 
        receiveCurrency: "LTC", 
        receipt: [
          {
            item: "MacBook Pro 27",
            descr: "bla-bla-bla",
            num: 1, 
            price: 0.95
          }, 
          {
            item: "iPhone 13",
            descr: "bla-bla-bla",
            num: 1, 
            price: 0.1
          }
        ]
      }
    
    

    The sign is formed as a hash from the following line:

    
      {
        shopInvoiceId: "1",
        amount: 1.05,
        invoiceCurrency: "BTC",
        receiveCurrency: "LTC",
        receipt: [
          {
            item: "MacBook Pro 27",
            descr: "bla-bla-bla",
            num: 1, 
            price: 0.95,
          }, 
          {
            item: "iPhone 13",
            descr: "bla-bla-bla",
            num: 1,
            price: 0.1,
          }
        ]
      }
    
    
    
    /api/v1/invoices/create/fromdata3tqst5zCLA1h81t2EM9YfYu1w4H2YMRrpS4CNDGuA7BhQKBLFjnjbVfkMQTH6Dzt
    
    

    Response example:

    
      {
        type: "success",
        data: {
          result: {
            id: 330,
            amount: 1.05,
            rate: null,
            amountForTransfer: null,
            receiveCurrencyRate: null,
            payAmount: null,
            merchantFee: 0,
            createdAt: 1614861478,
            openedAt: null,
            endedAt: null,
            paidAt: null,
            status: 1,
            returned: false,
            receipt: [
              {
                item: "MacBook Pro 27",
                descr: "bla-bla-bla",
                num: 1,
                price: 0.95,
              },
              {
                item: "iPhone 13",
                descr: "bla-bla-bla",
                num: 1,
                price: 0.1,
              }
            ],
            shopInvoiceId: "1",
            invoiceCurrencyName: "BTC",
            receiveCurrencyName: "LTC",
            paymentCurrencyName: null,
            email: "example@test.com",
            payFormLink: "https://hashbon.com/processing/simple-payform?id=dVt6FgaHukB12uFk3L7x1Vmnr3m23pPd"
          }
        },
        errorCode: null,
      }
    
    

    Field description table:

    Field name

    Description

    type

    Request Status

    errorCode

    Error Code

    data.result

    Request result

    id

    Acoount ID

    amount

    Transfer amount

    rate

    Rate

    amountForTransfer

    Amount for transfer

    receiveCurrencyRate

    Receiving payment currency rate

    payAmount

    Amount to be paid in the payment currency

    feeFromMerchant

    Set an additional fee that is taken from the client in your favor. if you set a negative value it becomes a bonus for the client. The value is given as a percentage. min: -15%, max: 15%

    createdAt

    Creation Date

    openedAt

    Opening time of payment form

    endedAt

    Status set time completed

    paidAt

    The time when at least 1 confirmation was received for each incoming bitcoin transaction

    status

    Transfer status (All possible statuses can be viewed in the «Table of correspondence of numerical values of invoice statuses»)

    returned

    The flag that the transfer was returned to the sender

    shopInvoiceId

    Unique account number in the shop system

    invoiceCurrencyName

    Invoice currency

    receiveCurrencyName

    Currency received to the merchant’s account

    paymentCurrencyName

    Currency in which the invoice was paid

    email

    Email, which will receive a notification and the amount of payment or surplus if there are problems with paying the bill.

    payFormLink

    Link to the form

    receipt

    Receipt. An array of products/services (null - if not specified when creating)

    receipt.item

    Product/service name

    receipt.descr

    Product/service description

    receipt.num

    Product/service quantity

    receipt.price

    Product/service price

  2. Provide this link to your buyer. The buyer will be able to choose the cryptocurrency that is more convenient for him to pay and will make the payment.

  3. There are three ways to track your invoice status:

    1. Manually in the list of invoices.

    2. If you specified the Status URL in the shop settings, we will send a notification about the invoice status as soon as it changes.

    3. Via API (see the Invoice Verification tab)

  4. As soon as the invoice receives the status succeeded, it means that it is fully paid and confirmed.

img

Checking invoice status.

To get information on the invoice, you need to make a POST request to the address
https://hashbon.com/api/v1/invoice/status


  Request body: 
  {
    shopInvoiceId: "test448",
  }

The «shopId» and «sign» data is passed in the request headers sign is formed as a hash of the concatenation of three strings: JSON, request address and Shop Secret Key (specified in the BusinessSettingsDevelopers tab). Sha256 is used.
The sign is generated in the same way as in the invoice creation method.

An example of a response can be found in the method of creating an invoice «Response example»

Webhook.

The result of the status change is sent to the address specified in the personal account (specified in the Business → Settings → Developers tab) in the field «Address to which the payment result will be sent».
The request contains in headers:


  {
    content-type: application/json
    sign : a89d4ee44f8b3254794e5f5f44fc4c6e9fb8a848284caa69ffb3a9b4eb1989b0,
  }

Sign is formed as a hash of the concatenation of two strings: the request body in JSON and the Shop Secret Key (specified in theBusinessSettings Developers section). Sha256 is used.

The sign is formed as a hash from the following line:


  { 
    id: 267,
    amount: 1,
    rate: 0.00460897,
    amountForTransfer: 0.00460897,
    receiveCurrencyRate: 1,
    payAmount: 0.00460897, 
    merchantFee: -0.00001152,
    createdAt: 1617808109,
    openedAt: 1617884590,
    endedAt: null,
    paidAt: null,
    status: 1,
    returned: false,
    receipt: null,
    shopInvoiceId: "test448",
    invoiceCurrencyName: "EUR",
    receiveCurrencyName: "DASH",
    paymentCurrencyName: "DASH",
    payFormLink: "https://hashbon.com/processing/simple-payform?id=YDqtnFUY1eKV992t8FUM1d9qmQi4SpLG3tqst5zCLA1h81t2EM9YfYu1w4H2YMRrpS4CNDGuA7BhQKBLFjnjbVfkMQTH6Dzt",
  }

Request body example :

The description of the fields can be found in the table «Field description table»


  {
    id: 267,
    amount: 1,
    rate: 0.00460897,
    amountForTransfer: 0.00460897,
    receiveCurrencyRate: 1,
    payAmount: 0.00460897,
    merchantFee: -0.00001152,
    feeFromMerchant: 0,
    createdAt: 1617808109,
    openedAt: 1617884590,
    endedAt: null,
    paidAt: null,
    status: 1,
    returned: false,
    receipt: null,
    shopInvoiceId: "test448",
    invoiceCurrencyName: "EUR",
    receiveCurrencyName: "DASH",
    paymentCurrencyName: "DASH",
    email: "example@test.com",
    payFormLink: "https://hashbon.com/processing/simple-payform?id=YDqtnFUY1eKV992t8FUM1d9qmQi4SpLG",
  }

Table of correspondence of numerical values of invoice statuses:

Status number

Value

0

Overdue transaction

1

Waiting for the receipt of payment

2

Waiting for at least 1 confirmation to be received for all incoming bitcoin transaction

3

At least 1 confirmation was received for all incoming bitcoin transactions

4

Transaction completed

5

The waiting time for at least 1 confirmation has expired

6

The waiting time for the required number of confirmations has expired

7

Canceled by the sender

8

There is a transaction, but due to a very small commission, it is most likely that it will not be confirmed

Massive payments create.

Massive payments, you need to make a POST request to the address
https://hashbon.com/api/massive-payments/create

Request body:


  {
    registry: [ 
      {
        address: "2NFkkuZcsqkmuHoPGTUzVihz7v4ZyQE9z5V",
        amount: 0.0005 ,
        currency:"BTC".
      }, 
      {
        address: "my7RGheoJv4ENd9XtKUCd3YFuERpNsA13t",
        amount:0.0009, 
        currency:"LTC",
      },
      {
        address: "tmWsA3L5hz3eLKvai1oYthj8zCAYCrqKvi9", 
        amount: 0.01, 
        currency: "ZEC",
      }
    ],
    exchangeFrom: ["USD","EUR"]",
  }

Registry - JSON array consisting of address, amount and currency.ExchangeFrom - JSON array of currencies, from which conversion into bitcoins is possible to effect a massive payment.

The «shopId» and «sign» data is passed in the request headers sign is formed as a hash of the concatenation of three strings: JSON, request address and Shop Secret Key (specified in the BusinessSettingsDevelopers tab). Sha256 is used.

The sign is generated in the same way as in the invoice creation method.

Response example:


  {
    type: "success",
    text: "The request for a mass payment was received",
  }