| @@ -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 | } |
| @@ -63,21 +61,12 @@ | ||
| 63 | 61 | * |
| 64 | 62 | * @return void |
| 65 | 63 | */ |
| 66 | 64 | public static function maybe_redirect_to_stripe_settings() { |
| 67 | - if ( ! FrmAppHelper::is_admin_page( 'formidable-payments' ) ) { | |
| 65 | + if ( ! FrmAppHelper::is_admin_page( 'formidable-payments' ) || FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 68 | 66 | return; |
| 69 | 67 | } |
| 70 | 68 | |
| 71 | - if ( class_exists( 'FrmPaymentsController' ) ) { | |
| 72 | - // Never redirect when someone is using the PayPal add-on. | |
| 73 | - return; | |
| 74 | - } | |
| 75 | - | |
| 76 | - if ( FrmTransLiteAppHelper::payments_table_exists() ) { | |
| 77 | - return; | |
| 78 | - } | |
| 79 | - | |
| 80 | 69 | wp_safe_redirect( admin_url( 'admin.php?page=formidable-settings&t=stripe_settings' ) ); |
| 81 | 70 | die(); |
| 82 | 71 | } |
| 83 | 72 | |
| @@ -85,9 +74,8 @@ | ||
| 85 | 74 | * Add the gateway for compatibility with the Payments submodule. |
| 86 | 75 | * This adds the Stripe checkbox option to the list of gateways. |
| 87 | 76 | * |
| 88 | 77 | * @param array $gateways |
| 89 | - * | |
| 90 | 78 | * @return array |
| 91 | 79 | */ |
| 92 | 80 | public static function add_gateway( $gateways ) { |
| 93 | 81 | $gateways['stripe'] = array( |
| @@ -111,9 +99,8 @@ | ||
| 111 | 99 | * @since 6.5.1 |
| 112 | 100 | * |
| 113 | 101 | * @param array $errors Errors data. Is empty array if no errors found. |
| 114 | 102 | * @param array $params Form params. See {@FrmForm::get_params()}. |
| 115 | - * | |
| 116 | 103 | * @return array |
| 117 | 104 | */ |
| 118 | 105 | public static function maybe_add_payment_error( $errors, $params ) { |
| 119 | 106 | if ( intval( $params['posted_form_id'] ) !== intval( $params['form_id'] ) ) { |
| @@ -129,14 +116,12 @@ | ||
| 129 | 116 | * @since 6.5.1 |
| 130 | 117 | * |
| 131 | 118 | * @param array $errors |
| 132 | 119 | * @param int $form_id |
| 133 | - * | |
| 134 | 120 | * @return array |
| 135 | 121 | */ |
| 136 | 122 | private static function maybe_add_payment_error_on_redirect( $errors, $form_id ) { |
| 137 | 123 | $details = FrmStrpLiteUrlParamHelper::get_details_for_form( $form_id ); |
| 138 | - | |
| 139 | 124 | if ( ! is_array( $details ) ) { |
| 140 | 125 | return $errors; |
| 141 | 126 | } |
| 142 | 127 | |
| @@ -156,15 +141,13 @@ | ||
| 156 | 141 | 'type' => 'credit_card', |
| 157 | 142 | 'form_id' => $entry->form_id, |
| 158 | 143 | ) |
| 159 | 144 | ); |
| 160 | - | |
| 161 | 145 | if ( ! $cc_field_id ) { |
| 162 | 146 | return $errors; |
| 163 | 147 | } |
| 164 | 148 | |
| 165 | - $is_setup_intent = str_starts_with( $intent->id, 'seti_' ); | |
| 166 | - | |
| 149 | + $is_setup_intent = 0 === strpos( $intent->id, 'seti_' ); | |
| 167 | 150 | if ( $is_setup_intent ) { |
| 168 | 151 | $errors[ 'field' . $cc_field_id ] = is_object( $intent->last_setup_error ) ? $intent->last_setup_error->message : ''; |
| 169 | 152 | } else { |
| 170 | 153 | $errors[ 'field' . $cc_field_id ] = is_object( $intent->last_payment_error ) ? $intent->last_payment_error->message : ''; |
| @@ -191,9 +174,8 @@ | ||
| 191 | 174 | * |
| 192 | 175 | * @param int $form_id |
| 193 | 176 | * @param int $entry_id |
| 194 | 177 | * @param array<string,string> $errors |
| 195 | - * | |
| 196 | 178 | * @return void |
| 197 | 179 | */ |
| 198 | 180 | private static function setup_form_after_payment_error( $form_id, $entry_id, $errors ) { |
| 199 | 181 | $form = FrmForm::getOne( $form_id ); |
| @@ -219,9 +201,8 @@ | ||
| 219 | 201 | * Set the entry back to draft status after error. |
| 220 | 202 | * |
| 221 | 203 | * @param string $html |
| 222 | 204 | * @param int $entry_id |
| 223 | - * | |
| 224 | 205 | * @return string |
| 225 | 206 | */ |
| 226 | 207 | function ( $html ) use ( $entry_id ) { |
| 227 | 208 | global $wpdb; |
| @@ -237,9 +218,8 @@ | ||
| 237 | 218 | * @since 2.08 |
| 238 | 219 | * |
| 239 | 220 | * @param array $values Entry edit values. |
| 240 | 221 | * @param object $field Field object. |
| 241 | - * | |
| 242 | 222 | * @return array |
| 243 | 223 | */ |
| 244 | 224 | public static function maybe_delete_pay_entry( $values, $field ) { |
| 245 | 225 | if ( self::$delete_pay_entry ) { |