PluginProbe
PayPlug for WooCommerce (Official) / 2.8.2
PayPlug for WooCommerce (Official) v2.8.2
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.8.2, at src/Admin/Validator.php

181 lines 3.1 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){
81 return "yes";
82 }
83
84 if ($value == 0){
85 return "no";
86 }
87
88 http_response_code(400);
89 wp_send_json_error(['error' => $payment . ' is missing']);
90 }
91
92 /**
93 * prevent saving when neither cart and checkout is enabled
94 *
95 * @param $cart
96 * @param $checkout
97 * @return true
98 */
99 public static function applePayPaymentGatewayOptions($apple_pay, $cart, $checkout, $carriers){
100
101 if($apple_pay === "no"){
102 return true;
103 }
104
105 if(!$cart && !$checkout){
106 http_response_code(400);
107
108 $arr = [
109 "msg"=>__( 'applepay_cart_checkout_option_validation', 'payplug' ),
110 "class"=>"error",
111 "title"=>__( 'applepay_cart_checkout_option_validation_title', 'payplug' ),
112 "close"=> __( 'payplug_ok', 'payplug' )
113 ];
114
115 wp_send_json_error($arr);
116 }
117
118 if($cart && empty($carriers)){
119 http_response_code(400);
120
121 $arr = [
122 "msg"=>__( 'applepay_cart_carrier_enabled', 'payplug' ),
123 "class"=>"error",
124 "title"=>__( 'applepay_cart_checkout_option_validation_title', 'payplug' ),
125 "close"=> __( 'payplug_ok', 'payplug' )
126 ];
127
128 wp_send_json_error($arr);
129 }
130
131 return true;
132
133 }
134
135 public static function oney($value) {
136
137 if ($value == 1){
138 return "yes";
139 }
140
141 return "no";
142
143 http_response_code(400);
144 wp_send_json_error(['error' => 'oney is missing']);
145 }
146
147 public static function oney_type($value) {
148 if (isset($value) && !empty($value)) {
149 if (in_array($value, ['with_fees', 'without_fees'])) {
150 return true;
151 }
152 }
153 return false;
154 }
155
156 public static function oney_thresholds($min, $max) {
157
158 $rmin = 100;
159 $rmax = 3000;
160 if( $min > 99 && $min<$max){
161 $rmin = $min;
162 }
163
164 if( $max <= 3000 && $max>$min ){
165 $rmax = $max;
166 }
167
168 return array("min"=>$rmin, "max"=>$rmax);
169 }
170
171 public static function oney_product_animation($status){
172
173 if($status){
174 return "yes";
175 }else{
176 return "no";
177 }
178
179 }
180 }
181