Skip to content

Commit

Permalink
Merge branch 'feature/stripe-webhooks' into 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Feb 7, 2024
2 parents 6e33ce4 + e7d8d69 commit af8e6fb
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 27 deletions.
5 changes: 1 addition & 4 deletions src/Jobs/Webhooks/HandleOtherEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks;

use Illuminate\Support\Facades\Config;

class HandleOtherEvent extends WebhookHandler
{
/**
Expand All @@ -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();
}
}
4 changes: 1 addition & 3 deletions src/Jobs/Webhooks/HandlePaymentIntentCancelled.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Jobs/Webhooks/HandlePaymentIntentCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks;

use Illuminate\Support\Facades\Config;

class HandlePaymentIntentCreated extends WebhookHandler
{
/**
Expand All @@ -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();
}
}
4 changes: 1 addition & 3 deletions src/Jobs/Webhooks/HandlePaymentIntentFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Jobs/Webhooks/HandlePaymentIntentProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks;

use Illuminate\Support\Facades\Config;

class HandlePaymentIntentProcessing extends WebhookHandler
{
/**
Expand All @@ -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();
}
}
5 changes: 1 addition & 4 deletions src/Jobs/Webhooks/HandlePaymentIntentRequiresAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Dystcz\LunarApiStripeAdapter\Jobs\Webhooks;

use Illuminate\Support\Facades\Config;

class HandlePaymentIntentRequiresAction extends WebhookHandler
{
/**
Expand All @@ -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();
}
}
3 changes: 0 additions & 3 deletions src/Jobs/Webhooks/HandlePaymentIntentSucceeded.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Dystcz\LunarApiStripeAdapter\Actions\AuthorizeStripePayment;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;

class HandlePaymentIntentSucceeded extends WebhookHandler
{
Expand All @@ -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);
}
}
5 changes: 3 additions & 2 deletions src/Jobs/Webhooks/WebhookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ abstract class WebhookHandler implements ShouldQueue

public function __construct(
WebhookCall $webhookCall,
protected PaymentAdaptersRegister $register
) {
$this->webhookCall = $webhookCall;
}
Expand Down Expand Up @@ -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'));
}

/**
Expand Down

0 comments on commit af8e6fb

Please sign in to comment.