--- a/payment/uc_paypal/uc_paypal.module 2011-07-30 08:00:20.000000000 +1000 +++ b/payment/uc_paypal/uc_paypal.module 2011-10-08 16:31:47.000000000 +1100 @@ -408,9 +408,21 @@ } } + // DEBUG: request. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_wpp_charge: uc_paypal_api: request:
@debug
', array('@debug' => print_r($nvp_request, TRUE))); + } + + // send request. $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp')); $types = uc_credit_transaction_types(); + // DEBUG: response. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_wpp_charge: uc_paypal_api: response:
@debug
', array('@debug' => print_r($nvp_response, TRUE))); + } + + // process response. switch ($nvp_response['ACK']) { case 'SuccessWithWarning': watchdog('uc_payment', '@type succeeded with a warning.!paypal_message', @@ -712,13 +724,26 @@ unset($nvp_request['ADDROVERRIDE']); } + // DEBUG: request. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_checkout: uc_paypal_api: request:
@debug
', array('@debug' => print_r($nvp_request, TRUE))); + } + + // send request. $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp')); + // DEBUG: response. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_checkout: uc_paypal_api: response:
@debug
', array('@debug' => print_r($nvp_response, TRUE))); + } + + // error if ($nvp_response['ACK'] != 'Success') { drupal_set_message(t('Error message from PayPal:
@message', array('@message' => $nvp_response['L_LONGMESSAGE0'])), 'error'); drupal_goto('cart/checkout'); } + // success $_SESSION['TOKEN'] = $nvp_response['TOKEN']; if (strpos(variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp'), 'sandbox') > 0) { @@ -796,8 +821,32 @@ $order->products = $items; uc_order_save($order); + // DEBUG: request. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_form_submit: uc_paypal_api: request:
@debug
', array('@debug' => print_r($nvp_request, TRUE))); + } + + // send request. $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp')); + // DEBUG: response. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_form_submit: uc_paypal_api: response:
@debug
', array('@debug' => print_r($nvp_response, TRUE))); + } + + // unknown error. + if (!$nvp_response || !isset($nvp_response['ACK'])) { + drupal_set_message(t('Error:
uc_paypal_ec_form_submit: uc_paypal_api_request() returned unknown response'), 'error'); + drupal_goto('cart/checkout'); + } + + // failure. + if ($nvp_response['ACK'] != 'Success') { + drupal_set_message(t('Error message from PayPal:
@message', array('@message' => $nvp_response['L_LONGMESSAGE0'])), 'error'); + drupal_goto('cart/checkout'); + } + + // success. $_SESSION['cart_order'] = $order->order_id; $_SESSION['TOKEN'] = $nvp_response['TOKEN']; @@ -872,11 +921,38 @@ 'CURRENCYCODE' => variable_get('uc_paypal_wpp_currency', 'USD'), ); + // DEBUG: request. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_submit_form_submit: uc_paypal_api: request:
@debug
', array('@debug' => print_r($nvp_request, TRUE))); + } + + // send request. $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp')); + // DEBUG: response. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_submit_form_submit: uc_paypal_api: response:
@debug
', array('@debug' => print_r($nvp_response, TRUE))); + } + + // unknown error. + if (!$nvp_response || !isset($nvp_response['ACK'])) { + drupal_set_message(t('Error:
uc_paypal_ec_submit_form_submit: uc_paypal_api_request() returned unknown response'), 'error'); + drupal_goto('cart/checkout'); + } + + // failure. + if ($nvp_response['ACK'] != 'Success') { + watchdog('uc_paypal', 'Request of IPN transaction FAILED: @message', array('@message' => $nvp_response['L_LONGMESSAGE0'])); + drupal_set_message(t('Error message from PayPal:
@message', array('@message' => $nvp_response['L_LONGMESSAGE0'])), 'error'); + drupal_goto('cart/checkout'); + } + + // success. unset($_SESSION['TOKEN'], $_SESSION['PAYERID']); $_SESSION['do_complete'] = TRUE; + watchdog('uc_paypal', 'Request of IPN transaction succeeded.'); + $form_state['redirect'] = 'cart/checkout/complete'; } --- a/payment/uc_paypal/uc_paypal.pages.inc 2011-07-30 08:00:20.000000000 +1000 +++ b/payment/uc_paypal/uc_paypal.pages.inc 2011-10-08 16:26:01.000000000 +1100 @@ -180,8 +180,25 @@ 'TOKEN' => $_SESSION['TOKEN'], ); + // DEBUG: request. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_review_redirect: uc_paypal_api: request:
@debug
', array('@debug' => print_r($nvp_request, TRUE))); + } + + // send request. $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp')); + // DEBUG: response. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_review_redirect: uc_paypal_api: response:
@debug
', array('@debug' => print_r($nvp_response, TRUE))); + } + + // error + if ($nvp_response['ACK'] != 'Success') { + drupal_set_message(t('Error message from PayPal:
@message', array('@message' => $nvp_response['L_LONGMESSAGE0'])), 'error'); + drupal_goto('cart/checkout'); + } + $_SESSION['PAYERID'] = $nvp_response['PAYERID']; drupal_goto('cart/checkout/review'); @@ -203,8 +220,26 @@ 'TOKEN' => $_SESSION['TOKEN'], ); + // DEBUG: request. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_review: uc_paypal_api: request:
@debug
', array('@debug' => print_r($nvp_request, TRUE))); + } + + // send request. $nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp')); + // DEBUG: response. + if (variable_get('uc_paypal_wps_debug_ipn', FALSE)) { + watchdog('uc_paypal', 'DEBUG: uc_paypal_ec_review: uc_paypal_api: response:
@debug
', array('@debug' => print_r($nvp_response, TRUE))); + } + + // error + if ($nvp_response['ACK'] != 'Success') { + drupal_set_message(t('Error message from PayPal:
@message', array('@message' => $nvp_response['L_LONGMESSAGE0'])), 'error'); + drupal_goto('cart/checkout'); + } + + // success. $_SESSION['PAYERID'] = $nvp_response['PAYERID']; $shipname = check_plain($nvp_response['SHIPTONAME']);