| @@ -166,8 +166,45 @@ | ||
| 166 | 166 | |
| 167 | 167 | return ['min' => $rmin, 'max' => $rmax]; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | + /** | |
| 171 | + * Reject Scalapay min/max amounts (cents) that are inconsistent, or that widen beyond | |
| 172 | + * what the PayPlug account currently authorizes (also in cents). The merchant can only | |
| 173 | + * narrow the account's range, never widen it. | |
| 174 | + * | |
| 175 | + * @param $min | |
| 176 | + * @param $max | |
| 177 | + * @param $account_min | |
| 178 | + * @param $account_max | |
| 179 | + * | |
| 180 | + * @return array{min: int, max: int} | |
| 181 | + */ | |
| 182 | + public static function scalapay_thresholds($min, $max, $account_min, $account_max) | |
| 183 | + { | |
| 184 | + if ($min > $max) { | |
| 185 | + http_response_code(200); | |
| 186 | + wp_send_json_error([ | |
| 187 | + 'msg' => __('payplug_thresholds_scalapay_error_mintext_msg', 'payplug'), | |
| 188 | + 'class' => 'error', | |
| 189 | + 'title' => __('payplug_thresholds_scalapay_error_title', 'payplug'), | |
| 190 | + 'close' => __('payplug_ok', 'payplug'), | |
| 191 | + ]); | |
| 192 | + } | |
| 193 | + | |
| 194 | + if ($min < $account_min || $max > $account_max) { | |
| 195 | + http_response_code(200); | |
| 196 | + wp_send_json_error([ | |
| 197 | + 'msg' => __('payplug_thresholds_scalapay_error_msg', 'payplug'), | |
| 198 | + 'class' => 'error', | |
| 199 | + 'title' => __('payplug_thresholds_scalapay_error_title', 'payplug'), | |
| 200 | + 'close' => __('payplug_ok', 'payplug'), | |
| 201 | + ]); | |
| 202 | + } | |
| 203 | + | |
| 204 | + return ['min' => $min, 'max' => $max]; | |
| 205 | + } | |
| 206 | + | |
| 170 | 207 | public static function oney_product_animation($status) |
| 171 | 208 | { |
| 172 | 209 | if ($status) { |
| 173 | 210 | return true; |