PHP API
Setup and usage

Getting started


Setup and usage

Include the file functions.php in your PHP file and you are done! You can start now using the functions below.

                                require("functions.php");
                            

PHP API
Transactions

Transactions


bxc_transactions_get_all()

Returns all Boxcoin transactions.


Arguments

pagination
Set the pagination number from 0 to N. Returns only 100 results per page. Set it to -1 to get all results. Default: 0.
search
Returns only the transactions matching the specified search terms. Default: false.
status
Returns only the transactions with the given status. Accepted values: C(completed), P(pending), R(refunded), X(underpayment). Default: false.
cryptocurrency
Returns only the transactions in the given cryptocurrency. Default: false.
date_range
Returns only the transactions within the date range. Syntax: ['yyyy-mm-dd', 'yyyy-mm-dd']. Example: ['2022-08-02', '2022-08-03'].

Response

[
    {
	    "id": "433",
	    "title": "",
	    "description": "",
	    "from": "",
	    "to": "bc1qj2hafvdxnrt1pzyyhmp3z335kdxzuakqyynpuc",
	    "hash": "",
	    "amount": "0.00032102",
	    "amount_fiat": "10",
	    "cryptocurrency": "btc",
	    "currency": "usd",
	    "external_reference": "",
	    "creation_time": "2022-05-30 15:57:51",
	    "status": "P",
	    "webhook": "0"
    },
    ...
]                                 

bxc_transactions_get()

Returns a Boxcoin transaction.


Arguments

transaction_id
The transaction ID.

Response

{
	"id": "433",
	"title": "",
	"description": "",
	"from": "",
	"to": "bc1qj2hafvdxnrt1pzyyhmp3z335kdxzuakqyynpuc",
	"hash": "",
	"amount": "0.00032102",
	"amount_fiat": "10",
	"cryptocurrency": "btc",
	"currency": "usd",
	"external_reference": "",
	"creation_time": "2022-05-30 15:57:51",
	"status": "P",
	"webhook": "0"
}                                 

bxc_transactions_create()

Create a new transaction ready to be paid by the user.


Arguments

amount
The transaction amount in FIAT, e.g. 123.
cryptocurrency_code
The cryptocurrency code, e.g. btc.
currency_code
The currency code, e.g. usd. Default: Settings > Currency.
external_reference
Enter the string you want, it will be sent via webhook and as a redirect URL parameter.
title
Enter the string you want, it will be shown in the the admin area.
description
Enter the string you want, it will be shown in the the admin area.
billing
A JSON string containing billing details. Default empty string.
vat
A JSON string containing billing details. Default empty string.

Response

[433, '0.00032102', 'bc1rj7hascxdxnrt3pzyehmp3z221kdxzuakquunpwc']                                 

bxc_transactions_update()

Update a transaction.


Arguments

transaction_id
The transaction ID.
values
Array in PHP or JSON format, with the values to update. Syntax: ['key' => 'value', 'key' => 'value', ...]. Example: ['status' => 'C', 'title' => 'Example']. Allowed keys: title, description, from, to, hash, amount, amount_fiat, cryptocurrency, currency, external_reference, creation_time(2022-04-14 10:00:00), status (C for completed, P for pending, R for refunded), billing.

Response

true                             

bxc_transactions_delete_pending()

Deletes pending transactions older than 24h.


Response

true                                 

bxc_transactions_check()

Check the latest Blockchain transactions of the payment address and returns the Blockchain transaction details if the payment is detected.


Arguments

transaction_id
The transaction ID.

Response

Returns false if the payment is not found, or and encrypted string if the payment is detected. The encrypted string can be used for the attribute transaction of the function bxc_transactions_check_single().


bxc_transactions_check_single()

Returns the details of a Blockchain transaction.


Arguments

transaction
Enter the encrypted string returned by the function bxc_transactions_check(). If you're logged as admin you can pass the following array as well: { id: "", hash: "", cryptocurrency: "", to: "" }. The id is the Boxcoin transaction ID.

Response

{
    "confirmed" => true,
    "confirmations" => 1155,
    "minimum_confirmations" => 3,
    "hash" => "8f50833a701b122698d56a4412d7c92bd56af97..."
}

bxc_transactions_webhook()

Send the webhook of a transaction. The webhook can be sent only 1 time per transaction.


