Skip to content

Commit

Permalink
add interferes, move url to config remove not need validation add php…
Browse files Browse the repository at this point in the history
…Stan move service class out of http dir
  • Loading branch information
KalimeroMK committed Nov 23, 2024
1 parent 8143f39 commit 40fa1a2
Show file tree
Hide file tree
Showing 12 changed files with 358 additions and 138 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "kalimeromk/casys-laravel",
"description": "Integration of casys payment method",
"require": {
"php": ">=7.4.0",
"php": ">=8.0",
"ext-json": "*",
"ext-soap": "*"
},
Expand Down Expand Up @@ -43,6 +43,7 @@
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0|^7.0|8.0",
"mockery/mockery": "^1.4|^1.5|^1.6|^1.7"
"mockery/mockery": "^1.4|^1.5|^1.6|^1.7",
"larastan/larastan": "^2.0"
}
}
190 changes: 187 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
includes:
- vendor/larastan/larastan/extension.neon
- vendor/nesbot/carbon/extension.neon

parameters:

paths:
- src/

# Level 9 is the highest level
level: 9
38 changes: 23 additions & 15 deletions src/CasysServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
namespace Kalimero\Casys;

use Illuminate\Support\ServiceProvider;
use Kalimero\Casys\Http\Service\RecurringPayment;
use Kalimero\Casys\Interfaces\RecurringPaymentInterface;
use Kalimero\Casys\Service\RecurringPayment;
use SoapClient;
use InvalidArgumentException;

class CasysServiceProvider extends ServiceProvider
{


/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
public function boot(): void
{

$this->loadViewsFrom(__DIR__.'/resources/views', 'casys');
$this->loadRoutesFrom(__DIR__.'/routes/casys.php');
$this->loadViewsFrom(__DIR__ . '/resources/views', 'casys');
$this->loadRoutesFrom(__DIR__ . '/routes/casys.php');

$this->publishes([
__DIR__ . '/resources/views' => resource_path('views/vendor/casys'),
__DIR__ . '/config/casys.php' => config_path('/casys.php'),
__DIR__ . '/config/casys.php' => config_path('casys.php'),
]);
}

Expand All @@ -31,23 +31,31 @@ public function boot()
*
* @return void
*/
public function register()
public function register(): void
{
$this->registerConfig();
$this->app->bind(RecurringPayment::class, function () {
return new RecurringPayment();
});

$this->app->singleton(RecurringPaymentInterface::class, function ($app) {
$wsdl = config('casys.RecurrentPaymentWsdl');

// Ensure the WSDL is valid
if (!is_string($wsdl) || empty($wsdl)) {
throw new InvalidArgumentException('The WSDL URL for the Recurrent Payment service must be a valid non-empty string.');
}

$soapClient = new SoapClient($wsdl);

return new RecurringPayment($soapClient);
});
}

/**
* Register package config.
*
* @return void
*/
protected function registerConfig()
protected function registerConfig(): void
{
$this->mergeConfigFrom(__DIR__.'/config/casys.php', 'casys');
$this->mergeConfigFrom(__DIR__ . '/config/casys.php', 'casys');
}

}
15 changes: 8 additions & 7 deletions src/Http/Controllers/CasysController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Routing\Controller;
use Kalimero\Casys\Http\Service\Casys;
use Kalimero\Casys\Service\Casys;
use stdClass;

class CasysController extends Controller
{
Expand All @@ -27,19 +28,19 @@ public function __construct(Casys $casys)
*
* @return Application|Factory|View
*/
public function index()
public function index(): View|Factory|Application
{
return view('casys::loader');
}

/**
* Generate and display the payment data.
*
* @param $client
* @param $amount
* @param stdClass $client An object containing client data (name, last_name, country, email).
* @param float $amount The amount to be paid.
* @return Application|Factory|View
*/
public function getCasys($client, $amount)
public function getCasys(stdClass $client, float $amount): View|Factory|Application
{
$casysData = $this->casys->getCasysData($client, $amount);
return view('casys::index', compact('casysData'));
Expand All @@ -50,7 +51,7 @@ public function getCasys($client, $amount)
*
* @return Application|Factory|View
*/
public function success()
public function success(): View|Factory|Application
{
return view('casys::okurl')->with('success', 'Your transaction was successful');
}
Expand All @@ -60,7 +61,7 @@ public function success()
*
* @return Application|Factory|View
*/
public function fail()
public function fail(): View|Factory|Application
{
return view('casys::failurl')->with('error', 'Your transaction failed');
}
Expand Down
Loading

0 comments on commit 40fa1a2

Please sign in to comment.