PluginProbe
PayPlug for WooCommerce (Official) / 2.6.3
PayPlug for WooCommerce (Official) v2.6.3
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / src / Admin / Vue / PaymentMethods.php

PaymentMethods.php in PayPlug for WooCommerce (Official) 2.6.3, at src/Admin/Vue/PaymentMethods.php

453 lines 15.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce\Admin\Vue;
4
5 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
6
7 class PaymentMethods {
8
9 /**
10 * @param $active
11 *
12 * @return array
13 */
14 public function payment_method_standard( ) {
15
16 $option = (get_option( 'woocommerce_payplug_settings', [] )['payment_method'] != "") ? get_option( 'woocommerce_payplug_settings', [] )['payment_method'] : "";
17
18 $method = [
19 "redirect" => false,
20 "popup" => false,
21 "integrated" => false,
22 ];
23
24 switch($option){
25 case "popup" : $method["popup"] = true;break;
26 case "integrated" : $method["integrated"] = true;break;
27 default: $method["redirect"] = true;break;
28 }
29
30 return [
31 "type" => "payment_method",
32 "name" => "standard",
33 "title" => __( 'payplug_section_standard_payment_title', 'payplug' ),
34 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/standard.svg' ),
35 "checked" => true,
36 "hide" => true,
37 "available_test_mode" => true,
38 "descriptions" => [
39 "live" => [
40 "description" => __( 'payplug_section_standard_payment_description', 'payplug' ),
41 "advanced_options" => __( 'payplug_section_standard_payment_advanced_options_label', 'payplug' ),
42 ],
43 "sandbox" => [
44 "description" => __( 'payplug_section_standard_payment_description', 'payplug' ),
45 "advanced_options" => __( 'payplug_section_standard_payment_advanced_options_label', 'payplug' ),
46 ]
47 ],
48 "options" => [
49 $this->title_field(),
50 $this->description_field(),
51 $this->embeded_option($method),
52 $this->standard_warning_message(),
53 $this->one_click_option()
54 ],
55 ];
56 }
57
58 private function description_field(){
59 $description = get_option( 'woocommerce_payplug_settings', [] )['description'];
60 return array(
61 "type" => "payment_option",
62 "sub_type" => "input",
63 "name" => "standard_payment_description",
64 "title" => __("payplug_standard_payment_description_title", "payplug"),
65 "value" => $description ?: null,
66 "descriptions" => [
67 "live" => [
68 "description" => __("payplug_standard_payment_description_description", "payplug"),
69 "placeholder" => __("payplug_standard_payment_description_placeholder", "payplug"),
70 ],
71 "sandbox" => [
72 "description" => __("payplug_standard_payment_description_description", "payplug"),
73 "placeholder" => __("payplug_standard_payment_description_placeholder", "payplug"),
74 ]
75 ]
76 );
77 }
78 private function title_field(){
79 $title = get_option( 'woocommerce_payplug_settings', [] )['title'];
80 return array(
81 "type" => "payment_option",
82 "sub_type" => "input",
83 "name" => "standard_payment_title",
84 "title" => __("payplug_standard_payment_title_title", "payplug"),
85 "value" => !empty($title) ? $title : __("payplug_standard_payment_title_placeholder", "payplug"),
86 "descriptions" => [
87 "live" => [
88 "description" => __("payplug_standard_payment_title_description", "payplug"),
89 "placeholder" => __("payplug_standard_payment_title_placeholder", "payplug"),
90 ],
91 "sandbox" => [
92 "description" => __("payplug_standard_payment_title_description", "payplug"),
93 "placeholder" => __("payplug_standard_payment_title_placeholder", "payplug"),
94 ]
95 ],
96 );
97 }
98
99 /**
100 * @param $active
101 *
102 * @return array|bool[]|false[]
103 */
104 public function standard_warning_message( $active = null ) {
105 $arr = [
106 "type" => "warning_message",
107 "sub_type" => "warning",
108 "name" => "warning_message",
109 "payment_method" => "integrated",
110 "description" => __( 'payplug_section_standard_ip_warning', 'payplug' )
111 ];
112
113 return $arr;
114 }
115
116 /**
117 * @param $active
118 *
119 * @return array|bool[]|false[]
120 */
121 public function one_click_option( $active = null ) {
122 $option = [
123 "type" => "payment_option",
124 "sub_type" => "switch",
125 "name" => "one_click",
126 "title" => __( 'payplug_section_one_click_option_title', 'payplug' ),
127 "descriptions" => [
128 "live" => [
129 "description" => __( 'payplug_section_one_click_option_description', 'payplug' ),
130 "link_know_more" => Component::link(
131 __( 'payplug_know_more_label', 'payplug' ),
132 "https://support.payplug.com/hc/en-gb/articles/4409698334098",
133 "_blank" ),
134 ],
135 "sandbox" => [
136 "description" => __( 'payplug_section_one_click_option_description', 'payplug' ),
137 "link_know_more" => Component::link(
138 __( 'payplug_know_more_label', 'payplug' ),
139 "https://support.payplug.com/hc/en-gb/articles/4409698334098",
140 "_blank" ),
141 ]
142 ]
143 ];
144 if (isset(get_option( 'woocommerce_payplug_settings', [] )['oneclick'])) {
145 if (get_option( 'woocommerce_payplug_settings', [] )['oneclick'] != 'no') {
146 $option = $option + ["checked" => true];
147 } elseif (get_option( 'woocommerce_payplug_settings', [] )['oneclick'] == 'no') {
148 $option = $option + ["checked" => false];
149 }
150
151 }
152 return $option;
153 }
154
155 /**
156 * @return array
157 */
158 public function embeded_option($method) {
159
160 $options = Array(
161 array(
162 "name" => "payplug_embedded",
163 "label" => __( 'payplug_section_standard_payment_option_integrated_label', 'payplug' ),
164 "value" => "integrated",
165 "checked" => $method['integrated']
166 ),
167 array(
168 "name" => "payplug_embedded",
169 "label" => __( 'payplug_section_standard_payment_option_popup_label', 'payplug' ),
170 "value" => "popup",
171 "checked" => $method['popup']
172 ),
173 array(
174 "name" => "payplug_embedded",
175 "label" => __( 'payplug_section_standard_payment_option_redirected_label', 'payplug' ),
176 "value" => "redirect",
177 "checked" => $method['redirect']
178 )
179 );
180
181 return [
182 "type" => "payment_option",
183 "sub_type" => "IOptions",
184 "name" => "embeded",
185 "title" => __( 'payplug_section_standard_payment_option_title', 'payplug' ),
186 "descriptions" => [
187 "live" => [
188 "description_redirect" => __( 'payplug_section_standard_payment_redirected_description', 'payplug' ),
189 "description_popup" => __( 'payplug_section_standard_payment_popup_description', 'payplug' ),
190 "description_integrated" => __( 'payplug_section_standard_payment_integrated_description', 'payplug' ),
191 "link_know_more" => Component::link(
192 __( 'payplug_know_more_label', 'payplug' ),
193 __( 'payplug_embeded_option_url', 'payplug' ),
194 "_blank" ),
195 ],
196 "sandbox" => [
197 "description_redirect" => __( 'payplug_section_standard_payment_redirected_description', 'payplug' ),
198 "description_popup" => __( 'payplug_section_standard_payment_popup_description', 'payplug' ),
199 "description_integrated" => __( 'payplug_section_standard_payment_integrated_description', 'payplug' ),
200 "link_know_more" => Component::link(
201 __( 'payplug_know_more_label', 'payplug' ),
202 __( 'payplug_embeded_option_url', 'payplug' ),
203 "_blank" ),
204 ]
205 ],
206 "options" => $options
207 ];
208 }
209
210 /**
211 * @param $active
212 *
213 * @return array
214 */
215 public static function payment_method_applepay( $active = false ) {
216 return [
217 "type" => "payment_method",
218 "name" => "applepay",
219 "title" => __( 'payplug_section_applepay_payment_title', 'payplug' ),
220 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/applepay.svg' ),
221 "checked" => $active,
222 "available_test_mode" => false,
223 "descriptions" => [
224 "live" => [
225 "description" => __( 'payplug_section_applepay_payment_description', 'payplug' ),
226 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_applepay_more_url', 'payplug' ), "_blank"),
227 ],
228 "sandbox" => [
229 "description" => __( 'payplug_applepay_unavailable_testmode_description', 'payplug' ),
230 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_applepay_more_url', 'payplug' ), "_blank"),
231 ]
232 ],
233 ];
234 }
235
236 /**
237 * @param $active
238 *
239 * @return array
240 */
241 public static function payment_method_bancontact( $active = false ) {
242 return [
243 "type" => "payment_method",
244 "name" => "bancontact",
245 "title" => __( 'payplug_section_bancontact_payment_title', 'payplug' ),
246 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/bancontact.svg' ),
247 "checked" => $active,
248 "available_test_mode" => false,
249 "descriptions" => [
250 "live" => [
251 "description" => __( 'payplug_section_bancontact_payment_description', 'payplug' ),
252 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_bancontact_more_url', 'payplug' ), "_blank"),
253 ],
254 "sandbox" => [
255 "description" => __( 'payplug_bancontact_unavailable_testmode_description', 'payplug' ),
256 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_bancontact_more_url', 'payplug' ), "_blank"),
257 ]
258 ],
259 ];
260 }
261
262 /**
263 * @param $active
264 *
265 * @return array
266 */
267 public static function payment_method_amex( $active = false ) {
268 return [
269 "type" => "payment_method",
270 "name" => "american_express",
271 "title" => __( 'payplug_section_american_express_payment_title', 'payplug' ),
272 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/Amex_logo_color.svg' ),
273 "checked" => $active,
274 "available_test_mode" => false,
275 "descriptions" => [
276 "live" => [
277 "description" => __( 'payplug_section_american_express_payment_description', 'payplug' ),
278 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_amex_more_url', 'payplug' ), "_blank"),
279 ],
280 "sandbox" => [
281 "description" => __( 'payplug_amex_unavailable_testmode_description', 'payplug' ),
282 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_amex_more_url', 'payplug' ), "_blank"),
283 ]
284 ],
285 ];
286 }
287
288 /**
289 * @param $active
290 * @return array
291 */
292 public static function payment_method_satispay( $active = false ) {
293 return [
294 "type" => "payment_method",
295 "name" => "satispay",
296 "title" => __( 'payplug_satispay_activate', 'payplug' ),
297 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/satispay.svg' ),
298 "checked" => $active,
299 "available_test_mode" => false,
300 "descriptions" => [
301 "live" => [
302 "description" => __( 'payplug_section_satispay_payment_description', 'payplug' ),
303 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_satispay_more_url', 'payplug' ), "_blank"),
304 ],
305 "sandbox" => [
306 "description" => __( 'payplug_satispay_unavailable_testmode_description', 'payplug' ),
307 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_satispay_more_url', 'payplug' ), "_blank"),
308 ]
309 ],
310 "options" => [
311 self::get_allowed_countries("satispay")
312 ],
313 ];
314 }
315
316 /**
317 * @param $active
318 * @return array
319 */
320 public static function payment_method_mybank( $active = false ) {
321 return [
322 "type" => "payment_method",
323 "name" => "mybank",
324 "title" => __( 'payplug_mybank_activate', 'payplug' ),
325 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/mybank.svg' ),
326 "checked" => $active,
327 "available_test_mode" => false,
328 "descriptions" => [
329 "live" => [
330 "description" => __( 'payplug_section_mybank_payment_description', 'payplug' ),
331 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_mybank_more_url', 'payplug' ), "_blank"),
332 ],
333 "sandbox" => [
334 "description" => __( 'payplug_mybank_unavailable_testmode_description', 'payplug' ),
335 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_mybank_more_url', 'payplug' ), "_blank"),
336 ]
337 ],
338 "options" => [
339 self::get_allowed_countries("mybank")
340 ],
341 ];
342 }
343
344 /**
345 * @param $active
346 * @return array
347 */
348 public static function payment_method_sofort( $active = false ) {
349 return [
350 "type" => "payment_method",
351 "name" => "sofort",
352 "title" => __( 'payplug_sofort_activate', 'payplug' ),
353 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/sofort.svg' ),
354 "checked" => $active,
355 "available_test_mode" => false,
356 "descriptions" => [
357 "live" => [
358 "description" => __( 'payplug_section_sofort_payment_description', 'payplug' ),
359 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_sofort_more_url', 'payplug' ), "_blank"),
360 ],
361 "sandbox" => [
362 "description" => __( 'payplug_sofort_unavailable_testmode_description', 'payplug' ),
363 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_sofort_more_url', 'payplug' ), "_blank"),
364 ]
365 ],
366 "options" => [
367 self::get_allowed_countries("sofort")
368 ],
369 ];
370 }
371
372 /**
373 * @param $active
374 * @return array
375 */
376 public static function payment_method_giropay( $active = false ) {
377 return [
378 "type" => "payment_method",
379 "name" => "giropay",
380 "title" => __( 'payplug_giropay_activate', 'payplug' ),
381 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/giropay.svg' ),
382 "checked" => $active,
383 "available_test_mode" => false,
384 "descriptions" => [
385 "live" => [
386 "description" => __( 'payplug_section_giropay_payment_description', 'payplug' ),
387 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_giropay_more_url', 'payplug' ), "_blank"),
388 ],
389 "sandbox" => [
390 "description" => __( 'payplug_giropay_unavailable_testmode_description', 'payplug' ),
391 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_giropay_more_url', 'payplug' ), "_blank"),
392 ]
393 ],
394 "options" => [
395 self::get_allowed_countries("giropay")
396 ],
397 ];
398 }
399
400 /**
401 * @param $active
402 * @return array
403 */
404 public static function payment_method_ideal( $active = false ) {
405 return [
406 "type" => "payment_method",
407 "name" => "ideal",
408 "title" => __( 'payplug_ideal_activate', 'payplug' ),
409 "image" => esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/ideal.svg' ),
410 "checked" => $active,
411 "available_test_mode" => false,
412 "descriptions" => [
413 "live" => [
414 "description" => __( 'payplug_section_ideal_payment_description', 'payplug' ),
415 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_ideal_more_url', 'payplug' ), "_blank"),
416 ],
417 "sandbox" => [
418 "description" => __( 'payplug_ideal_unavailable_testmode_description', 'payplug' ),
419 "link_know_more" => Component::link(__( 'payplug_know_more_label', 'payplug' ), __( 'payplug_ideal_more_url', 'payplug' ), "_blank"),
420 ]
421 ],
422 "options" => [
423 self::get_allowed_countries("ideal")
424 ],
425 ];
426 }
427
428 /**
429 * @param $id
430 * @return false|string
431 */
432 private static function get_allowed_countries($id){
433 $account = PayplugWoocommerceHelper::get_account_data_from_options();
434
435 if(empty($account['payment_methods'][$id])){
436 return false;
437 }
438
439 $arr = [
440 "type" => "info_message",
441 "sub_type" => "text",
442 "name" => "allowed_countries",
443 "payment_method" => $id,
444 "description" => trim(sprintf(__("payplug_payment_gateways_country_permissions", "payplug"), ucfirst($id))) . implode(", ", $account['payment_methods'][$id]['allowed_countries']) . "."
445 ];
446
447 return $arr;
448
449 }
450
451
452 }
453