简体   繁体   English

发送电子邮件后,将用户重定向到PayPal结帐页面

[英]Redirect user to PayPal checkout page after sending email

I have an order form where a user gives some input about a product and when s/he submits the form s/he will receive an email which contains product specification. 我有一个订单,用户可以在其中输入有关产品的一些输入,而当他/他提交表单时,他/她将收到一封包含产品规格的电子邮件。

Basically the website provide Logo designing services. 该网站基本上提供徽标设计服务。

Here products are : 3 Logo Mockups, 5 Logo Mockups, 7 Logo Mockups and 10 Logo Mockups, not any tangible product like(other shopping cart offers). 这里的产品有:3个徽标模型,5个徽标模型,7个徽标模型和10个徽标模型,但没有任何有形产品(其他购物车提供)。

Now, I have created a PayPal Buy Now button using paypal account for that product and want to send an email(which contain product specification that s/he had already filled before click to Buy Now button) to the customer as well as redirecting them to the appropriate product checkout page generated by PayPal. 现在,我已经使用该产品的贝宝帐户创建了贝宝“ 立即购买”按钮,并希望向客户发送电子邮件(包含他/他在单击“ 立即购买”按钮之前已经填写的产品规格),并将其重定向到贝宝(PayPal)生成的相应产品结帐页面。

Paypal Buy Now button code is: Paypal 立即购买按钮代码为:

<form id="logo-design-paypal-form" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="46J7HLDHY7TBE">
    <table>
        <tr>
        <td><input type="hidden" name="on0" value="Logo Design">
            Logo Design</td>
        </tr>
        <tr>
        <td><select name="os0">
        <option value="3 Logo Mockups">3 Logo Mockups $50.00</option>
        <option value="5 Logo Mockups">5 Logo Mockups $120.00</option>
        <option value="7 Logo Mockups">7 Logo Mockups $350.00</option>
        <option value="10 Logo Mockups">10 Logo Mockups $650.00</option>
        </select>
        </td>
        </tr>
    </table>
    <input type="hidden" name="currency_code" value="USD">
    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">

If I understand your question correctly, earlier, you created a form with a normal submit button. 如果我正确理解了您的问题,那么您之前创建的表单带有一个正常的提交按钮。 If a user enters all the input and clicks submit, you would send him an email. 如果用户输入所有输入并单击提交,您将向他发送电子邮件。 Right now, you replaced the normal button with a PayPal submit button and you wants that PayPal button to invoke the sending email function just like the old button. 现在,您将常规按钮替换为PayPal提交按钮,并且希望该PayPal按钮像旧按钮一样调用发送电子邮件功能。 If that's what you want to do, you can try this way: 如果那是您想要做的,您可以尝试这种方式:

<div id="paypal_button">
    // wrap your encrypted paypal button in a div
</div>

// PayPal button is actually a form so you can make a script like the following

<script type="text/javascript">
    $("div#paypal_button > form").submit(function() {

        // Call your sending email function here (maybe by using Ajax)

    });
</script>

EDIT : if you don't want to bind onclick event to the PayPal button itself, I think you should use this Ajax plugin to submit your original form (ie don't use normal submit because the user would be redirected to the page in action attribute and it'd be more difficult to achieve what you want). 编辑 :如果您不想将onclick事件绑定到PayPal按钮本身,我认为您应该使用此Ajax 插件来提交原始表单(即,不要使用普通的提交,因为用户将被重定向到实际使用的页面属性,实现您想要的目标会更加困难)。

<form id="original_form" action="somePage">
    ...
    <input type="submit" value="Submit" /> 
</form>

<div id="paypal_button" style="display:none">
    // wrap your encrypted paypal button in a HIDDEN div
</div>

<script type="text/javascrip">
    $(document).ready(function() {
        // submit your original form to send the email and redirect the user on success
        $('#original_form').ajaxForm({
            success: function() { 
               $("div#paypal_button > form").submit();
            }     
        });

    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM