=== modified file 'payment/uc_paypal/uc_paypal.module' --- payment/uc_paypal/uc_paypal.module 2009-09-28 17:22:40 +0000 +++ payment/uc_paypal/uc_paypal.module 2009-10-22 23:35:26 +0000 @@ -1211,6 +1211,11 @@ } } +// Outputs the proper HTTP response for failed incoming PayPal requests. +function _uc_paypal_send_error_response() { + drupal_set_header('HTTP/1.1 500 Internal Server Error'); +} + // Returns an array of possible currency codes. function _uc_paypal_currency_array() { return drupal_map_assoc(array('AUD', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'ILS', 'JPY', 'MXN', 'NOK', 'NZD', 'PLN', 'SEK', 'SGD', 'USD')); === modified file 'payment/uc_paypal/uc_paypal.pages.inc' --- payment/uc_paypal/uc_paypal.pages.inc 2009-09-22 19:51:50 +0000 +++ payment/uc_paypal/uc_paypal.pages.inc 2009-10-24 19:09:25 +0000 @@ -49,18 +49,20 @@ $req .= 'cmd=_notify-validate'; - if (variable_get('uc_paypal_wpp_server', '') == 'https://api-3t.paypal.com/nvp') { + // Per the PayPal Sandbox User Guide, test_ipn signifies a SandBox request + if (isset($_POST['test_ipn']) && $_POST['test_ipn'] == "1") { + $host = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; + } + else { $host = 'https://www.paypal.com/cgi-bin/webscr'; } - else { - $host = variable_get('uc_paypal_wps_server', 'https://www.sandbox.paypal.com/cgi-bin/webscr'); - } $response = drupal_http_request($host, array(), 'POST', $req); // TODO: Change this to property_exists when we have a PHP requirement >= 5.1. if (array_key_exists('error', $response)) { watchdog('uc_paypal', 'IPN failed with HTTP error @error, code @code.', array('@error' => $response->error, '@code' => $response->code), WATCHDOG_ERROR); + _uc_paypal_send_error_response(); return; } @@ -134,11 +136,20 @@ case 'Voided': uc_order_comment_save($order_id, 0, t('The authorization has been voided.'), 'admin'); break; + default: + uc_order_comment_save($order_id, 0, t('Unknown IPN payment status @status', array('@status' => $payment_status)), 'admin'); + watchdog('uc_paypal', 'Unknown IPN payment status @status', array('@status' => $payment_status), WATCHDOG_ERROR); + _uc_paypal_send_error_response(); } } elseif (strcmp($response->data, 'INVALID') == 0) { watchdog('uc_paypal', 'IPN transaction failed verification.', array(), WATCHDOG_ERROR); uc_order_comment_save($order_id, 0, t('An IPN transaction failed verification for this order.'), 'admin'); + _uc_paypal_send_error_response(); + } + else { + watchdog('uc_paypal', 'Unknown IPN verification response @res', array('@res' => $response->data), WATCHDOG_ERROR); + _uc_paypal_send_error_response(); } }