PHP – how to submit Paypal details to intermediate class

I currently have a form on my WordPress shop which submits details to Paypal using the “Buy Now” button API. What I would like to do is based on the ‘School’ my customer selects on the form, I would like to submit the related Paypal e-mail address. I am currently storing the e-mail address related to the school in my database, so all I need to do is a SELECT from my database based on the selected school name.

I’d like to do this by submitting the form to a PHP class which then forwards the information to the Paypal API. My question is, as a PHP newbie, how do I do this? Here’s the form code I have… how do I forward these fields to another PHP class which collects the selected dropdown field value and submits to Paypal?

Read More

Thanks in advance!!

<?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
}

}
?>

Related posts