Jump to content

Pending to Processing


Recommended Posts

In the gateway.class.php file of a gateway (as opposed to a plugin), there will be a call() or process() function that will instantiate the Order class:

Order::getInstance()

Later, depending on the result of verifying the transaction, there will be:

$order->orderStatus(Order::ORDER_PROCESS, $cart_order_id);

That statement tells CubeCart to move the order to the Processing status.

Link to comment
Share on other sites

8 hours ago, bsmither said:

In the gateway.class.php file of a gateway (as opposed to a plugin), there will be a call() or process() function that will instantiate the Order class:


Order::getInstance()

Later, depending on the result of verifying the transaction, there will be:


$order->orderStatus(Order::ORDER_PROCESS, $cart_order_id);

That statement tells CubeCart to move the order to the Processing status.

It appears to be missing:

## Get the Order ID
        $cart_order_id    = $_POST['invoice'];
        if (!empty($cart_order_id) && !empty($data)) {
            $order                = Order::getInstance();
            $order_summary        = $order->getSummary($cart_order_id);
            $transData['notes']    = array();
            switch ($data) {
                case 'INVALID':
                    ## If this is the response, then something is wrong with the callback
                    $transData['notes'][]    = "Unspecified Error.";
                    break;
                case 'VERIFIED':
                    switch ($_POST['payment_status']) {
                        case 'Completed':
                            $transData['notes'][]    = "Payment successful. <br />Address: ".$_POST['address_status']."<br />Payer Status: ".$_POST['payer_status'];
                            $order->paymentStatus(Order::PAYMENT_SUCCESS, $cart_order_id);
                            $order->orderStatus(Order::ORDER_PROCESS, $cart_order_id);
                            break;
                        case 'Canceled_Reversal':
                            $transData['notes'][]    = "This means a reversal has been canceled; for example, you, the merchant, won a dispute with the customer and the funds for the transaction that was reversed have been returned to you.";
                            $order->paymentStatus(Order::PAYMENT_CANCEL, $cart_order_id);
                            $order->orderStatus(Order::ORDER_CANCELLED, $cart_order_id);
                            break;
                        case 'Denied':
                            $transData['notes'][]    = "You, the merchant, denied the payment. This will only happen if the payment was previously pending due to one of the following pending reasons.";
                            $order->paymentStatus(Order::PAYMENT_DECLINE, $cart_order_id);
                            $order->orderStatus(Order::ORDER_CANCELLED, $cart_order_id);
                            break;
                        case 'Failed':
                            $transData['notes'][]    = "The payment has failed. This will only happen if the payment was attempted from your customer's bank account.";
                            $order->paymentStatus(Order::PAYMENT_DECLINE, $cart_order_id);
                            $order->orderStatus(Order::ORDER_DECLINED, $cart_order_id);
                            break;
                        case 'Pending':
                            $transData['notes'][]    = "The payment is pending; see the pending_reason variable for more information. Please note, you will receive another Instant Payment Notification when the status of the payment changes to 'Completed', 'Failed', or 'Denied'.";
                            $order->paymentStatus(Order::PAYMENT_PENDING, $cart_order_id);
                            $order->orderStatus(Order::ORDER_PENDING, $cart_order_id);
                            break;
                        case 'Refunded':
                            $transData['notes'][]    = "You, the merchant, refunded the payment.";
                            
                            if(isset($_POST['payment_gross']) && !empty($_POST['payment_gross'])) { // Support for legacy PayPal code for USD
                                $_POST['mc_gross'] = $_POST['payment_gross'];
                            }
                            
                            if((string)$_POST['mc_gross']==(string)'-'.$order_summary['total']) { // Change status to refunded if it is a full refund
                                $order->paymentStatus(Order::PAYMENT_CANCEL, $cart_order_id);
                                $order->orderStatus(Order::ORDER_CANCELLED, $cart_order_id);
                            }
                            break;
                        case 'Reversed':
                            $transData['notes'][]    = "This means that a payment was reversed due to a chargeback or other type of reversal. The funds have been debited from your account balance and returned to the customer. The reason for the reversal is given by the reason_code variable.";
                            $order->paymentStatus(Order::PAYMENT_CANCEL, $cart_order_id);
                            $order->orderStatus(Order::ORDER_CANCELLED, $cart_order_id);
                            break;
                        default:
                            $transData['notes'][]    = "Unspecified Error.";
                            $order->paymentStatus(Order::PAYMENT_DECLINE, $cart_order_id);
                            $order->orderStatus(Order::ORDER_DECLINED, $cart_order_id);
                            break;
                    }
                    break;
            }

Link to comment
Share on other sites

2 hours ago, bsmither said:

It's there, five lines after Case 'VERIFIED':

 case 'VERIFIED':
                    switch ($_POST['payment_status']) {
                        case 'Completed':
                            $transData['notes'][]    = "Payment successful. <br />Address: ".$_POST['address_status']."<br />Payer Status: ".$_POST['payer_status'];
                            $order->paymentStatus(Order::PAYMENT_SUCCESS, $cart_order_id);
                            $order->orderStatus(Order::ORDER_PROCESS, $cart_order_id);
                            break;

I guess this line? I had this fixed before, but I don't recall it being here. I need to change the code to update to processing upon payment pending.

 

 

 

Link to comment
Share on other sites

So, you are wanting CubeCart to send an order to Processing when it would otherwise go to Pending?

When an order goes to Pending, up to two things happen depending on settings: the admin is notified, and the stock level is adjusted.

So, in /classes/order.class.php

Near line 399, find:

				case self::ORDER_PENDING;

On a new blank line after that, add:

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

 

Link to comment
Share on other sites

  • 3 weeks later...
On 3/9/2017 at 1:02 AM, bsmither said:

So, you are wanting CubeCart to send an order to Processing when it would otherwise go to Pending?

When an order goes to Pending, up to two things happen depending on settings: the admin is notified, and the stock level is adjusted.

So, in /classes/order.class.php


Near line 399, find:

				case self::ORDER_PENDING;

On a new blank line after that, add:

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

 

I'm not sure this is working. I get double emails, my customers are getting doubles as well. I need to have the order status go to pending when they checkout, and process on payment notification, which will be a payment is pending( The payment is pending; see the pending_reason variable for more information. Please note, you will receive another Instant Payment Notification when the status of the payment changes to 'Completed', 'Failed', or 'Denied'. This Transaction ID has been processed before. Recipient account didn't match specified PayPal account. ). This message should trigger pending to processing for me. I can;t see to find where I made the change on the last version before the upgrade. This setup allows me to have inventory reduced as a payment has been authorized and the money is guaranteed at this point from paypal( would be a nice feature to add to cubecart by the way)

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...