--- uc_paypal.module 2012-04-18 07:01:02.000000000 -0500
+++ uc_paypal_new.module 2012-04-18 07:03:09.000000000 -0500
@@ -841,6 +841,29 @@ function uc_paypal_ec_submit_form_submit
$nvp_response = uc_paypal_api_request($nvp_request, variable_get('uc_paypal_wpp_server', 'https://api-3t.sandbox.paypal.com/nvp'));
+ //Kirkham Systems http://kirkhamsystems.com, Joseph Farhat. 2012-04-17 Added the section to properly apply the paymenr to the order
+ // on succeeded payment transaction.
+ if ($nvp_response['ACK'] == 'Success' || $nvp_response['ACK'] == 'SuccessWithWarning') {
+ $message = t('@type
Success: @amount @currency', array('@type' => $nvp_response['TRANSACTIONTYPE'], '@amount' => uc_price($nvp_response['AMT'], $context, array('sign' => FALSE)), '@currency' => $nvp_response['CURRENCYCODE']));
+ $comment = t('PayPal EC transaction ID: @transactionid', array('@transactionid' => $nvp_response['TRANSACTIONID']));
+
+ // Store the PayPal transaction ID to the order
+ $order->data['transactionid'] = $nvp_response['TRANSACTIONID'];
+
+ // 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'], $nvp_response['TRANSACTIONTYPE'], $nvp_response['AMT'], $nvp_response['PAYMENTSTATUS'], '', $order->primary_email, time());
+
+ // enter payment to the order
+ uc_payment_enter($order->order_id, 'paypal_ec', $nvp_response['AMT'], empty($user->uid) ? 0 : $user->uid, $order->data, $comment);
+ }
+ else if($nvp_response['ACK'] == 'Failure'){
+ $message = t('@type failed.', array('@type' => $nvp_response['TRANSACTIONTYPE'])) . _uc_paypal_build_error_messages($nvp_response);
+ }
+
+ uc_order_comment_save($order_id, $user->uid, $message, 'admin');
+ // End Kirkham Systems. 2012-04-17 log payment
+
unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
$_SESSION['do_complete'] = TRUE;