: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
protected function is_recurring_settings_ok( $settings ) {
// Check subscription settings are provided.
if ( empty( $settings['period'] ) || empty( $settings['email'] ) ) {
$error = esc_html__( 'Stripe subscription payment stopped, missing form settings.', 'wpforms-lite' );
// Check for required customer email.
if ( ! $error && empty( $this->fields[ $settings['email'] ]['value'] ) ) {
$error = esc_html__( 'Stripe subscription payment stopped, customer email not found.', 'wpforms-lite' );
// Before proceeding, check if any basic errors were detected.
$this->log_error( $error );
$this->display_error( $error );
* Process subscription API call.
* @param array $args Prepared subscription arguments.
protected function process_subscription( $args ) {
$this->subscription_settings = $args['settings'];
if ( ! Helpers::is_license_ok() && Helpers::is_application_fee_supported() ) {
$args['application_fee_percent'] = 3;
$this->api->process_subscription( $args );
// Set payment processing flag.
$this->is_payment_processed = true;
// Update the credit card field value to contain basic details.
$this->update_credit_card_field_value();
$this->process_api_error( 'subscription' );
* Get base subscription arguments.
protected function get_base_subscription_args() {
'form_id' => $this->form_id,
'form_title' => sanitize_text_field( $this->form_data['settings']['form_title'] ),
'amount' => $this->amount * Helpers::get_decimals_amount(),
* Map WPForms Address field to Stripe format.
* @param array $submitted_data Submitted address data.
* @param string $field_id Address field ID.
private function map_address_field( array $submitted_data, string $field_id ): array {
$line = sanitize_text_field( $submitted_data['address1'] );
if ( isset( $submitted_data['address2'] ) ) {
$line .= ' ' . sanitize_text_field( $submitted_data['address2'] );
if ( isset( $submitted_data['country'] ) ) {
$country = sanitize_text_field( $submitted_data['country'] );
} elseif ( $this->form_data['fields'][ $field_id ]['scheme'] !== 'international' ) {
'state' => isset( $submitted_data['state'] ) ? sanitize_text_field( $submitted_data['state'] ) : '',
'city' => sanitize_text_field( $submitted_data['city'] ),
'postal_code' => sanitize_text_field( $submitted_data['postal'] ),
* Check the submitted payment data whether it was corrupted.
* If so, refund a payment / cancel subscription.
* @param array $entry Submitted entry data.
private function is_submitted_payment_data_corrupted( array $entry ): bool {
// Bail early if there are no payment intents.
if ( empty( $entry['payment_intent_id'] ) ) {
// Get stored corrupted payment intents if exist.
$corrupted_intents = (array) Transient::get( 'corrupted-stripe-intents' );
// We must prevent a processing if payment intent was identified as corrupted.
// Also if the transaction ID exists in DB (transaction ID is unique value).
if ( in_array( $entry['payment_intent_id'], $corrupted_intents, true ) || wpforms()->get( 'payment' )->get_by( 'transaction_id', $entry['payment_intent_id'] ) ) {
wpforms()->get( 'process' )->errors[ $this->form_id ]['footer'] = esc_html__( 'Secondary form submission was declined.', 'wpforms-lite' );
$intent = $this->api->retrieve_payment_intent(
$entry['payment_intent_id'],
'expand' => [ 'invoice.subscription' ],
// Round to the nearest whole number because $this->amount can contain a number close to,
// but slightly under it, due to how it is stored in the memory.
$submitted_amount = round( $this->amount * Helpers::get_decimals_amount() );
// Prevent form submission if a mismatch of the payment amount is detected.
if ( ! empty( $intent ) && (int) $submitted_amount !== (int) $intent->amount ) {
wpforms()->get( 'process' )->errors[ $this->form_id ]['footer'] = esc_html__( 'Irregular activity detected. Your submission has been declined and payment refunded.', 'wpforms-lite' );
'reason' => 'fraudulent',
// We can't cancel a payment because it's already paid.
// So we can perform a refund only.
$this->api->refund_payment( $entry['payment_intent_id'], $args );
// Cancel subscription if exists.
if ( ! empty( $intent->invoice->subscription ) ) {
$this->api->cancel_subscription( $intent->invoice->subscription->id );
// This payment indent is identified as corrupted.
// Store it in order to prevent re-using it (form re-submitting).
if ( ! in_array( $entry['payment_intent_id'], $corrupted_intents, true ) ) {
$corrupted_intents[] = $entry['payment_intent_id'];
Transient::set( 'corrupted-stripe-intents', $corrupted_intents, WEEK_IN_SECONDS );