diff --git a/stripe/helpers/FrmStrpLiteConnectHelper.php b/stripe/helpers/FrmStrpLiteConnectHelper.php index 2e84c13019..53f085b63a 100644 --- a/stripe/helpers/FrmStrpLiteConnectHelper.php +++ b/stripe/helpers/FrmStrpLiteConnectHelper.php @@ -410,14 +410,19 @@ private static function set_stripe_details_as_submitted( $mode ) { * @return void */ private static function handle_oauth() { + $redirect_url = self::get_oauth_redirect_url(); + if ( is_array( $redirect_url ) ) { + wp_send_json_error( $redirect_url['error'] ); + } + $response_data = array( - 'redirect_url' => self::get_oauth_redirect_url(), + 'redirect_url' => $redirect_url, ); wp_send_json_success( $response_data ); } /** - * @return string|false + * @return array|string|false */ private static function get_oauth_redirect_url() { $mode = self::get_mode_value_from_post(); @@ -437,7 +442,7 @@ private static function get_oauth_redirect_url() { $data = self::post_to_connect_server( 'oauth_request', $additional_body ); if ( is_string( $data ) ) { - return false; + return array( 'error' => $data ); } if ( ! empty( $data->password ) ) { diff --git a/stripe/js/connect_settings.js b/stripe/js/connect_settings.js index 0df1b9d04e..edf71b1394 100644 --- a/stripe/js/connect_settings.js +++ b/stripe/js/connect_settings.js @@ -68,20 +68,24 @@ renderStripeConnectSettingsButton(); } }, - isTriggerInTestMode( trigger ) + isTriggerInTestMode( trigger ), + function( data ) { + alert( data ); + renderStripeConnectSettingsButton(); + } ); } - function strpSettingsAjaxRequest( action, success, testMode ) { + function strpSettingsAjaxRequest( action, success, testMode, error ) { var data = { action: action, testMode: testMode, nonce: frmGlobal.nonce }; - postAjax( data, success ); + postAjax( data, success, error ); } - function postAjax( data, success ) { + function postAjax( data, success, error ) { var xmlHttp, params; xmlHttp = new XMLHttpRequest(); @@ -103,6 +107,8 @@ response.data = {}; } success( response.data ); + } else if ( 'function' === typeof error ) { + error( response.data ); } } }