class-learndash-unknown-gateway.php
3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* This class is made for null object pattern support.
*
* @since 4.5.0
*
* @package LearnDash
*/
use LearnDash\Core\Models\Product;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Learndash_Unknown_Gateway' ) && class_exists( 'Learndash_Payment_Gateway' ) ) {
/**
* Unknown gateway class.
*
* @since 4.5.0
*/
class Learndash_Unknown_Gateway extends Learndash_Payment_Gateway {
private const GATEWAY_NAME = '';
/**
* Returns a flag to easily identify if the gateway supports transactions management.
*
* @since 4.5.0
*
* @return bool True if a gateway supports managing subscriptions/other transactions. False otherwise.
*/
public function supports_transactions_management(): bool {
return false;
}
/**
* Returns a flag to easily identify if the gateway supports logger.
*
* @since 4.5.0
*
* @return bool True if a gateway supports logger. False otherwise.
*/
public function supports_logger(): bool {
return false;
}
/**
* Cancels a subscription.
*
* @since 4.5.0
*
* @param string $subscription_id Subscription ID.
*
* @return WP_Error
*/
public function cancel_subscription( string $subscription_id ): WP_Error {
return new WP_Error(
self::$wp_error_code,
__( 'Subscription management is not possible because the payment gateway is not enabled or configured.', 'learndash' )
);
}
/**
* Returns the gateway name.
*
* @since 4.5.0
*
* @return string
*/
public static function get_name(): string {
return self::GATEWAY_NAME;
}
/**
* Returns the gateway label.
*
* @since 4.5.0
*
* @return string
*/
public static function get_label(): string {
return esc_html__( 'Unknown', 'learndash' );
}
/**
* Adds hooks.
*
* @since 4.5.0
*
* @return void
*/
public function add_extra_hooks(): void {
// No hooks.
}
/**
* Enqueues scripts.
*
* @since 4.5.0
*
* @return void
*/
public function enqueue_scripts(): void {
// No scripts.
}
/**
* Creates a session/order/subscription on backend if needed.
*
* @since 4.5.0
*
* @return void
*/
public function setup_payment(): void {
// No actions.
}
/**
* Returns true if everything is configured and payment gateway can be used, otherwise false.
*
* @since 4.5.0
*
* @return bool Always true.
*/
public function is_ready(): bool {
return true;
}
/**
* Returns true it's a test mode, otherwise false.
*
* @since 4.5.0
*
* @return bool Always true.
*/
protected function is_test_mode(): bool {
return true;
}
/**
* Configures settings.
*
* @since 4.5.0
*
* @return void
*/
protected function configure(): void {
// Do nothing.
}
/**
* Maps transaction meta.
*
* @since 4.5.0
*
* @param mixed $data Data.
* @param Product $product Product.
*
* @throws Learndash_DTO_Validation_Exception Exception.
*
* @return Learndash_Transaction_Meta_DTO
*/
protected function map_transaction_meta( $data, Product $product ): Learndash_Transaction_Meta_DTO {
return Learndash_Transaction_Meta_DTO::create();
}
/**
* Handles the webhook.
*
* @since 4.5.0
*
* @return void
*/
public function process_webhook(): void {
// Do nothing.
}
/**
* Returns payment button HTML markup.
*
* @since 4.5.0
*
* @param array<mixed> $params Payment params.
* @param WP_Post $post Post being processing.
*
* @return string Empty string.
*/
public function map_payment_button_markup( array $params, WP_Post $post ): string {
return '';
}
}
}