Credits

Modified on Fri, 28 Oct 2022 at 01:21 PM

What is Credit Deduction?

If you have a credits management system on your website and want your users to buy credits to use AtomChat's features, you can use our Credit Deduction feature! 

We basically deduct credits when your users use a particular feature. If a user runs out of credits, then they will no longer be able to use that feature (until they add more credits). 

This feature is ideal when you would like to charge for using certain features. Credit Deduction can be configured for text chat, audio calling and audio+video calling. 

The Credits APIs will facilitate you to check credits, deduct credits and update credits.

PLEASE NOTE
You have to have your own Credits management system on your website from where users can buy credits. 


Let's dive in!

Update Credits

POST - https://api.cometondemand.net/api/v2/updateCredits

POST
curl --request POST \
  --url https://api.cometondemand.net/api/v2/updateCredits \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/updateCredits",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "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;
}
PHP
Copy

Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
The Unique User ID

optional
Integer
The number of credits

optional
Boolean
If set to true, it will remove existing credits before updating

Get Credits

GET - https://api.cometondemand.net/api/v2/getCredits

GET
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getCredits \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getCredits",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "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;
}
PHP
Copy


Get Deduction History

GET - https://api.cometondemand.net/api/v2/getCreditDeductionHistory

GE
curl --request POST \
  --url https://api.cometondemand.net/api/v2/getCreditDeductionHistory \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/x-www-form-urlencoded'
TypeScript
Copy
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.cometondemand.net/api/v2/getCreditDeductionHistory",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Accept: application/json",
    "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;
}
PHP
Copy

Header Parameters
optional
String
Your API Key

Form Parameters
optional
String
The Unique User ID

optional
String
Page offset

optional
String
The maximum number of results

optional
String
Values can be: video, voice, text. If empty, it will return all results.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article