Collections

Mobile Money collections

This section demostrates how you can use Silicon Pay to collect funds in different currencies to different wallets from your clients. You can either use the API or the silicon pay Modal

Using the Silicon Pay API

Collect payment using the silicon pay API

General Payload


  // Sample PHP pay Load
  $data_req = [
    "req"=>"mobile_money",
    "currency"=>"XXXXXX",
    "phone"=>"MSISDN",
    "encryption_key"=>"XXXXXX",
    "amount"=>"XXXX",
    "emailAddress"=>"test@gmail.com",
    'call_back'=>"your-call-back-url",
    "txRef"=> "XXXXXX"
];
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://silicon-pay.com/process_payments',
  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 => array(
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;  

Using the Silicon Pay Modal

You can use the silicon pay modal to integrate payments into your application with limited coding.

In your silicon Pay dashboard, click on collect payments then payment links. Copy the generate payment link and use this link to collect payments.

Incase you are interested in getting IPN call backs when using the pay modal, You need to pass additional parameters to your payment link.


$txRef = "Unique transaction reference";
$redirect_url = "Your Successfull payment redirect URL";
$call_back_url = "IPN/webhook notification URL";
$amount = "Amount to pay";

$paymentModalUrl = 'payment url generated from your dashboard';

// Appends these parameter as GET parameters in your payment Link URL. 
// Sample payload. 
$parameters = 'amount='.$amount.'& currency='.$currency.'&txRef='.$txRef.'&call_back_url='.$call_back_url.'&redirect_url='.$redirect_url;
 
// Payment Modal URL. 
//Append the parameters as "Get" parameters on the payment modal URL. 
// Load the url in the browser to make the payment. 

$FinalLink = $paymentModalUrl?.$parameters

// You are required to load the final link in the browser to complete the payment. 



UGX Collection

For UGX collections, Pass currency as UGX


  "currency"=>"UGX"

TZS Collection

For TZS collections, Pass currency as TZS


  "currency"=>"TZS"

KES Collection

For KES collections, Pass currency as KES


  "currency"=>"KES"

ZMW Collection

For ZMW collections, Pass currency as ZMW


  "currency"=>"ZMW"

RWF Collection

For RWF collections, Pass currency as RWF


  "currency"=>"RWF"

NGN Collection

For NGNcollections, Pass currency as NGN


  "currency"=>"NGN"

XOF Collection

For XOF collections, Pass currency as XOF


  "currency"=>"XOF"

XAF Collection

For XAF collections, Pass currency as XAF


  "currency"=>"XAF"

Parameter Description

# Parameter Description
1 encryption_key Your-Account-Encryption-key". Found on top of your dashboard
2 Amount Amount you are charging the user
3 emailAddress Email Address of the person paying
4 phone MSISDN Phone number of the paying customer.
5 txRef Unique Transaction Reference
6 call_back Call Back url where we shall push a success notification
7 currency This is the currency in which you are charging the customer

Response

When all the payload parameters are correct, We shall a push notification to the MSIDN number provided. Below is the sample response code


{
  "status":"Successful",
  "message":"A push Notification has been sent to the Customer",
  "txRef":1234589
}

Success Call Back Notification.

Sample response that shall be triggered and sent to the call back url when the trasanction is successful



{
  "status":"successful",
  "amount":"xxxxx",
  "txRef":"XXXX",
  "nework_ref":"XXXXX",
  "msisdn":"XXXXX",
  "secure_hash":"XXXXX"
}

Failure Call Back Notification.

Sample response that shall be triggered and sent to the call back url when the trasanction has Failed



{
  "status":"failed",
  "amount":"xxxxx",
  'reason': "reason for failure",
  "txRef":"XXXX",
  "nework_ref":"XXXXX",
  "msisdn":"XXXXX",
  "secure_hash":"XXXXX"
}

Process 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.
  }

Check Transaction Status.

It is good practice to check the transaction status on our end before giving value to your cuatomers.


// Sample Pay Load
$payload = ["encryption_key"=>"XXXXX"];

//parameters
$transaction_reference =  "XXXXX";


$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://silicon-pay.com/transaction_status/'.$transaction_reference,
  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($payload),
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Sample Check Transaction status Response

Sample response for a successful check transaction status



{"code":200,"status":"SUCCESSFUL","amount":"5000","currency":"UGX"}

Plugins and SDK

Wordpress Plugin




Woo-commerce Plugin