From 1da40abc03aef463c8425205ec1193151163f4da Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 8 Jul 2024 13:36:59 -0400 Subject: [PATCH] New send money --- www-api/app/Config/Routes.php | 4 ++- www-api/app/Controllers/WrenchWallet.php | 46 +++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index 943afb14..fb3b41f9 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -167,7 +167,9 @@ $routes->post('/en/wrench/api/v1/accounttypes', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/getjob', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/mybanklist', 'WrenchApi::apigate'); -$routes->post('/en/wrench/api/v1/sendmoney', 'WrenchApi::apigate'); + +$routes->post('/en/wrench/api/v1/sendmoney', 'WrenchWallet::sendMoney');//'WrenchApi::apigate' + $routes->post('/en/wrench/api/v1/sendinterest', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/waitinginterest', 'WrenchApi::apigate'); diff --git a/www-api/app/Controllers/WrenchWallet.php b/www-api/app/Controllers/WrenchWallet.php index abd90fee..d89111c1 100644 --- a/www-api/app/Controllers/WrenchWallet.php +++ b/www-api/app/Controllers/WrenchWallet.php @@ -2,15 +2,59 @@ namespace App\Controllers; +use CodeIgniter\API\ResponseTrait; + class WrenchWallet extends BaseController { - + use ResponseTrait; public function __construct() { log_message('critical', "WrenchWallet Path GATE 001"); $this->request = $request = \Config\Services::request(); } + + + public function sendMoney(){ + + $raw_json = file_get_contents('php://input'); + $in = json_decode($raw_json, true); + + $in["action"] = WRENCHBOARD_USER_SENDMONEY; + $out["internal_return"] = 0; + $in["InitiatingChannel"] = 7; + $in["InitiatingPaymentMethodCode"] = "CA"; + $in["InitiatingCurrencyCode"] = '566'; // 566 - NRN - Naira + $in["InitiatingEntityCode"] = "MBA"; + $in["transaction_id"] = "T" . rand(120000, 999999); + $in["TerminatingPaymentMethodCode"] = "AC"; + $in["TerminatingCurrencyCode"] = '566'; // 566 - NRN - Naira + $in["TerminatingCountryCode"] = 'NG'; // NG - Nigeria + $in["bankid"] = $in["recipientid"]; + $in["InitiatingAmount"] = $in["amount"]; + $in["TerminatingAmount"] = $in["amount"]; + + $out=[]; + + $ret = $this->wrenchboard->wrenchboard_api($in, $out); + $out['internal_return'] = $ret; + log_message('critical', "***** ***** WrenchWallet::sendMoney Ret = ".$ret ); + if ( isset($out['internal_return']) && isset( $out['confirmation']) ){ + $endpoint = "SENDMONEY_".$in["assign_mode"]."-". $out["confirmation"]; + log_message('critical', "***** ***** WrenchWallet::sendMoney SENDMONEY_ = ".$endpoint ); + $this->saveCache($endpoint,$out,25000); + $local_url = "http://".$this->micro_service_net1.":3037/eventSendMoney"; + $outX = $this->APIcall('POST', $local_url, ["message"=>$out]); + + }else + { + $fail_endpoint = "SENDMONEY_FAIL_".strtoupper( date("FDYjGis") ); + log_message('critical', "***** ***** WrenchWallet::sendMoney FAIL_OFFER = ".$fail_endpoint ); + $this->saveCache($fail_endpoint,$in,25000); + } + return $this->respond( $this->summaryReturnData($in,$out), 200); + } + public function index() { return [];