Arguments

transaction
Enter the encrypted string returned by the function bxc_transactions_check(). If you're logged as admin you can pass the following array as well: { id: "", hash: "", cryptocurrency: "", to: "" }. The id is the Boxcoin transaction ID.

Response

true

Returns false if the webhook has already been sent.


bxc_transactions_download()

Download a CSV file with transaction details.


Arguments

search
Returns only the transactions matching the search.
status
Returns only the transactions with the provided status.
cryptocurrency
Returns only the transactions with the provided cryptocurrency.
date_range
Returns only the transactions within the date range. Syntax: ['yyyy-mm-dd', 'yyyy-mm-dd']. Example: ['2022-08-02', '2022-08-03'].

Response

http://boxcoin.dev/uploads/transactions-790419984.csv

bxc_transactions_invoice()

Generate an invoice and return the link to the invoice.


Arguments

transaction_id
The transaction ID.

Response

http://boxcoin.dev/uploads/inv-5.pdf

bxc_transactions_random_amount()

Changes the cryptocurrency amount of a transaction and makes it unique. The change in value is less than 0.002%.


Arguments

amount
The amount in array format. First value of the array is the value before the comma, the second value of the array is the value after the comma. For example the array of 123.456 is [123, 456].
decimals
The max number of decimals after the comma.

Response

12.45776

PHP API

Checkout

Checkout

bxc_checkout_get()

Returns the checkouts list, or a single checkout.


Arguments

checkout_id
The checkout ID. Leave it empty to get all checkouts.

Response

[{
    "id": "2",
    "title": "Cloud Storage Premium",
    "description": "",
    "price": "99",
    "currency": "CNY",
    "type": "I",
    "redirect": "",
    "external_reference": "ABC",
    "creation_time": "2022-02-02 10:00:00"
}, {
    "id": "3",
    "title": "Cloud Storage Base",
    "description": "",
    "price": "99.5",
    "currency": "USD",
    "type": "P",
    "redirect": "",
    "external_reference": "",
    "creation_time": "2022-02-03 11:05:19"
},
...
]


bxc_checkout_save()

Create a new checkout, or update an existing one.


Arguments

checkout
Pass the checkout array below or get it from the function bxc_checkout_get(). Add the key id: CHECKOUT-ID to update an existing checkout.
{
    "title": "Cloud Storage Premium",
    "description": "",
    "price": "99",
    "currency": "CNY",
    "type": "I",
    "redirect": "",
    "external_reference": "ABC",
    "creation_time": "2022-02-02 10:00:00"
}

Response

Returns the checkout ID.


bxc_checkout_delete()

Delete a checkout.


Arguments

checkout_id
The checkout ID.

Response

true

PHP API

Crypto

Crypto

bxc_crypto_balances()

Returns the balances of the cryptocurrency addresses saved in the admin area.


Response

{
    "balances": {
        "btc": {
            "amount": 0.63521135,
            "fiat": 19563.05,
            "name": "Bitcoin"
        },
        "eth": {
            "amount": 0.001,
            "fiat": 1.92,
            "name": "Ethereum"
        },
        "doge": {
            "amount": 10,
            "fiat": 0.98,
            "name": "Dogecoin"
        }
    },
    "total": 18461.67,
    "currency": "USD"
}

bxc_crypto_api_key()

Returns the API key of a Blockchain explorer. Returns the key set by the user if available, otherwise one of the default keys.


Arguments

service
Enter etherscan, ethplorer.
url
The Blockchain explorer URL to apply the key to. Returns the URL with key.

Response

Returns the URL with the key, or the key. Return false if the service or key is not found.


bxc_crypto_get_fiat_value()

Get the FIAT value of a cryptocurrency value.


Arguments

amount
The FIAT value.
cryptocurrency_code
The cryptocurrency code, e.g. btc.
currency_code
The currency code, e.g. usd.

Response

305126.4

bxc_crypto_get_cryptocurrency_value()

Get the cryptocurrency value of a FIAT value.


Arguments

amount
The cryptocurrency value.
cryptocurrency_code
The cryptocurrency code, e.g. btc.
currency_code
The currency code, e.g. usd.

Response

 0.0458965                                

bxc_blockchain()

Query the Blockchain and return the data.


Arguments

