Payment Gateway - Payment Status when navigating to third party payment gateway

Chamara Janaka asked on January 20, 2017 06:15

Hi,

When the user navigates to a third party payment gateway, Kentico always sets the OrderStatusID = 1 which is Failed Payment but actually user hasn't made the payment yet. Following is my code. Even though I try to set the status to InProgress forcefully it still sets to 1 in the database.

public override void ProcessPayment()
    {
        // Get payment gateway url
        string url = GetPaymentGatewayUrl();
        if (url != "")
        {
            //this.ShoppingCartControl.RedirectAfterPurchase
            // Initialize payment parameters
            Hashtable parameters = InitializePaymentParameters();
            // Add required payment data to the url
            url = GetFullPaymentGatewayUrl(url, parameters);
            InfoMessage = "Redirecting to Payment Gateway.";
            PaymentResult.PaymentDescription = InfoMessage;

            OrderInfo order = OrderInfoProvider.GetOrderInfo(ShoppingCartInfoObj.OrderId);
            int statusID = 0;
            CMS.DataEngine.ObjectQuery<OrderStatusInfo> statuses = OrderStatusInfoProvider.GetOrderStatuses();

            foreach (OrderStatusInfo item in statuses)
            {
                if (item.StatusName == "InProgress")
                    statusID = item.StatusID;
            }


            // Update order payment result in database
            UpdateOrderPaymentResult();
            UpdateOrderStatus(order, statusID);
            // Redirect to payment gateway to finish payment
            URLHelper.Redirect(url);
        }
        else
        {
            // Show error message - payment gateway url not found
            ErrorMessage = "Unable to finish payment: Payment gateway url not found.";
            // Update payment result
            PaymentResult.PaymentDescription = ErrorMessage;
            PaymentResult.PaymentIsCompleted = false;
            // Update order payment result in database
            UpdateOrderPaymentResult();
        }


    }

Recent Answers


Anton Grekhovodov answered on January 20, 2017 07:53

Hi Chamara,

Are you sure that the line statusID = item.StatusID; is executed?

Also, order statuses can be global and internal. So maybe you have "InProgress" status in globals and don't have it in your store.

Links:
Order statuses
Multisite store
Enabling global E-commerce objects

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.