Html Paypal 支付和邮件用户同时进行

Html Paypal payment and emailing user at the same time

我在一个使用贝宝作为支付系统的网站上工作。但我有一个问题。我想要发生的是,当我点击 paypal 按钮时,它将带我到一个新页面,客户可以在其中购买我的产品(这完全可以正常工作)。但我也想发送一封电子邮件。我想通了电子邮件部分,但我无法在将客户端重定向到贝宝页面的同时弄清楚 运行 代码。

codepen

这是处理电子邮件的按钮:

<button formaction="/contact" type="submit" class="paypal-btn-check" onclick="simple_gaming_radio_check();">

这是将用户重定向到贝宝页面的代码:

<input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="cmd" value="_s-xclick">
          <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="hosted_button_id" value="W6SHV472B68TC">
          <input type="submit" formaction="https://www.paypal.com/cgi-bin/webscr" name="submit">

Html代码

<body>
<section>
    <div class="contact-container">
        <h1>Contact</h1>
        <form method="post">
            <div class="contact-input-container">
                <div>
                    <input formaction="/contact" name="email" class="contact-input contact-email" type="text" placeholder="name@gmail.com" autocomplete="off">
                </div>
                <div>
                    <input formaction="/contact" name="subject" class="contact-input contact-subject" type="text" placeholder="subject.." autocomplete="off">
                </div>
                <div>
                    <textarea formaction="/contact" name="message" class="contact-input contact-message" type="text" placeholder="message.."></textarea>
                </div>
            </div>
            <button formaction="/contact" type="submit" class="paypal-btn-check" onclick="simple_gaming_radio_check();">
              <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="cmd" value="_s-xclick">
              <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="hosted_button_id" value="W6SHV472B68TC">
              <input type="submit" formaction="https://www.paypal.com/cgi-bin/webscr" name="submit">
            </button>
        </form>
    </div>
</section>

解决办法是通过Javascript中的onclick事件调用你发送邮件的功能。

    <body>
    <section>
    <div class="contact-container">
        <h1>Contact</h1>
        <form method="post">
            <div class="contact-input-container">
                <div>
                    <input formaction="/contact" name="email" class="contact-input contact-email" type="text" placeholder="name@gmail.com" autocomplete="off">
                </div>
                <div>
                    <input formaction="/contact" name="subject" class="contact-input contact-subject" type="text" placeholder="subject.." autocomplete="off">
                </div>
                <div>
                    <textarea formaction="/contact" name="message" class="contact-input contact-message" type="text" placeholder="message.."></textarea>
                </div>
            </div>
            <button formaction="/contact" type="submit" class="paypal-btn-check" onclick="simple_gaming_radio_check();">
              <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="cmd" value="_s-xclick">
              <input formaction="https://www.paypal.com/cgi-bin/webscr" type="hidden" name="hosted_button_id" value="W6SHV472B68TC">
              <input type="submit" onclick="sendMail()" formaction="https://www.paypal.com/cgi-bin/webscr" name="submit">
            </button>
        </form>
    </div>
</section>

您的 javascript 代码将是这样的

   function sendMail(){
      //Your sending mail code will go here
      alert("Mail Sent")
   }