| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Events\Subscription; |
| 4 |
|
| 5 |
use FluentCart\App\Events\EventDispatcher; |
| 6 |
use FluentCart\App\Listeners; |
| 7 |
use FluentCart\App\Models\Customer; |
| 8 |
use FluentCart\App\Models\Order; |
| 9 |
use FluentCart\App\Models\Subscription; |
| 10 |
|
| 11 |
class SubscriptionRenewalFailed extends EventDispatcher |
| 12 |
{ |
| 13 |
public string $hook = 'fluent_cart/subscription_renewal_failed'; |
| 14 |
protected array $listeners = [ |
| 15 |
Listeners\Subscription\SubscriptionRenewalFailed::class, |
| 16 |
]; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var Subscription $subscription |
| 20 |
*/ |
| 21 |
public Subscription $subscription; |
| 22 |
|
| 23 |
/** |
| 24 |
* @var Order $order |
| 25 |
*/ |
| 26 |
public Order $order; |
| 27 |
|
| 28 |
/** |
| 29 |
* @var Customer|null $customer |
| 30 |
*/ |
| 31 |
public ?Customer $customer; |
| 32 |
|
| 33 |
/** |
| 34 |
* @var string $error Gateway failure reason |
| 35 |
*/ |
| 36 |
public string $error; |
| 37 |
|
| 38 |
public function __construct($subscription, $order, $customer, $error = '') |
| 39 |
{ |
| 40 |
$this->subscription = $subscription; |
| 41 |
$this->order = $order; |
| 42 |
$this->customer = $customer; |
| 43 |
$this->error = $error; |
| 44 |
} |
| 45 |
|
| 46 |
public function toArray(): array |
| 47 |
{ |
| 48 |
return [ |
| 49 |
'subscription' => $this->subscription ?? null, |
| 50 |
'order' => $this->order ?? null, |
| 51 |
'customer' => $this->customer ?? null, |
| 52 |
'error' => $this->error ?? '', |
| 53 |
]; |
| 54 |
} |
| 55 |
|
| 56 |
public function getActivityEventModel() |
| 57 |
{ |
| 58 |
return $this->subscription; |
| 59 |
} |
| 60 |
|
| 61 |
} |
| 62 |
|