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; use MakesHash;
/** @var AuthorizePaymentDriver */ public function __construct(public AuthorizePaymentDriver $authorize)
public $authorize;
public function __construct(AuthorizePaymentDriver $authorize)
{ {
$this->authorize = $authorize;
} }
/** /**
* livewirePaymentView * livewirePaymentView
* *

View File

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