Show
Ignore:
Timestamp:
02/29/08 11:13:21 (5 years ago)
Author:
d0nut
Message:

validating paypal input

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • donation/optionals/de.easy-coding.wcf.donation.paypal/files/lib/system/event/listener/DonationAddFormPayPalListener.class.php

    r255 r259  
    1515         
    1616        //data 
    17         protected $arr = array('paypal_enable','paypal_code'); 
     17        protected $arr = array('paypal_enable','paypal_business', 'paypal_auth_token', 'paypal_item_name', 'paypal_amount_type', 'paypal_amount_default', 'paypal_amount_select', 'paypal_currency', 'paypal_img'); 
    1818         
    1919        /** 
    20          * 
     20         * paypal check 
    2121         */ 
    2222        protected function validatePaypal() { 
     
    2525 
    2626                $tx_token = $_GET['tx']; 
    27                 $auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0"; 
     27                $auth_token = $this->data['paypal_auth_token']; 
    2828                $req .= "&tx=$tx_token&at=$auth_token"; 
    2929 
     
    6868                                // check that txn_id has not been previously processed 
    6969                                // check that receiver_email is your Primary PayPal email 
     70                                if($keyarray['business'] != $this->data['paypal_business']) { 
     71                                        return false; 
     72                                } 
    7073                                // check that payment_amount/payment_currency are correct 
     74                                if($keyarray['payment_gross'] <= 0) { 
     75                                        return false; 
     76                                } 
    7177                                // process payment 
    72                                 $firstname = $keyarray['first_name']; 
    73                                 $lastname = $keyarray['last_name']; 
    7478                                $itemname = $keyarray['item_name']; 
    75                                 $amount = $keyarray['payment_gross']; 
    76                                 $currency = $keyarray['mc_currency']; 
    77                                 $text = urldecode($keyarray['custom']); 
    7879 
    79                                 echo ("<p><h3>Thank you for your purchase!</h3></p>"); 
    80  
    81                                 echo ("<b>Payment Details</b><br>\n"); 
    82                                 echo ("<li>Name: $firstname $lastname</li>\n"); 
    83                                 echo ("<li>Item: $itemname</li>\n"); 
    84                                 echo ("<li>Amount: $amount</li>\n"); 
    85                                 echo (""); 
     80                                $this->username = $keyarray['last_name'].', '.$keyarray['first_name']; 
     81                                $this->present['amount'] = $keyarray['payment_gross']; 
     82                                $this->present['currency'] = $keyarray['mc_currency']; 
     83                                $this->present['mail'] = $keyarray['payer_email']; 
     84                                $this->message = urldecode($keyarray['custom']); 
     85                                 
     86                                WCF::getTPL()->assign(array( 
     87                                        'pageurl'=>WCF::getLanguage()->get('wcf.donation.paypal.thanks') 
     88                                )); 
    8689 
    8790                                fclose ($fp);            
     
    97100                return false; 
    98101        } 
    99  
     102         
    100103        /** 
    101          * @see Form::readFormParameters() 
     104         * @see Form::assignVariables() 
    102105         */ 
    103         protected function readFormParameters() { 
    104                 //TODO: get information from paypal 
     106        protected function assignVariables() { 
     107                WCF::getTPL()->assign(array( 
     108                        'pageurl'=>FileUtil::addTrailingSlash(PAGE_URL) 
     109                )); 
     110                parent::assignVariables(); 
    105111        } 
    106112         
     
    109115         */ 
    110116        protected function validate() { 
    111                 //TODO: did we get an answer from paypal? submission finished? 
     117                // did we get an answer from paypal? submission finished? 
    112118                switch($this->eventObj->step) { 
    113119                        case 10: // return page 
    114120                                if($this->validatePaypal()) { 
    115                                         EventListener::fireEvent($this->eventObj, 'save'); //TODO: EventListener 
     121                                        $this->save(); 
    116122                                } 
    117123