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 -44 6.30 → trunk View file →
@@ -153,12 +153,8 @@
153 153 $body = array_merge( $body, $additional_body );
154 154 $url = self::get_url_to_connect_server();
155 155 $headers = self::build_headers_for_post();
156 156
157 - if ( ! $headers ) {
158 - return 'Unable to build headers for post. Is your pro license configured properly?';
159 - }
160 -
161 157 // (Seconds) default timeout is 5. we want a bit more time to work with.
162 158 $timeout = 45;
163 159
164 160 self::try_to_extend_server_timeout( $timeout );
@@ -266,9 +262,9 @@
266 262 */
267 263 private static function handle_disconnect() {
268 264 self::disconnect();
269 265 self::reset_stripe_connect_integration();
270 - self::maybe_unschedule_crons();
266 + FrmTransLiteAppHelper::trigger_gateway_disconnected_hook( 'stripe', self::get_mode_value_from_post() );
271 267 wp_send_json_success();
272 268 }
273 269
274 270 /**
@@ -287,38 +283,16 @@
287 283 /**
288 284 * @return false|object
289 285 */
290 286 private static function disconnect() {
291 - $additional_body = array(
292 - 'frm_strp_connect_mode' => self::get_mode_value_from_post(),
293 - );
287 + $mode = self::get_mode_value_from_post();
288 + $additional_body = self::get_body_for_mode( $mode );
294 289 return self::post_with_authenticated_body( 'disconnect', $additional_body );
295 290 }
296 291
297 292 /**
298 - * Stop the payment cron once all Stripe connections have been disconnected.
299 - *
300 293 * @since 6.5
301 294 *
302 - * @return void
303 - */
304 - private static function maybe_unschedule_crons() {
305 - if ( self::at_least_one_mode_is_setup() ) {
306 - // Don't unschedule if a mode is still on.
307 - return;
308 - }
309 -
310 - $event = 'frm_payment_cron';
311 - $timestamp = wp_next_scheduled( $event );
312 -
313 - if ( false !== $timestamp ) {
314 - wp_unschedule_event( $timestamp, $event );
315 - }
316 - }
317 -
318 - /**
319 - * @since 6.5
320 - *
321 295 * @return bool
322 296 */
323 297 public static function at_least_one_mode_is_setup() {
324 298 return self::stripe_connect_is_setup( 'test' ) || self::stripe_connect_is_setup( 'live' );
@@ -327,16 +301,15 @@
327 301 /**
328 302 * @return void
329 303 */
330 304 private static function handle_reauth() {
331 - $additional_body = array(
332 - 'frm_strp_connect_mode' => self::get_mode_value_from_post(),
333 - );
305 + $mode = self::get_mode_value_from_post();
306 + $additional_body = self::get_body_for_mode( $mode );
334 307 $data = self::post_with_authenticated_body( 'reauth', $additional_body );
335 308
336 309 if ( false === $data ) {
337 310 // Check account status.
338 - if ( self::check_server_for_connected_account_status() ) {
311 + if ( self::check_server_for_connected_account_status( $mode ) ) {
339 312 wp_send_json_success();
340 313 }
341 314
342 315 wp_send_json_error();
@@ -351,13 +324,26 @@
351 324 /**
352 325 * @return array
353 326 */
354 327 private static function get_standard_authenticated_body() {
355 - $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 ) {
356 341 return array(
357 - 'account_id' => get_option( self::get_account_id_option_name( $mode ) ),
358 - 'server_password' => get_option( self::get_server_side_token_option_name( $mode ) ),
359 - '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,
360 346 );
361 347 }
362 348
363 349 private static function redirect() {
@@ -465,20 +451,26 @@
465 451 return $data->redirect_url;
466 452 }
467 453
468 454 /**
455 + * @param string $mode
456 + *
469 457 * @return bool true if our account is onboarded
470 458 */
471 - public static function check_server_for_connected_account_status() {
472 - $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' );
473 462
474 - if ( 'live' !== $mode ) {
475 - $mode = 'test';
463 + if ( 'live' !== $mode ) {
464 + $mode = 'test';
465 + }
476 466 }
477 467
478 - $additional_body = array(
479 - 'frm_strp_connect_mode' => $mode,
480 - );
468 + if ( self::stripe_connect_is_setup( $mode ) ) {
469 + return false;
470 + }
471 +
472 + $additional_body = self::get_body_for_mode( $mode );
481 473 $data = self::post_with_authenticated_body( 'account_status', $additional_body );
482 474 $success = false !== $data && ! empty( $data->details_submitted );
483 475
484 476 if ( $success ) {