예제 #1
0
 function validateIPN($data)
 {
     // parse the paypal URL
     $url = plgPaymentPaypalHelper::buildPaypalUrl();
     $this->paypal_url = $url;
     $url_parsed = parse_url($url);
     // generate the post string from the _POST vars aswell as load the
     // _POST vars into an arry so we can play with them from the calling
     // script.
     // append ipn command
     // open the connection to paypal
     $fp = fsockopen($url_parsed[host], "80", $err_num, $err_str, 30);
     // $fp = fsockopen ($this->paypal_url, 80, $errno, $errstr, 30);
     if (!$fp) {
         // could not open the connection.  If loggin is on, the error message
         // will be in the log.
         $this->last_error = "fsockopen error no. {$errnum}: {$errstr}";
         plgPaymentPaypalHelper::log_ipn_results(false);
         return false;
     } else {
         $post_string = '';
         foreach ($data as $field => $value) {
             $this->ipn_data["{$field}"] = $value;
             $post_string .= $field . '=' . urlencode(stripslashes($value)) . '&';
         }
         $post_string .= "cmd=_notify-validate";
         // Post the data back to paypal
         fputs($fp, "POST {$url_parsed['path']} HTTP/1.1\r\n");
         fputs($fp, "Host: {$url_parsed['host']}\r\n");
         fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
         fputs($fp, "Content-length: " . strlen($post_string) . "\r\n");
         fputs($fp, "Connection: close\r\n\r\n");
         fputs($fp, $post_string . "\r\n\r\n");
         // loop through the response from the server and append to variable
         while (!feof($fp)) {
             $this->ipn_response .= fgets($fp, 1024);
         }
         fclose($fp);
         // close connection
     }
     if (eregi("verified", $post_string)) {
         // Valid IPN transaction.
         plgPaymentPaypalHelper::log_ipn_results(true);
         return true;
     } else {
         // Invalid IPN transaction.  Check the log for details.
         $this->last_error = 'IPN Validation Failed.';
         plgPaymentPaypalHelper::log_ipn_results(false);
         return false;
     }
 }
예제 #2
0
 function onTP_GetHTML($vars)
 {
     $plgPaymentPaypalHelper = new plgPaymentPaypalHelper();
     $vars->action_url = $plgPaymentPaypalHelper->buildPaypalUrl();
     //Take this receiver email address from plugin if component not provided it
     if (empty($vars->business)) {
         $vars->business = $this->params->get('business');
     }
     //if component does not provide cmd
     if (empty($vars->cmd)) {
         $vars->cmd = '_xclick';
     }
     $html = $this->buildLayout($vars);
     return $html;
 }
예제 #3
0
 function onTP_ProcessSubmitRecurring($data, $vars)
 {
     //Take this receiver email address from plugin if component not provided it
     if (empty($vars->business)) {
         $submitVaues['business'] = $this->params->get('business');
     } else {
         $submitVaues['business'] = $vars->business;
     }
     //if component does not provide cmd
     if (empty($vars->cmd)) {
         $submitVaues['cmd'] = '_xclick-subscriptions';
     } else {
         $submitVaues['cmd'] = $vars->cmd;
     }
     $submitVaues['custom'] = $vars->order_id;
     $submitVaues['item_name'] = $vars->item_name;
     $submitVaues['return'] = $vars->return;
     $submitVaues['cancel_return'] = $vars->cancel_return;
     $submitVaues['notify_url'] = $vars->notify_url;
     $submitVaues['currency_code'] = $vars->currency_code;
     $submitVaues['no_note'] = '1';
     $submitVaues['rm'] = '2';
     $submitVaues['a3'] = $vars->amount;
     if ($vars->recurring_frequency == 'QUARTERLY') {
         $submitVaues['p3'] = 3;
         $submitVaues['t3'] = 'MONTH';
     } else {
         $submitVaues['p3'] = 1;
         $submitVaues['t3'] = $vars->recurring_frequency;
     }
     $submitVaues['srt'] = $vars->recurring_count;
     $submitVaues['src'] = 1;
     $submitVaues['sra'] = 1;
     //$submitVaues['TRIALBILLINGPERIOD']='DAY'; //Parameters to test Recurring payment
     //$submitVaues['TRIALBILLINGFREQUENCY']=3; //Parameters to test Recurring payment
     $plgPaymentPaypalHelper = new plgPaymentPaypalHelper();
     $postaction = $plgPaymentPaypalHelper->buildPaypalUrl();
     /* for offsite plugin */
     $postvalues = http_build_query($submitVaues);
     header('Location: ' . $postaction . '?' . $postvalues);
 }