PluginProbe
PayPlug for WooCommerce (Official) / 2.10.0
PayPlug for WooCommerce (Official) v2.10.0
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 / Validator.php

Validator.php in PayPlug for WooCommerce (Official) 2.10.0, at src/Admin/Validator.php

176 lines 3.0 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;
4
5 class Validator {
6
7 public static function enabled($value) {
8
9 if ($value == 1){
10 return "yes";
11 }
12
13 if ($value == 0){
14 return "no";
15 }
16
17 http_response_code(400);
18 wp_send_json_error(['error' => 'enabled is missing']);
19 }
20
21 public static function mode($value) {
22 if ($value == 1){
23 return "no";
24 }
25
26 if ($value == 0){
27 return "yes";
28 }
29
30 http_response_code(400);
31 wp_send_json_error(['error' => 'mode is missing']);
32 }
33
34 public static function payment_method($value) {
35
36 if ( !empty($value) && in_array($value, ['redirect', 'popup', 'integrated']) ) {
37 return true;
38 }
39
40 http_response_code(400);
41 wp_send_json_error(['error' => 'payment_method is missing']);
42 }
43
44 public static function debug($value) {
45
46 if ($value == 1){
47 return "yes";
48 }
49
50 if ($value == 0){
51 return "no";
52 }
53
54 http_response_code(400);
55 wp_send_json_error(['error' => 'mode is missing']);
56
57 return "no";
58 }
59
60 public static function oneclick($value) {
61
62 if ($value == 1){
63 return "yes";
64 }
65
66 if ($value == 0){
67 return "no";
68 }
69
70 http_response_code(400);
71 wp_send_json_error(['error' => 'oneclick is missing']);
72 }
73
74 public static function genericPaymentGateway($value, $payment, $test_mode) {
75
76 if($test_mode){
77 return "no";
78 }
79
80 if ($value == 1 || $value){
81 return "yes";
82 }
83
84 return "no";
85 }
86
87 /**
88 * prevent saving when neither cart and checkout is enabled
89 *
90 * @param $cart
91 * @param $checkout
92 * @return true
93 */
94 public static function applePayPaymentGatewayOptions($apple_pay, $cart, $checkout, $carriers){
95
96 if($apple_pay === "no"){
97 return true;
98 }
99
100 if( $cart === "no" && $checkout === "no" ){
101 http_response_code(400);
102
103 $arr = [
104 "msg"=>__( 'applepay_cart_checkout_option_validation', 'payplug' ),
105 "class"=>"error",
106 "title"=>__( 'applepay_cart_checkout_option_validation_title', 'payplug' ),
107 "close"=> __( 'payplug_ok', 'payplug' )
108 ];
109
110 wp_send_json_error($arr);
111 }
112
113 if( $cart === "yes" && empty($carriers)){
114 http_response_code(400);
115
116 $arr = [
117 "msg"=>__( 'applepay_cart_carrier_enabled', 'payplug' ),
118 "class"=>"error",
119 "title"=>__( 'applepay_cart_checkout_option_validation_title', 'payplug' ),
120 "close"=> __( 'payplug_ok', 'payplug' )
121 ];
122
123 wp_send_json_error($arr);
124 }
125
126 return true;
127
128 }
129
130 public static function oney($value) {
131
132 if ($value == 1){
133 return "yes";
134 }
135
136 return "no";
137
138 http_response_code(400);
139 wp_send_json_error(['error' => 'oney is missing']);
140 }
141
142 public static function oney_type($value) {
143 if (isset($value) && !empty($value)) {
144 if (in_array($value, ['with_fees', 'without_fees'])) {
145 return true;
146 }
147 }
148 return false;
149 }
150
151 public static function oney_thresholds($min, $max) {
152
153 $rmin = 100;
154 $rmax = 3000;
155 if( $min > 99 && $min<$max){
156 $rmin = $min;
157 }
158
159 if( $max <= 3000 && $max>$min ){
160 $rmax = $max;
161 }
162
163 return array("min"=>$rmin, "max"=>$rmax);
164 }
165
166 public static function oney_product_animation($status){
167
168 if($status){
169 return "yes";
170 }else{
171 return "no";
172 }
173
174 }
175 }
176