diff --git a/src/Http/Controllers/WebhookController.php b/src/Http/Controllers/WebhookController.php index 771680d..807158e 100644 --- a/src/Http/Controllers/WebhookController.php +++ b/src/Http/Controllers/WebhookController.php @@ -24,7 +24,7 @@ public function handleWebhook(Request $request) $molliePayment = $this->getMolliePaymentById( $request->get('id'), - owner: $payment->owner instanceof ProvidesOauthInformation ? $payment->owner : null, + owner: $payment?->owner instanceof ProvidesOauthInformation ? $payment?->owner : null, ); if ($molliePayment) { @@ -38,7 +38,7 @@ public function handleWebhook(Request $request) /** @var UpdateMolliePayment $updateMolliePayment */ $updateMolliePayment = app()->make(UpdateMolliePayment::class); - $updateMolliePayment->execute($molliePayment, $payment->owner instanceof ProvidesOauthInformation ? $payment->owner : null); + $updateMolliePayment->execute($molliePayment, $payment?->owner instanceof ProvidesOauthInformation ? $payment?->owner : null); break; case PaymentStatus::STATUS_FAILED: diff --git a/src/Mollie/GetMollieRefund.php b/src/Mollie/GetMollieRefund.php index 7f44658..8706fd8 100644 --- a/src/Mollie/GetMollieRefund.php +++ b/src/Mollie/GetMollieRefund.php @@ -12,11 +12,6 @@ class GetMollieRefund extends BaseMollieInteraction implements Contract { - /** - * @var \Mollie\Api\MollieApiClient - */ - protected Mollie $mollie; - /** * @var \Laravel\Cashier\Mollie\Contracts\GetMolliePayment */ @@ -24,7 +19,7 @@ class GetMollieRefund extends BaseMollieInteraction implements Contract public function __construct(Mollie $mollie, GetMolliePayment $getMolliePayment) { - $this->mollie = $mollie; + parent::__construct($mollie); $this->getMolliePayment = $getMolliePayment; } diff --git a/tests/Refunds/RefundsBuilderTest.php b/tests/Refunds/RefundsBuilderTest.php index 6875b5d..8004ea7 100644 --- a/tests/Refunds/RefundsBuilderTest.php +++ b/tests/Refunds/RefundsBuilderTest.php @@ -32,7 +32,7 @@ public function can_create_a_refund_for_a_complete_order(): void 'value' => '22.00', 'currency' => 'EUR', ], - ])->once()->andReturn($mollieRefund); + ], null)->once()->andReturn($mollieRefund); }); $user = $this->getUser(); diff --git a/tests/Traits/InteractsWithMocks.php b/tests/Traits/InteractsWithMocks.php index e04b4c3..76a65d9 100644 --- a/tests/Traits/InteractsWithMocks.php +++ b/tests/Traits/InteractsWithMocks.php @@ -144,7 +144,7 @@ protected function withMockedGetMollieMandatePending(int $times = 1): void 'customerId' => 'cst_unique_customer_id', 'status' => 'pending', ] - ]); + ], null); } protected function withMockedGetMollieMandate( @@ -165,7 +165,7 @@ protected function withMockedGetMollieMandate( $mandate->method = 'directdebit'; $mock->shouldReceive('execute') - ->with($data['customerId'], $data['mandateId']) + ->with($data['customerId'], $data['mandateId'], null) ->times($times) ->andReturn($mandate); } @@ -194,7 +194,7 @@ protected function withMockedGetMollieCustomer(int $times = 1, array $customerId $customer->id = $id; $mock->shouldReceive('execute') - ->with($id) + ->with($id, null) ->times($times) ->andReturn($customer); } @@ -207,7 +207,7 @@ protected function withMockedGetMollieMethodMinimumAmount(int $times = 1, int $a { $this->mock(GetMollieMethodMinimumAmount::class, function ($mock) use ($times, $amount) { return $mock->shouldReceive('execute') - ->with('directdebit', 'EUR') + ->with('directdebit', 'EUR', null) ->times($times) ->andReturn(new Money($amount, new Currency('EUR'))); }); @@ -219,7 +219,7 @@ protected function withMockedGetMollieMethodMaximumAmount(int $times = 1, ?int $ $this->mock(GetMollieMethodMaximumAmount::class, function ($mock) use ($times, $returnedValue) { return $mock->shouldReceive('execute') - ->with('directdebit', 'EUR') + ->with('directdebit', 'EUR', null) ->times($times) ->andReturn($returnedValue); }); @@ -279,7 +279,7 @@ protected function withMockedGetMolliePayment(int $times = 1, ?Payment $molliePa $this->mock(GetMolliePayment::class, function ($mock) use ($times, $molliePayment) { return $mock->shouldReceive('execute') - ->with($molliePayment->id, []) + ->with($molliePayment->id, [], null) ->times($times) ->andReturn($molliePayment); }); @@ -289,7 +289,7 @@ protected function withMockedGetMolliePaymentThrowingException(int $times = 1, s { $this->mock(GetMolliePayment::class, function ($mock) use ($times, $wrongId) { return $mock->shouldReceive('execute') - ->with($wrongId, []) + ->with($wrongId, [], null) ->times($times) ->andThrow(new ApiException); });