Button with Dual Functionality on Webflow

I am building a website in webflow - most of it is no code. However I need a button on my website to have dual functionality. One is to submit a form and the other is to submit payment. I have custom code that I will paste below, However when I press submit the payment won’t go through. When inspecting the page and looking at the console I get errors that look like this:

<script>
function selectOnlyThis(id) {
    for (var i = 1;i <= 3; i++){
        if ("Check" + i === id && document.getElementById("Check" + i).checked === true){
            document.getElementById("Check" + i).checked = true;
            } else {
              document.getElementById("Check" + i).checked = false;
            }
    }  
}

         $(function() {
             let submitted = false;

             $('#Sell-form').submit(function (e) {
                 if (submitted) {
                     return true;
                 }

                 e.preventDefault();
                 e.stopPropagation();
                 e.stopImmediatePropagation();

                 const amount = $('#cc-amount')
                 const cardName = $('#cc-name')
                 const cardNumber = $('#cc-number')
                 const cardExpir = $('#cc-exp')
                 const cardCv2 = $('#cc-cv2')

                 const frame = document.querySelector('#frame')

                 frame.contentDocument.write(
                     `
                        <form action="https://www.usaepay.com/gate.php" method="POST" id="inner-form">
                        <input type="hidden" name="UMkey" value="API_KEY">
                        <input type="hidden" name="UMredirDeclined" value="https://gownshadchan.com/failure">
                        <input type="hidden" name="UMredirApproved" value="https://gownshadchan.com/success">
                        <input type="hidden" name="UMname" value="${cardName.val()}">
                        <input type="hidden" name="UMcard" value="${cardNumber.val()}">
                        <input type="hidden" name="UMexpir" value="${cardExpir.val()}">
                        <input type="hidden" name="UMamount" value="${amount.val()}">
                        <input type="hidden" name="UMcvv2" value="${cardCv2.val()}">
                     `
                 )

                 function success() {
                     cardNumber.val('****' + cardNumber.val().slice(-4))
                     cardExpir.remove()
                     cardCv2.remove()

                     submitted = true;
                     $('#Sell-form').submit()
                 }

                 function failure() {
                     submitted = false;
                     $('#submission-error-message').show()
                 }

                 frame.onload = function () {
                     const content = frame.contentWindow.document.body.innerHTML.trim()
                     if (content.includes('success')) {
                         success()
                     } else {
                         failure()
                     }
                 }

                 let doc = (frame.contentWindow || frame.contentDocument);
                 if (doc.document) doc = doc.document;
                 doc.getElementById("inner-form").submit();
             })
         });

</script>

Here is my site Read-Only: [LINK](Webflow - Gown Shadchan)
(how to share your site Read-Only link)