PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | stripe/helpers/FrmStrpLiteConnectHelper.php +36 -40 6.31 → trunk View file →
@@ -262,9 +262,9 @@
262 262 */
263 263 private static function handle_disconnect() {
264 264 self::disconnect();
265 265 self::reset_stripe_connect_integration();
266 - self::maybe_unschedule_crons();
266 + FrmTransLiteAppHelper::trigger_gateway_disconnected_hook( 'stripe', self::get_mode_value_from_post() );
267 267 wp_send_json_success();
268 268 }
269 269
270 270 /**
@@ -283,38 +283,16 @@
283 283 /**
284 284 * @return false|object
285 285 */
286 286 private static function disconnect() {
287 - $additional_body = array(
288 - 'frm_strp_connect_mode' => self::get_mode_value_from_post(),
289 - );
287 + $mode = self::get_mode_value_from_post();
288 + $additional_body = self::get_body_for_mode( $mode );
290 289 return self::post_with_authenticated_body( 'disconnect', $additional_body );
291 290 }
292 291
293 292 /**
294 - * Stop the payment cron once all Stripe connections have been disconnected.
295 - *
296 293 * @since 6.5
297 294 *
298 - * @return void
299 - */
300 - private static function maybe_unschedule_crons() {
301 - if ( self::at_least_one_mode_is_setup() ) {
302 - // Don't unschedule if a mode is still on.
303 - return;
304 - }
305 -
306 - $event = 'frm_payment_cron';
307 - $timestamp = wp_next_scheduled( $event );
308 -
309 - if ( false !== $timestamp ) {
310 - wp_unschedule_event( $timestamp, $event );
311 - }
312 - }
313 -
314 - /**
315 - * @since 6.5
316 - *
317 295 * @return bool
318 296 */
319 297 public static function at_least_one_mode_is_setup() {
320 298 return self::stripe_connect_is_setup( 'test' ) || self::stripe_connect_is_setup( 'live' );
@@ -323,16 +301,15 @@
323 301 /**
324 302 * @return void
325 303 */
326 304 private static function handle_reauth() {
327 - $additional_body = array(
328 - 'frm_strp_connect_mode' => self::get_mode_value_from_post(),
329 - );
305 + $mode = self::get_mode_value_from_post();
306 + $additional_body = self::get_body_for_mode( $mode );
330 307 $data = self::post_with_authenticated_body( 'reauth', $additional_body );
331 308
332 309 if ( false === $data ) {
333 310 // Check account status.
334 - if ( self::check_server_for_connected_account_status() ) {
311 + if ( self::check_server_for_connected_account_status( $mode ) ) {
335 312 wp_send_json_success();
336 313 }
337 314
338 315 wp_send_json_error();
@@ -347,13 +324,26 @@
347 324 /**
348 325 * @return array
349 326 */
350 327 private static function get_standard_authenticated_body() {
351 - $mode = self::get_mode_value_from_post();
328 + return self::get_body_for_mode( FrmStrpLiteAppHelper::active_mode() );
329 + }
330 +
331 + /**
332 + * Get the standard body with account id, mode, and passwords to send to the connect server.
333 + *
334 + * @since 6.32.1
335 + *
336 + * @param string $mode 'live' or 'test'.
337 + *
338 + * @return array
339 + */
340 + private static function get_body_for_mode( $mode ) {
352 341 return array(
353 - 'account_id' => get_option( self::get_account_id_option_name( $mode ) ),
354 - 'server_password' => get_option( self::get_server_side_token_option_name( $mode ) ),
355 - 'client_password' => get_option( self::get_client_side_token_option_name( $mode ) ),
342 + 'account_id' => get_option( self::get_account_id_option_name( $mode ) ),
343 + 'server_password' => get_option( self::get_server_side_token_option_name( $mode ) ),
344 + 'client_password' => get_option( self::get_client_side_token_option_name( $mode ) ),
345 + 'frm_strp_connect_mode' => $mode,
356 346 );
357 347 }
358 348
359 349 private static function redirect() {
@@ -461,20 +451,26 @@
461 451 return $data->redirect_url;
462 452 }
463 453
464 454 /**
455 + * @param string $mode
456 + *
465 457 * @return bool true if our account is onboarded
466 458 */
467 - public static function check_server_for_connected_account_status() {
468 - $mode = FrmAppHelper::get_param( 'mode', '', 'get', 'sanitize_text_field' );
459 + public static function check_server_for_connected_account_status( $mode = 'check_get' ) {
460 + if ( 'check_get' === $mode ) {
461 + $mode = FrmAppHelper::get_param( 'mode', '', 'get', 'sanitize_text_field' );
469 462
470 - if ( 'live' !== $mode ) {
471 - $mode = 'test';
463 + if ( 'live' !== $mode ) {
464 + $mode = 'test';
465 + }
472 466 }
473 467
474 - $additional_body = array(
475 - 'frm_strp_connect_mode' => $mode,
476 - );
468 + if ( self::stripe_connect_is_setup( $mode ) ) {
469 + return false;
470 + }
471 +
472 + $additional_body = self::get_body_for_mode( $mode );
477 473 $data = self::post_with_authenticated_body( 'account_status', $additional_body );
478 474 $success = false !== $data && ! empty( $data->details_submitted );
479 475
480 476 if ( $success ) {