Skip to content

Commit

Permalink
Refactor reQuery method to return ReQuery object
Browse files Browse the repository at this point in the history
  • Loading branch information
damms005 committed Oct 25, 2024
1 parent 039baf8 commit 7440680
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Services/PaymentHandlers/BasePaymentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Foundation\Auth\User;
use Damms005\LaravelMultipay\Models\Payment;
use Damms005\LaravelMultipay\Models\PaymentPlan;
use Damms005\LaravelMultipay\ValueObjects\ReQuery;
use Illuminate\Database\Eloquent\Casts\ArrayObject;
use Damms005\LaravelMultipay\Services\PaymentService;
use Damms005\LaravelMultipay\Actions\CreateNewPayment;
Expand Down Expand Up @@ -228,24 +229,24 @@ protected static function getPaymentDescription(?Payment $payment): array
/**
* @see \Damms005\LaravelMultipay\Contracts\PaymentHandlerInterface::reQuery()
*/
public function reQueryUnsuccessfulPayment(Payment $unsuccessfulPayment)
public function reQueryUnsuccessfulPayment(Payment $unsuccessfulPayment): ?ReQuery
{
/** @var PaymentHandlerInterface **/
$handler = app()->make(PaymentHandlerInterface::class, [$unsuccessfulPayment]);

$reQueryResponse = $handler->reQuery($unsuccessfulPayment);

if ($reQueryResponse == null) {
return false;
return null;
}

$isSuccessFulPayment = boolval($reQueryResponse->payment->refresh()->is_success);
$isSuccessful = boolval($reQueryResponse->payment->refresh()->is_success);

if ($isSuccessFulPayment) {
if ($isSuccessful) {
event(new SuccessfulLaravelMultipayPaymentEvent($reQueryResponse->payment));
}

return $isSuccessFulPayment;
return $reQueryResponse;
}

public function paymentCompletionWebhookHandler(Request $request)
Expand Down

0 comments on commit 7440680

Please sign in to comment.