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