Documentation

AkashicPay
in package

Table of Contents

Constants

AC_PRIVATE_KEY_REGEX  = '/^0x[a-f\d]{64}$/'
L2_REGEX  = '/^AS[A-Fa-f\d]{64}$/'

Properties

$akashicChain  : AkashicChain
$akashicPayUrl  : string
$akashicUrl  : string
$apiSecret  : string
$env  : string
$httpClient  : HttpClient
$isFxBp  : bool
$logger  : Logger
$otk  : array<string|int, mixed>
$targetNode  : array<string|int, mixed>

Methods

__construct()  : mixed
addCallbackUrls()  : void
Experimental feature to add callback URLs for deposit and payout events from SDK
checkIfBp()  : array<string|int, mixed>
Check if BP
createDepositOrder()  : array<string|int, mixed>
Create deposit order
getBalance()  : array<string|int, mixed>
Get total balances, divided by Network and Token.
getByOwnerAndIdentifier()  : array<string|int, mixed>|null
Get key by BP and identifier
getDepositAddress()  : array<string|int, mixed>
Get an L1-address on the specified network for a user to deposit into
getDepositAddressWithRequestedValue()  : array<string|int, mixed>
Get an L1-address on the specified network for a user to deposit into
getDepositUrl()  : string
Get deposit page url
getDepositUrlWithRequestedValue()  : string
Get deposit page url with requested value Callback will match the requested value
getExchangeRates()  : array<string|int, mixed>
Get exchange rates for all supported main-net coins in value of requested currency
getKeysByOwnerAndIdentifier()  : array<string|int, mixed>|null
Get all keys by BP and identifier
getSupportedCurrencies()  : array<string|int, mixed>
Get the currently supported currencies in AkashicPay
getTransactionDetails()  : array<string|int, mixed>|null
Get details of an individual transaction. Returns null if no transaction found for the queried hash
getTransfers()  : array<string|int, mixed>
Get all or a subset of transactions. Optionally paginated with `page` and `limit`.
lookForL2Address()  : array<string|int, mixed>
Check which L2-address an alias or L1-address belongs to. Or call with an L2-address to verify it exists
onboardBp()  : array<string|int, mixed>
Experimental feature to onboard a new BP from SDK
payout()  : array<string|int, mixed>|string
Send a crypto-transaction
updateSettings()  : void
Experimental feature to update BP settings from SDK
verifySignature()  : bool
Verify HMAC signature against body and secret with sorted keys
prepareL2Transaction()  : array<string|int, mixed>
Prepares an L2 transaction by sending transaction data to the Akashic API.
becomeBp()  : void
Call AP to become a BP
boolsToString()  : mixed
chooseBestACNode()  : array<string|int, mixed>
Finds an AkashicChain node to target for requests. The SDK will attempt to find the fastest node for you.
generateApiKeyPair()  : array<string|int, mixed>
Generate a new API/SDK key pair for integration
get()  : array<string|int, mixed>|null
getCoinSymbol()  : mixed
getDepositAddressFunc()  : mixed
getDepositUrlFunc()  : mixed
mapMainToTestCurrency()  : string|null
Map receive currency from mainnet to testnet if in development
mapUSDTToTether()  : string|null
Map USDT to TETHER for Tron Shasta network
post()  : array<string|int, mixed>|null
retryWithAttempts()  : void
Retry a callback up to $maxAttempts times with $delay microseconds between attempts
setOtkFromKeyPair()  : void
Sets your OTK to sign transactions on AkashicChain (AC)
setOtkFromRecoveryPhrase()  : void
Sets your OTK to sign transactions on AkashicChain (AC)
sign()  : mixed
sortKeys()  : mixed
Recursively sort array keys for consistent JSON serialization

Constants

AC_PRIVATE_KEY_REGEX

private mixed AC_PRIVATE_KEY_REGEX = '/^0x[a-f\d]{64}$/'

L2_REGEX

private mixed L2_REGEX = '/^AS[A-Fa-f\d]{64}$/'

Properties

