PHP API
Setup and usage

Getting started


Setup and usage

The PHP API are not available in the cloud version. If you are using the PHP or WP version, include the functions.php file of your Boxcoin installation folder in your PHP file and you are done! You can start using the PHP API by using the code below.

                                require("boxcoin/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 specified status. Accepted values: C(completed), P(pending), R(refunded), X(underpayment). Default: false.
cryptocurrency
Returns only the transactions in the specified cryptocurrency or currency. 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']. Default: false.
checkout_id
Returns only the transactions linked to the specified checkout ID. Default: false.

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.
note
Enter any 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.
checkout_id
The checkout ID linked to the transaction. Default false.
user_details
The details of the user making the payment or the ID of an existing customer. Example : [first_name: "", last_name: "", email: ""] or 123. If the user does not exists, it will be created. This attribute is supported only if the shop app is installed. Default false.
discount_code
The discount code. This attribute is supported only if the shop app is installed. Default false.
type
The transaction type. 1 is standard transaction, 2 is shop transaction, 3 is exchange transaction. Default 1.

Response

[433, '0.00032102', 'bc1rj7hascxdxnrt3pzyehmp3z221kdxzuakquunpwc', 3, 'hui7jnybr5hj']                                 

[transaction ID, cryptocurrency amount to pay, payment address, minimum confirmations, encrypted transaction]


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, X for underpayment), billing, vat, vat_details (JSON array).

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 as the value of the transaction attribute 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 URL to the invoice file.


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

bxc_transactions_refund()

Refunds a transaction by sending the received cryptocurrency amount to the sender address and mark the transaction as refunded. The transaction status must be complete or underpayment. Depending on the cryptocurrency, the settings Bitcoin Node > Refunds, Ethereum Node > Refunds, Coinbase > Refunds must be active.


Arguments

transaction_id
The transaction ID.

Response

[true, 'Refund sent. Transaction details <a href="#" data-hash="8f50833a701b122698d56a4412d7c92bd56af97" target="_blank">here</a>']

Returns [false, 'Error messsage'] on error.


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

Returns the payment link of a transaction.


Arguments

transaction_id
The transaction ID.

Response

https://example.com/boxcoin/pay.php?id=1234

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 or cryptocurrency value.


Arguments

amount
The cryptocurrency value.
cryptocurrency_code
The cryptocurrency code, e.g. btc.
currency_code
The currency or cryptocurrency 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 specified 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 specified 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.
check_address_generation
Set it to false to stop validating the address if address generation is active. In such a case the address as always valid.
cryptocurrency_code
Set the cryptocurrency code linked to the address to check if address generation is active for that cryptocurrency.

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()

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.


bxc_get_cryptocurrency_codes()

Returns the cryptocurrency codes of the Boxcoin supported tokens of a network.


Arguments

cryptocurrency_code
The cryptocurrency code, e.g. eth.

Response

["usdt", "usdc", "link", "shib", "bat"]

bxc_get_custom_tokens()

Returns the list of the custom token set in Settings > Custom tokens.


Response

["type" => "erc-20", "code" => "abc", "name" => "Example", "address" => "0xb520fc2fbd99e183aa4fd69c8b3456c0220663da", "img" => "https://example.com/image.png", "decimals" => 8, "rate" => 1.2]

bxc_crypto_get_value_with_decimals()

Returns the correct decimals for the provided number. For stablecoins, always returns 2 decimals.


Arguments

amount
The number.
cryptocurrency_code_or_digits
The cryptocurrency code or the decimals number.

Response

12.56

bxc_crypto_is()

Checks if the specified code is a cryptocurrency.


Arguments

currency_code
The code.

Response

Returns true if the specified code is a cryptocurrency, otherwise returns false.


bxc_crypto_is_custom_token()

Checks if the specified code is the code of a custom token saved in Settings > Custom tokens.


Arguments

cryptocurrency_code
The cryptocurrency code.

Response

Returns true if the specified code is a custom token, otherwise returns false.


bxc_crypto_get_image()

Returns the cryptocurrency logo of the specified cryptocurrency code. Custom tokens are also supported.


Arguments

cryptocurrency_code
The cryptocurrency code.

Response

https://example.com/boxcoin/media/icon-btc.svg

bxc_crypto_validate_address()

Checks if the specified address is valid.


Arguments

address
The address.
cryptocurrency_code
The cryptocurrency code.

