Index: payment/uc_paypal/uc_paypal.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/payment/uc_paypal/uc_paypal.module,v retrieving revision 1.5.2.13 diff -u -p -r1.5.2.13 uc_paypal.module --- payment/uc_paypal/uc_paypal.module 28 Apr 2009 21:03:16 -0000 1.5.2.13 +++ payment/uc_paypal/uc_paypal.module 18 May 2009 23:50:35 -0000 @@ -392,48 +392,72 @@ function uc_paypal_wpp_charge($order_id, $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(); - if ($nvp_response['ACK'] != 'Success') { - $message = t('@type failed.
@severity: @error', array('@type' => $types[$data['txn_type']], '@severity' => $nvp_response['L_SEVERITYCODE0'], '@error' => $nvp_response['L_ERRORCODE0'] .'. '. $nvp_response['L_LONGMESSAGE0'])); - if ($data['txn_type'] != UC_CREDIT_PRIOR_AUTH_CAPTURE) { - $message .= '
'. t('Address: @avscode', array('@avscode' => _uc_paypal_avscode_message($nvp_response['AVSCODE']))); - if (variable_get('uc_credit_cvv_enabled', TRUE)) { - $message .= '
'. t('CVV2: @cvvmatch', array('@cvvmatch' => _uc_paypal_cvvmatch_message($nvp_response['CVV2MATCH']))); - } - } - $result = array( - 'success' => FALSE, - 'message' => $message, - 'uid' => $user->uid, - ); - } - else { - $message = t('@type
Success: @amount @currency', array('@type' => $types[$data['txn_type']], '@amount' => uc_price($nvp_response['AMT'], $context, array('sign' => FALSE)), '@currency' => $nvp_response['CURRENCYCODE'])); - if ($data['txn_type'] != UC_CREDIT_PRIOR_AUTH_CAPTURE) { - $message .= '
'. t('Address: @avscode', array('@avscode' => _uc_paypal_avscode_message($nvp_response['AVSCODE']))); - if (variable_get('uc_credit_cvv_enabled', TRUE)) { - $message .= '
'. t('CVV2: @cvvmatch', array('@cvvmatch' => _uc_paypal_cvvmatch_message($nvp_response['CVV2MATCH']))); + switch ($nvp_response['ACK']) { + case 'SuccessWithWarning': + watchdog('uc_payment', '@type succeeded with a warning.
@severity: @error', + array( + '@type' => $types[$data['txn_type']], + '@severity' => $nvp_response['L_SEVERITYCODE0'], + '@error' => $nvp_response['L_ERRORCODE0'] .'. '. $nvp_response['L_LONGMESSAGE0'] + ), + WATCHDOG_WARNING, + l(t('view order'), 'admin/store/orders/'. $order_id) + ); + // fall through + case 'Success': + $message = t('@type
Success: @amount @currency', array('@type' => $types[$data['txn_type']], '@amount' => uc_price($nvp_response['AMT'], $context, array('sign' => FALSE)), '@currency' => $nvp_response['CURRENCYCODE'])); + if ($data['txn_type'] != UC_CREDIT_PRIOR_AUTH_CAPTURE) { + $message .= '
'. t('Address: @avscode', array('@avscode' => _uc_paypal_avscode_message($nvp_response['AVSCODE']))); + if (variable_get('uc_credit_cvv_enabled', TRUE)) { + $message .= '
'. t('CVV2: @cvvmatch', array('@cvvmatch' => _uc_paypal_cvvmatch_message($nvp_response['CVV2MATCH']))); + } } - } - $result = array( - 'success' => TRUE, - 'comment' => t('PayPal transaction ID: @transactionid', array('@transactionid' => $nvp_response['TRANSACTIONID'])), - 'message' => $message, - 'data' => check_plain($nvp_response['TRANSACTIONID']), - 'uid' => $user->uid, - ); + $result = array( + 'success' => TRUE, + 'comment' => t('PayPal transaction ID: @transactionid', array('@transactionid' => $nvp_response['TRANSACTIONID'])), + 'message' => $message, + 'data' => check_plain($nvp_response['TRANSACTIONID']), + 'uid' => $user->uid, + ); - // If this was an authorization only transaction... - if ($data['txn_type'] == UC_CREDIT_AUTH_ONLY) { - // Log the authorization to the order. - uc_credit_log_authorization($order_id, $nvp_response['TRANSACTIONID'], $nvp_response['AMT']); - } - elseif ($data['txn_type'] == UC_CREDIT_PRIOR_AUTH_CAPTURE) { - uc_credit_log_prior_auth_capture($order_id, $data['auth_id']); - } + // If this was an authorization only transaction... + if ($data['txn_type'] == UC_CREDIT_AUTH_ONLY) { + // Log the authorization to the order. + uc_credit_log_authorization($order_id, $nvp_response['TRANSACTIONID'], $nvp_response['AMT']); + } + elseif ($data['txn_type'] == UC_CREDIT_PRIOR_AUTH_CAPTURE) { + uc_credit_log_prior_auth_capture($order_id, $data['auth_id']); + } - // Log the IPN to the database. - db_query("INSERT INTO {uc_payment_paypal_ipn} (order_id, txn_id, txn_type, mc_gross, status, receiver_email, payer_email, received) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', %d)", + // Log the IPN to the database. + db_query("INSERT INTO {uc_payment_paypal_ipn} (order_id, txn_id, txn_type, mc_gross, status, receiver_email, payer_email, received) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', %d)", $order->order_id, $nvp_response['TRANSACTIONID'], 'web_accept', $amount, 'Completed', '', $order->primary_email, time()); + + break; + case 'FailureWithWarning': + // fall through + case 'Failure': + $message = t('@type failed.
@severity: @error', array('@type' => $types[$data['txn_type']], '@severity' => $nvp_response['L_SEVERITYCODE0'], '@error' => $nvp_response['L_ERRORCODE0'] .'. '. $nvp_response['L_LONGMESSAGE0'])); + if ($data['txn_type'] != UC_CREDIT_PRIOR_AUTH_CAPTURE) { + $message .= '
'. t('Address: @avscode', array('@avscode' => _uc_paypal_avscode_message($nvp_response['AVSCODE']))); + if (variable_get('uc_credit_cvv_enabled', TRUE)) { + $message .= '
'. t('CVV2: @cvvmatch', array('@cvvmatch' => _uc_paypal_cvvmatch_message($nvp_response['CVV2MATCH']))); + } + } + $result = array( + 'success' => FALSE, + 'message' => $message, + 'uid' => $user->uid, + ); + break; + default: + $message = t('Unexpected acknowledgement status: @status', array('@status' => $nvp_response['ACK'])); + $result = array( + 'success' => NULL, + 'message' => $message, + 'uid' => $user->uid, + ); + break; } uc_order_comment_save($order_id, $user->uid, $message, 'admin');