Đổi Thẻ

Method: POST

Url: https://gate24h.com/api/charge

Request

Parameter Type Position # Description
api_key string Body Required Ví dụ : 8e619f2d8f925c88ec4bd130e261ff12. Tìm ở phần mục : https://gate24h.com/user/account
type string Body Required Nhận 1 trong các giá trị : zing, gate, telco .
seri string Body Required Số seri của thẻ. Ví dụ : AD0024174736 .
code string Body Required Mã thẻ. Ví dụ : YX8DTKNKX .

Response

{
    "success": true,
    "result_code": 200,
    "message": "Success!",
    "value": "100.000"
}

NodeJS Sample

var request = require("request");

var options = { method: 'POST',
  url: 'http://127.0.0.1:8000/api/charge',
  headers:
   {'Cache-Control': 'no-cache',
     'Content-Type': 'application/x-www-form-urlencoded' },
  form:
   { api_key: '8e619f2d8f925c88ec4bd130e261ff12',
     type: 'zing',
     seri: 'AD0024174736',
     code: 'YX8DTKNKX' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

PHP Sample

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8000",
  CURLOPT_URL => "http://127.0.0.1:8000/api/charge",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "api_key=8e619f2d8f925c88ec4bd130e261ff12&type=zing&seri=AD0024174736&code=YX8DTKNKX",
  CURLOPT_HTTPHEADER => array(
    "Cache-Control: no-cache",
    "Content-Type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Java Sample

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "api_key=8e619f2d8f925c88ec4bd130e261ff12&type=zing&seri=AD0024174736&code=YX8DTKNKX");
Request request = new Request.Builder()
  .url("http://127.0.0.1:8000/api/charge")
  .post(body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .addHeader("Cache-Control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

Python Sample

import requests

url = "http://127.0.0.1:8000/api/charge"

payload = "api_key=8e619f2d8f925c88ec4bd130e261ff12&type=zing&seri=AD0024174736&code=YX8DTKNKX"
headers = {
    'Content-Type': "application/x-www-form-urlencoded",
    'Cache-Control': "no-cache"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)