|
|
|
@@ -25,7 +25,8 @@ class Bkotransaction extends Bko_Controller {
|
|
|
|
|
$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 "
|
|
|
|
|
. "'<input type=submit id=\"acc'||m.id||'\" onclick=\"return smoneyProcess('||m.id||')\" name=\"manage\" class=\"btn btn-info btn-sm\" value=\"Process\">' As Process, "
|
|
|
|
|
. "m.initiatingamount AS raw_amount, m.fee AS raw_fee, sr.bank_code, sr.account_no "
|
|
|
|
|
. "FROM money_transfer m "
|
|
|
|
|
. "LEFT JOIN members me ON me.id=m.member_id "
|
|
|
|
|
. "LEFT JOIN sendmoney_recipient sr ON sr.id=m.recipientid "
|
|
|
|
@@ -39,7 +40,7 @@ class Bkotransaction extends Bko_Controller {
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'TRANSDETAIL':
|
|
|
|
|
case 'TRANSDETAIL':
|
|
|
|
|
|
|
|
|
|
$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 "
|
|
|
|
@@ -65,93 +66,155 @@ class Bkotransaction extends Bko_Controller {
|
|
|
|
|
|
|
|
|
|
case 'COMPLETE':
|
|
|
|
|
//echo 'complete 1';
|
|
|
|
|
// url: "/bkotransaction/smprocess?proc=COMPLETE&sendmoney_id="+link_id+'&tcode='+tcode+'&tref='+tref
|
|
|
|
|
// url: "/bkotransaction/smprocess?proc=COMPLETE&sendmoney_id="+link_id+'&tcode='+tcode+'&tref='+tref
|
|
|
|
|
$data["trans_code"] = $this->input->get('tcode');
|
|
|
|
|
$data["trans_tref"] = $this->input->get('tref');
|
|
|
|
|
$data["sendmoney_id"] = $sendmoney_id;
|
|
|
|
|
$data['action'] = WRENCHBOARD_SMONEY_BKOPROC;
|
|
|
|
|
$data['action_mode'] = SMONEY_PROCC_MANUAL;
|
|
|
|
|
$this->load->model('backend_model');
|
|
|
|
|
$out = array();
|
|
|
|
|
$this->backend_model->wrenchboard_api($data, $out);
|
|
|
|
|
echo $out['status'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $this->sendmoneyCompletePage($data);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected function sendmoneyCompletePage($data) {
|
|
|
|
|
$data['action'] = WRENCHBOARD_SMONEY_BKOPROC;
|
|
|
|
|
$data['action_mode'] = SMONEY_PROCC_MANUAL;
|
|
|
|
|
$this->load->model('backend_model');
|
|
|
|
|
$out = array();
|
|
|
|
|
$this->backend_model->wrenchboard_api($data, $out);
|
|
|
|
|
return $out['status'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function smTransmitProcess() {
|
|
|
|
|
// url: "/bkotransaction/smprocess?proc=PROCESS&sendmoney_id="+link_id
|
|
|
|
|
$proc = $this->input->get('proc');
|
|
|
|
|
$sendmoney_id = $this->input->get('sendmoney_id');
|
|
|
|
|
// url: "/bkotransaction/smprocess?proc=PROCESS&sendmoney_id="+link_id
|
|
|
|
|
$proc = $this->input->get('proc');
|
|
|
|
|
$sendmoney_id = $this->input->get('sendmoney_id');
|
|
|
|
|
|
|
|
|
|
switch ($proc) {
|
|
|
|
|
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;
|
|
|
|
|
switch ($proc) {
|
|
|
|
|
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, "
|
|
|
|
|
. "m.initiatingamount AS raw_amount, m.fee AS raw_fee, sr.bank_code, sr.account_no "
|
|
|
|
|
. "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();
|
|
|
|
|
$query = $this->db->query($mysql);
|
|
|
|
|
$row = $query->row_array();
|
|
|
|
|
|
|
|
|
|
echo $this->sendmoneyProcessPage($row);
|
|
|
|
|
echo $this->sendmoneyProcessPage($row);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'DETAIL':
|
|
|
|
|
case 'DETAIL':
|
|
|
|
|
|
|
|
|
|
echo 'detail';
|
|
|
|
|
echo 'detail';
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'TRANSMIT':
|
|
|
|
|
//echo 'complete 1';
|
|
|
|
|
// url: "/bkotransaction/smprocess?proc=COMPLETE&sendmoney_id="+link_id+'&tcode='+tcode+'&tref='+tref
|
|
|
|
|
$data["trans_code"] = $this->input->get('tcode');
|
|
|
|
|
$data["trans_tref"] = $this->input->get('tref');
|
|
|
|
|
$data["sendmoney_id"] = $sendmoney_id;
|
|
|
|
|
$data['action'] = WRENCHBOARD_SMONEY_BKOPROC;
|
|
|
|
|
$data['action_mode'] = SMONEY_PROCC_INTERSWITCH;
|
|
|
|
|
$this->load->model('backend_model');
|
|
|
|
|
$out = array();
|
|
|
|
|
$this->backend_model->wrenchboard_api($data, $out);
|
|
|
|
|
echo $out['status'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'TRANSMIT':
|
|
|
|
|
//echo 'complete 1';
|
|
|
|
|
// url: "/bkotransaction/smprocess?proc=COMPLETE&sendmoney_id="+link_id+'&tcode='+tcode+'&tref='+tref
|
|
|
|
|
$data["trans_code"] = $this->input->get('tcode');
|
|
|
|
|
$data["trans_tref"] = $this->input->get('tref');
|
|
|
|
|
$data["sendmoney_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,
|
|
|
|
|
m.initiatingamount AS raw_amount, m.fee AS raw_fee, sr.bank_code, sr.account_no
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
echo $this->sendmoneyProcessPage($row, $data);
|
|
|
|
|
/*
|
|
|
|
|
$data['action'] = WRENCHBOARD_SMONEY_BKOPROC;
|
|
|
|
|
$data['action_mode'] = SMONEY_PROCC_INTERSWITCH;
|
|
|
|
|
$this->load->model('backend_model');
|
|
|
|
|
$out = array();
|
|
|
|
|
$this->backend_model->wrenchboard_api($data, $out);
|
|
|
|
|
echo $out['status'];
|
|
|
|
|
*/
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function TransmitSendmoneyProcessPage($out) {
|
|
|
|
|
|
|
|
|
|
$myTable = "<form id='sendmoneyProcessPage" . $out['id'] . "' name='sendmoneyProcessPage" . $out['id'] . "'><table class='table table-striped table-hover table-bordered table-condensed'>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Confirmation</b></td><td>" . $out['confirmation'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Trx. Date</b></td><td>" . $out['added'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Sender</b></td><td>" . $out['sender'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Recipient</b></td><td>" . $out['recipient'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Amount</b></td><td>" . $out['amount'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Fee</b></td><td>" . $out['fee'] . "</td></tr>";
|
|
|
|
|
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b></b></td><td></td></tr>";
|
|
|
|
|
$myTable .="</table></form> ";
|
|
|
|
|
$myTable = "<form id='sendmoneyProcessPage" . $out['id'] . "' name='sendmoneyProcessPage" . $out['id'] . "'><table class='table table-striped table-hover table-bordered table-condensed'>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Confirmation</b></td><td>" . $out['confirmation'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Trx. Date</b></td><td>" . $out['added'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Sender</b></td><td>" . $out['sender'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Recipient</b></td><td>" . $out['recipient'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Amount</b></td><td>" . $out['amount'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Fee</b></td><td>" . $out['fee'] . "</td></tr>";
|
|
|
|
|
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b></b></td><td></td></tr>";
|
|
|
|
|
$myTable .="</table></form> ";
|
|
|
|
|
|
|
|
|
|
return $myTable;
|
|
|
|
|
}
|
|
|
|
|
return $myTable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function sendmoneyProcessPage($out) {
|
|
|
|
|
private function sendmoneyProcessPage($out, $page=array()) {
|
|
|
|
|
$data = array(
|
|
|
|
|
"account_bank" => $out['bank_code'],
|
|
|
|
|
"account_number" => $out['account_no'],
|
|
|
|
|
"amount" => $out['raw_amount'],
|
|
|
|
|
"narration" => $out['sender'],
|
|
|
|
|
"currency" => "NGN",
|
|
|
|
|
"reference" => $out['id'],
|
|
|
|
|
"debit_currency" => "NGN"
|
|
|
|
|
);
|
|
|
|
|
$url = "http://localhost:3000/create";
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
curl_setopt($ch,CURLOPT_URL, $url);
|
|
|
|
|
curl_setopt($ch,CURLOPT_POST, count($data));
|
|
|
|
|
curl_setopt($ch,CURLOPT_POSTFIELDS, json_encode($data));
|
|
|
|
|
curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
|
|
|
|
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
|
|
|
|
|
$result = curl_exec($ch);
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
|
|
$myTable = "<form id='sendmoneyProcessPage" . $out['id'] . "' name='sendmoneyProcessPage" . $out['id'] . "'><table class='table table-striped table-hover table-bordered table-condensed'>";
|
|
|
|
|
$data = json_decode($result, true);
|
|
|
|
|
// Error
|
|
|
|
|
// {"status":"failure","message":"Invalid response","details":"Request failed with status code 400","code":400,"data":{"status":"error","code":"UNAUTHORIZED_ACCESS","message":"Unauthorized access. Compliance approval required to use this feature"}}
|
|
|
|
|
// Success
|
|
|
|
|
// ???
|
|
|
|
|
$page["message"] = "";
|
|
|
|
|
if ($data == null || $data == "" || (array_key_exists("status",$data) && $data["status"]=="failure")) {
|
|
|
|
|
if ($data == null || $data == "") {
|
|
|
|
|
// Invalid response, not clear what is going on (non-JSON response from the payment API)
|
|
|
|
|
$page["message"] = "Invalid payment API respose: ".htmlentities($result);
|
|
|
|
|
} else if (array_key_exists("data",$data) && array_key_exists("message",$data["data"])) {
|
|
|
|
|
// Payment processor message
|
|
|
|
|
$page["message"] = $data["data"]["message"];
|
|
|
|
|
} else if (array_key_exists("message",$data)) {
|
|
|
|
|
// Payment API message
|
|
|
|
|
$page["message"] = $data["message"];
|
|
|
|
|
} else {
|
|
|
|
|
// Not clear what is going on (failure with no messages?)
|
|
|
|
|
$page["message"] = "Invalid payment API respose: ".htmlentities($result);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: success
|
|
|
|
|
}
|
|
|
|
|
// $page['confirmation']
|
|
|
|
|
// $page['trans_code']
|
|
|
|
|
// $data['trans_tref']
|
|
|
|
|
|
|
|
|
|
$myTable = "<form id='sendmoneyProcessPage" . $out['id'] . "' name='sendmoneyProcessPage" . $out['id'] . "'>";
|
|
|
|
|
$myTable .="<span style='font-weight:bold;color:red'>".$page["message"]."</span>";
|
|
|
|
|
$myTable .="<table class='table table-striped table-hover table-bordered table-condensed'>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Confirmation</b></td><td>" . $out['confirmation'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Trx. Date</b></td><td>" . $out['added'] . "</td></tr>";
|
|
|
|
|
$myTable .="<tr><td style='width:100px;'><b>Sender</b></td><td>" . $out['sender'] . "</td></tr>";
|
|
|
|
|