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

  1. <?php
  2. namespace App\Utilities\Zarinpal\Laravel;
  3. use App\Utilities\Zarinpal\Zarinpal;
  4. use Illuminate\Support\ServiceProvider;
  5. use App\Utilities\Zarinpal\Drivers\RestDriver;
  6. use App\Utilities\Zarinpal\Drivers\DriverInterface;
  7. class ZarinpalServiceProvider extends ServiceProvider
  8. {
  9. /**
  10. * Register the service provider.
  11. *
  12. * @return void
  13. */
  14. public function register()
  15. {
  16. $this->app->singleton(DriverInterface::class, function () {
  17. return new RestDriver();
  18. });
  19. $this->app->singleton('Zarinpal', function () {
  20. $merchantID = config('services.zarinpal.merchantID', config('Zarinpal.merchantID', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'));
  21. $zarinpal = new Zarinpal($merchantID, $this->app->make(DriverInterface::class));
  22. if (config('services.zarinpal.sandbox', false)) {
  23. $zarinpal->enableSandbox();
  24. }
  25. if (config('services.zarinpal.zarinGate', false)) {
  26. $zarinpal->isZarinGate();
  27. }
  28. return $zarinpal;
  29. });
  30. }
  31. /**
  32. * Publish the plugin configuration.
  33. */
  34. public function boot()
  35. {
  36. //
  37. }
  38. }