Index: paypal.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ecommerce/paypal/paypal.module,v
retrieving revision 1.35
diff -u -F^f -r1.35 paypal.module
--- paypal.module	30 Apr 2006 11:40:25 -0000	1.35
+++ paypal.module	10 May 2006 06:10:01 -0000
@@ -41,7 +41,15 @@ function paypal_ec_settings() {
 
   $form['paypal_return_url'] =  array( '#type' => 'textfield', '#title' => t('Successful payment URL'), '#default_value' => variable_get('paypal_return_url', '%order-history'), '#size' => 70, '#maxlength' => 180, '#description' => t("This is the destination to which you would like to send your customers when their payment has been successfully completed. The URL must be a Drupal system path. If you are not using clean URLs, specify the part after '?q='. If unsure, specify 'node'. You may also enter '%order-history' to link to the user's order history."));
 
-  $form['paypal_cancel_url'] =  array( '#type' => 'textfield', '#title' => t('Cancel payment URL'), '#default_value' => variable_get("paypal_cancel_url", "node"), '#size' => 70, '#maxlength' => 180, '#description' => t("This is the destination to which you would like to send your customers if they cancel their payment. The URL must be a Drupal system path. If you are not using clean URLs, specify the part after '?q='. If unsure, specify 'node'.")	);
+  $form['paypal_cancel_url'] =  array( '#type' => 'textfield', '#title' => t('Cancel payment URL'), '#default_value' => variable_get("paypal_cancel_url", "node"), '#size' => 70, '#maxlength' => 180, '#description' => t("This is the destination to which you would like to send your customers if they cancel their payment. The URL must be a Drupal system path. If you are not using clean URLs, specify the part after '?q='. If unsure, specify 'node'.")  );
+  $form['paypal_ipnrb_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('PayPal IPN "request back" validation URL'),
+    '#default_value' => variable_get('paypal_ipnrb_url', 'http://www.paypal.com/cgi-bin/webscr'),
+    '#size' => 70,
+    '#maxlength' => 180,
+    '#description' => t('URL where IPN "request back" is posted to validate the transaction.'),
+  );  
 
   $currency_codes = array('USD' => 'USD - U.S. Dollars', 'EUR' => 'EUR - Euros', 'AUD' => 'AUD - Australian Dollars', 'CAD' => 'CAD - Canadian Dollars', 'GBP'=> 'GBP - Pounds Sterling', 'JPY' => 'JPY - Yen');
   
@@ -217,9 +225,19 @@ function paypal_ipn() {
 
   /* Post back to PayPal system to validate */
   $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
+  $ipnrb = parse_url(variable_get('paypal_ipnrb_url', 'http://www.paypal.com/cgi-bin/webscr'));
+  $header = "POST {$ipnrb['path']} HTTP/1.0\r\n";
   $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
   $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
-  $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
+  if ($ipnrb['scheme']=='http') {
+    $port= 80;
+    $host=$ipnrb['host'];
+  }
+  else {
+    $port= 443;
+    $host="ssl://{$ipnrb['host']}";
+  }
+  $fp = fsockopen($host, $port, $errno, $errstr, 30);
 
   /* Assign posted variables to local variables */
   $payment_status = $_POST['payment_status'];
