GET API

For Developers

Kepaid Payment API version 1.0

Implementing Kepaid Payment API is simple. The below documentation will give you full understanding on how to implement the Payment API on your platform.

Requirement:

To be eligible to use Kepaid Payment API you must have completed the above requirement. After you done registering for a Business Account and an API, you should have a KEPAID_NUMBER, TOKEN and an ACCESS_KEY Create a config.php file in your root directory and add the below code



// Config File
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache"); //HTTP 1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 

//KEPAID MERCHANT INFO
$kepaid_number = "";  //YOUR KEPAID NUMBER
$website = $_SERVER['HTTP_HOST'];
$token = "";      //YOUR KEPAID TOKEN
$access_key = "";     //ACCESS KEY

// PAYMENT DETAILS
$description = "$_POST[description]";    //PRODUCT NAME;
$amount = "$_POST[cost]";    //TOTAL COST OF PRODUCT
$currency = "$_POST[currency]";    //CURRENCY OF PRODUCT IN CAP

$data->access_key = $access_key;
$data->token = $token;
$data->description = $description;
$data->amount = $amount;
$data->currency = $currency;
$data->website = $website;
$dataout = json_encode($data);
echo $dataout;


Add the following javascript to your website either in global scope or in the checkout page.


    
$(document).ready(function(){
    $(".kepaid_buy_now").click(function(){
        var cost = $(this).data("cost");
        var description = $(this).data("description");
        var currency = $(this).data("currency");
        
        $.ajax({
    url: "", //Link to your config file
    type: "post",
    data: {cost:cost, description:description, currency:currency},
    success: function(data){
            var response = JSON.parse(data);
            if(response.token){

$("iframe").attr("src", "https://www.kepaid.com/payment/?token="+response.token+
"&access_key="+response.access_key+"&description="+response.description+"&website="+response.website+
"&amount="+response.amount+"¤cy="+response.currency+"");
$("iframe").css({
    display: "block",
    border: "none",
    height: "100vh",
    width: "100vw"
}) 
         }
        
    }
})
    })
    
				
})

if (window.addEventListener) {
	window.addEventListener("message", handleMessage);
} else {
	window.attachEvent("onmessage", handleMessage);
}

function handleMessage(event) {
	console.log("Received a message from " + event.origin + ".");

	// When one window sends a message, or data, to another window via
	// `parent.postMessage()`, the message (the first argument) in the
	// `parent.postMessage()` call is accessible via `event.data` here.
	var messageFromSender = event.data;
	
	// Do something with the response.
	
	//If the payment was successfully 
           If(messageFromSender .message==”success”){
     
     //Hide iframe
	$("iframe").css({
	    display: "none"
	})
	
	//Do something example: product reciept
	
   }else if(messageFromSender .message==”insufficient fund”){
	
	$("iframe").css({
	    display: "none"
	})
	// Do something on payment error
}else{
// Do something.
}
	
}

Make sure to include the following attributes and their required values on your payment button:

data-cost="value should be cost of  product",  data-description="names of products being purchase",  data-currency="currency of product being purchase"

Add this class to your payment button

class="kepaid_buy_now"

Add this iframe in your checkout page, make sure to remove at the beginning and closing of iframe. It will be used to display KePaid Payment interface


< iframe style='display: none'>< /iframe>

For assistance on implementing Kepaid API email us at support@kepaid.com