Jump to content

Authorize.net/ Order Status


craigfh

Recommended Posts

Howdy, I need help with the Authorize.net payment plugin. I'm using a vendor called plug n pay which uses the authorize.net payment api. The only change I had to make to make this paymet gateway wrk was to change:

line: 95 of modules/gateway/Authorize_AIM/Form.Inc.PHP From:

if($module['testMode'] == 1) {

$auth_net_url = "https://test.authorize.net/gateway/transact.dll";

$TESTING = 1; # Set the testing flag so that transactions are not live

} else {

$auth_net_url = "https://test.authorize.net/gateway/transact.dll";

}

To:

if($module['testMode'] == 1) {

$auth_net_url = "https://pay1.plugnpay.com/payment/pnpremote.cgi";

//$auth_net_url = "https://test.authorize.net/gateway/transact.dll";

$TESTING = 1; # Set the testing flag so that transactions are not live

} else {

$auth_net_url = "https://pay1.plugnpay.com/payment/pnpremote.cgi";

}

Everything seemed to work just fine is testing mode. When I put thru a test transaction it came back and said the payment was received, and automatically moved the order status to Order Complete & Dispatched(Note this is how I want it to react). Now that it is live all orders drop directly into Processing. Not what we want.

I've tied the cart directly to a Point of Sale System that auto drop ships the products for me. However it doesn't send the info into the POS system until the order status is: Order Complete and Dispatched.

I'm not sure If what I need is a mod or not, because originally it worked fine(in test mode). I even reviewed the code for the payment gateway and I don;t see how it could post anything but an order status of 3. If it fails it sends it's own error message based on the Authorize.net system, and doesn't change the order status.

Help.

My Email Direct

Paul Norton Production Manager

Link to comment
Share on other sites

  • 1 year later...

Howdy, I need help with the Authorize.net payment plugin. I'm using a vendor called plug n pay which uses the authorize.net payment api. The only change I had to make to make this paymet gateway wrk was to change:

line: 95 of modules/gateway/Authorize_AIM/Form.Inc.PHP From:

if($module['testMode'] == 1) {

$auth_net_url = "https://test.authorize.net/gateway/transact.dll";

$TESTING = 1; # Set the testing flag so that transactions are not live

} else {

$auth_net_url = "https://test.authorize.net/gateway/transact.dll";

}

To:

if($module['testMode'] == 1) {

$auth_net_url = "https://pay1.plugnpay.com/payment/pnpremote.cgi";

//$auth_net_url = "https://test.authorize.net/gateway/transact.dll";

$TESTING = 1; # Set the testing flag so that transactions are not live

} else {

$auth_net_url = "https://pay1.plugnpay.com/payment/pnpremote.cgi";

}

Everything seemed to work just fine is testing mode. When I put thru a test transaction it came back and said the payment was received, and automatically moved the order status to Order Complete & Dispatched(Note this is how I want it to react). Now that it is live all orders drop directly into Processing. Not what we want.

I've tied the cart directly to a Point of Sale System that auto drop ships the products for me. However it doesn't send the info into the POS system until the order status is: Order Complete and Dispatched.

I'm not sure If what I need is a mod or not, because originally it worked fine(in test mode). I even reviewed the code for the payment gateway and I don;t see how it could post anything but an order status of 3. If it fails it sends it's own error message based on the Authorize.net system, and doesn't change the order status.

Help.

My Email Direct

Paul Norton Production Manager

Paul,

We recently started using a Cube Cart site (v 4.3.8). We also use Authorize.net. I have discovered the same problem. I believe I have discovered the cause of this error.

When an order is moved to the payment processing screen, it is set to Status = 2.

When the payment is successful, it SHOULD be set to Status = 3.

However, a line in /classes/cart/order.php prevents the code from entering the switch statement that will update the status (and other processing).

The culprit:

/classes/cart/order.php

approx. line 196: if($currentStatus[0]['status'] !== $statusId)

Problem:

Using === OR !== as comparison operators requires that the two values be identical in every way. Same value. Same type. etc. Unfortunately, the values being compared are not exact matches. In this case, the values may both look like numbers but they are not both considered integers. One may be a string and one may be an integer for example.

Here is the results of a quick test I ran that should help illustrate my point...

<!-- $currentStatus[0]['status']: 1 -->

<!-- $statusId: 1 -->

<!-- $currentStatus[0]['status'] $string: STRING -->

<!-- $statusId $string: NOT STRING -->

Solution:

There are two options:

1) Make sure that both pieces of information are the same type. This can be accomplished by type casting. PHP variables are flexible when it comes to type. If you set the type then you can be sure the types are the same.

To type cast the values, I'd add the following lines above the if statement...

$currentStatusId = (int)$currentStatus[0]['status'];

$statusId = (int)$statusId;

2) Alter the comparison operator to be 'less exact'. If you use the operators == OR != then it only compares the value. Now the type of the data held in the variable is no longer a concern for the sake of comparison. It will simply compare the value held in one variable against the other for a match.

change approx. line 196: if($currentStatus[0]['status'] != $statusId)

I'd suggest option 2. It's the simplest to implement.

Link to comment
Share on other sites

Follow up...

We were still having problems with orders not confirming. We were getting into the case statement, however the Status was being set to 2 once inside.

The culprit...

/classes/cart/order.php

approx. line 243

## If the order contains tangible items, we set it to ORDER_PROCESSING, and break the loop

if(!$this->orderInv[$i]['digital'] && !$force)

{

$this->orderStatus(2, $cart_order_id);

$statusId = 2; ## Safeguard

$breakStatus = true; ## Stops email sending below no way to stop this case ?!

break;

}

Simply put, if you have a tangible item in your basket, the status will be set to 2 and you'll exit the loop.

At the bottom of the method, an update is run on the status of the order, which is now status 2 (processing).

Possible solutions...

If you want the cart to always automatically set status to complete, then...

1) Comment out the entire if statement.

OR

2) add (just above if)

$force = TRUE;

If you want to just force accepted payments to always set status to complete, then...

/modules/gateway/Authorize_AIM/form.inc.php

approx. line 305

$order->orderStatus(3,$orderSum['cart_order_id']);

change to

$order->orderStatus(3,$orderSum['cart_order_id'], TRUE);

That third parameter sets $force == TRUE for that particular call.

Personally, I am going to comment out the entire if statement and monitor CubeCart's behaviour to see if there are any problems.

You may wish to just add the third parameter to the orderStatus call. It's not a sweeping change like the one I'm making so if there is a problem, you know exactly where it stems from.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...