private void PaymentLogUpdateNewOrderNotification(NewOrderNotification notification) { string paymentResponse = "new-order-notification :: "; paymentResponse += String.Format("Buyerbillingaddress: {0},", notification.buyerbillingaddress); paymentResponse += String.Format("BuyerID: {0},", notification.buyerid); paymentResponse += String.Format("Buyermarketingpreferences: {0},", notification.buyermarketingpreferences); paymentResponse += String.Format("Buyershippingaddress: {0},", notification.buyershippingaddress); paymentResponse += String.Format("Financialorderstate: {0},", notification.financialorderstate); paymentResponse += String.Format("Fulfillmentorderstate: {0},", notification.fulfillmentorderstate); paymentResponse += String.Format("Orderadjustment: {0},", notification.orderadjustment); paymentResponse += String.Format("Ordertotal: {0},", notification.ordertotal); paymentResponse += String.Format("Serialnumber: {0},", notification.serialnumber); paymentResponse += String.Format("ShoppingCart: {0},", notification.shoppingcart); paymentResponse += String.Format("Timestamp: {0},", notification.timestamp); Log.Debug("Start Save Payment Log"); PaymentLog paymentLog = new PaymentLog(); paymentLog.OrderID = notification.googleordernumber; paymentLog.PaymentResponse = paymentResponse; paymentLog.PaymentGateway = GetPaymentName(); paymentLog.PaymentType = String.Empty; DataAccessContext.PaymentLogRepository.Save(paymentLog); Log.Debug("End Save Payment Log"); }
public NewOrderHandler(NewOrderNotification n1) { if (n1 == null) { throw new ArgumentNullException("n1 cant be null"); } N1 = n1; }
private Vevo.Base.Domain.Address CreateBuyerBillingAddress(NewOrderNotification n1) { return(new Vevo.Base.Domain.Address( ConvertToString(n1.buyerbillingaddress.contactname), " ", String.Empty, ConvertToString(n1.buyerbillingaddress.address1), ConvertToString(n1.buyerbillingaddress.address2), ConvertToString(n1.buyerbillingaddress.city), ConvertToString(n1.buyerbillingaddress.region), ConvertToString(n1.buyerbillingaddress.postalcode), ConvertToString(n1.buyerbillingaddress.countrycode), String.Empty, String.Empty)); }
public async Task Consume(ConsumeContext <INewOrder> context) { await Console.Out.WriteLineAsync($"Received: {context.Message.ID}"); //publish a NewOrderNotification NewOrderNotification orderNote = new NewOrderNotification { ID = Guid.NewGuid() }; if (context.RequestId.HasValue) { await context.RespondAsync <INewOrderNotification>(orderNote); } await context.Publish(orderNote); await Console.Out.WriteLineAsync($"Send a NewOrderNotification: {orderNote.ID}"); }
private static void ProcessNotification(string Type, string Xml) { switch (Type) { case "new-order-notification": NewOrderNotification N1 = (NewOrderNotification) EncodeHelper.Deserialize(Xml, typeof(NewOrderNotification)); // Add call to existing business system here, passing data from N1. break; case "risk-information-notification": RiskInformationNotification N2 = (RiskInformationNotification) EncodeHelper.Deserialize(Xml, typeof(RiskInformationNotification)); // Add call to existing business system here, passing data from N2. break; case "order-state-change-notification": OrderStateChangeNotification N3 = (OrderStateChangeNotification) EncodeHelper.Deserialize(Xml, typeof(OrderStateChangeNotification)); // Add call to existing business system here, passing data from N3. break; case "charge-amount-notification": ChargeAmountNotification N4 = (ChargeAmountNotification) EncodeHelper.Deserialize(Xml, typeof(ChargeAmountNotification)); // Add call to existing business system here, passing data from N4. break; case "refund-amount-notification": RefundAmountNotification N5 = (RefundAmountNotification) EncodeHelper.Deserialize(Xml, typeof(RefundAmountNotification)); // Add call to existing business system here, passing data from N5. break; case "chargeback-amount-notification": ChargebackAmountNotification N6 = (ChargebackAmountNotification) EncodeHelper.Deserialize(Xml, typeof(ChargebackAmountNotification)); // Add call to existing business system here, passing data from N6. break; default: throw new ApplicationException("Unknown notification type: " + Type); } }
private void processNewOrderNotification(string xmlData) { try { NewOrderNotification newOrderNotification = (NewOrderNotification)EncodeHelper.Deserialize(xmlData, typeof(NewOrderNotification)); string googleOrderNumber = newOrderNotification.googleordernumber; XmlNode CustomerInfo = newOrderNotification.shoppingcart.merchantprivatedata.Any[0]; int CustomerID = Convert.ToInt32(CustomerInfo.Attributes["CustomerID"].Value); int CustomerLanguageID = Convert.ToInt32(CustomerInfo.Attributes["CustomerLanguageID"].Value); int CustomerCurrencyID = Convert.ToInt32(CustomerInfo.Attributes["CustomerCurrencyID"].Value); Customer customer = CustomerManager.GetCustomerById(CustomerID); NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCart Cart = ShoppingCartManager.GetCustomerShoppingCart(customer.CustomerId, ShoppingCartTypeEnum.ShoppingCart); if (customer == null) { logMessage("Could not load a customer"); return; } NopContext.Current.User = customer; if (Cart.Count == 0) { logMessage("Cart is empty"); return; } //validate cart foreach (NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCartItem sci in Cart) { bool ok = false; foreach (Item item in newOrderNotification.shoppingcart.items) { if (!String.IsNullOrEmpty(item.merchantitemid)) { if ((Convert.ToInt32(item.merchantitemid) == sci.ShoppingCartItemId) && (item.quantity == sci.Quantity)) { ok = true; break; } } } if (!ok) { logMessage(string.Format("Shopping Cart item has been changed. {0}. {1}", sci.ShoppingCartItemId, sci.Quantity)); return; } } string[] billingFullname = newOrderNotification.buyerbillingaddress.contactname.Trim().Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string billingFirstName = billingFullname[0]; string billingLastName = string.Empty; if (billingFullname.Length > 1) { billingLastName = billingFullname[1]; } string billingEmail = newOrderNotification.buyerbillingaddress.email.Trim(); string billingAddress1 = newOrderNotification.buyerbillingaddress.address1.Trim(); string billingAddress2 = newOrderNotification.buyerbillingaddress.address2.Trim(); string billingPhoneNumber = newOrderNotification.buyerbillingaddress.phone.Trim(); string billingCity = newOrderNotification.buyerbillingaddress.city.Trim(); int billingStateProvinceID = 0; StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceByAbbreviation(newOrderNotification.buyerbillingaddress.region.Trim()); if (billingStateProvince != null) { billingStateProvinceID = billingStateProvince.StateProvinceId; } string billingZipPostalCode = newOrderNotification.buyerbillingaddress.postalcode.Trim(); int billingCountryID = 0; Country billingCountry = CountryManager.GetCountryByTwoLetterIsoCode(newOrderNotification.buyerbillingaddress.countrycode.Trim()); if (billingCountry != null) { billingCountryID = billingCountry.CountryId; } NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Address BillingAddress = customer.BillingAddresses.FindAddress( billingFirstName, billingLastName, billingPhoneNumber, billingEmail, string.Empty, string.Empty, billingAddress1, billingAddress2, billingCity, billingStateProvinceID, billingZipPostalCode, billingCountryID); if (BillingAddress == null) { BillingAddress = CustomerManager.InsertAddress(CustomerID, true, billingFirstName, billingLastName, billingPhoneNumber, billingEmail, string.Empty, string.Empty, billingAddress1, billingAddress2, billingCity, billingStateProvinceID, billingZipPostalCode, billingCountryID, DateTime.Now, DateTime.Now); } customer = CustomerManager.SetDefaultBillingAddress(customer.CustomerId, BillingAddress.AddressId); NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Address ShippingAddress = null; customer.LastShippingOption = null; bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (shoppingCartRequiresShipping) { string[] shippingFullname = newOrderNotification.buyershippingaddress.contactname.Trim().Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string shippingFirstName = shippingFullname[0]; string shippingLastName = string.Empty; if (shippingFullname.Length > 1) { shippingLastName = shippingFullname[1]; } string shippingEmail = newOrderNotification.buyershippingaddress.email.Trim(); string shippingAddress1 = newOrderNotification.buyershippingaddress.address1.Trim(); string shippingAddress2 = newOrderNotification.buyershippingaddress.address2.Trim(); string shippingPhoneNumber = newOrderNotification.buyershippingaddress.phone.Trim(); string shippingCity = newOrderNotification.buyershippingaddress.city.Trim(); int shippingStateProvinceID = 0; StateProvince shippingStateProvince = StateProvinceManager.GetStateProvinceByAbbreviation(newOrderNotification.buyershippingaddress.region.Trim()); if (shippingStateProvince != null) { shippingStateProvinceID = shippingStateProvince.StateProvinceId; } int shippingCountryID = 0; string shippingZipPostalCode = newOrderNotification.buyershippingaddress.postalcode.Trim(); Country shippingCountry = CountryManager.GetCountryByTwoLetterIsoCode(newOrderNotification.buyershippingaddress.countrycode.Trim()); if (shippingCountry != null) { shippingCountryID = shippingCountry.CountryId; } ShippingAddress = customer.ShippingAddresses.FindAddress( shippingFirstName, shippingLastName, shippingPhoneNumber, shippingEmail, string.Empty, string.Empty, shippingAddress1, shippingAddress2, shippingCity, shippingStateProvinceID, shippingZipPostalCode, shippingCountryID); if (ShippingAddress == null) { ShippingAddress = CustomerManager.InsertAddress(CustomerID, false, shippingFirstName, shippingLastName, shippingPhoneNumber, shippingEmail, string.Empty, string.Empty, shippingAddress1, shippingAddress2, shippingCity, shippingStateProvinceID, shippingZipPostalCode, shippingCountryID, DateTime.Now, DateTime.Now); } customer = CustomerManager.SetDefaultShippingAddress(customer.CustomerId, ShippingAddress.AddressId); string shippingMethod = string.Empty; decimal shippingCost = decimal.Zero; if (newOrderNotification.orderadjustment != null && newOrderNotification.orderadjustment.shipping != null && newOrderNotification.orderadjustment.shipping.Item != null) { FlatRateShippingAdjustment ShippingMethod = (FlatRateShippingAdjustment)newOrderNotification.orderadjustment.shipping.Item; shippingMethod = ShippingMethod.shippingname; shippingCost = ShippingMethod.shippingcost.Value; ShippingOption shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod; shippingOption.Rate = shippingCost; customer.LastShippingOption = shippingOption; } } //customer.LastCalculatedTax = decimal.Zero; PaymentMethod googleCheckoutPaymentMethod = PaymentMethodManager.GetPaymentMethodBySystemKeyword("GoogleCheckout"); PaymentInfo paymentInfo = new PaymentInfo(); paymentInfo.PaymentMethodId = googleCheckoutPaymentMethod.PaymentMethodId; paymentInfo.BillingAddress = BillingAddress; paymentInfo.ShippingAddress = ShippingAddress; paymentInfo.CustomerLanguage = LanguageManager.GetLanguageById(CustomerLanguageID); paymentInfo.CustomerCurrency = CurrencyManager.GetCurrencyById(CustomerCurrencyID); paymentInfo.GoogleOrderNumber = googleOrderNumber; int orderID = 0; string result = OrderManager.PlaceOrder(paymentInfo, customer, out orderID); if (!String.IsNullOrEmpty(result)) { logMessage("new-order-notification received. CreateOrder() error: Order Number " + orderID + ". " + result); return; } Order order = OrderManager.GetOrderById(orderID); logMessage("new-order-notification received and saved: Order Number " + orderID); } catch (Exception exc) { logMessage("processNewOrderNotification Exception: " + exc.Message + ": " + exc.StackTrace); } }
/// <summary> /// Processes the notification. /// </summary> /// <param name="xmlFile">The XML file.</param> /// <returns>Serial number of the notification</returns> public static string ProcessNotification(string xmlFile) { string conn = GetConnectionString(); StoreDataClassesDataContext db = new StoreDataClassesDataContext(conn); string SerialNumber = ""; //Read XML file StreamReader strReader = new StreamReader(xmlFile); string requestedXml = strReader.ReadToEnd(); //Act on XML file switch (EncodeHelper.GetTopElement(requestedXml)) { case "new-order-notification": NewOrderNotification N1 = (NewOrderNotification)EncodeHelper.Deserialize(requestedXml, typeof(NewOrderNotification)); ///This notification tells us that Google has accepted the order SerialNumber = N1.serialnumber; Int64 OrderNumber1 = Int64.Parse(N1.googleordernumber); int pos = N1.buyershippingaddress.contactname.IndexOf(" "); string ShipToFirstName = N1.buyershippingaddress.contactname.Substring(0, pos); string ShipToLatsName = N1.buyershippingaddress.contactname.Substring(pos + 1); string UserName = N1.shoppingcart.merchantprivatedata.Any[1].InnerText; int internalOrderId = int.Parse(EncodeHelper.GetElementValue(requestedXml, "MERCHANT_DATA_HIDDEN")); order newOrder = db.orders.Where(o => o.order_id == internalOrderId).Single <order>(); newOrder.google_order_number = OrderNumber1; newOrder.order_date = N1.timestamp; newOrder.order_by = UserName; newOrder.sub_total = N1.ordertotal.Value; newOrder.total = N1.ordertotal.Value; newOrder.charged_amount = 0; newOrder.status = "NEW"; newOrder.root_id = 1; //newOrder.shipping_first_name = ShipToFirstName; //newOrder.shipping_last_name = ShipToLatsName; //newOrder.shipping_address = N1.buyershippingaddress.address1; //newOrder.shipping_city = N1.buyershippingaddress.city; //newOrder.shipping_state = N1.buyershippingaddress.region; //newOrder.shipping_zip = N1.buyershippingaddress.postalcode; //newOrder.shipping_country = N1.buyerbillingaddress.countrycode; db.SubmitChanges(); db.orders.DeleteAllOnSubmit(db.orders.Where(o => (o.status == "TEMP" && o.order_by == UserName))); db.SubmitChanges(); foreach (Item ThisItem in N1.shoppingcart.items) { int itemId = int.Parse(ThisItem.merchantprivateitemdata.Any[0].InnerText); string desc = ThisItem.itemdescription; int quantity = ThisItem.quantity; decimal price = ThisItem.unitprice.Value; bool tangible = false; if (ThisItem.digitalcontent != null) { tangible = true; } order_item newItem = new order_item(); newItem.item_id = itemId; newItem.order_id = internalOrderId; newItem.price = price; newItem.qty = quantity; newItem.tangible = tangible; newItem.item_desc = desc; newItem.item_name = ThisItem.itemname; db.order_items.InsertOnSubmit(newItem); db.SubmitChanges(); } break; case "risk-information-notification": RiskInformationNotification N2 = (RiskInformationNotification)EncodeHelper.Deserialize(requestedXml, typeof(RiskInformationNotification)); // This notification tells us that Google has authorized the order and it has passed the fraud check SerialNumber = N2.serialnumber; long googleOrderNumber = Int64.Parse(N2.googleordernumber); string contactName = EncodeHelper.GetElementValue(requestedXml, "contact-name"); string email = EncodeHelper.GetElementValue(requestedXml, "email"); string city = EncodeHelper.GetElementValue(requestedXml, "city"); int zip = int.Parse(EncodeHelper.GetElementValue(requestedXml, "postal-code")); string country = EncodeHelper.GetElementValue(requestedXml, "country-code"); bool elibible = N2.riskinformation.eligibleforprotection; char cvn = char.Parse(N2.riskinformation.cvnresponse); if (elibible && N2.riskinformation.cvnresponse == "M") { customer newCustomer = new customer(); newCustomer.google_order_number = googleOrderNumber; newCustomer.eligibility = elibible; newCustomer.contact_name = contactName; newCustomer.email = email; newCustomer.address = N2.riskinformation.billingaddress.address1; newCustomer.city = city; newCustomer.zip = zip; newCustomer.country = country; newCustomer.avs = char.Parse(N2.riskinformation.avsresponse); newCustomer.cvn = cvn; newCustomer.cc_number = int.Parse(N2.riskinformation.partialccnumber); newCustomer.ip = N2.riskinformation.ipaddress; db.customers.InsertOnSubmit(newCustomer); db.SubmitChanges(); } else { string reason = "You did not pass Google security check!"; string comment = "Please visis http://checkout.google.com/support/sell/bin/topic.py?topic=15055 for more information"; GCheckout.OrderProcessing.CancelOrderRequest cancelReq = new GCheckout.OrderProcessing.CancelOrderRequest(N2.googleordernumber, reason, comment); cancelReq.Send(); } break; case "order-state-change-notification": OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize(requestedXml, typeof(OrderStateChangeNotification)); // The order has changed either financial or fulfillment state in Google's system. SerialNumber = N3.serialnumber; long googleOrderNumber1 = Int64.Parse(N3.googleordernumber); string newFinanceState = N3.newfinancialorderstate.ToString(); string newFulfillmentState = N3.newfulfillmentorderstate.ToString(); string prevFinanceState = N3.previousfinancialorderstate.ToString(); string prevFulfillmentState = N3.previousfulfillmentorderstate.ToString(); order thisOrder1 = (from or in db.orders where or.google_order_number == googleOrderNumber1 select or).Single <order>(); //if (newFinanceState == "CHARGEABLE") //{ // GCheckout.OrderProcessing.ChargeOrderRequest chargeReq = new GCheckout.OrderProcessing.ChargeOrderRequest(N3.googleordernumber); // chargeReq.Send(); //} thisOrder1.status = newFinanceState; if (newFulfillmentState == "WILL_NOT_DELIVER") { thisOrder1.shipping_status = "CANCELLED"; } else { thisOrder1.shipping_status = newFulfillmentState; } db.SubmitChanges(); break; case "charge-amount-notification": ChargeAmountNotification N4 = (ChargeAmountNotification)EncodeHelper.Deserialize(requestedXml, typeof(ChargeAmountNotification)); // Google has successfully charged the customer's credit card. SerialNumber = N4.serialnumber; long googleOrderNumber2 = Int64.Parse(N4.googleordernumber); decimal chargedAmount = N4.latestchargeamount.Value; order thisOrder2 = (from or in db.orders where or.google_order_number == googleOrderNumber2 select or).Single <order>(); thisOrder2.charged_amount += chargedAmount; thisOrder2.sub_total -= chargedAmount; db.SubmitChanges(); break; case "refund-amount-notification": RefundAmountNotification N5 = (RefundAmountNotification)EncodeHelper.Deserialize(requestedXml, typeof(RefundAmountNotification)); // Google has successfully refunded the customer's credit card. SerialNumber = N5.serialnumber; long googleOrderNumber3 = Int64.Parse(N5.googleordernumber); decimal refundedAmount = N5.latestrefundamount.Value; order thisOrder3 = (from or in db.orders where or.google_order_number == googleOrderNumber3 select or).Single <order>(); thisOrder3.status = "REFUNDED"; thisOrder3.charged_amount -= refundedAmount; db.SubmitChanges(); break; case "chargeback-amount-notification": ChargebackAmountNotification N6 = (ChargebackAmountNotification)EncodeHelper.Deserialize(requestedXml, typeof(ChargebackAmountNotification)); // A customer initiated a chargeback with his credit card company to get her money back. SerialNumber = N6.serialnumber; long googleOrderNumber4 = Int64.Parse(N6.googleordernumber); decimal chargebackAmount = N6.latestchargebackamount.Value; order thisOrder4 = (from or in db.orders where or.google_order_number == googleOrderNumber4 select or).Single <order>(); thisOrder4.status = "CHARGEBACK"; db.SubmitChanges(); break; default: break; } strReader.Close(); strReader.Dispose(); return(SerialNumber); }
/// <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; } }
protected void Page_Load(object sender, EventArgs e) { // Extract the XML from the request. Stream RequestStream = Request.InputStream; StreamReader RequestStreamReader = new StreamReader(RequestStream); string RequestXml = RequestStreamReader.ReadToEnd(); RequestStream.Close(); Log.Debug("Request XML:\n" + RequestXml); string gatewayOrderID = ""; string orderID; OrderNotifyService orderBusiness; try { // Act on the XML. switch (EncodeHelper.GetTopElement(RequestXml)) { case "new-order-notification": Log.Debug("Start new-order-notification"); NewOrderNotification N1 = (NewOrderNotification)EncodeHelper.Deserialize(RequestXml, typeof(NewOrderNotification)); string OrderNumber1 = N1.googleordernumber; PaymentLogUpdateNewOrderNotification(N1); _serialNumber = N1.serialnumber; Log.Debug("-********************- Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-"); Log.Debug("GetOrderIDByGateWayID ( " + OrderNumber1 + " ) = " + DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1)); Log.Debug("-********************- END Check DataAccessContext.GetOrderIDByGateWayID Data -**********************-"); if (DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1) == "0") { BuildShoppingCart(RequestXml, N1); Log.Debug("Start converting to order"); OrderCreateService orderCreateService = new OrderCreateService( StoreContext.ShoppingCart, StoreContext.CheckoutDetails, StoreContext.Culture, StoreContext.Currency, AffiliateHelper.GetAffiliateCode(), WebUtilities.GetVisitorIP()); string storeID = EncodeHelper.GetElementValue(RequestXml, "StoreID"); DataAccessContext.SetStoreRetriever(new StoreRetriever(storeID)); OrderAmount orderAmount = orderCreateService.GetOrderAmount(Customer.Null) .Add(CartItemPromotion.CalculatePromotionShippingAndTax( StoreContext.CheckoutDetails, StoreContext.ShoppingCart.SeparateCartItemGroups(), Customer.Null)); Order order = orderCreateService.PlaceOrderAnonymous(orderAmount, SystemConst.UnknownUser, CreateBuyerBillingAddress(N1), ConvertToString(N1.buyerbillingaddress.email), DataAccessContext.StoreRetriever, StoreContext.Culture); AffiliateOrder affiliateorder = new AffiliateOrder(); affiliateorder.AffiliateCode = AffiliateHelper.GetAffiliateCode(); affiliateorder.CreateAffiliateOrder(order.OrderID, orderAmount.Subtotal, orderAmount.Discount); orderBusiness = new OrderNotifyService(order.OrderID); Log.Debug("End converting to order"); Log.Debug("Start sending order email"); orderBusiness.SendOrderEmail(); Log.Debug("End sending order email"); Order orderDetail = DataAccessContext.OrderRepository.GetOne(order.OrderID); orderDetail.GatewayOrderID = OrderNumber1; Log.Debug("OrderDetail.GatewayOrderID = " + OrderNumber1); Log.Debug("Start Save Order Detail"); DataAccessContext.OrderRepository.Save(orderDetail); Log.Debug("End Save Order Detail"); DataAccessContext.SetStoreRetriever(new StoreRetriever()); } else { Order orderDetail = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(OrderNumber1)); Log.Debug("-**************************- start Check Error -**************************-"); Log.Debug("N1.googleOrderNumber = " + N1.googleordernumber); Log.Debug("OrderNumber1 = " + OrderNumber1); Log.Debug("N1.buyerbillingaddress.contactname = " + ConvertToString(N1.buyerbillingaddress.contactname)); Log.Debug("N1.buyerbillingaddress.address1 = " + ConvertToString(N1.buyerbillingaddress.address1)); Log.Debug("N1.buyerbillingaddress.city = " + ConvertToString(N1.buyerbillingaddress.city)); Log.Debug("N1.buyerbillingaddress.region = " + ConvertToString(N1.buyerbillingaddress.contactname)); Log.Debug("N1.buyerbillingaddress.postalcode = " + ConvertToString(N1.buyerbillingaddress.postalcode)); Log.Debug("orderDetail.Billing.Company = " + orderDetail.Billing.Company); Log.Debug("orderDetail.Billing.Country = " + orderDetail.Billing.Country); Log.Debug("orderDetail.Billing.Phone = " + orderDetail.Billing.Phone); Log.Debug("orderDetail.Billing.Fax = " + orderDetail.Billing.Fax); Log.Debug("-**************************- End Check Error -**************************-"); orderDetail.Billing = new Vevo.Base.Domain.Address(ConvertToString(N1.buyerbillingaddress.contactname), String.Empty, orderDetail.Billing.Company, ConvertToString(N1.buyerbillingaddress.address1), ConvertToString(N1.buyerbillingaddress.address2), ConvertToString(N1.buyerbillingaddress.city), ConvertToString(N1.buyerbillingaddress.region), ConvertToString(N1.buyerbillingaddress.postalcode), orderDetail.Billing.Country, orderDetail.Billing.Phone, orderDetail.Billing.Fax); orderDetail.Email = ConvertToString(N1.buyerbillingaddress.email); DataAccessContext.OrderRepository.Save(orderDetail); } Log.Debug("End new-order-notification"); break; case "risk-information-notification": Log.Debug("risk-information-notification"); RiskInformationNotification N2 = (RiskInformationNotification)EncodeHelper.Deserialize( RequestXml, typeof(RiskInformationNotification)); // This notification tells us that Google has authorized the order // and it has passed the fraud check. // Use the data below to determine if you want to accept the order, then start processing it. gatewayOrderID = N2.googleordernumber; _serialNumber = N2.serialnumber; PaymentLogUpdateRiskInformation(N2); VerifyAvsAndCvv(N2); break; case "order-state-change-notification": Log.Debug("Start order-state-change-notification"); OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize( RequestXml, typeof(OrderStateChangeNotification)); _serialNumber = N3.serialnumber; PaymentLogUpdateOrderStateChange(N3); if (N3.newfinancialorderstate != N3.previousfinancialorderstate) { Order orderDetail = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(N3.googleordernumber)); orderDetail.GatewayPaymentStatus = N3.newfinancialorderstate.ToString(); DataAccessContext.OrderRepository.Save(orderDetail); switch (N3.newfinancialorderstate) { case FinancialOrderState.PAYMENT_DECLINED: case FinancialOrderState.CANCELLED_BY_GOOGLE: SendErrorEmail(N3); break; case FinancialOrderState.CHARGEABLE: if (DataAccessContext.Configurations.GetBoolValueNoThrow("GCheckoutChargeAuto")) { GoogleChargeOrder(N3.googleordernumber); } break; } } Log.Debug("End order-state-change-notification"); break; case "charge-amount-notification": Log.Debug("Start charge-amount-notification"); ChargeAmountNotification N4 = (ChargeAmountNotification)EncodeHelper.Deserialize(RequestXml, typeof(ChargeAmountNotification)); // Google has successfully charged the customer's credit card. gatewayOrderID = N4.googleordernumber; _serialNumber = N4.serialnumber; PaymentLogChargeAmountUpdate(N4); orderID = DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID); orderBusiness = new OrderNotifyService(orderID); orderBusiness.ProcessPaymentComplete(); Log.Debug("End charge-amount-notification"); break; case "refund-amount-notification": Log.Debug("Start refund-amount-notification"); RefundAmountNotification N5 = (RefundAmountNotification)EncodeHelper.Deserialize( RequestXml, typeof(RefundAmountNotification)); // Google has successfully refunded the customer's credit card. gatewayOrderID = N5.googleordernumber; _serialNumber = N5.serialnumber; //decimal RefundedAmount = N5.latestrefundamount.Value; PaymentLogUpdateRefundAmount(N5); Order orderDetails = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID)); orderDetails.PaymentComplete = false; DataAccessContext.OrderRepository.Save(orderDetails); Log.Debug("End refund-amount-notification"); break; case "chargeback-amount-notification": Log.Debug("Start chargeback-amount-notification"); ChargebackAmountNotification N6 = (ChargebackAmountNotification)EncodeHelper.Deserialize( RequestXml, typeof(ChargebackAmountNotification)); // A customer initiated a chargeback with his credit card company to get her money back. gatewayOrderID = N6.googleordernumber; _serialNumber = N6.serialnumber; decimal ChargebackAmount = N6.latestchargebackamount.Value; PaymentLogUpdateChargeback(N6); orderDetails = DataAccessContext.OrderRepository.GetOne( DataAccessContext.OrderRepository.GetOrderIDByGatewayID(gatewayOrderID)); orderDetails.GatewayPaymentStatus = "ChargeBack"; DataAccessContext.OrderRepository.Save(orderDetails); Log.Debug("End chargeback-amount-notification"); break; default: break; } } catch (Exception ex) { DataAccessContext.SetStoreRetriever(new StoreRetriever()); Log.Debug(ex.ToString()); } }
private void BuildShoppingCart(string requestXml, NewOrderNotification notification) { foreach (Item item in notification.shoppingcart.items) { XmlNode[] node = item.merchantprivateitemdata.Any; Product product = DataAccessContext.ProductRepository.GetOne( StoreContext.Culture, item.merchantitemid, new StoreRetriever().GetCurrentStoreID() ); if (node.Length <= 1) { StoreContext.ShoppingCart.AddItem( product, item.quantity); } else { // Creating option item from google checkout is not details of option type is text. OptionItemValueCollection optionCollection = OptionItemValueCollection.Null; if (!String.IsNullOrEmpty(node[1].InnerText)) { optionCollection = new OptionItemValueCollection( StoreContext.Culture, node[1].InnerText, item.merchantitemid); } StoreContext.ShoppingCart.AddItem( product, item.quantity, optionCollection); } } Log.Debug("SetShippingDetails"); Vevo.Base.Domain.Address address = new Vevo.Base.Domain.Address( notification.buyershippingaddress.contactname, "", notification.buyerbillingaddress.companyname, notification.buyershippingaddress.address1, notification.buyershippingaddress.address2, notification.buyershippingaddress.city, notification.buyershippingaddress.region, notification.buyershippingaddress.postalcode, notification.buyershippingaddress.countrycode, notification.buyerbillingaddress.phone, notification.buyerbillingaddress.fax); StoreContext.CheckoutDetails.ShippingAddress = new ShippingAddress(address, false); Log.Debug("Set Shipping "); MerchantCalculatedShippingAdjustment shippingAdjust = (MerchantCalculatedShippingAdjustment)notification.orderadjustment.shipping.Item; string shippingID = DataAccessContext.ShippingOptionRepository.GetIDFromName(shippingAdjust.shippingname); ShippingMethod shipping = ShippingFactory.CreateShipping(shippingID); shipping.Name = shippingAdjust.shippingname; StoreContext.CheckoutDetails.SetShipping(shipping); StoreContext.CheckoutDetails.SetCustomerComments(""); PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne( StoreContext.Culture, PaymentOption.GoogleCheckout); StoreContext.CheckoutDetails.SetPaymentMethod( paymentOption.CreatePaymentMethod()); Log.Debug("Set Coupon ID"); StoreContext.CheckoutDetails.SetCouponID(GetCouponCode(notification.orderadjustment.merchantcodes.Items)); Log.Debug("Set Gift"); string giftID = GetGiftCertificateCode(notification.orderadjustment.merchantcodes.Items); if (giftID != String.Empty) { StoreContext.CheckoutDetails.SetGiftCertificate(giftID); } StoreContext.CheckoutDetails.SetGiftRegistryID("0"); StoreContext.CheckoutDetails.SetShowShippingAddress(true); }