PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.27
Booktics – Appointment Booking Calendar for Service Businesses v1.0.27
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / payment / payment-methods / abstract-payment-method.php

abstract-payment-method.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.27, at core/payment/payment-methods/abstract-payment-method.php

76 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Payment\Payment_Methods;
4
5 use Booktics\Payment\Contracts\Payment_Method_Interface;
6 use Booktics\Payment\Payment_Status;
7 use Booktics\Models\Order_Model;
8
9 abstract class Abstract_Payment_Method implements Payment_Method_Interface {
10
11 /**
12 * The unpaid order was actually paid — repair it, do not release the slot.
13 */
14 const RESERVATION_REPAIR = 'repair';
15
16 /**
17 * The customer never completed payment — release the held slot.
18 */
19 const RESERVATION_RELEASE = 'release';
20
21 /**
22 * Payment is still legitimately in progress — keep the slot and re-check later.
23 */
24 const RESERVATION_WAIT = 'wait';
25
26 protected $id;
27 protected $name;
28 private $order;
29
30 /**
31 * Decide what to do with a slot held by an unpaid order that has passed the
32 * reservation timeout: repair (payment actually went through), release (free
33 * the slot), or wait (payment still genuinely in progress — check again later).
34 *
35 * Default implementation infers the action from get_payment_status(). Gateways
36 * with richer lifecycle states (e.g. Stripe's 3D-Secure flow) should override
37 * this to avoid canceling a customer who is mid-payment.
38 *
39 * @param Order_Model $order The order whose reservation is being evaluated.
40 *
41 * @return string One of the RESERVATION_* constants.
42 */
43 public function resolve_reservation_action( $order ): string {
44 return Payment_Status::COMPLETED === $this->get_payment_status( $order )
45 ? self::RESERVATION_REPAIR
46 : self::RESERVATION_RELEASE;
47 }
48
49 /**
50 * Get the unique identifier for this payment method
51 *
52 * @return string
53 */
54 public function get_id(): string {
55 return $this->id;
56 }
57
58 /**
59 * Get the display name of the payment method
60 *
61 * @return string
62 */
63 public function get_name(): string {
64 return $this->name;
65 }
66
67 /**
68 * Get Order
69 *
70 * @return Order_Model
71 */
72 protected function get_order() {
73 return $this->order;
74 }
75 }
76