Skip to main content

Chargily Pay API

Here is how you can work with our API.

1. Make payment

  • Request method POST url

  • Request Headers : X-Authorization : API_KEY , Accept : application/json

  • Request Parameters :

client Your client namerequired ; string ; min:3
client_email Your client emailrequired ; email
invoice_number Order number will be used to check payment responserequired ;
amount Order total amount must be greater than or equal 75required ; numeric ; min:75
discount Discount percentagerequired ; numeric ; min:0 ; max:99.99
back_url This url you will be redirected to after the payment is done, and must be active URLrequired ; string ; url
webhook_urlThis is the source url wich you will get information of payment responcerequired ; string ; url
mode This is the payment method "EDAHABIA" or "CIB"required ; in:EDAHABIA / CIB
comment Description for the payment raisonrequired ; string
  • Responses :

    • 201 : payment created successffully

      Response as 'json' : 'checkout_url'

      Example: {"checkout_url"=>""}
    • 401 : Unauthorized

      Invalid API_KEY
    • 422 : invalid parametters

      The request was well-formed but was unable to be followed due to semantic errors

if the creation of invoice successed make redirection to checkout_url

2. Payment confirmation

We will send you operation responce via already sent "webhook_url".

  • Method POST

  • Headers :

  • Body :

      invoice with payment status
  • Signature Validation :

      Incoming webhook request has a header that can be used to verify the payload
    The name of the header containing the signature can be configured in the 'Signature' header key to validate signatures
  • This is an example how you will compute the signature in PHP

    //Secret key can be found in your profile information
$secret = "API_SECRET";
//get incoming webhook request body content
$body_content = file_get_contents("php://input");
$computed_signature = hash_hmac('sha256', $body_content,$secret);
//get signature from header
$signature = getallheaders()["Signature"];
//check computed signature
$validated = hash_equals($computed_signature, $signature);// : bool

$payment = json_decode($body_content,true);
//@Todo: check invoice status first ($payment["invoice"]["status"] === 'paid')
if($payment["invoice"]["status"] === 'paid'){
//@Todo: confirm order
}elseif($payment["invoice"]["status"] === 'failed'){
//@Todo: do anything when payment failed