Request
Here are examples of how to send a check balance request to the OpenAPI system.
A Sample fetch balance request
curl -X POST \
{base-url}/api/v2/partner/balance
-H 'Content-Type: application/json'
-H 'KEY: API Key'
-H 'TOKEN: token'
-H 'VERSION: 2.0'
-H 'accept: application/json'
-H 'cache-control: no-cache'
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "{base-url}/api/v2/partner/balance"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("accept", "application/json")
req.Header.Add("KEY", "API Key")
req.Header.Add("TOKEN", "token")
req.Header.Add("VERSION", "1.0")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Cache-Control", "no-cache")
req.Header.Add("Host", "dev.openapi.ayopop.id")
req.Header.Add("Accept-Encoding", "gzip, deflate")
req.Header.Add("Content-Length", "")
req.Header.Add("Connection", "keep-alive")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "{base-url}/api/v2/partner/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Accept-Encoding: gzip, deflate",
"Cache-Control: no-cache",
"Connection: keep-alive",
"Content-Length: ",
"Content-Type: application/json",
"KEY: API Key",
"TOKEN: token",
"VERSION: 1.0",
"accept: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
var settings = {
async: true,
crossDomain: true,
url: "{base-url}/api/v2/partner/balance",
method: "POST",
headers: {
accept: "application/json",
KEY: "API Key",
TOKEN: "token",
VERSION: "1.0",
Content-Type: "application/json",
Cache-Control: "no-cache",
Accept-Encoding: "gzip, deflate",
Content-Length: "",
Connection: "keep-alive",
cache-control: "no-cache"
}
};
$.ajax(settings).done(function(response) {
console.log(response);
});
Sample body payload
{
"partnerId": "partner_api_key"
}
The body for the token is defined below
Parameter | Type | Description |
---|---|---|
partnerId | STRING | Partner API key provided |
Response
This API is called to check the current available Balance.
Sample Response for Balance Request
{
"responseCode": 0,
"success": true,
"message": {
"ID": "sukses",
"EN": "success"
},
"data": {
"balance": 5523560,
"currency": "IDR",
"partnerId": "partner_api_key"
}
}
Below are details for each field and the value type.
TOP LEVEL
Parameter | Type | Description |
---|---|---|
responseCode | INT | Status of the balance request. Refer to the Response code section/document for more details |
success | BOOLEAN | Status of balance |
message | JSON | Messages in Bahasa and English describing the RC above. |
data | JSON | The main payload with the balance details. |
DATA OBJECT
Parameter | Type | Description |
---|---|---|
balance | FLOAT | Current available balance. |
currency | STRING | Balance currency format. |
partnerId | STRING | PartnerID associated with this request |