$targetNode

private array<string|int, mixed> $targetNode

Methods

__construct()

public __construct(mixed $args) : mixed
Parameters
$args : mixed

addCallbackUrls()

Experimental feature to add callback URLs for deposit and payout events from SDK

public addCallbackUrls(string $l2Address, string $privateKey, array<string|int, mixed> $params) : void
Parameters
$l2Address : string

L2 address of the BP

$privateKey : string

Private key of the BP

$params : array<string|int, mixed>

Parameters containing URLs for different events e.g. pendingDepositUrl, confirmedDepositUrl, etc.

checkIfBp()

Check if BP

public checkIfBp(mixed $l2Address) : array<string|int, mixed>
Parameters
$l2Address : mixed
Return values
array<string|int, mixed>

createDepositOrder()

Create deposit order

public createDepositOrder(mixed $payload) : array<string|int, mixed>
Parameters
$payload : mixed
Return values
array<string|int, mixed>

getBalance()

Get total balances, divided by Network and Token.

public getBalance() : array<string|int, mixed>
Return values
array<string|int, mixed>

getByOwnerAndIdentifier()

Get key by BP and identifier

public getByOwnerAndIdentifier(mixed $getByOwnerAndIdentifierParams) : array<string|int, mixed>|null
Parameters
$getByOwnerAndIdentifierParams : mixed
Return values
array<string|int, mixed>|null

address

getDepositAddress()

Get an L1-address on the specified network for a user to deposit into

public getDepositAddress(string $network, string $identifier[, string $referenceId = null ]) : array<string|int, mixed>
Parameters
$network : string

L1-network

$identifier : string

userID or similar identifier of the user making the deposit

$referenceId : string = null

referenceId to identify the order

Return values
array<string|int, mixed>

getDepositAddressWithRequestedValue()

Get an L1-address on the specified network for a user to deposit into

public getDepositAddressWithRequestedValue(string $network, string $identifier, string $referenceId, string $requestedCurrency, string $requestedAmount[, string $token = null ][, float|null $markupPercentage = null ]) : array<string|int, mixed>
Parameters
$network : string

L1-network

$identifier : string

userID or similar identifier of the user making the deposit

$referenceId : string

referenceId to identify the order

$requestedCurrency : string

CurrencySymbol requestedCurrency to identify the order

$requestedAmount : string

requestedAmount to identify the order

$token : string = null

Optional. Include if sending token, e.g. USDT

$markupPercentage : float|null = null

Optional. Include if you want to add a markup percentage to the requested amount

Return values
array<string|int, mixed>

getDepositUrl()

Get deposit page url

public getDepositUrl(string $identifier[, string $referenceId = null ][, array<string|int, mixed> $receiveCurrencies = null ][, array<string|int, mixed> $networks = null ][, string $redirectUrl = null ]) : string
Parameters
$identifier : string

userID or similar identifier of the user making the deposit

$referenceId : string = null

optional referenceId to identify the order

$receiveCurrencies : array<string|int, mixed> = null

optional currencies to be display on deposit page, comma separated

$networks : array<string|int, mixed> = null

optional networks to be display on deposit page, comma separated

$redirectUrl : string = null

optional redirect URL after deposit

Return values
string

getDepositUrlWithRequestedValue()

Get deposit page url with requested value Callback will match the requested value

public getDepositUrlWithRequestedValue(string $identifier, string $referenceId, string $requestedCurrency, string $requestedAmount[, array<string|int, mixed> $receiveCurrencies = null ][, array<string|int, mixed> $networks = null ][, float|null $markupPercentage = null ][, string|null $redirectUrl = null ]) : string
Parameters
$identifier : string

userID or similar identifier of the user making the deposit

$referenceId : string

referenceId to identify the order

$requestedCurrency : string

CurrencySymbol requestedCurrency to identify the order

$requestedAmount : string

requestedAmount to identify the order

$receiveCurrencies : array<string|int, mixed> = null

optional currencies to be display on deposit page, comma separated

$networks : array<string|int, mixed> = null

