Get account balance
You can use the API to check your account balance.
Request
<?php
define("API_KEY", "YOUR API KEY");
$opts = array(
'http' => array(
'method' => 'GET',
'header' => 'Content-type: application/x-www-form-urlencoded'
)
);
$context = stream_context_create($opts);
$result = file_get_contents("https://api-us1.stannp.com/v1/accounts/balance?api_key=" . API_KEY, false, $context);
$response = json_decode($result, true);
print_r($response);
?>
Response
{ "success": true, "data": { "balance": "214.42" } }
Top up balance
You can use the API to top up your balance if you have a saved card and set one to default.
Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-us1.stannp.com/v1/accounts/topup?api_key={API_KEY}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'net' => "100.00"
),
));
$response = curl_exec($curl);
curl_close($curl);
print_r($response);
?>
Response
{ "success": true, "data": { "receipt_pdf": "https:\/\/www.stannp.com\/invoice\/12345--abcdefg-uhusdsfsi34545-fgfdfdb.pdf" } }