wp_send_json_error( [ 'message' => esc_html__( 'Subscription cancellation failed.', 'wpforms-lite' ) ] );
}
if ( UpdateHelpers::cancel_subscription( $payment_db->id, 'Stripe subscription cancelled from the WPForms plugin interface.' ) ) {
wp_send_json_success( [ 'message' => esc_html__( 'Subscription cancelled.', 'wpforms-lite' ) ] );
}
wp_send_json_error( [ 'message' => esc_html__( 'Updating subscription in the database failed.', 'wpforms-lite' ) ] );
}
/**
* Check the current payment collection type.
* If the deprecated type is still used, then warn users about it.
*
* When it's dropped from the addon, this method can be safely removed.
*
* @since 1.8.4
*/
private function check_payment_collection_type() {
if ( ! Helpers::is_pro() || absint( wpforms_setting( 'stripe-api-version' ) ) !== 2 ) {
return;
}
$message = sprintf(
wp_kses( /* translators: %s - Payments settings page URL. */
__( "The used Stripe payment collection type doesn't support this action.
Please update your payment collection type to continue processing payments successfully." ),
[
'br' => [],
'a' => [
'href' => [],
],
]
),
esc_url( admin_url( 'admin.php?page=wpforms-settings&view=payments#wpforms-setting-row-stripe-api-version' ) )
);
wp_send_json_error( [ 'modal_msg' => $message ] );
}
}