PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.0
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Events / Order / OrderPaymentFailed.php

OrderPaymentFailed.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.5.0, at app/Events/Order/OrderPaymentFailed.php

93 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Events\Order;
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\OrderTransaction;
10
11 class OrderPaymentFailed extends EventDispatcher
12 {
13
14 public string $hook = 'fluent_cart/order_payment_failed';
15 protected array $listeners = [
16 Listeners\Order\OrderPaymentFailed::class,
17 ];
18
19 /**
20 * @var Order $order
21 */
22 public Order $order;
23
24 /**
25 * @var Customer|null $customer
26 */
27 public ?Customer $customer;
28
29 /**
30 * @var OrderTransaction|null $transaction
31 */
32
33 /**
34 * @var string|null $oldStatus
35 */
36 public ?string $oldStatus;
37
38 /**
39 * @var string|null $newStatus
40 */
41 public ?string $newStatus;
42
43 /**
44 * @var string|null $reason
45 */
46 public ?string $reason;
47
48
49
50 public ?OrderTransaction $transaction;
51
52 public function __construct(Order $order, $transaction = null, $oldStatus = null, $newStatus = null, $reason = null)
53 {
54 $this->order = $order;
55 $this->order->load('customer', 'order_items', 'shipping_address', 'billing_address');
56 $this->customer = $order->customer;
57 $this->transaction = $transaction;
58 $this->oldStatus = $oldStatus;
59 $this->newStatus = $newStatus;
60 $this->reason = $reason;
61 }
62
63 public function toArray(): array
64 {
65 return [
66 'order' => $this->order,
67 'customer' => $this->customer ?? null,
68 'transaction' => $this->transaction ?? null,
69 'old_status' => $this->oldStatus,
70 'new_status' => $this->newStatus,
71 'reason' => $this->reason,
72 ];
73 }
74
75 public function getActivityEventModel()
76 {
77 return $this->order;
78 }
79
80 public function beforeDispatch()
81 {
82 // Add any pre-dispatch logic here if needed
83 }
84
85 public function afterDispatch()
86 {
87 // to do: maybe add some logic here
88
89 }
90
91 }
92
93