admin

python.ds.com@gmail.com

CCVenue Payment Transactional API integration in PHP CodeIgniter

Posted on February 15, 2021



Production API URL:-https://api.ccavenue.com/apis/servlet/DoWebTrans

Staging API URL:- https://apitest.ccavenue.com/apis/servlet/DoWebTran


public function ccaVenueStatusSuccess()

{

$this->load->library('ccvenuecrypto');

$txnid=$orders['txnid'];

$time=3*60; // 3 minute

if(isset($_REQUEST['time']) && $_REQUEST['time']>0)

$time=$_REQUEST['time'];

sleep($time);

$working_key='XXXX';//Shared by CCAVENUES

$access_code='XXXX';//Shared by CCAVENUES

$merchant_json_data = array('order_no' => $order_id);

// $merchant_json_data = array('txnid' => $txnid);

$merchant_data = json_encode($merchant_json_data);

$encrypted_data = $this->ccvenuecrypto->encrypt($merchant_data, $working_key);

$final_data = 'enc_request='.$encrypted_data.'&access_code='.$access_code.'&command=orderStatusTracker&request_type=JSON&response_type=JSON';

// https://apitest.ccavenue.com/apis/servlet/DoWebTrans

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.ccavenue.com/apis/servlet/DoWebTrans");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER,'Content-Type: application/json') ;

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $final_data);

// Get server response ...

$result = curl_exec($ch);

curl_close($ch);

$status = '';

$information = explode('&', $result);

print_r($information);

$dataSize = sizeof($information);

for ($i = 0; $i < $dataSize; $i++) {

$info_value = explode('=', $information[$i]);

if ($info_value[0] == 'enc_response') {

$status = $this->ccvenuecrypto->decrypt(trim($info_value[1]), $working_key);

}

}

echo 'Status revert is: ' . $status.'<pre>';

$obj = json_decode($status);

print_r($obj);

if($obj->Order_Status_Result->status==0 && $obj->Order_Status_Result->order_status=='Shipped'){

$bank_reponse=$obj->Order_Status_Result->order_bank_response;

$payment_status=2;

if($bank_reponse=='Y' && $order_r_id==$order_id)

{

 // Logic Here

}

}

}


Sign In for comment and like the post.