Skip to content

Commit

Permalink
fix getting payment adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
theimerj committed Feb 7, 2024
1 parent 414a8cd commit 77f7e09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/Jobs/Webhooks/HandlePaymentIntentCancelled.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
use Dystcz\LunarApi\Domain\Orders\Actions\FindOrderByIntent;
use Dystcz\LunarApi\Domain\Orders\Events\OrderPaymentCanceled;
use Dystcz\LunarApi\Domain\Payments\Data\PaymentIntent;
use Dystcz\LunarApi\Domain\Payments\PaymentAdapters\PaymentAdaptersRegister;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;
use Lunar\Stripe\Facades\StripeFacade;
use Illuminate\Support\Facades\Config;
use Spatie\WebhookClient\Models\WebhookCall;
use Stripe\Event;
use Throwable;
Expand All @@ -21,11 +22,16 @@ class HandlePaymentIntentCancelled implements ShouldQueue

public WebhookCall $webhookCall;

public function __construct(WebhookCall $webhookCall)
{
public function __construct(
WebhookCall $webhookCall,
protected PaymentAdaptersRegister $register
) {
$this->webhookCall = $webhookCall;
}

/**
* Handle cancelled payment intent.
*/
public function handle(): void
{
try {
Expand All @@ -41,7 +47,7 @@ public function handle(): void
$this->fail($e);
}

$paymentAdapter = StripeFacade::getFacadeRoot();
$paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe'));

OrderPaymentCanceled::dispatch($order, $paymentAdapter, $paymentIntent);
}
Expand Down
14 changes: 10 additions & 4 deletions src/Jobs/Webhooks/HandlePaymentIntentFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
use Dystcz\LunarApi\Domain\Orders\Actions\FindOrderByIntent;
use Dystcz\LunarApi\Domain\Orders\Events\OrderPaymentFailed;
use Dystcz\LunarApi\Domain\Payments\Data\PaymentIntent;
use Dystcz\LunarApi\Domain\Payments\PaymentAdapters\PaymentAdaptersRegister;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;
use Lunar\Stripe\Facades\StripeFacade;
use Illuminate\Support\Facades\Config;
use Spatie\WebhookClient\Models\WebhookCall;
use Stripe\Event;
use Throwable;
Expand All @@ -21,11 +22,16 @@ class HandlePaymentIntentFailed implements ShouldQueue

public WebhookCall $webhookCall;

public function __construct(WebhookCall $webhookCall)
{
public function __construct(
WebhookCall $webhookCall,
protected PaymentAdaptersRegister $register
) {
$this->webhookCall = $webhookCall;
}

/**
* Handle failed payment intent.
*/
public function handle(): void
{
try {
Expand All @@ -41,7 +47,7 @@ public function handle(): void
$this->fail($e);
}

$paymentAdapter = StripeFacade::getFacadeRoot();
$paymentAdapter = $this->register->get(Config::get('lunar-api.stripe.driver', 'stripe'));

OrderPaymentFailed::dispatch($order, $paymentAdapter, $paymentIntent);
}
Expand Down

0 comments on commit 77f7e09

Please sign in to comment.