Cleanup for Authorize.net

This commit is contained in:
David Bomba 2025-05-14 15:15:43 +10:00
parent a2a12834f8
commit e22562613d
2 changed files with 12 additions and 13 deletions

View File

@ -36,15 +36,10 @@ class AuthorizeACH implements LivewireMethodInterface
{
use MakesHash;
/** @var AuthorizePaymentDriver */
public $authorize;
public function __construct(AuthorizePaymentDriver $authorize)
public function __construct(public AuthorizePaymentDriver $authorize)
{
$this->authorize = $authorize;
}
/**
* livewirePaymentView
*

View File

@ -221,6 +221,14 @@ class AuthorizePaymentDriver extends BaseDriver
return $this->init()->getPublicClientKey() ? 'ok' : 'error';
}
/**
* processWebhookRequest
*
* We only handle voided payments for now.
*
* @param PaymentWebhookRequest $request
* @return void
*/
public function processWebhookRequest(PaymentWebhookRequest $request)
{
@ -295,7 +303,7 @@ class AuthorizePaymentDriver extends BaseDriver
// 'id' => '80040995616',
// ),
// )
private function voidPayment($data)
private function voidPayment(array $data)
{
$payment = Payment::withTrashed()
@ -303,10 +311,7 @@ class AuthorizePaymentDriver extends BaseDriver
->where('transaction_reference', $data['payload']['id'])
->first();
if($payment){
if($payment->status_id != Payment::STATUS_COMPLETED)
return;
if($payment && $payment->status_id == Payment::STATUS_COMPLETED){
$payment->service()->deletePayment();
$payment->status_id = Payment::STATUS_FAILED;
@ -322,7 +327,6 @@ class AuthorizePaymentDriver extends BaseDriver
$error = 'Payment for '.$payment->client->present()->name()." for {$payment->amount} failed";
}
PaymentFailedMailer::dispatch(
$payment_hash,
$payment->client->company,