diff --git a/src/Jobs/Webhooks/HandleOtherEvent.php b/src/Jobs/Webhooks/HandleOtherEvent.php index 93d416d..de0a9ca 100644 --- a/src/Jobs/Webhooks/HandleOtherEvent.php +++ b/src/Jobs/Webhooks/HandleOtherEvent.php @@ -2,8 +2,6 @@ namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks; -use Illuminate\Support\Facades\Config; - class HandleOtherEvent extends WebhookHandler { /** @@ -14,7 +12,6 @@ public function handle(): void // $event = $this->constructStripeEvent(); // $paymentIntent = $this->getPaymentIntentFromEvent($event); // $order = $this->findOrderByIntent($paymentIntent); - // - // $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + // $paymentAdapter = $this->getPaymentAdapter(); } } diff --git a/src/Jobs/Webhooks/HandlePaymentIntentCancelled.php b/src/Jobs/Webhooks/HandlePaymentIntentCancelled.php index 43848b0..678c77e 100644 --- a/src/Jobs/Webhooks/HandlePaymentIntentCancelled.php +++ b/src/Jobs/Webhooks/HandlePaymentIntentCancelled.php @@ -3,7 +3,6 @@ namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks; use Dystcz\LunarApi\Domain\Orders\Events\OrderPaymentCanceled; -use Illuminate\Support\Facades\Config; class HandlePaymentIntentCancelled extends WebhookHandler { @@ -15,8 +14,7 @@ public function handle(): void $event = $this->constructStripeEvent(); $paymentIntent = $this->getPaymentIntentFromEvent($event); $order = $this->findOrderByIntent($paymentIntent); - - $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + $paymentAdapter = $this->getPaymentAdapter(); OrderPaymentCanceled::dispatch($order, $paymentAdapter, $paymentIntent); } diff --git a/src/Jobs/Webhooks/HandlePaymentIntentCreated.php b/src/Jobs/Webhooks/HandlePaymentIntentCreated.php index 65f8027..23c340f 100644 --- a/src/Jobs/Webhooks/HandlePaymentIntentCreated.php +++ b/src/Jobs/Webhooks/HandlePaymentIntentCreated.php @@ -2,8 +2,6 @@ namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks; -use Illuminate\Support\Facades\Config; - class HandlePaymentIntentCreated extends WebhookHandler { /** @@ -14,7 +12,6 @@ public function handle(): void // $event = $this->constructStripeEvent(); // $paymentIntent = $this->getPaymentIntentFromEvent($event); // $order = $this->findOrderByIntent($paymentIntent); - // - // $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + // $paymentAdapter = $this->getPaymentAdapter(); } } diff --git a/src/Jobs/Webhooks/HandlePaymentIntentFailed.php b/src/Jobs/Webhooks/HandlePaymentIntentFailed.php index 4ac5216..100c414 100644 --- a/src/Jobs/Webhooks/HandlePaymentIntentFailed.php +++ b/src/Jobs/Webhooks/HandlePaymentIntentFailed.php @@ -3,7 +3,6 @@ namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks; use Dystcz\LunarApi\Domain\Orders\Events\OrderPaymentFailed; -use Illuminate\Support\Facades\Config; class HandlePaymentIntentFailed extends WebhookHandler { @@ -15,8 +14,7 @@ public function handle(): void $event = $this->constructStripeEvent(); $paymentIntent = $this->getPaymentIntentFromEvent($event); $order = $this->findOrderByIntent($paymentIntent); - - $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + $paymentAdapter = $this->getPaymentAdapter(); OrderPaymentFailed::dispatch($order, $paymentAdapter, $paymentIntent); } diff --git a/src/Jobs/Webhooks/HandlePaymentIntentProcessing.php b/src/Jobs/Webhooks/HandlePaymentIntentProcessing.php index 17aa947..dcd5acf 100644 --- a/src/Jobs/Webhooks/HandlePaymentIntentProcessing.php +++ b/src/Jobs/Webhooks/HandlePaymentIntentProcessing.php @@ -2,8 +2,6 @@ namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks; -use Illuminate\Support\Facades\Config; - class HandlePaymentIntentProcessing extends WebhookHandler { /** @@ -14,7 +12,6 @@ public function handle(): void // $event = $this->constructStripeEvent(); // $paymentIntent = $this->getPaymentIntentFromEvent($event); // $order = $this->findOrderByIntent($paymentIntent); - // - // $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + // $paymentAdapter = $this->getPaymentAdapter(); } } diff --git a/src/Jobs/Webhooks/HandlePaymentIntentRequiresAction.php b/src/Jobs/Webhooks/HandlePaymentIntentRequiresAction.php index 24724f2..8c44c88 100644 --- a/src/Jobs/Webhooks/HandlePaymentIntentRequiresAction.php +++ b/src/Jobs/Webhooks/HandlePaymentIntentRequiresAction.php @@ -2,8 +2,6 @@ namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks; -use Illuminate\Support\Facades\Config; - class HandlePaymentIntentRequiresAction extends WebhookHandler { /** @@ -14,7 +12,6 @@ public function handle(): void // $event = $this->constructStripeEvent(); // $paymentIntent = $this->getPaymentIntentFromEvent($event); // $order = $this->findOrderByIntent($paymentIntent); - // - // $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + // $paymentAdapter = $this->getPaymentAdapter(); } } diff --git a/src/Jobs/Webhooks/HandlePaymentIntentSucceeded.php b/src/Jobs/Webhooks/HandlePaymentIntentSucceeded.php index f7fd6de..b12526e 100644 --- a/src/Jobs/Webhooks/HandlePaymentIntentSucceeded.php +++ b/src/Jobs/Webhooks/HandlePaymentIntentSucceeded.php @@ -4,7 +4,6 @@ use Dystcz\LunarApiStripeAdapter\Actions\AuthorizeStripePayment; use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Config; class HandlePaymentIntentSucceeded extends WebhookHandler { @@ -17,8 +16,6 @@ public function handle(): void $paymentIntent = $this->getPaymentIntentFromEvent($event); $order = $this->findOrderByIntent($paymentIntent); - $paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); - App::make(AuthorizeStripePayment::class)($order, $order->cart, $paymentIntent); } } diff --git a/src/Jobs/Webhooks/WebhookHandler.php b/src/Jobs/Webhooks/WebhookHandler.php index 1a14ef7..4a8ce3f 100644 --- a/src/Jobs/Webhooks/WebhookHandler.php +++ b/src/Jobs/Webhooks/WebhookHandler.php @@ -27,7 +27,6 @@ abstract class WebhookHandler implements ShouldQueue public function __construct( WebhookCall $webhookCall, - protected PaymentAdaptersRegister $register ) { $this->webhookCall = $webhookCall; } @@ -64,7 +63,9 @@ protected function getPaymentIntentFromEvent(Event $event): PaymentIntentContrac */ protected function getPaymentAdapter(): PaymentAdapter { - return $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe')); + $register = App::make(PaymentAdaptersRegister::class); + + return $register->get(Config::get('lunar-api.stripe.driver', 'stripe')); } /**