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,14 +36,9 @@ 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

@ -220,7 +220,15 @@ 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,11 +311,8 @@ 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;
$payment->save(); $payment->save();
@ -321,7 +326,6 @@ class AuthorizePaymentDriver extends BaseDriver
} else { } else {
$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,