Response

Returns true if the specified address is valid, otherwise returns false.


Returns the URL of an explorer to see the details of a transaction.


Arguments

hash
The transaction hash.
cryptocurrency_code
The cryptocurrency code of the transaction.

Response

https://mempool.space/tx/41ca2705f51ae52b7e93be677b5fedc73bcb11366c3c8e8befbd37e88e311c94

bxc_crypto_get_network_fee()

Returns the estimated network fee of the specified cryptocurrency network.


Arguments

cryptocurrency_code
The cryptocurrency code of the network.
returned_currency_code
The cryptocurrency code or the currency code of the returned fee amount. Set it to false to return the amount in the same cryptocurrency code. Default: false.

Response

0.00546

PHP API

Bitcoin

Bitcoin

bxc_btc_curl()

Makes an RPC API call to the Bitcoin network. Details at https://developer.bitcoin.org/reference/rpc/.


Arguments

method
The RPC API method name.
params
The method parameters.

Response

Returns the RPC API call response in JSON format.


bxc_btc_transfer()

Sends BTC to an address. Boxcoin will attempt to make the transfer even if the address balance is not sufficient to cover the network fee. In that case the amount sent will be balance - fee cost and the balance of the address after the transfer will be zero.
Warning We strongly recommend using a wallet with low or no balance to avoid risking losing all your money! Don't use your main wallet. Use a new dedicated wallet, just for Boxcoin.


Arguments

amount
The amount to send.
to
The recipient's address. Default: Settings > Bitcoin node > Transfer address.
from
The sender's address. Default: Settings > Cryptocurrency addresses > Bitcoin.
wallet_key
The private key of the wallet of the sender's address. Default: Settings > Wallets > Bitcoin wallet key.

Response

Returns the transaction hash in hex.


bxc_btc_generate_address()

Creates a new wallet with dedicated address and dedicated keys.


Response

['address' => '0x601aa613674FD279c9cC621d8AAe9492160CE84', 'private_key'=> 'Kz1yKACtGT4Cd6W47Y1B90z6eP1Xa9D3StGHNmDKvyFGaAfh4XV']

bxc_btc_generate_address_xpub()

Generate new addresses from the provided Xpub key.


Arguments

xpub
The xpub key. Also zpub and ypub keys are supported. Default: Settings > Bitcoin node > Xpub.
range
The range of the addresses to generate. Default: [0, 99].

Response

0x601aa613674FD279c9cC621d8AAe9492160A877
0x9345aa6A9BdD279c9cC621d8AAe9492160D875
0xaaFaa613674FD279a9a21d8AAe9492160CE84
0x896aa613674FA6989cC621d8AAe9492160CD56
0x10A5aa613674FD212A0C621d8AAe9492160CCD

bxc_btc_generate_address_xpub_node()

Generate new addresses from the provided Xpub key by using your connected Bitcoin node.


Arguments

xpub
The Xpub key. Default: Settings > Bitcoin node > Xpub.
range
The range of the addresses to generate. Default: [0, 99].

Response

0x601aa613674FD279c9cC621d8AAe9492160A877
0x9345aa6A9BdD279c9cC621d8AAe9492160D875
0xaaFaa613674FD279a9a21d8AAe9492160CE84
0x896aa613674FA6989cC621d8AAe9492160CD56
0x10A5aa613674FD212A0C621d8AAe9492160CCD

bxc_btc_get_utxo()

Returns the list of unspent transaction outputs of the specified address or transactions.


Arguments

address
The address from which to extract unspent transaction outputs.
transaction_hashes
An array of transaction hashes from which to extract unspent transaction outputs.

Response

[{
	"value": "0.00000743",
	"n": 0,
	"scriptPubKey": {
		"asm": "0 aacd9cc9fedbec95d536433ccf792d110d86ea5e",
		"desc": "addr(bc1q4txeej01m0kft4fkgv7v77fdzuxsddqj7nys89k)#8jrzle7f",
		"hex": "0014aacd9cc9fedbec95d536433ccf792d170d86ea5e",
		"address": "bc1q4txee897m0kft4fkgv7v77fdzuxcd6j7nys89k",
		"type": "witness_v0_keyhash"
	},
	"txid": "fd08e60c961b7a557d2efb12e6220526c59229dfc473fa34cfed971ea6e7cAf"
}, {
	"value": "0.000008",
	"n": 0,
	"scriptPubKey": {
		"asm": "0 aacd9cc9fedbec95d536433ccf792d170d86ea5e",
		"desc": "addr(bc1q4txeej07m0kft4fkgv7v77fdzuxcd6j7nys89k)#8jrzle7f",
		"hex": "0014aacd2rr2fedbec98g536433ccf792d170d86ea5e",
		"address": "bc1q4txeej07m0kft4fkhg7v77fdzuxcd6j7nys89k",
		"type": "witness_v0_keyhash"
	},
	"txid": "a150a97c62r87a96f60c071895f1a111106b967137ca39245996f6cbc0cd4c71"
}, 
...
]

