Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 63 additions & 67 deletions app/Classes/MP2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,68 @@

namespace App\Classes;


use Livepixel\MercadoPago\Facades\MP;

class MP2
{
public static $saving = false;
public static $mocking = false;
public static $responses = [];


public static function fileMock($request, $fileName)
{
$path = app_path('Mock/mp/') . $fileName;
$file = fopen($path, 'r');

$content = fread($file, filesize($path));

fclose($file);

static::mock($request, json_decode($content));
}

public static function saveResponse($name, $response)
{
if (static::$saving === true) {
$path = app_path('Mock/' . str_replace('/', '-', $name));

$file = fopen($path, 'w');
fwrite($file, json_encode($response));
fclose($file);
}

return $response;
}

public static function create_preference($preference)
{
if (static::$mocking === true) {
return static::mock('create_preference');
}

return static::saveResponse('create_preference', \MP::create_preference($preference));
}

public static function get_payment($paymentId)
{
if (static::$mocking === true) {
return static::mock('get_payment');
}

return static::saveResponse('get_payment', \MP::get_payment($paymentId));
}

public static function get($type, $url)
{
if (static::$mocking === true) {
return static::mock('get' . $type);
}

return static::saveResponse('get' . '/' . $type . '/' . $url, \MP::get('/' . $type . '/' . $url));
}

public static function mock($name)
{
if (static::$mocking === true) {
return static::$responses[ $name ];
}
}
}
public static $saving = false;
public static $mocking = false;
public static $responses = [];

public static function fileMock($request, $fileName)
{
$path = app_path('Mock/mp/').$fileName;
$file = fopen($path, 'r');

$content = fread($file, filesize($path));

fclose($file);

static::mock($request, json_decode($content));
}

public static function saveResponse($name, $response)
{
if (static::$saving === true) {
$path = app_path('Mock/'.str_replace('/', '-', $name));

$file = fopen($path, 'w');
fwrite($file, json_encode($response));
fclose($file);
}

return $response;
}

public static function create_preference($preference)
{
if (static::$mocking === true) {
return static::mock('create_preference');
}

return static::saveResponse('create_preference', \MP::create_preference($preference));
}

public static function get_payment($paymentId)
{
if (static::$mocking === true) {
return static::mock('get_payment');
}

return static::saveResponse('get_payment', \MP::get_payment($paymentId));
}

public static function get($type, $url)
{
if (static::$mocking === true) {
return static::mock('get'.$type);
}

return static::saveResponse('get'.'/'.$type.'/'.$url, \MP::get('/'.$type.'/'.$url));
}

public static function mock($name)
{
if (static::$mocking === true) {
return static::$responses[$name];
}
}
}
1 change: 0 additions & 1 deletion app/Console/Commands/CheckConfirmations.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Console\Commands;

use App\Confirmation;
use App\Events\ConfirmationExpired;
use App\Order;
use Illuminate\Console\Command;
Expand Down
70 changes: 35 additions & 35 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\RefreshOPSkinsCache::class,
Commands\RefreshActiveSteamOrders::class,
Commands\FakeAcceptSteamOrders::class,
Commands\CheckConfirmations::class,
Commands\EmailDuskScreenshots::class,
];
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\RefreshOPSkinsCache::class,
Commands\RefreshActiveSteamOrders::class,
Commands\FakeAcceptSteamOrders::class,
Commands\CheckConfirmations::class,
Commands\EmailDuskScreenshots::class,
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('backup:clean')->daily()->at('03:00');
$schedule->command('backup:run')->daily()->at('04:00');
}
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('backup:clean')->daily()->at('03:00');
$schedule->command('backup:run')->daily()->at('04:00');
}

/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
4 changes: 3 additions & 1 deletion app/Events/ConfirmationExpired.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

class ConfirmationExpired
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $expiredConfirmations;

Expand Down
4 changes: 3 additions & 1 deletion app/Events/ConfirmationGenerated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

class ConfirmationGenerated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $confirmation;

Expand Down
4 changes: 3 additions & 1 deletion app/Events/OrderCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

class OrderCreated implements IMailableEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $order;

Expand Down
4 changes: 3 additions & 1 deletion app/Events/SyncServerTriggered.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

class SyncServerTriggered
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

/**
* Create a new event instance.
Expand Down
4 changes: 3 additions & 1 deletion app/Events/TokenCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

class TokenCreated implements IMailableEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $token;

Expand Down
4 changes: 3 additions & 1 deletion app/Events/TokenUsed.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

class TokenUsed implements IMailableEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $token;
public $redeem;
Expand Down
4 changes: 3 additions & 1 deletion app/Events/TradeOfferSent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

class TradeOfferSent implements IMailableEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $order;

Expand Down
4 changes: 3 additions & 1 deletion app/Events/UserCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

class UserCreated implements IMailableEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $user;

Expand Down
32 changes: 16 additions & 16 deletions app/Forms/LaravelSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ public function buildForm()
'text' => __('messages.form-app-order-expiration-time-help'),
],
])
->add('cost-per-day', 'number', [
'label' => __('messages.form-app-cost-per-day'),
'pre-addon' => '$',
'post-addon' => trans_choice('messages.currency-dollar-cents', 2),
'help_block' => [
'text' => __('messages.form-app-cost-per-day-help'),
],
])
->add('mp-cost-per-month', 'number', [
'label' => __('messages.form-app-mpcost-per-month'),
'pre-addon' => 'R$',
'post-addon' => trans_choice('messages.currency-real-cents', 2),
'help_block' => [
'text' => __('messages.form-app-cost-per-month-help'),
],
])
->add('cost-per-day', 'number', [
'label' => __('messages.form-app-cost-per-day'),
'pre-addon' => '$',
'post-addon' => trans_choice('messages.currency-dollar-cents', 2),
'help_block' => [
'text' => __('messages.form-app-cost-per-day-help'),
],
])
->add('mp-cost-per-month', 'number', [
'label' => __('messages.form-app-mpcost-per-month'),
'pre-addon' => 'R$',
'post-addon' => trans_choice('messages.currency-real-cents', 2),
'help_block' => [
'text' => __('messages.form-app-cost-per-month-help'),
],
])
->add('global-home', 'summernote', [
'label' => __('messages.form-app-global-home'),
])
Expand Down
Loading