optional networks to be display on deposit page, comma separated

$markupPercentage : float|null = null

optional markup percentage to be applied to the requested amount

$redirectUrl : string|null = null

optional redirect URL after deposit

Return values
string

getExchangeRates()

Get exchange rates for all supported main-net coins in value of requested currency

public getExchangeRates(string $requestedCurrency) : array<string|int, mixed>
Parameters
$requestedCurrency : string
Return values
array<string|int, mixed>

getKeysByOwnerAndIdentifier()

Get all keys by BP and identifier

public getKeysByOwnerAndIdentifier(mixed $getKeysByOwnerAndIdentifierParams) : array<string|int, mixed>|null
Parameters
$getKeysByOwnerAndIdentifierParams : mixed
Return values
array<string|int, mixed>|null

address

getSupportedCurrencies()

Get the currently supported currencies in AkashicPay

public getSupportedCurrencies() : array<string|int, mixed>
Return values
array<string|int, mixed>

with the currency as the keys and a list of networks as the values

getTransactionDetails()

Get details of an individual transaction. Returns null if no transaction found for the queried hash

public getTransactionDetails(string $l2TxHash) : array<string|int, mixed>|null
Parameters
$l2TxHash : string

l2Hash of transaction

Return values
array<string|int, mixed>|null

getTransfers()

Get all or a subset of transactions. Optionally paginated with `page` and `limit`.

public getTransfers(array<string|int, mixed> $getTransactionParams) : array<string|int, mixed>

Optionally parameters: layer, status, startDate, endDate, hideSmallTransactions, identifier, referenceId hideSmallTransactions excludes values below 1 USD

Parameters
$getTransactionParams : array<string|int, mixed>
Return values
array<string|int, mixed>

lookForL2Address()

Check which L2-address an alias or L1-address belongs to. Or call with an L2-address to verify it exists

public lookForL2Address(string $aliasOrL1OrL2Address[, string|null $network = null ]) : array<string|int, mixed>
Parameters
$aliasOrL1OrL2Address : string
$network : string|null = null
Return values
array<string|int, mixed>

onboardBp()

Experimental feature to onboard a new BP from SDK

public onboardBp(string $l2Address, string $privateKey) : array<string|int, mixed>
Parameters
$l2Address : string

L2 address of the BP

$privateKey : string

Private key of the BP

Return values
array<string|int, mixed>

OTK and apiPrivateKey

payout()

Send a crypto-transaction

public payout(string $referenceId, string $to, string $amount, string $network[, string|null $token = null ]) : array<string|int, mixed>|string
Parameters
$referenceId : string

userID or similar identifier to identify the transaction

$to : string

L1 or L2 address of receiver

$amount : string
$network : string

L1-Network the funds belong to, e.g. ETH

$token : string|null = null

Optional. Include if sending token, e.g. USDT

Return values
array<string|int, mixed>|string

$l2Hash|$error L2 Transaction hash of the transaction or error

updateSettings()

Experimental feature to update BP settings from SDK

public updateSettings(string $l2Address, string $privateKey, array<string|int, mixed> $params) : void
Parameters
$l2Address : string

L2 address of the BP

$privateKey : string

Private key of the BP

$params : array<string|int, mixed>

Parameters containing enableManualTransactionCallback, etc.

verifySignature()

Verify HMAC signature against body and secret with sorted keys

public verifySignature(mixed $body, string $signature) : bool
Parameters
$body : mixed
$signature : string
Return values
bool

prepareL2Transaction()

Prepares an L2 transaction by sending transaction data to the Akashic API.

protected prepareL2Transaction(array<string|int, mixed> $transactionData) : array<string|int, mixed>
Parameters
$transactionData : array<string|int, mixed>

The transaction data required for the L2 withdrawal.

Tags
throws
GuzzleException

If the HTTP request fails.

Return values
array<string|int, mixed>

The signed transactionData

becomeBp()

Call AP to become a BP

private becomeBp(array<string|int, mixed> $otk) : void
Parameters
$otk : array<string|int, mixed>

