| 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 |
public static function oney($value) { |
| 93 |
|
| 94 |
if ($value == 1){ |
| 95 |
return "yes"; |
| 96 |
} |
| 97 |
|
| 98 |
return "no"; |
| 99 |
|
| 100 |
http_response_code(400); |
| 101 |
wp_send_json_error(['error' => 'oney is missing']); |
| 102 |
} |
| 103 |
|
| 104 |
public static function oney_type($value) { |
| 105 |
if (isset($value) && !empty($value)) { |
| 106 |
if (in_array($value, ['with_fees', 'without_fees'])) { |
| 107 |
return true; |
| 108 |
} |
| 109 |
} |
| 110 |
return false; |
| 111 |
} |
| 112 |
|
| 113 |
public static function oney_thresholds($min, $max) { |
| 114 |
|
| 115 |
$rmin = 100; |
| 116 |
$rmax = 3000; |
| 117 |
if( $min > 99 && $min<$max){ |
| 118 |
$rmin = $min; |
| 119 |
} |
| 120 |
|
| 121 |
if( $max <= 3000 && $max>$min ){ |
| 122 |
$rmax = $max; |
| 123 |
} |
| 124 |
|
| 125 |
return array("min"=>$rmin, "max"=>$rmax); |
| 126 |
} |
| 127 |
|
| 128 |
public static function oney_product_animation($status){ |
| 129 |
|
| 130 |
if($status){ |
| 131 |
return "yes"; |
| 132 |
}else{ |
| 133 |
return "no"; |
| 134 |
} |
| 135 |
|
| 136 |
} |
| 137 |
} |
| 138 |
|