PluginProbe
Easy Hotel – Powerful Hotel Booking / 2.0.2
Easy Hotel – Powerful Hotel Booking v2.0.2
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / native-checkout / gateways / abstract-gateway.php

abstract-gateway.php in Easy Hotel – Powerful Hotel Booking 2.0.2, at admin/includes/native-checkout/gateways/abstract-gateway.php

73 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Abstract base class for native-checkout payment gateways.
4 *
5 * Concrete gateways extend this and implement the create_payment() /
6 * capture_payment() lifecycle. Adding a new gateway is a matter of
7 * dropping a subclass into ./gateways/ and registering it with the
8 * gateway manager — no edits to the checkout flow are required.
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) exit;
12
13 abstract class ESHB_Native_Abstract_Gateway {
14
15 /** Unique gateway identifier (e.g. 'paypal'). */
16 protected $id = '';
17
18 /** Human-readable title shown in the checkout. */
19 protected $title = '';
20
21 /** Short description shown under the title. */
22 protected $description = '';
23
24 public function get_id() {
25 return $this->id;
26 }
27
28 public function get_title() {
29 return $this->title;
30 }
31
32 public function get_description() {
33 return $this->description;
34 }
35
36 /**
37 * Whether this gateway is fully configured and enabled.
38 */
39 abstract public function is_enabled();
40
41 /**
42 * Frontend payload (script handles, API keys, gateway-specific
43 * settings) needed by the JS layer to render the gateway button.
44 *
45 * @return array
46 */
47 public function get_frontend_data() {
48 return [
49 'id' => $this->id,
50 'title' => $this->title,
51 'description' => $this->description,
52 ];
53 }
54
55 /**
56 * Create a server-side payment intent / order for the given reservation.
57 * Returns gateway-specific data the JS layer needs to launch the flow
58 * (e.g. PayPal order id).
59 *
60 * @return array { success: bool, data: array, message?: string }
61 */
62 abstract public function create_payment( array $reservation, array $customer, array $pricing );
63
64 /**
65 * Verify and capture a previously-created payment. Called server-side
66 * once the JS layer signals user approval. Must return a normalized
67 * result so the checkout flow can persist payment metadata.
68 *
69 * @return array { success: bool, transaction_id?: string, amount?: float, currency?: string, mode?: string, raw?: array, message?: string }
70 */
71 abstract public function capture_payment( array $params );
72 }
73