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