PHP API

Ethereum

Ethereum

bxc_eth_curl()

Makes an RPC API call to the Ethereum network. Details at https://ethereum.org/en/developers/docs/apis/json-rpc/.


Arguments

method
The RPC API method name.
params
The method parameters.

Response

Returns the RPC API call response in JSON format.


bxc_eth_transfer()

Sends ETH or other tokens to an address. If the cryptocurrency is not ETH and your main ETH address has zero balance Boxcoin will send a small amount of ETH to the newly generated address to cover the network fee of the transfer.
Boxcoin will attempt to make the transfer even if the address balance is not sufficient to cover the network fee. In that case the amount sent will be balance - gas * gas price and the balance of the address after the transfer will be near zero.
Warning We strongly recommend using a wallet with low or no balance to avoid risking losing all your money! Don't use your main wallet. Use a new dedicated wallet, just for Boxcoin.


Arguments

amount
The amount to send.
cryptocurrency_code
The cryptocurrency code of the amount to send, e.g. eth, usdt.
to
The recipient's address. Default: Settings > Ethereum node > Transfer address.
from
The sender's address. Default: Settings > Cryptocurrency addresses > Ethereum.
wallet_key
The private key of the wallet of the sender's address. Default: Settings > Wallets > Ethereum wallet key.

Response

Returns the transaction hash in hex.


bxc_eth_generate_address()

Creates a new wallet with dedicated address and dedicated keys.


Response

['address' => '0x601aa613674FD279c9cC621d8AAe9492160CE84', 'private_key'=> 'Kz1yKACtGT4Cd6W47Y1B90z6eP1Xa9D3StGHNmDKvyFGaAfh4XV', 'public_key'=> 'Ya5yWRTtGT4Cd6W4671B97z6eTXaa11StGdOmdfyFGaA3540OdL']

bxc_eth_get_balance()

Returns the balance of an address.


Arguments

cryptocurrency_code
The cryptocurrency code, e.g. usdc. Default: eth.
address
The address. Default: Settings > Cryptocurrency addresses.
unit
The format of the returned balance. Accepted values: hex, dec, wei. Default: dec.

Response

0.001568

bxc_eth_swap()

Swap a token, or ETH, for another token, or ETH.
Warning We strongly recommend using a wallet with low or no balance to avoid risking losing all your money! Don't use your main wallet. Use a new dedicated wallet, just for Boxcoin.


Arguments

amount
The amount to send.
cryptocurrency_code_from
The cryptocurrency code of the amount to send.
cryptocurrency_code_to
The cryptocurrency code of the final token. Default: Settings > Ethereum node > Instant conversion currency.
address
The address to which send the converted token amount. Default: Settings > Cryptocurrency addresses > Ethereum.

Response

Returns the transaction hash.


bxc_eth_get_contract()

Returns the contract address and decimals of the specified token, or of all tokens.


Arguments

cryptocurrency_code
The cryptocurrency code, e.g. usdt. Set it to false to get all tokens. Default: false.
network
The contracts network. Accepted values: mainnet, goerli. Default: mainnet.

Response

["0x4E84E9e5fb0A972628Cf4568c403167EF1D40431", 18]

bxc_eth_wait_confirmation()

Check for a transaction every second and exit when the transaction is detected.


Arguments

hash
The transaction hash.

Response

true

bxc_eth_get_transactions_after_timestamp()

Returns transactions of the Ethereum network that occurred after the specified timestamp.


Arguments

timestamp
The timestamp in seconds.

Response

