Пример #1
0
    private static void HandleNewOrderNotification(GCheckout.AutoGen.NewOrderNotification inputNewOrderNotification)
    {
        // Retrieve data from MerchantPrivateData
        GCheckout.AutoGen.anyMultiple oneAnyMultiple  = inputNewOrderNotification.shoppingcart.merchantprivatedata;
        System.Xml.XmlNode[]          oneXmlNodeArray = oneAnyMultiple.Any;
        string hiddenMerchantPrivateData = oneXmlNodeArray[0].InnerText;

        // TODO: Process the MerchantPrivateData if provided

        foreach (GCheckout.AutoGen.Item oneItem in inputNewOrderNotification.shoppingcart.items)
        {
            // TODO: Get MerchantItemId from shopping cart item (oneItem.merchantitemid) and process it
        }

        // TODO: Add custom processing for this notification type
    }
    private static void HandleNewOrderNotification(GCheckout.AutoGen.NewOrderNotification inputNewOrderNotification)
    {
        try
        {
            if (inputNewOrderNotification.shoppingcart.merchantprivatedata != null && inputNewOrderNotification.shoppingcart.merchantprivatedata.Any != null && inputNewOrderNotification.shoppingcart.merchantprivatedata.Any.Length > 0)
            {
                //Retrieve data from MerchantPrivateData
                GCheckout.AutoGen.anyMultiple oneAnyMultiple  = inputNewOrderNotification.shoppingcart.merchantprivatedata;
                System.Xml.XmlNode[]          oneXmlNodeArray = oneAnyMultiple.Any;
                foreach (XmlNode xn in oneXmlNodeArray)
                {
                    if (xn.Name == "OrderID")
                    {
                        orderID = Int32.Parse(xn.InnerText.ToString());
                    }

                    if (xn.Name == "userName")
                    {
                        userName = xn.InnerText.ToString();
                    }

                    if (xn.Name == "amount")
                    {
                        totalAmount = decimal.Parse(xn.InnerText.ToString());
                    }

                    if (xn.Name == "selectedCurrency")
                    {
                        selectedCurrency = xn.InnerText.ToString();
                    }

                    if (xn.Name == "portalID")
                    {
                        portalID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "customerID")
                    {
                        customerID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "itemIds")
                    {
                        itemIds = xn.InnerText.ToString();
                    }
                    if (xn.Name == "storeID")
                    {
                        storeID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "couponCode")
                    {
                        couponCode = xn.InnerText.ToString();
                    }
                    if (xn.Name == "sessionCode")
                    {
                        sessionCode = xn.InnerText.ToString();
                    }
                    if (xn.Name == "pgID")
                    {
                        pgID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "MerchantID")
                    {
                        MerchantID = xn.InnerText.ToString();
                    }
                    if (xn.Name == "MerchantKey")
                    {
                        MerchantID = xn.InnerText.ToString();
                    }
                }
                paymentStatus = GCNotificationStatus.Succeeded.ToString();
                transID       = inputNewOrderNotification.googleordernumber;

                if (paymentStatus == "Succeeded")
                {
                    TransactionLogInfo     tinfo = new TransactionLogInfo();
                    TransactionLog         Tlog  = new TransactionLog();
                    OrderDetailsCollection odc   = new OrderDetailsCollection();

                    tinfo.ResponseReasonText = "Succeeded";
                    tinfo.OrderID            = orderID;
                    tinfo.StoreID            = storeID;
                    tinfo.PortalID           = portalID;
                    tinfo.AddedBy            = userName;
                    tinfo.CustomerID         = customerID;
                    tinfo.SessionCode        = sessionCode;
                    tinfo.PaymentGatewayID   = pgID;
                    tinfo.PaymentStatus      = paymentStatus;
                    tinfo.PayerEmail         = "";
                    tinfo.CreditCard         = "";
                    tinfo.TotalAmount        = totalAmount;
                    tinfo.TransactionID      = transID;
                    tinfo.RecieverEmail      = "";
                    tinfo.CurrencyCode       = selectedCurrency;
                    Tlog.SaveTransactionLog(tinfo);

                    GoogleCheckOutHandler.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode);
                    GoogleCheckOutHandler.UpdateItemQuantity(itemIds, couponCode, storeID, portalID, userName);
                    CartManageSQLProvider cms           = new CartManageSQLProvider();
                    AspxCommonInfo        aspxCommonObj = new AspxCommonInfo();
                    aspxCommonObj.CustomerID  = customerID;
                    aspxCommonObj.SessionCode = sessionCode;
                    aspxCommonObj.StoreID     = storeID;
                    aspxCommonObj.PortalID    = portalID;
                    aspxCommonObj.CultureName = null;
                    aspxCommonObj.UserName    = null;
                    cms.ClearCartAfterPayment(aspxCommonObj);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        // TODO: Process the MerchantPrivateData if provided

        foreach (GCheckout.AutoGen.Item oneItem in inputNewOrderNotification.shoppingcart.items)
        {
            // TODO: Get MerchantItemId from shopping cart item (oneItem.merchantitemid) and process it
        }

        // TODO: Add custom processing for this notification type
    }
    //private GoogleCheckOutSettingInfo GetSettingGooglePayment()
    //{
    //    GoogleCheckOutSettingInfo setting = new GoogleCheckOutSettingInfo();
    //    GoogleCheckOutWCFService ser = new GoogleCheckOutWCFService();

    //}
    public static void ProcessNotification(string serialNumber)
    {
        GoogleCheckOutWCFService            pw = new GoogleCheckOutWCFService();
        List <GoogleCheckOutSettingKeyInfo> sf;

        sf          = pw.GoogleCheckOutSettingKey();
        MerchantID  = sf[0].GoogleMerchantID;
        MerchantKey = sf[0].GoogleMerchantKey;
        Environment = sf[0].GoogleEnvironmentType;

        GCheckout.OrderProcessing.NotificationHistorySerialNumber sn = new NotificationHistorySerialNumber(serialNumber);
        GCheckout.OrderProcessing.NotificationHistoryRequest      oneNotificationHistoryRequest = new NotificationHistoryRequest(MerchantID, MerchantKey, Environment, sn); //newNotificationHistorySerialNumber(serialNumber)
        //Response
        NotificationHistoryResponse oneNotificationHistoryResponse = (NotificationHistoryResponse)oneNotificationHistoryRequest.Send();

//Get type of notification
        object notification = GCheckout.Util.EncodeHelper.Deserialize(oneNotificationHistoryResponse.ResponseXml);

//Check for the notification and call functions according to that
        if (notification.GetType().Equals(typeof(GCheckout.AutoGen.NewOrderNotification)))

        {
            GCheckout.AutoGen.NewOrderNotification oneNewOrderNotification = (GCheckout.AutoGen.NewOrderNotification)notification;

            if (oneNewOrderNotification.serialnumber.Equals(serialNumber))

            {
                HandleNewOrderNotification(oneNewOrderNotification);
            }
        }

        else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.OrderStateChangeNotification)))

        {
            GCheckout.AutoGen.OrderStateChangeNotification oneOrderStateChangeNotification = (GCheckout.AutoGen.OrderStateChangeNotification)notification;

            if (oneOrderStateChangeNotification.serialnumber.Equals(serialNumber))

            {
                HandleOrderStateChangeNotification(oneOrderStateChangeNotification);
            }
        }

        else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.RiskInformationNotification)))

        {
            GCheckout.AutoGen.RiskInformationNotification oneRiskInformationNotification = (GCheckout.AutoGen.RiskInformationNotification)notification;

            if (oneRiskInformationNotification.serialnumber.Equals(serialNumber))

            {
                HandleRiskInformationNotification(oneRiskInformationNotification);
            }
        }

        else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.AuthorizationAmountNotification)))

        {
            GCheckout.AutoGen.AuthorizationAmountNotification oneAuthorizationAmountNotification = (GCheckout.AutoGen.AuthorizationAmountNotification)notification;

            if (oneAuthorizationAmountNotification.serialnumber.Equals(serialNumber))

            {
                HandleAuthorizationAmountNotification(oneAuthorizationAmountNotification);
            }
        }

        else if (notification.GetType().Equals(typeof(GCheckout.AutoGen.ChargeAmountNotification)))

        {
            GCheckout.AutoGen.ChargeAmountNotification oneChargeAmountNotification = (GCheckout.AutoGen.ChargeAmountNotification)notification;

            if (oneChargeAmountNotification.serialnumber.Equals(serialNumber))

            {
                HandleChargeAmountNotification(oneChargeAmountNotification);
            }
        }

        else

        {
            string exceptionText = "Unhandled Type [" + notification.GetType().ToString() + "]!; serialNumber=[" + serialNumber + "];";

            throw new ArgumentOutOfRangeException(exceptionText);
        }
    }
 /// <summary>
 /// Initialize the Xml Documents
 /// </summary>
 static NotificationTests()
 {
     using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("GCheckout.Checkout.Tests.Xml.new-order-notification-base.xml")) {
     extended = GCheckout.Util.EncodeHelper.Deserialize(s) as NewOrderNotification;
       }
 }
