<?php
chdir('../../');
require_once 'autoload.php';
$gateways = new payment_gateways_controller;

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['csrf_token']) && isset($_POST['csrf_form_id']) && $waf->csrf_validate($_POST['csrf_form_id'], $_POST['csrf_token'], $utility->action_name())) {

$sanitezed_data = $utility->sanitize_request($_POST);

switch ($_POST['gateway_type']) {

case 'lenco':

$gateway_data['secret_key'] = $sanitezed_data['secret_key'];
$gateway_data['public_key'] = $sanitezed_data['public_key'];
$gateway_data['status'] = 1;

$data['details'] = serialize($gateway_data);

$gateways->update($_POST['id'], $data);

$utility->setMessage("success", 'Lenco API updated');

header("location:../settings");

break;

}
}else{

header("location:../settings");

}
?>
