138 lines
4.4 KiB
PHP
138 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class WrenchHooks extends BaseController
|
|
{
|
|
|
|
// protected $db;
|
|
// public $con_name = 'wrench_blog';
|
|
// use ResponseTrait;
|
|
// protected $request;
|
|
public function __construct()
|
|
{
|
|
// $this->request = $request = \Config\Services::request();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$envID = getenv('ENV_ID');
|
|
}
|
|
|
|
|
|
public function stripes(){
|
|
|
|
log_message('critical', "WrenchHooks stripes");
|
|
|
|
}
|
|
public function flutter(){
|
|
|
|
$raw_json = file_get_contents('php://input');
|
|
$raw_array = json_decode($raw_json, true);
|
|
$in = $raw_array;
|
|
//7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5
|
|
log_message('critical', "WrenchHooks flutter");
|
|
log_message('critical', "WrenchHooks ***************************** flutter");
|
|
log_message('critical', "WrenchHooks-CALL PREPARE DATA".serialize($in) );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["event.type"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["status"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["txRef"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["flwRef"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["orderRef"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["amount"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["appfee"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["customer"]["id"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["customer"]["AccountId"] );
|
|
log_message('critical', "WrenchHooks-CALL ********** RETURN *************** DATA".$in["customer"]["fullName"] );
|
|
|
|
$data = [
|
|
"event_type" => $in["event.type"],
|
|
"status" => $in["status"],
|
|
"txRef" => $in["txRef"],
|
|
"flwRef" => $in["orderRef"],
|
|
"orderRef" => $in["orderRef"] ,
|
|
"amount" => $in["amount"]*100 ,
|
|
"appfee" => $in["appfee"]*100,
|
|
"customer_id" => $in["customer"]["id"],
|
|
"AccountId" => $in["customer"]["AccountId"],
|
|
"fullName" => $in["customer"]["fullName"],
|
|
"action" => WRECNH_CREDIT_HOOKS_FULUTTER,
|
|
"raw_result" => serialize($in),
|
|
|
|
];
|
|
|
|
|
|
if ( $data["action"] !='' ){
|
|
$wrenchboard = new \App\Models\BackendModel();
|
|
$ret = $wrenchboard->wrenchboard_api($data, $out);
|
|
$out['internal_return'] = $ret;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
CREATE TABLE flutterwave_hooks (
|
|
id SERIAL,
|
|
uid uuid DEFAULT uuid_generate_v4(),
|
|
event_type VARCHAR(25),
|
|
status VARCHAR(25),
|
|
txRef VARCHAR(50),
|
|
flwRef VARCHAR(50),
|
|
orderRef VARCHAR(50),
|
|
amount INT DEFAULT 0,
|
|
appfee INT DEFAULT 0,
|
|
customer_id VARCHAR(25),
|
|
AccountId VARCHAR(25),
|
|
fullName VARCHAR(50),
|
|
raw_result TEXT,
|
|
process_status INT DEFAULT 1,
|
|
added timestamp without time zone DEFAULT now(),
|
|
updated timestamp without time zone DEFAULT now()
|
|
);
|
|
ALTER TABLE ONLY flutterwave_hooks
|
|
ADD CONSTRAINT flutterwave_hooks_id_key UNIQUE (id);
|
|
|
|
|
|
*{
|
|
s:2:"id";i:4490321;
|
|
s:5:"txRef";s:13:"1690507667625";
|
|
s:6:"flwRef";s:41:"FLW-MOCK-8705ee76a3efc2ae124c783f79f8e681";
|
|
s:8:"orderRef";s:25:"URF_1690507780219_8700835";
|
|
s:11:"paymentPlan";N;
|
|
s:11:"paymentPage";N;
|
|
s:9:"createdAt";s:24:"2023-07-28T01:29:40.000Z";
|
|
s:6:"amount";i:555;
|
|
s:14:"charged_amount";i:555;
|
|
s:6:"status";s:10:"successful";
|
|
s:2:"IP";s:12:"54.75.161.64";
|
|
s:8:"currency";s:3:"NGN";
|
|
s:6:"appfee";d:7.77;
|
|
s:11:"merchantfee";i:0;
|
|
s:16:"merchantbearsfee";i:1;
|
|
s:8:"customer";a:9:
|
|
{
|
|
s:2:"id";i:2158727;
|
|
s:5:"phone";N;
|
|
s:8:"fullName";s:15:"Last11 Olusesan";
|
|
s:13:"customertoken";N;
|
|
s:5:"email";s:20:"ses66181+1@gmail.com";
|
|
s:9:"createdAt";s:24:"2023-07-28T01:29:40.000Z";
|
|
s:9:"updatedAt";s:24:"2023-07-28T01:29:40.000Z";
|
|
s:9:"deletedAt";N;
|
|
s:9:"AccountId";i:1017511;
|
|
}
|
|
s:6:"entity";a:4:
|
|
{
|
|
s:5:"card6";s:6:"553188";
|
|
s:10:"card_last4";s:4:"2950";
|
|
s:16:"card_country_iso";s:2:"NG";
|
|
s:9:"createdAt";s:24:"2020-04-24T15:19:22.000Z";
|
|
}
|
|
s:10:"event.type"; s:16:"CARD_TRANSACTION";
|
|
}
|
|
*/
|