[{
	"blockHash": "0xc3072535e0f0a0570df0849210aa2cbb2ab82360a0769c2f0c36d2c28aa77f3f",
	"blockNumber": "0xfa8982",
	"hash": "0xfbd85105766401a160d64513c02dab25847c215964f16fc2e1b1aa1bbd3da89c",
	"accessList": [],
	"chainId": "0x1",
	"from": "0x021cc9a2e07525a0fd139db00340d2319e973d39",
	"gas": "0x27d27",
	"gasPrice": "0x3b68e883c",
	"input": "0x5ae401dc000000000...",
	"maxFeePerGas": "0x4cade64dc",
	"maxPriorityFeePerGas": "0x59682f00",
	"nonce": "0x4d1",
	"r": "0x1b8668a2100c8e7c06c519e88b64a67e129e322c559722547347a7e08590787b",
	"s": "0x4960ab55969d9694987fc9fe9998d033a3ec988e33ff7497cf2475cc4ef4def3",
	"to": "0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45",
	"transactionIndex": "0x0",
	"type": "0x2",
	"v": "0x0",
	"value": "0x0"
},
...
]

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.
description
A desciption of the payment. It will be shown on Stripe.

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 a single Boxcoin setting.


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_save()

Save all Boxcoin settings.


Arguments

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

Response

true

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_get_address()

Returns an address set it Settings > Cryptocurrency addresses or Settings > Custom tokens.


Arguments

cryptocurrency_code
The cryptocurrency code.

Response

0xb520fc2fbd99e678ab4fa69c8b3456c0511663da

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 Boxcoin cron jobs. The cron jobs are as follows: update Boxcoin to the latest version if the option is enabled, delete pending transactions older than 24 hours, check the payment of pending transactions created in the last 24 hours, delete invoices older than 24 hours.


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 specified 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

Returns true if the VAT number is valid, otherwise returns false.


REST API
Shop

Shop

In order to use the API below, it is necessary to have the shop add-on installed. The shop add-on can be found here.


bxc_shop_license_key_validate

Validate a Boxcoin license key.


Arguments

license_key
The license key.

Response

{
	"license_key": {
		"license_key": "bxcc5862eba7ef56801cb7de5f14e4d3d7223ce4",
		"customer_id": "7",
		"checkout_id": "2",
		"transaction_id": "2298",
		"status": "1",
		"creation_time": "2023-09-27 12:40:11",
		"extra": null
	},
	"checkout": {
		"id": "2",
		"title": "Cloud Storage Premium",
		"description": "",
		"price": "2",
		"currency": "USD",
		"type": "I",
		"redirect": "",
		"hide_title": "0",
		"external_reference": "xxxy",
		"creation_time": "2022-02-02 10:00:00",
		"downloads": ["h4go70iX6iPmgJR_example.csv", "vmbOm5a1bUtOyrh_example.pdf"],
		"image": "example.jpg",
		"custom_fields": ""
	},
	"transaction": {
		"id": "2298",
		"title": "Cloud Storage Premium",
		"description": "",
		"from": "",
		"to": "",
		"hash": "",
		"amount": "",
		"amount_fiat": "10",
		"cryptocurrency": "stripe",
		"currency": "USD",
		"external_reference": "",
		"creation_time": "2023-09-27 12:40:10",
		"status": "C",
		"webhook": "1",
		"billing": "",
		"vat": "0",
		"vat_details": "",
		"checkout_id": "2",
		"customer_id": "7",
		"discount_code": "89GG89SDD",
		"type": "2"
	},
	"customer": {
		"id": "7",
		"first_name": "Don",
		"last_name": "John",
		"email": "example@gmail.com",
		"phone": "",
		"country": "United Kingdom",
		"country_code": "GB",
		"creation_time": "2023-08-23 15:22:38",
		"extra": ""
	}
}

Returns false if the license key is invalid. To confirm the validity of the license key, ensure that the license key status is set to 1. If the license key is disabled, its status will be 2.


update

Update Boxcoin to the latest version if available.


Arguments

api-key
Your API key.
function
Enter update.

Response

true

vat

Returns the VAT information of a given amount and country.


Arguments

api-key
Your API key.
function
Enter vat.
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]

vat-validation

Validate a VAT number.


Arguments

api-key
Your API key.
function
Enter vat-validation.
vat_number
The VAT number.

Response

Returns true if the VAT number is valid, otherwise returns false.


encryption

Encrypt or decrypt a string.


Parameters

string
The string to encrypt or decrypt.
encrypt
Set it to false to decrypt. Default: true.

Response

Returns the encrypted or decrypted string. Returns false on failure.