PHP - 如何向中级类提交Paypal详细信息

时间:2016-02-04 22:12:26

标签: php jquery wordpress forms paypal

我目前在我的Wordpress商店有一个表单,使用"立即购买"向Paypal提交详细信息。按钮API。我想做的是基于学校'我的客户在表单上选择,我想提交相关的Paypal电子邮件地址。我目前正在我的数据库中存储与学校相关的电子邮件地址,因此我需要做的就是根据所选学校名称从我的数据库中选择SELECT。

我希望将表单提交给PHP类,然后将该信息转发给Paypal API。我的问题是,作为一个PHP新手,我该怎么做?这里是我的表单代码...如何将这些字段转发到另一个PHP类,它收集所选的下拉字段值并提交给Paypal?

提前致谢!!

<?php

class Template {

    public function __construct() {

    }

    public function getForm($project_list, $business){  
        $require_mark = '<strong style="color:red;">*</strong>';
    ?>
        <div id="payment_booking_main">            
            <form name="_xclick" id="payment_booking_form" action="https://www.paypal.com/cgi-bin/webscr" method="post">
            <!-- <form name="_xclick" id="payment_booking_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> -->
            <input type="hidden" name="cmd" value="_xclick" /> 
            <input type="hidden" name="hosted_button_id" value="7ACDDDD4URDK2" /> 

            <!-- This is the paypal email that is sent.  -->
            <input type="hidden" name="business" value="<?php echo $business; ?>" />
            <input type="hidden" name="a3" value="1">
            <input type="hidden" name="p3" value="1">
            <input type="hidden" name="t3" value="D">
            <input type="hidden" name="no_note" value="1">
            <input type="hidden" name="currency_code" value="GBP">
            <input type="hidden" id="payment_booking_return_url" name="return" value="" />
            <input type="hidden" id="payment_booking_notify_url" name="notify_url" value="">
            <input type="hidden" id="payment_booking_total_amount" name="amount" value="0">
            <input type="hidden" id="payment_booking_item_name" name="item_name" value="">
            <input type="hidden" id="payment_booking_item_number" name="item_number" value="">

            <!-- Where the project name option input is populated on form load -->
            <div id="payment_booking_project_selectform">
                <div class="payment_booking_line" style="heigth:20px !important;">
                    <span class="payment_booking_label">Project :</span>
                    <select id="payment_booking_project" name="payment_booking_project">
                    <?php
                     global $wpdb;
                     $sql = "SELECT * FROM `{$wpdb->prefix}payment_booking_project` WHERE project_status =1";
                     $project_list = $wpdb->get_results($sql);
                     foreach($project_list as $project){
                        echo '<option value="'.$project->id.'" amount="'.number_format($project->project_amount, 2).'" description="'.$project->project_description.'" price="'.$project->project_price.'">'.$project->project_name.'</option>';
                     }
                    ?>
                    </select>
                    <span id="payment_booking_project_description" style="font-size:12px;"></span>
                </div>
            </div>                

            <div id="payment_booking_project_list"></div>
            <div class="payment_booking_line">
                <span class="payment_booking_label">Name <?php echo $require_mark; ?> :</span>
                <span class="payment_booking_input"><input type="text" id="payment_booking_name" name="payment_booking_name" class="required" /></span>
            </div>
            <div class="payment_booking_line">
                <span class="payment_booking_label">Address <?php echo $require_mark; ?> :</span>
                <span class="payment_booking_input"><textarea id="payment_booking_address" name="payment_booking_address" class="required"></textarea></span>
            </div>
            <div class="payment_booking_line">
                <span class="payment_booking_label">Home Phone Number :</span>
                <span class="payment_booking_input"><input type="text" id="payment_booking_phone" name="payment_booking_phone" /></span>
            </div>
            <div class="payment_booking_line">
                <span class="payment_booking_label">Email Address <?php echo $require_mark; ?> :</span>
                <span class="payment_booking_input"><input type="text" id="payment_booking_email" name="payment_booking_email" class="required" /></span>
            </div>
            <div class="payment_booking_line">
                <center>
                    <img id="img_submit" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" alt="PayPal — The safer, easier way to pay online." />
                </center>
            </div>
        </form>
    </div>
<?php
}

} ?&GT;

0 个答案:

没有答案