Flutterwave calling from back office
This commit is contained in:
@@ -92,16 +92,17 @@ class Bkotransaction extends Bko_Controller {
|
|||||||
|
|
||||||
switch ($proc) {
|
switch ($proc) {
|
||||||
case 'PROCESS':
|
case 'PROCESS':
|
||||||
$mysql = "SELECT m.id,mp.confirmation, m.added,me.firstname||' '||me.lastname||'<br>'||me.email AS Sender,"
|
|
||||||
. "sr.firstname||' '||sr.lastname||'<br>ACC:'||sr.account_no||'-'||be.name AS recipient, m.initiatingamount*0.01 AS Amount,m.fee*0.01 AS Fee, "
|
|
||||||
. "'<input type=submit id=\"accs'||m.id||'\" onclick=\"return smoneyDetail('||m.id||')\" name=\"manage\" class=\"btn btn-info btn-sm\" value=\"Detail\">' As Detail, "
|
|
||||||
. "'<input type=submit id=\"acc'||m.id||'\" onclick=\"return smoneyProcess('||m.id||')\" name=\"manage\" class=\"btn btn-info btn-sm\" value=\"Process\">' As Process "
|
|
||||||
. "FROM money_transfer m "
|
|
||||||
. "LEFT JOIN members me ON me.id=m.member_id "
|
|
||||||
. "LEFT JOIN sendmoney_recipient sr ON sr.id=m.recipientid "
|
|
||||||
. "LEFT JOIN members_payments mp ON mp.what_sendmoney = m.id "
|
|
||||||
. "LEFT JOIN bank_entity_codes be ON be.code=sr.bank_code WHERE m.id=" . $sendmoney_id;
|
|
||||||
|
|
||||||
|
$mysql = "SELECT m.id,mp.confirmation, m.added,me.firstname||' '||me.lastname||'<br>'||me.email AS Sender,"
|
||||||
|
. "sr.firstname||' '||sr.lastname||'<br>ACC:'||sr.account_no||'-'||be.name AS recipient, m.initiatingamount*0.01 AS Amount,m.fee*0.01 AS Fee, "
|
||||||
|
. "'<input type=submit id=\"accs'||m.id||'\" onclick=\"return smoneyDetail('||m.id||')\" name=\"manage\" class=\"btn btn-info btn-sm\" value=\"Detail\">' As Detail, "
|
||||||
|
. "'<input type=submit id=\"acc'||m.id||'\" onclick=\"return smoneyProcess('||m.id||')\" name=\"manage\" class=\"btn btn-info btn-sm\" value=\"Process\">' As Process "
|
||||||
|
. "FROM money_transfer m "
|
||||||
|
. "LEFT JOIN members me ON me.id=m.member_id "
|
||||||
|
. "LEFT JOIN sendmoney_recipient sr ON sr.id=m.recipientid "
|
||||||
|
. "LEFT JOIN members_payments mp ON mp.what_sendmoney = m.id "
|
||||||
|
. "LEFT JOIN bank_entity_codes be ON be.code=sr.bank_code WHERE m.id=" . $sendmoney_id;
|
||||||
|
|
||||||
$query = $this->db->query($mysql);
|
$query = $this->db->query($mysql);
|
||||||
$row = $query->row_array();
|
$row = $query->row_array();
|
||||||
|
|
||||||
@@ -116,23 +117,39 @@ class Bkotransaction extends Bko_Controller {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'TRANSMIT':
|
case 'TRANSMIT':
|
||||||
/*
|
$mysql = "SELECT m.id,mp.confirmation, m.added,"
|
||||||
|
. "'Transfer from '||me.firstname||' '||me.lastname||'<br>'||me.email AS narration,"
|
||||||
|
. "sr.firstname,sr.lastname,sr.account_no,be.code AS bank_code, m.initiatingamount*0.01 AS Amount,m.fee*0.01 AS Fee "
|
||||||
|
. "FROM money_transfer m "
|
||||||
|
. "LEFT JOIN members me ON me.id=m.member_id "
|
||||||
|
. "LEFT JOIN sendmoney_recipient sr ON sr.id=m.recipientid "
|
||||||
|
. "LEFT JOIN members_payments mp ON mp.what_sendmoney = m.id "
|
||||||
|
. "LEFT JOIN bank_entity_codes be ON be.code=sr.bank_code WHERE m.id=" . $sendmoney_id;
|
||||||
|
|
||||||
|
$query = $this->db->query($mysql);
|
||||||
|
$row = $query->row_array();
|
||||||
|
/*
|
||||||
This is te place to call the Fluuerwve API for testing
|
This is te place to call the Fluuerwve API for testing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
$data["trans_code"] = $this->input->get('tcode');
|
$this->load->helper('FlutterWave');
|
||||||
$data["trans_tref"] = $this->input->get('tref');
|
$out = flutterwave_api($row);
|
||||||
$data["sendmoney_id"] = $sendmoney_id;
|
if (is_array($out) && $out['result'] > 0) {
|
||||||
$data['action'] = WRENCHBOARD_SMONEY_BKOPROC;
|
$data["trans_code"] = $this->input->get('tcode');
|
||||||
$data['action_mode'] = SMONEY_PROCC_INTERSWITCH;
|
$data["trans_tref"] = $this->input->get('tref');
|
||||||
$this->load->model('backend_model');
|
$data["sendmoney_id"] = $sendmoney_id;
|
||||||
$out = array();
|
$data['action'] = WRENCHBOARD_SMONEY_BKOPROC;
|
||||||
$this->backend_model->wrenchboard_api($data, $out); //THis calls he backend - dont worry about it for now.
|
$data['action_mode'] = SMONEY_PROCC_INTERSWITCH;
|
||||||
echo $out['status'];
|
$this->load->model('backend_model');
|
||||||
|
$out = array();
|
||||||
|
$this->backend_model->wrenchboard_api($data, $out); //THis calls he backend - dont worry about it for now.
|
||||||
|
echo $out['status'];
|
||||||
|
} else {
|
||||||
|
if (is_array($out) && array_key_exists('status',$out)) {
|
||||||
|
echo $out['status'];
|
||||||
|
} else {
|
||||||
|
var_dump($out); // Unexpected failure
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
|
||||||
|
if ( ! function_exists('flutterwave_api'))
|
||||||
|
{
|
||||||
|
function flutterwave_api($in)
|
||||||
|
{
|
||||||
|
$out = array();
|
||||||
|
$out['status'] = 'Unhandled error';
|
||||||
|
$out['result'] = -1;
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
/* Example :
|
||||||
|
OrderedMap {
|
||||||
|
"account_bank": "044",
|
||||||
|
"account_number": "0690000040",
|
||||||
|
"amount": 5500,
|
||||||
|
"narration": "Akhlm Pstmn Trnsfr xx007",
|
||||||
|
"currency": "NGN",
|
||||||
|
"reference": "akhlm-pstmnpyt-rfxx007_PMCKDU_1",
|
||||||
|
"debit_currency": "NGN"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$reference = str_replace('.','-',$in['id'].'.'.microtime());
|
||||||
|
$out['my_reference'] = $reference;
|
||||||
|
|
||||||
|
// Setup request to send json via POST.
|
||||||
|
$payload = json_encode(array(
|
||||||
|
"account_bank" => $in['bank_code'],
|
||||||
|
"account_number" => $in['account_no'],
|
||||||
|
"amount" => $in['amount'],
|
||||||
|
"narration" => $in['narration'],
|
||||||
|
"currency" => "NGN",
|
||||||
|
"reference" => $reference,
|
||||||
|
"debit_currency" => "NGN"
|
||||||
|
));
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL,"http://10.20.30.32:9086/create");
|
||||||
|
// curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
||||||
|
|
||||||
|
// Receive server response ...
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
$result = curl_exec($ch);
|
||||||
|
|
||||||
|
curl_close ($ch);
|
||||||
|
|
||||||
|
$data = json_decode($result, true);
|
||||||
|
|
||||||
|
// Further processing ...
|
||||||
|
if ($data!=null && is_array($data)) {
|
||||||
|
if (array_key_exists('status',$data) && $data['status']=='success') {
|
||||||
|
$out['result'] = 0; // OK
|
||||||
|
$out['status'] = 'Transfer successful';
|
||||||
|
if (array_key_exists('message',$data) && $data['message']!='') {
|
||||||
|
$out['status'].= ': '.$data['message'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$out['result'] = -3;
|
||||||
|
$out['status'] = 'failure';
|
||||||
|
if (array_key_exists('status',$data) && $data['status']!='') {
|
||||||
|
$out['status'] = $data['status'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('message',$data) && $data['message']!='') {
|
||||||
|
$out['status'].= ': '.$data['message'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('details',$data) && $data['details']!='') {
|
||||||
|
$out['status'].= ': '.$data['details'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('data',$data) && is_array($data['data'])
|
||||||
|
&& array_key_exists('message',$data['data']) && $data['data']['message']!='') {
|
||||||
|
$out['status'].= ': '.$data['data']['message'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('data',$data) && is_array($data['data'])
|
||||||
|
&& array_key_exists('data',$data['data']) && is_array($data['data']['data'])
|
||||||
|
&& array_key_exists('complete_message',$data['data']['data']) && $data['data']['data']['complete_message']!='') {
|
||||||
|
$out['status'].= ': '.$data['data']['data']['complete_message'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$out['result'] = -2;
|
||||||
|
$out['stauts'] = 'Invalid service response: ' . $result;
|
||||||
|
}
|
||||||
|
// Cannot POST /api/create
|
||||||
|
|
||||||
|
$out['response'] = $result;
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,15 +106,15 @@ return false;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function smoneyProcessComplete(link_id) {
|
function smoneyProcessComplete(link_id) {
|
||||||
|
|
||||||
if(confirm("Are you sure you want to transmit this transaction ?")) {
|
if(confirm("Are you sure you want to transmit this transaction ?")) {
|
||||||
// do something
|
// do something
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var f = document.getElementById('sendmoneyProcessPage'+link_id);
|
var f = document.getElementById('sendmoneyProcessPage'+link_id);
|
||||||
|
|
||||||
$('#btump'+link_id).html('Processing...');
|
$('#btump'+link_id).html('Processing...');
|
||||||
$('#acmp'+link_id).prop('disabled', true);
|
$('#acmp'+link_id).prop('disabled', true);
|
||||||
|
|||||||
Reference in New Issue
Block a user