Pay NWSC

THis is method is used to complete payment for NWSC(Water Bills)

Request Type

POST

General Payload


  // Sample PHP pay Load

  $live_url = "https://silicon-pay.com/pay_water";
  $test_url = "https://silicon-pay.com/test/pay_water";
  
  $data_req = [
    "area"=>"Customer Area",
    "account_number"=>"Customer Reference/ Account Number/ Meter Number",
    "emailAddress"=>"User Email Address",
    "phone"=> "User Phone Number",
    "encryption_key"=>"Account Encryption Key",
    "amount"=>"Amount to pay",
    "call_back"=> "Success callback URL",
    "tx_ref"=>"Unique Transaction Reference"
];
// Now Generate the signature. 
$secrete_key ="XXXX";
$encryption_key = "XXXXX";
$phone = "XXXX";

$msg	=	hash('sha256',$encryption_key).$phone_number;

$signature	= hash_hmac('sha256',$msg, $secrete_key);
  
$headers  = [
  "signature:". $signature,
  'Content-Type: application/json'
];

$curl = curl_init();

curl_setopt_array($curl, array(
  //Use live url ($live_url) when in production. 
  CURLOPT_URL => $test_url,
  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 =>json_encode( $data_req),
  CURLOPT_HTTPHEADER => $headers,
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;



Test Customer Reference/ Account Number

Customer Reference/Account Number: 2170635

Area: Kampala

Parameter Description

# Parameter Description
1 Area This is got from the query areas endpoint and selected
2 Account Number This is the Customer Reference/ Account Number/ Meter Number
3 emailAddress Email Address of the user
4 phone Phone Number of the user
5 encryption_key Account Encryption Key
6 amount Amount to pay
7 call_back URL where a callback IPN shall be sent
8 tx_ref Unique transaction reference

Success Response

When all the payload parameters are correct


{
"status":200,
"message":"Pay NWSC transaction accepted."
}

Failure Response

When there is an issue with the network or when something is not right, you shall get a failed notification


{
"status":201,
"message":"Pay NWSC transaction failed.",
"description":"XXXXX"
}

CallBack/ IPN Notification

Once the transaction has been succeefully proceessed, An IPN is sent back to your provided call back URL.


{

      'code'=>200,
      'status'=>'success',
      'txRef':"XXXXX",
      'amount':"XXXXX",
      'charge':"XXXXXX",
      'type'=>"NWSC",
      'secure_hash'=>"XXXX"
}

Recieve IPN/Call Back

A secure hash is sent with the call back data. This is to help you confirm that the call back came from us.


// Recieve IPN. 

$body = file_get_contents("php://input");
$dataObject = json_decode($body);

$reference = $dataObject->txRef;
$secure_hash = $dataObject->secure_hash;
$secrete_key ="Enter your account Secrete key"

// Generate a secure hash on your end.
  $cipher = 'aes-256-ecb';
	$generated_hash = openssl_encrypt($reference, $cipher, $secrete_key);
  
  if($generated_hash == $secure_hash){
    // The call back came from us. 
    // Give value to your customers.
  }