/// <summary>
 /// Create a new instance of the Exception
 /// </summary>
 /// <param name="response">The original
 /// NotificationHistoryResponse if it exists</param>
 /// <param name="nextPageToken">The Next Page Token if it exists</param>
 /// <param name="innerException">The inner exception that was throw</param>
 public NotificationHistoryException(NotificationHistoryResponse response,
     string nextPageToken, Exception innerException)
     : base(MESSAGE, innerException)
 {
     _nextPageToken = nextPageToken;
       _response = response;
 }
 /// <summary>
 /// Create a new instance of the Exception
 /// </summary>
 /// <param name="response">The original
 /// NotificationHistoryResponse if it exists</param>
 /// <param name="nextPageToken">The Next Page Token if it exists</param>
 /// <param name="innerException">The inner exception that was throw</param>
 public NotificationHistoryException(NotificationHistoryResponse response,
                                     string nextPageToken, Exception innerException)
     : base(MESSAGE, innerException)
 {
     _nextPageToken = nextPageToken;
     _response      = response;
 }
        public void Verify_new_order_notification_Messages_Can_Be_Handled()
        {
            string xml = null;

            using (Stream s = Assembly.GetExecutingAssembly()
                              .GetManifestResourceStream(
                       "GCheckout.Checkout.Tests.Xml.new-order-notification-base.xml")) {
                using (StreamReader sr = new StreamReader(s)) {
                    xml = sr.ReadToEnd();
                }
            }

            var test = new NotificationHistoryResponse(xml);

            Assert.IsTrue(test.IsGood);
            Assert.AreEqual(1, test.NotificationResponses.Count);
        }
コード例 #4
0
    //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>
        /// perform additional queries as needed.
        /// </summary>
        /// <param name="response"></param>
        private void ProcessAdditionalTokens(NotificationHistoryResponse response)
        {
            NotificationHistoryResponse currentResponse = response;

              while (string.IsNullOrEmpty(currentResponse.NextPageToken) == false) {
            NotificationHistoryRequest newRequest
              = new NotificationHistoryRequest(MerchantID, MerchantKey,
              Environment.ToString(), response.NextPageToken);
            try {
              NotificationHistoryResponse nextResponse = newRequest.Send()
            as NotificationHistoryResponse;
              response.AddAdditionalResponse(nextResponse);
              currentResponse = nextResponse;
            }
            catch (Exception ex) {
              Log.Err("NotificationHistoryRequest ProcessAdditionalTokens:" + ex.Message);
              throw new NotificationHistoryException(response, response.NextPageToken, ex);
            }
              }
        }
        /// <summary>
        /// Parse the Message for a NotificationDataResponse
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        protected override GCheckoutResponse ParseResponse(string response)
        {
            NotificationHistoryResponse retVal = null;

              try {
            retVal = new NotificationHistoryResponse(response);
              }
              catch (Exception ex) {
            string token = null;
            if (retVal != null) {
              token = retVal.NextPageToken;
            }
            Log.Err("NotificationHistoryRequest ParseResponse:" + ex.Message);
            throw new NotificationHistoryException(retVal, token, ex);
              }

              //now process the additional results.
              if (retVal.HasMoreResults && RetrieveAllNotifications) {
            ProcessAdditionalTokens(retVal);
              }

              return retVal;
        }
        public void Verify_new_order_notification_Messages_Can_Be_Handled()
        {
            string xml = null;

              using (Stream s = Assembly.GetExecutingAssembly()
            .GetManifestResourceStream(
            "GCheckout.Checkout.Tests.Xml.new-order-notification-base.xml")) {

            using (StreamReader sr = new StreamReader(s)) {
              xml = sr.ReadToEnd();
            }
              }

              var test = new NotificationHistoryResponse(xml);

              Assert.IsTrue(test.IsGood);
              Assert.AreEqual(1, test.NotificationResponses.Count);
        }
 public void Verify_Regular_Response_Works()
 {
     NotificationHistoryResponse test
     = new NotificationHistoryResponse(_response_regular_string);
 }
コード例 #9
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 + "];");
            }
        }
    }
 public void Verify_Regular_Response_Works()
 {
     NotificationHistoryResponse test
         = new NotificationHistoryResponse(_response_regular_string);
 }