Issue redirecting after submitting in WordPress

I want to redirect after the form is submitted, anything that has not the id contact-370 to a remote URL. The issue right now is that the contact form is also redirecting and it shouldn’t.

document.addEventListener('wpcf7submit', function (event) {
    if ('contact-370' !== event.detail.contactFormId) {
        var newTab = window.open('', '_blank');
        newTab.location.href = 'https://buy.stripe.com/test_xxxx';
    }
}, false);

I’m using the latest version of Contact Form 7, so on_sent_ok and on_submit are deprecated. What am I doing wrong? I’m open to a different solution. Thanks.