Hello!

I seem to have a problem and can't find any posts or any further information, I'm hoping someone here can help.

I have anonymous checkout enabled. Which means ubercart creates a user with the email and information you insert during checkout.

In a few orders, customer accounts were created and I can see Ubercart/Drupal have assigned an ID to them "customer number" If they have this ID, the system can track the order status correctly (in progress, abanadoned, completed)

I can see the payment go through the Moneris hosted pay page gateway. Moneris replies "Completed" if the credit card is approved and returns us to the completed page. This works well and updates the order status to completed.

Problem is, on orders, even if I see the payment go through Moneris, the order status stays to "Abandoned". The ONLY thing that I could find that didnt make sense was the fact that no user account had been created for this order. In the "View customers" page I cant see the customer with the problem and in the invoice the customer has an id of 0.

Any ideas?

Thanks!

Comments

TR’s picture

Priority: Major » Normal

Test to see if you can reproduce this with one of the core Ubercart payment methods, like check or test gateway. It's likely the problem is with the Moneris module, in which case your report should be moved to that queue.

voodoodan245730’s picture

I will try to reproduce it for sure!

But I can see 2-3 payments that have gone through without any problems.

I don't see why the payment gateway would be the issue as no customer ID is being created.

I have 2-3 payments that have been completed with customer ID and everything and payment received at Moneris and I also have 2-3 orders that have been abandoned in Ubercart but have been completed in Moneris???

Many thanks!

TR’s picture

The order isn't set to "Abandoned" unless the payment gateway fails to confirm the payment and set the status to "Payment received". If the payment isn't getting confirmed, or the user isn't getting created, that indicates that the payment gateway code is executing things in the wrong order (where it calls uc_cart_complete_sale(), in particular) or perhaps has buggy/incomplete code.

longwave’s picture

Can you try upgrading Ubercart to 7.x-3.x-dev and see if the issue goes away? Since 7.x-3.5 was released, #1597154: Some PayPal Standard Orders "Abandoned" even though payment is received was fixed, and if Moneris works in a similar way to PayPal - that is, it relies on a callback being sent to confirm the payment - then the same issue and fix might apply here.

voodoodan245730’s picture

Thank you for your suggestion, I will give this a try and report back!

The Moneris payment gateway module that is being used is one that was ported from Commerce to Ubercart. It works well but I just noticed this problem. It also relies on a callback to confirm the payment. If "some" paypal orders had this same issue then the dev version should fix it.

Here is the code for Callback of a completed order :


/**
 * Callback for completed order.
 */
function uc_monerishpp_complete($cart_id = 0) {
  $output = '';
  $comment = '';
  // Passed through Moneris.
  $order_id = $_POST['rvar_order_id'];
  $order = uc_order_load($order_id);

  if ($order === FALSE || uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
    return variable_get('uc_monerishpp_order_error_msg', '');
  }
  if ((int) $_POST['response_code'] < '50') {
    // Transaction approved.
    $comment = t('Dear !cardholder.  Your order #!order was processed.  Your !type in the amount of !amount was processed on !date at !time.  Authorization #!auth.  Response code !resp. ISO code !iso.  Reference #!refnum.  !message.',
      array(
        '!type' => check_plain($_POST['trans_name']),
        '!order' => check_plain($_POST['rvar_order_id']),
        '!amount' => check_plain($_POST['charge_total']),
        '!date' => check_plain($_POST['date_stamp']),
        '!time' => check_plain($_POST['time_stamp']),
        '!auth' => check_plain($_POST['bank_approval_code']),
        '!resp' => check_plain($_POST['response_code']),
        '!iso' => check_plain($_POST['iso_code']),
        '!message' => check_plain($_POST['message']),
        '!refnum' => check_plain($_POST['bank_transaction_id']),
        '!cardholder' => check_plain($_POST['cardholder']),
      )
    );
    uc_payment_enter($order->order_id, 'monerishpp', $_POST['charge_total'], 0, NULL, $comment);
    $output = uc_cart_complete_sale($order, TRUE);
    uc_cart_empty($cart_id);
  }
  else {
    drupal_set_message(t('Credit card payment declined.'));
    uc_order_comment_save($order->order_id, 0, t('Credit card payment declined at Moneris.'), 'admin');
  }
  $message = $output['#message'];
  $message .= '<br/><br/>' . $comment;
  $output['#message'] = $message;
  return $output;
}

Many thanks!

longwave’s picture

Status: Active » Postponed (maintainer needs more info)

Did upgrading to 7.x-3.x-dev solve this issue?

sigveio’s picture

Just a thought on this;

If it's a new user, who is not logged on, uc_payment_enter() would call uc_cart_complete_sale() to make sure the account is created prior to entering the payment. However... since $order is not passed directly to uc_payment_enter() there is no reference to the original $order object in uc_monerishpp_complete(). This in turns means that the $order object will not be up to date at the point where uc_cart_complete_sale($order, TRUE) is called to do the login... and $order->uid would therefore be the default 0.

If the above is correct... I would also think that it could potentially cause further trouble/unintended behaviour seeing as uc_cart_complete_sale() relies on updated order data to safeguard against running the account creation and such more than once.
(I missed the fact that $order->data is refreshed through a query in uc_cart_complete_sale().)

For an example uc_paypal manages to avoid this issue because it redirects to cart/checkout/complete after a completed sale. This in turn executes the menu callback uc_cart_checkout_complete() - which makes sure to reload the order before uc_cart_complete_sale() is ran again.

Might be worth looking into.

The quick-fix could potentially be to alter uc_monerishpp_complete() as follows:

     uc_payment_enter($order->order_id, 'monerishpp', $_POST['charge_total'], 0, NULL, $comment);
+    $order = uc_order_load($order);
     $output = uc_cart_complete_sale($order, TRUE);
-    uc_cart_empty($cart_id);

(Note: uc_cart_empty() can be removed while you are at it... because uc_cart_complete_sale() will take care of this.)

I am not able to test this... so this is all theoretical of course.

longwave’s picture

The above doesn't explain why it only happens for some orders and not all, which is why I thought it was the timing related issue fixed in #1597154: Some PayPal Standard Orders "Abandoned" even though payment is received. That's definitely another avenue to explore though if the 7.x-3.x-dev upgrade doesn't work here.

voodoodan245730’s picture

Thanks for you help everyone!

Upgrading to the Dev version did fix the issue.

However, after some extensive research, I'm not 100% sure that this was an Ubercart/Moneris payment module problem. I believe Moneris might of had some issues during these transactions and was not returning the correct response code. This is my conclusion as I cant reproduce the problem on the Dev or Recommended release version anymore.

Many thanks!

longwave’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed

Thanks for getting back to us :)

longwave’s picture

Issue summary: View changes

added correct page

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.