You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
1.2 KiB

<?php
namespace App\Utilities\Zarinpal\Laravel;
use App\Utilities\Zarinpal\Zarinpal;
use Illuminate\Support\ServiceProvider;
use App\Utilities\Zarinpal\Drivers\RestDriver;
use App\Utilities\Zarinpal\Drivers\DriverInterface;
class ZarinpalServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton(DriverInterface::class, function () {
return new RestDriver();
});
$this->app->singleton('Zarinpal', function () {
$merchantID = config('services.zarinpal.merchantID', config('Zarinpal.merchantID', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'));
$zarinpal = new Zarinpal($merchantID, $this->app->make(DriverInterface::class));
if (config('services.zarinpal.sandbox', false)) {
$zarinpal->enableSandbox();
}
if (config('services.zarinpal.zarinGate', false)) {
$zarinpal->isZarinGate();
}
return $zarinpal;
});
}
/**
* Publish the plugin configuration.
*/
public function boot()
{
//
}
}