OTK to become a BP with

boolsToString()

private boolsToString(mixed $value) : mixed
Parameters
$value : mixed

chooseBestACNode()

Finds an AkashicChain node to target for requests. The SDK will attempt to find the fastest node for you.

private chooseBestACNode() : array<string|int, mixed>
Tags
Returns

string The URL of an AC node on the network matching your environment (production or development)

Return values
array<string|int, mixed>

generateApiKeyPair()

Generate a new API/SDK key pair for integration

private generateApiKeyPair(array<string|int, mixed> $otk) : array<string|int, mixed>
Parameters
$otk : array<string|int, mixed>

OTK to generate the key pair from

Return values
array<string|int, mixed>

The generated API key pair

get()

private get(string $url) : array<string|int, mixed>|null
Parameters
$url : string
Return values
array<string|int, mixed>|null

getCoinSymbol()

private getCoinSymbol(mixed $key) : mixed
Parameters
$key : mixed

getDepositAddressFunc()

private getDepositAddressFunc(mixed $network, mixed $identifier[, mixed $referenceId = null ][, mixed $token = null ][, mixed $requestedCurrency = null ][, mixed $requestedAmount = null ][, mixed $markupPercentage = null ]) : mixed
Parameters
$network : mixed
$identifier : mixed
$referenceId : mixed = null
$token : mixed = null
$requestedCurrency : mixed = null
$requestedAmount : mixed = null
$markupPercentage : mixed = null

getDepositUrlFunc()

private getDepositUrlFunc(mixed $identifier[, mixed $referenceId = null ][, mixed $receiveCurrencies = null ][, mixed $networks = null ][, mixed $redirectUrl = null ][, mixed $requestedCurrency = null ][, mixed $requestedAmount = null ][, mixed $markupPercentage = null ]) : mixed
Parameters
$identifier : mixed
$referenceId : mixed = null
$receiveCurrencies : mixed = null
$networks : mixed = null
$redirectUrl : mixed = null
$requestedCurrency : mixed = null
$requestedAmount : mixed = null
$markupPercentage : mixed = null

mapMainToTestCurrency()

Map receive currency from mainnet to testnet if in development

private mapMainToTestCurrency(string|null $currency) : string|null
Parameters
$currency : string|null
Return values
string|null

mapUSDTToTether()

Map USDT to TETHER for Tron Shasta network

private mapUSDTToTether(string $coinSymbol, string|null $tokenSymbol) : string|null
Parameters
$coinSymbol : string
$tokenSymbol : string|null
Return values
string|null

post()

private post(string $url, mixed $payload) : array<string|int, mixed>|null
Parameters
$url : string
$payload : mixed
Return values
array<string|int, mixed>|null

retryWithAttempts()

Retry a callback up to $maxAttempts times with $delay microseconds between attempts

private retryWithAttempts(callable $callback[, int $maxAttempts = 3 ][, int $delay = 1000000 ]) : void
Parameters
$callback : callable
$maxAttempts : int = 3
$delay : int = 1000000

(microseconds)

Tags
throws
Exception

setOtkFromKeyPair()

Sets your OTK to sign transactions on AkashicChain (AC)

private setOtkFromKeyPair(string $privateKey, string $l2Address) : void
Parameters
$privateKey : string

private key from Akashic Link.

$l2Address : string

L2-address of your Akashic account

setOtkFromRecoveryPhrase()

Sets your OTK to sign transactions on AkashicChain (AC)

private setOtkFromRecoveryPhrase(string $recoveryPhrase, string $l2Address) : void
Parameters
$recoveryPhrase : string

the recovery phrase generated when you created your Akashic Link account.

$l2Address : string

L2-address of your Akashic account

sign()

private sign(mixed $data[, mixed $otk = null ]) : mixed
Parameters
$data : mixed
$otk : mixed = null

sortKeys()

Recursively sort array keys for consistent JSON serialization

private sortKeys(mixed $obj) : mixed
Parameters
$obj : mixed

        
On this page

Search results