cryptocurrency
The cryptocurrency code, e.g. btc, eth, doge.
action
The query. Accepted values: balance, transaction, transactions, blocks_count.
extra
Set it to transaction hash for balance action. Default: false.
address
Set the Blockchain explorer URL. Default: the addresses saved in the settings.

Response

Responses change for each cryptocurrency and action.


bxc_crypto_name()

Returns the cryptocurrency full name of the given cryptocurrency code.


Arguments

cryptocurrency_code
The cryptocurrency code, e.g. btc, eth, doge.
uppercase
Set it to true to get capitalized names.

Response

Bitcoin                                 

bxc_crypto_get_address()

Returns the payment address for the given cryptocurrency.


Arguments

cryptocurrency_code
The cryptocurrency code, e.g. btc, eth, doge.

Response

bc1jj2hasvdxnrt1pzyehmp3z456kdxzuakiipnpwc                                 

bxc_usd_rates()

Returns the exchange rate of USD to other FIAT currencies like EURO or GBP.


Arguments

currency_code
Returns the USD exchange rate to the specified FIAT currency code. If not set the return the USD exchange rate of all FIAT currencies.

Response

1.002914                                 

bxc_exchange_rates()

Returns the exchange rate of the specified FIAT currency code to the specified cryptocurrency code.


Arguments

currency_code
The FIAT currency code.
cryptocurrency_code
The cryptocurrency code, e.g. btc, eth, doge.

Response

0.05781                                

bxc_crypto_whitelist_invalid()

Check if an address is added to the Boxcoin whitelist.


Arguments

address
The cryptocurrency address.

Response

Returns false if the address is valid and added to the whitelist, or if the whitelist is not set, otherwise returns true.


bxc_crypto_transfer()

Send the cryptocurrency amount of a transaction to the addresses set in Settings > Cryptocurrency addresses. This function can be successfully performed a maximum of once per transaction. More details a here.


Arguments

transaction_id
The Boxcoin transaction ID.
cryptocurrency_code
The cryptocurrency code, e.g. btc.
amount
The cryptocurrency amount to send.

Response

Returns the transfer details on success, otherwise returns false.


bxc_crypto_convert_to_fiat()

Exchange the cryptocurrency amount of a transaction to the currency set in Settings > Gemini or Settings > Coinbase. This function can be successfully performed a maximum of once per transaction. More details a here.


Arguments

transaction_id
The Boxcoin transaction ID.
cryptocurrency_code
The cryptocurrency code, e.g. btc.
amount
The cryptocurrency amount to convert.

Response

Returns the conversion details on success, otherwise returns false.


PHP API

FIAT

FIAT

bxc_stripe_payment()

Generate the Stripe checkout and return the URL.


Arguments

price_amount
The amount of the price in cents. Multiply the amount x 100. For example, if the amount is 2.05 USD, enter 205.
checkout_url
The return URL that redirects the user when the payment is completed.
client_reference_id
Enter the transaction ID.
currency_code
The FIAT currency code, e.g. usd or eur. List here: stripe.com/docs/currencies. Default: the currency set in the settings area.

Response

https://checkout.stripe.com/pay/cs_werw_a1nDsq8CdRiK8yNWR7TjGdBLklw

bxc_stripe_curl()

Use this function to query the Stripe API.


Arguments

url_part
The URL part of a Stripe API URL. For example, if the API URL is https://api.stripe.com/v1/prices, the URL part is prices. Docs here: stripe.com/docs/api.
type
The HTTP call type. Available types: POST, GET. Default POST.

Response

Returns the Stripe API response.

bxc_verifone_create_checkout()

Generate the Verifone (2checkout) checkout and return the URL.


Arguments

price_amount
The amount of the price.
checkout_url
The return URL that redirects the user when the payment is completed.
client_reference_id
Enter the transaction ID.
title
The checkout title.
currency_code
The FIAT currency code, e.g. usd or eur. Default: the currency set in the settings area.

Response

https://secure.2checkout.com/checkout/buy?currency=USD&dynamic=1&merchant=253145249128&order...

bxc_verifone_curl()

Use this function to query the Verifone API.


Arguments