Пример #5
0
    public static void ProcessNotification(string serialNumber)
    {
        //The next two statements set up a request and call google checkout for the details based on that serial number.

        NotificationHistoryRequest oneNotificationHistoryRequest
            = new NotificationHistoryRequest(new NotificationHistorySerialNumber(serialNumber));

        NotificationHistoryResponse oneNotificationHistoryResponse
            = (NotificationHistoryResponse)oneNotificationHistoryRequest.Send();

        // oneNotificationHistoryResponse.ResponseXml contains the complete response

        //what you need to do now is process the data that was returned.

        // Iterate through the notification history for this order looking for the notification that exactly matches the given serial number
        foreach (object oneNotification in oneNotificationHistoryResponse.NotificationResponses)
        {
            if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.NewOrderNotification)))
            {
                GCheckout.AutoGen.NewOrderNotification oneNewOrderNotification = (GCheckout.AutoGen.NewOrderNotification)oneNotification;
                if (oneNewOrderNotification.serialnumber.Equals(serialNumber))
                {
                    HandleNewOrderNotification(oneNewOrderNotification);
                }
            }
            else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.OrderStateChangeNotification)))
            {
                GCheckout.AutoGen.OrderStateChangeNotification oneOrderStateChangeNotification = (GCheckout.AutoGen.OrderStateChangeNotification)oneNotification;
                if (oneOrderStateChangeNotification.serialnumber.Equals(serialNumber))
                {
                    HandleOrderStateChangeNotification(oneOrderStateChangeNotification);
                }
            }
            else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.RiskInformationNotification)))
            {
                GCheckout.AutoGen.RiskInformationNotification oneRiskInformationNotification = (GCheckout.AutoGen.RiskInformationNotification)oneNotification;
                if (oneRiskInformationNotification.serialnumber.Equals(serialNumber))
                {
                    HandleRiskInformationNotification(oneRiskInformationNotification);
                }
            }
            else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.AuthorizationAmountNotification)))
            {
                GCheckout.AutoGen.AuthorizationAmountNotification oneAuthorizationAmountNotification = (GCheckout.AutoGen.AuthorizationAmountNotification)oneNotification;
                if (oneAuthorizationAmountNotification.serialnumber.Equals(serialNumber))
                {
                    HandleAuthorizationAmountNotification(oneAuthorizationAmountNotification);
                }
            }
            else if (oneNotification.GetType().Equals(typeof(GCheckout.AutoGen.ChargeAmountNotification)))
            {
                GCheckout.AutoGen.ChargeAmountNotification oneChargeAmountNotification = (GCheckout.AutoGen.ChargeAmountNotification)oneNotification;
                if (oneChargeAmountNotification.serialnumber.Equals(serialNumber))
                {
                    HandleChargeAmountNotification(oneChargeAmountNotification);
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException("Unhandled Type [" + oneNotification.GetType().ToString() + "]!; serialNumber=[" + serialNumber + "];");
            }
        }
    }