| @@ -17,9 +17,8 @@ | ||
| 17 | 17 | /** |
| 18 | 18 | * Install required tables. |
| 19 | 19 | * |
| 20 | 20 | * @param mixed $old_db_version |
| 21 | - * | |
| 22 | 21 | * @return void |
| 23 | 22 | */ |
| 24 | 23 | public static function install( $old_db_version = false ) { |
| 25 | 24 | FrmTransLiteAppController::install( $old_db_version ); |
| @@ -44,9 +43,8 @@ | ||
| 44 | 43 | ); |
| 45 | 44 | |
| 46 | 45 | $modes = array( 'test', 'live' ); |
| 47 | 46 | $option_name_keys = array( 'account_id', 'client_password', 'server_password', 'details_submitted' ); |
| 48 | - | |
| 49 | 47 | foreach ( $modes as $mode ) { |
| 50 | 48 | foreach ( $option_name_keys as $key ) { |
| 51 | 49 | $options_to_delete[] = 'frm_strp_connect_' . $key . '_' . $mode; |
| 52 | 50 | } |
| @@ -57,16 +55,20 @@ | ||
| 57 | 55 | } |
| 58 | 56 | } |
| 59 | 57 | |
| 60 | 58 | /** |
| 61 | - * Gets payments settings URL. | |
| 59 | + * Redirect to Stripe settings when payments are not yet installed | |
| 60 | + * and the payments page is accessed by its URL. | |
| 62 | 61 | * |
| 63 | - * @since 6.30 | |
| 64 | - * | |
| 65 | - * @return string | |
| 62 | + * @return void | |
| 66 | 63 | */ |
| 67 | - public static function get_payments_settings_url() { | |
| 68 | - return admin_url( 'admin.php?page=formidable-settings&t=stripe_settings' ); | |
| 64 | + public static function maybe_redirect_to_stripe_settings() { | |
| 65 | + if ( ! FrmAppHelper::is_admin_page( 'formidable-payments' ) || FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 66 | + return; | |
| 67 | + } | |
| 68 | + | |
| 69 | + wp_safe_redirect( admin_url( 'admin.php?page=formidable-settings&t=stripe_settings' ) ); | |
| 70 | + die(); | |
| 69 | 71 | } |
| 70 | 72 | |
| 71 | 73 | /** |
| 72 | 74 | * Add the gateway for compatibility with the Payments submodule. |
| @@ -72,9 +74,8 @@ | ||
| 72 | 74 | * Add the gateway for compatibility with the Payments submodule. |
| 73 | 75 | * This adds the Stripe checkbox option to the list of gateways. |
| 74 | 76 | * |
| 75 | 77 | * @param array $gateways |
| 76 | - * | |
| 77 | 78 | * @return array |
| 78 | 79 | */ |
| 79 | 80 | public static function add_gateway( $gateways ) { |
| 80 | 81 | $gateways['stripe'] = array( |
| @@ -98,9 +99,8 @@ | ||
| 98 | 99 | * @since 6.5.1 |
| 99 | 100 | * |
| 100 | 101 | * @param array $errors Errors data. Is empty array if no errors found. |
| 101 | 102 | * @param array $params Form params. See {@FrmForm::get_params()}. |
| 102 | - * | |
| 103 | 103 | * @return array |
| 104 | 104 | */ |
| 105 | 105 | public static function maybe_add_payment_error( $errors, $params ) { |
| 106 | 106 | if ( intval( $params['posted_form_id'] ) !== intval( $params['form_id'] ) ) { |
| @@ -116,14 +116,12 @@ | ||
| 116 | 116 | * @since 6.5.1 |
| 117 | 117 | * |
| 118 | 118 | * @param array $errors |
| 119 | 119 | * @param int $form_id |
| 120 | - * | |
| 121 | 120 | * @return array |
| 122 | 121 | */ |
| 123 | 122 | private static function maybe_add_payment_error_on_redirect( $errors, $form_id ) { |
| 124 | 123 | $details = FrmStrpLiteUrlParamHelper::get_details_for_form( $form_id ); |
| 125 | - | |
| 126 | 124 | if ( ! is_array( $details ) ) { |
| 127 | 125 | return $errors; |
| 128 | 126 | } |
| 129 | 127 | |
| @@ -143,15 +141,13 @@ | ||
| 143 | 141 | 'type' => 'credit_card', |
| 144 | 142 | 'form_id' => $entry->form_id, |
| 145 | 143 | ) |
| 146 | 144 | ); |
| 147 | - | |
| 148 | 145 | if ( ! $cc_field_id ) { |
| 149 | 146 | return $errors; |
| 150 | 147 | } |
| 151 | 148 | |
| 152 | - $is_setup_intent = str_starts_with( $intent->id, 'seti_' ); | |
| 153 | - | |
| 149 | + $is_setup_intent = 0 === strpos( $intent->id, 'seti_' ); | |
| 154 | 150 | if ( $is_setup_intent ) { |
| 155 | 151 | $errors[ 'field' . $cc_field_id ] = is_object( $intent->last_setup_error ) ? $intent->last_setup_error->message : ''; |
| 156 | 152 | } else { |
| 157 | 153 | $errors[ 'field' . $cc_field_id ] = is_object( $intent->last_payment_error ) ? $intent->last_payment_error->message : ''; |
| @@ -178,9 +174,8 @@ | ||
| 178 | 174 | * |
| 179 | 175 | * @param int $form_id |
| 180 | 176 | * @param int $entry_id |
| 181 | 177 | * @param array<string,string> $errors |
| 182 | - * | |
| 183 | 178 | * @return void |
| 184 | 179 | */ |
| 185 | 180 | private static function setup_form_after_payment_error( $form_id, $entry_id, $errors ) { |
| 186 | 181 | $form = FrmForm::getOne( $form_id ); |
| @@ -206,9 +201,8 @@ | ||
| 206 | 201 | * Set the entry back to draft status after error. |
| 207 | 202 | * |
| 208 | 203 | * @param string $html |
| 209 | 204 | * @param int $entry_id |
| 210 | - * | |
| 211 | 205 | * @return string |
| 212 | 206 | */ |
| 213 | 207 | function ( $html ) use ( $entry_id ) { |
| 214 | 208 | global $wpdb; |
| @@ -224,9 +218,8 @@ | ||
| 224 | 218 | * @since 2.08 |
| 225 | 219 | * |
| 226 | 220 | * @param array $values Entry edit values. |
| 227 | 221 | * @param object $field Field object. |
| 228 | - * | |
| 229 | 222 | * @return array |
| 230 | 223 | */ |
| 231 | 224 | public static function maybe_delete_pay_entry( $values, $field ) { |
| 232 | 225 | if ( self::$delete_pay_entry ) { |
| @@ -233,18 +226,6 @@ | ||
| 233 | 226 | self::$delete_pay_entry = false; |
| 234 | 227 | return FrmTransLiteActionsController::fill_entry_from_previous( $values, $field ); |
| 235 | 228 | } |
| 236 | 229 | return $values; |
| 237 | - } | |
| 238 | - | |
| 239 | - /** | |
| 240 | - * Redirect to Stripe settings when payments are not yet installed | |
| 241 | - * and the payments page is accessed by its URL. | |
| 242 | - * | |
| 243 | - * @deprecated 6.33 | |
| 244 | - * | |
| 245 | - * @return void | |
| 246 | - */ | |
| 247 | - public static function maybe_redirect_to_stripe_settings() { | |
| 248 | - _deprecated_function( __METHOD__, '6.33' ); | |
| 249 | 230 | } |
| 250 | 231 | } |