url_part
The URL part of a Stripe API URL. For example, if the API URL is https://api.2checkout.com/rest/6.0/prices, the URL part is prices. Docs here: app.swaggerhub.com/apis-docs/2Checkout-API/api-rest_documentation/6.0.
type
The HTTP call type. Available types: POST, GET. Default POST.

Response

Returns the Verifone API response.

PHP API

Account

Account

bxc_login()

Log in as an administrator.


Arguments

username
The username.
password
The password.

Response

Returns an encrypted string to be saved in a cookie named BXC_LOGIN. Returns false if login fails.


bxc_verify_admin()

Check the Boxcoin administrator is logged in.


Response

Returns true if the administrator is logged in, otherwise returns false.


PHP API

Settings

Settings

bxc_settings_get()

Returns all Boxcoin settings.


Arguments

id
The setting ID.
default
A default value to return if the setting is not found or is not set. Default: false.

Response

Returns the setting value


bxc_settings_get_all()

Returns all Boxcoin settings.


Response

{
    "address-btc": "",
    "address-eth": "",
    "address-doge": "",
    "refresh-interval": "5",
    "confirmations": "",
    "currency": "",
    "custom-explorer-active": false,
    "custom-explorer-divider": "",
    "custom-explorer-balance-url": "",
    "custom-explorer-balance-path": "",
    "custom-explorer-transaction-url": "",
    "custom-explorer-transaction-path": "",
    "custom-explorer-transactions-url": "",
    "custom-explorer-transactions-path": "",
    "custom-explorer-address": "",
    "custom-explorer-address-path": "",
    "webhook-url": "",
    ...
}

bxc_settings_db()

Returns a database row from the table bxc_settings or save a new row into it.


Arguments

name
The setting name.
value
The setting value if you want to save it.
default
A default value to return if the setting is not found or is not set. Default: false.

Response

Returns the row value, or true on save.


bxc_settings_save()

Save all Boxcoin settings.


Arguments

settings
Pass the array of all settings. Get it with the function bxc_settings_get_all().

Response

true

PHP API

Database

Database

bxc_db_get()

Query the database and return the results. Use the function bxc_db_escape($value) to sanatize the query values.


Arguments

Query
The MySQL query.
single
Set it to false if you expect to get multiple results.

Response

Returns the single result or an array or results.


bxc_db_query()

Insert data into the database.


Arguments

Query
The MySQL query.
return
Set it to true to get the ID of the newly inserted row.

Response

Returns true or the ID.


PHP API

Miscellaneous

Miscellaneous

bxc_language()

Return the language of the admin area, or checkout form, relative to the active user.


Arguments

admin
Set it to true to get the language of the admin area. Default: false.

Response

Returns the language code, e.g. it, es, zh.


bxc_()

Translate a string in the language returned by the function bxc_language.


Arguments

string
The string to translate.

Response

The translated string.


bxc_encryption()

Encrypt or decrypt a string.


Arguments

string
The string to encrypt or decrypt.
encrypt
Set it to true to encrypt a string.

Response

The encryped or decrypted string.


bxc_cron()

Run the cron jobs.


Response

true

bxc_update()

Update Boxcoin to the latest version if available.


Response

true

bxc_versions()

Returns the latest Boxcoin version.


Response

1.0.0                            

bxc_is_demo()

Check if the active checkout is in demo mode.


Response

Returns true if it is demo mode, otherwise returns false.


bxc_is_address_generation()

Check if the checkout addresses are dynamically generated via Gemini, other exchanges, or via the custom explorer.


Response

Returns true if the address is dynamically generated, otherwise returns false.


bxc_vat()

Returns the VAT information of a given amount and country.


Arguments

amount
The amount.
country_code
The country code of the VAT-registered country you want to apply. If not provided, the country is automatically retrieved from the user's IP. Default: false.
currency_code
The currency code of the provided amount. Default: false.

Response

[12.2,2.2,"IT","Italy","Including  2.2 for VAT in Italy",22]

bxc_vat_validation()

Validate a VAT number.


Arguments

vat_number
The VAT number.

Response

{
  "success": true,
  "code": 200,
  "data": {
    "valid": true,
    "company": {
      "vat_number": "288305674",
      "country_code": "GB",
      "company_name": "WEIO LTD",
      "company_address": "142 CROMWELL ROAD\nLONDON\nGREATER LONDON\n\n\nSW7 4EF"
    }
  }
}