private void ProcessOrder( Cart cart, Store store, WorldPayPaymentResponse wpResponse, PayPalLog worldPayLog, Page page) { // process the cart into an order then // return an html order result template for use at world pay cart.DeSerializeCartOffers(); if (wpResponse.CompName.Length > 0) { cart.OrderInfo.CustomerCompany = wpResponse.CompName; } if (wpResponse.Address1.Length > 0) { cart.OrderInfo.CustomerAddressLine1 = wpResponse.Address1; } if (wpResponse.Address2.Length > 0) { cart.OrderInfo.CustomerAddressLine2 = wpResponse.Address2; } if (wpResponse.Address3.Length > 0) { cart.OrderInfo.CustomerAddressLine2 += " " + wpResponse.Address3; } if (wpResponse.Town.Length > 0) { cart.OrderInfo.CustomerCity = wpResponse.Town; } //cart.OrderInfo.DeliveryFirstName = wpResponse.Name; if ( (wpResponse.Name.Length > 0) && ((cart.OrderInfo.CustomerLastName.Length == 0) || (!wpResponse.Name.Contains((cart.OrderInfo.CustomerLastName)))) ) { cart.OrderInfo.CustomerLastName = wpResponse.Name; // this is full name } if (wpResponse.Postcode.Length > 0) { cart.OrderInfo.CustomerPostalCode = wpResponse.Postcode; } if (wpResponse.Region.Length > 0) { cart.OrderInfo.CustomerState = wpResponse.Region; } if (wpResponse.Country.Length > 0) { cart.OrderInfo.CustomerCountry = wpResponse.Country; } if (wpResponse.Tel.Length > 0) { cart.OrderInfo.CustomerTelephoneDay = wpResponse.Tel; } if (wpResponse.Email.Length > 0) { cart.OrderInfo.CustomerEmail = wpResponse.Email; } cart.CopyCustomerToBilling(); cart.CopyCustomerToShipping(); //cart.TaxTotal = taxAmount; //cart.OrderTotal = grossAmount; //if (shippingAmount > 0) //{ // cart.ShippingTotal = shippingAmount; //} StoreHelper.EnsureUserForOrder(cart); cart.Save(); Order order = Order.CreateOrder( store, cart, wpResponse.TransId, wpResponse.TransId, string.Empty, wpResponse.Currency, "WorldPay", OrderStatus.OrderStatusFulfillableGuid); // grab the return url before we delete the un-needed logs string orderDetailUrl = worldPayLog.ReturnUrl; string storePageUrl = worldPayLog.RawResponse; // remove any previous logs GoogleCheckoutLog.DeleteByCart(order.OrderGuid); PayPalLog.DeleteByCart(order.OrderGuid); // create a final log that has the serialized reposnse from worldpay rather than the serialized cart worldPayLog = new PayPalLog(); worldPayLog.SiteGuid = store.SiteGuid; worldPayLog.StoreGuid = store.Guid; worldPayLog.CartGuid = order.OrderGuid; worldPayLog.UserGuid = order.UserGuid; worldPayLog.ProviderName = "WebStoreWorldPayResponseHandler"; worldPayLog.RequestType = "WorldPay"; worldPayLog.PaymentStatus = "Paid"; worldPayLog.PaymentType = "WorldPay"; worldPayLog.CartTotal = order.OrderTotal; worldPayLog.PayPalAmt = wpResponse.AuthAmount; worldPayLog.TransactionId = wpResponse.TransId; worldPayLog.CurrencyCode = wpResponse.Currency; worldPayLog.ReasonCode = wpResponse.AVS; worldPayLog.RawResponse = SerializationHelper.SerializeToString(wpResponse); worldPayLog.CreatedUtc = DateTime.UtcNow; worldPayLog.ReturnUrl = orderDetailUrl; worldPayLog.Save(); try { StoreHelper.ConfirmOrder(store, order); } catch (Exception ex) { log.Error("error sending confirmation email", ex); } // retrun the html if (config.WorldPayProduceShopperResponse) { CultureInfo currencyCulture = ResourceHelper.GetCurrencyCulture(wpResponse.Currency); string htmlTemplate = ResourceHelper.GetMessageTemplate(CultureInfo.CurrentUICulture, config.WorldPayShopperResponseTemplate); StringBuilder finalOutput = new StringBuilder(); finalOutput.Append(htmlTemplate); finalOutput.Replace("#WorldPayBannerToken", "<WPDISPLAY ITEM=banner>"); //required by worldpay finalOutput.Replace("#CustomerName", wpResponse.Name); finalOutput.Replace("#StoreName", store.Name); finalOutput.Replace("#OrderId", order.OrderGuid.ToString()); finalOutput.Replace("#StorePageLink", "<a href='" + storePageUrl + "'>" + storePageUrl + "</a>"); finalOutput.Replace("#OrderDetailLink", "<a href='" + orderDetailUrl + "'>" + orderDetailUrl + "</a>"); StringBuilder orderDetails = new StringBuilder(); DataSet dsOffers = Order.GetOrderOffersAndProducts(store.Guid, order.OrderGuid); foreach (DataRow row in dsOffers.Tables["Offers"].Rows) { string og = row["OfferGuid"].ToString(); orderDetails.Append(row["Name"].ToString() + " "); orderDetails.Append(row["Quantity"].ToString() + " @ "); orderDetails.Append(string.Format(currencyCulture, "{0:c}", Convert.ToDecimal(row["OfferPrice"]))); orderDetails.Append("<br />"); string whereClause = string.Format("OfferGuid = '{0}'", og); DataView dv = new DataView(dsOffers.Tables["Products"], whereClause, "", DataViewRowState.CurrentRows); if (dv.Count > 1) { foreach (DataRow r in dsOffers.Tables["Products"].Rows) { string pog = r["OfferGuid"].ToString(); if (og == pog) { orderDetails.Append(r["Name"].ToString() + " "); orderDetails.Append(r["Quantity"].ToString() + " <br />"); } } } } finalOutput.Replace("#OrderDetails", orderDetails.ToString()); page.Response.Write(finalOutput.ToString()); page.Response.Flush(); } }
private void btnMakePayment_Click(object sender, EventArgs e) { if (store != null && cart != null && IsValidForCheckout()) { IPaymentGateway gateway = commerceConfig.GetDirectPaymentGateway(); if (gateway == null) { lblMessage.Text = WebStoreResources.PaymentGatewayNotConfiguredForDirectCardProcessing; btnMakePayment.Enabled = false; return; } gateway.MerchantInvoiceNumber = cart.CartGuid.ToString("N"); var cartItems = new List <string>(); foreach (var cartOffer in cart.CartOffers) { cartItems.Add($"({cartOffer.Quantity}x) {cartOffer.Name} {cartOffer.OfferPrice.ToString("c", currencyCulture)} (GUID: {cartOffer.OfferGuid:N})"); } gateway.MerchantTransactionDescription = string.Join("\n", cartItems); gateway.CardType = ddCardType.SelectedValue; gateway.CardNumber = txtCardNumber.Text; gateway.CardExpiration = ddExpireMonth.SelectedValue + ddExpireYear.SelectedValue; gateway.ChargeTotal = cart.OrderTotal; gateway.CardSecurityCode = txtCardSecurityCode.Text; gateway.CardOwnerFirstName = txtCardOwnerFirstName.Text; gateway.CardOwnerLastName = txtCardOwnerLastName.Text; gateway.CardOwnerCompanyName = cart.OrderInfo.BillingCompany; gateway.CardBillingAddress = cart.OrderInfo.BillingAddress1 + " " + cart.OrderInfo.BillingAddress2; gateway.CardBillingCity = cart.OrderInfo.BillingCity; gateway.CardBillingState = cart.OrderInfo.BillingState; gateway.CardBillingPostalCode = cart.OrderInfo.BillingPostalCode; gateway.CardBillingCountry = cart.OrderInfo.BillingCountry; gateway.CardBillingCountryCode = cart.OrderInfo.BillingCountry; gateway.CardBillingPhone = cart.OrderInfo.CustomerTelephoneDay; gateway.CustomerIPAddress = SiteUtils.GetIP4Address(); gateway.CurrencyCulture = currencyCulture; // this is where the actual request is made, it can timeout here bool executed; try { executed = gateway.ExecuteTransaction(); } catch (WebException ex) { if (commerceConfig.PaymentGatewayUseTestMode) { lblMessage.Text = ex.Message; } else { lblMessage.Text = WebStoreResources.PaymentGatewayCouldNotConnectMessage; } return; } var serializedCart = string.Empty; gateway.LogTransaction( siteSettings.SiteGuid, store.ModuleGuid, store.Guid, cart.CartGuid, cart.UserGuid, string.Empty, "WebStoreCheckout", serializedCart ); if (executed) { switch (gateway.Response) { case PaymentGatewayResponse.Approved: cart.LastUserActivity = DateTime.UtcNow; cart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address(); cart.OrderInfo.Completed = DateTime.UtcNow; StoreHelper.EnsureUserForOrder(cart); cart.Save(); Order order = Order.CreateOrder(store, cart, gateway, siteSettings.GetCurrency().Code, "CreditCard"); StoreHelper.ClearCartCookie(cart.StoreGuid); // send confirmation email try { // this also happens in StoreHelper.ConfirmOrder StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); GoogleCheckoutLog.DeleteByCart(order.OrderGuid); } catch (Exception ex) { log.Error("error sending confirmation email", ex); } // redirect to order details string redirectUrl = SiteRoot + "/WebStore/OrderDetail.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&orderid=" + order.OrderGuid.ToString(); //TODO: if we charged a card here we can safely delete any paypal log or googlecheckout logs // need methods to delete those by carguid if (WebStoreConfiguration.LogCardTransactionStatus) { log.Info("accepted transaction " + gateway.ChargeTotal.ToString("c") + " " + gateway.ResponseCode + " " + gateway.ResponseReason); } WebUtils.SetupRedirect(this, redirectUrl); return; case PaymentGatewayResponse.Declined: lblMessage.Text = WebStoreResources.TransactionDeclinedMessage; if (WebStoreConfiguration.LogCardTransactionStatus || WebStoreConfiguration.LogCardFailedTransactionStatus) { log.Info("declined transaction " + gateway.ChargeTotal.ToString("c") + " " + gateway.ResponseCode + " " + gateway.ResponseReason); } break; case PaymentGatewayResponse.Error: if (gateway.UseTestMode) { if (gateway.LastExecutionException != null) { lblMessage.Text = gateway.LastExecutionException.ToString(); } else { // TODO: should not show user real messages? Mask CCNumber and login credentials in the gateways RawResponse property ... those shouldn't be logged either lblMessage.Text = gateway.RawResponse; } } else { lblMessage.Text = WebStoreResources.TransactionErrorMessage; if (WebStoreConfiguration.LogCardTransactionStatus || WebStoreConfiguration.LogCardFailedTransactionStatus) { if (gateway.LastExecutionException != null) { log.Info("transaction error " + gateway.LastExecutionException.ToString()); } } } break; case PaymentGatewayResponse.NoRequestInitiated: lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage; break; } } else { lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage + (!string.IsNullOrEmpty(gateway.ResponseReason) ? "<br>" + gateway.ResponseReason : string.Empty); if (gateway.LastExecutionException != null) { if (commerceConfig.PaymentGatewayUseTestMode) { lblMessage.Text = gateway.LastExecutionException.ToString(); } } } } btnMakePayment.Text = WebStoreResources.PaymentButton; }
public override void HandleNewOrderNotificationExtended( string requestXml, NewOrderNotificationExtended newOrder, MerchantData merchantData) { //NotificationSerialNumber = newOrder.serialnumber; GoogleCheckoutLog gLog = new GoogleCheckoutLog(); gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.RawResponse = requestXml; gLog.NotificationType = "NewOrderNotification"; gLog.SerialNumber = newOrder.serialnumber; gLog.OrderNumber = newOrder.googleordernumber; gLog.OrderTotal = newOrder.ordertotal.Value; gLog.BuyerId = newOrder.buyerid.ToString(CultureInfo.InvariantCulture); gLog.FullfillState = newOrder.fulfillmentorderstate.ToString(); gLog.FinanceState = newOrder.financialorderstate.ToString(); gLog.ShippingTotal = newOrder.ShippingCost; gLog.TaxTotal = newOrder.orderadjustment.totaltax.Value; //gLog.DiscountTotal = ext.orderadjustment.adjustmenttotal.Value; gLog.EmailListOptIn = newOrder.buyermarketingpreferences.emailallowed; gLog.GTimestamp = newOrder.timestamp; gLog.CartXml = SerializationHelper.RestoreXmlDeclaration(merchantData.SerializedObject); gLog.Save(); Cart gCart = DeserializeCart(merchantData); Guid cartGuid = Guid.Empty; if (gCart != null) { cartGuid = gCart.CartGuid; } if (cartGuid == Guid.Empty) { return; } Cart cart = new Cart(cartGuid); if (cart.CartGuid != cartGuid) { return; } Store store = new Store(gCart.StoreGuid); if (store.Guid != cart.StoreGuid) { return; } gCart.DeSerializeCartOffers(); gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = gCart.UserGuid; gLog.CartGuid = gCart.CartGuid; gLog.StoreGuid = gCart.StoreGuid; gLog.Save(); gCart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address(); gCart.OrderInfo.Completed = DateTime.UtcNow; if (newOrder.buyerbillingaddress.structuredname != null) { gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.structuredname.firstname; gCart.OrderInfo.CustomerLastName = newOrder.buyerbillingaddress.structuredname.lastname; } else { gCart.OrderInfo.CustomerFirstName = newOrder.buyerbillingaddress.contactname; gCart.OrderInfo.CustomerLastName = newOrder.buyerbillingaddress.contactname; } gCart.OrderInfo.CustomerEmail = newOrder.buyerbillingaddress.email; gCart.OrderInfo.CustomerCompany = newOrder.buyerbillingaddress.companyname; gCart.OrderInfo.CustomerAddressLine1 = newOrder.buyerbillingaddress.address1; gCart.OrderInfo.CustomerAddressLine2 = newOrder.buyerbillingaddress.address2; gCart.OrderInfo.CustomerCity = newOrder.buyerbillingaddress.city; gCart.OrderInfo.CustomerState = newOrder.buyerbillingaddress.region; gCart.OrderInfo.CustomerCountry = newOrder.buyerbillingaddress.countrycode; gCart.OrderInfo.CustomerPostalCode = newOrder.buyerbillingaddress.postalcode; gCart.OrderInfo.CustomerTelephoneDay = newOrder.buyerbillingaddress.phone; gCart.CopyCustomerToBilling(); if (newOrder.buyershippingaddress.structuredname != null) { gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.structuredname.firstname; gCart.OrderInfo.DeliveryLastName = newOrder.buyershippingaddress.structuredname.lastname; } else { gCart.OrderInfo.DeliveryFirstName = newOrder.buyershippingaddress.contactname; gCart.OrderInfo.DeliveryLastName = newOrder.buyershippingaddress.contactname; } gCart.OrderInfo.DeliveryCompany = newOrder.buyershippingaddress.companyname; gCart.OrderInfo.DeliveryAddress1 = newOrder.buyershippingaddress.address1; gCart.OrderInfo.DeliveryAddress2 = newOrder.buyershippingaddress.address2; gCart.OrderInfo.DeliveryCity = newOrder.buyershippingaddress.city; gCart.OrderInfo.DeliveryState = newOrder.buyershippingaddress.region; gCart.OrderInfo.DeliveryCountry = newOrder.buyershippingaddress.countrycode; gCart.OrderInfo.DeliveryPostalCode = newOrder.buyershippingaddress.postalcode; gCart.TaxTotal = newOrder.orderadjustment.totaltax.Value; if (newOrder.ShippingCost > 0) { gCart.ShippingTotal = newOrder.ShippingCost; } gCart.OrderTotal = newOrder.ordertotal.Value; Guid orderStatusGuid = OrderStatus.OrderStatusReceivedGuid; if ( (newOrder.financialorderstate == FinancialOrderState.CHARGEABLE) || (newOrder.financialorderstate == FinancialOrderState.CHARGED) || (newOrder.financialorderstate == FinancialOrderState.CHARGING) ) { orderStatusGuid = OrderStatus.OrderStatusFulfillableGuid; } StoreHelper.EnsureUserForOrder(gCart); gCart.Save(); //Currency currency = new Currency(store.DefaultCurrencyId); SiteSettings siteSettings = new SiteSettings(store.SiteGuid); Order order = Order.CreateOrder( store, gCart, gLog.RawResponse, gLog.OrderNumber, string.Empty, siteSettings.GetCurrency().Code, "GoogleCheckout", orderStatusGuid); //StoreHelper.ClearCartCookie(cart.StoreGuid); if (orderStatusGuid == OrderStatus.OrderStatusFulfillableGuid) { StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); } if (orderStatusGuid == OrderStatus.OrderStatusReceivedGuid) { StoreHelper.ConfirmOrderReceived(store, order); } }
private void btnMakePayment_Click(object sender, System.EventArgs e) { //Page.Validate(); if ( (store != null) && (cart != null) && (IsValidForCheckout()) ) { IPaymentGateway gateway = commerceConfig.GetDirectPaymentGateway(); if (gateway == null) { lblMessage.Text = WebStoreResources.PaymentGatewayNotConfiguredForDirectCardProcessing; btnMakePayment.Enabled = false; return; } //if (gateway is PlugNPayPaymentGateway) //{ gateway.MerchantInvoiceNumber = cart.CartGuid.ToString("N"); string CartItems = ""; int itemnum = 0; foreach (CartOffer coffer in cart.CartOffers) { itemnum++; CartItems += string.Format("&item{1}={0}&cost{1}={2}&description{1}={3}&quantity{1}={4}", coffer.OfferGuid, itemnum, coffer.OfferPrice, coffer.Name, coffer.Quantity); } gateway.MerchantTransactionDescription = CartItems; //not sure if this is the intended purpose or not //} gateway.CardType = ddCardType.SelectedValue; gateway.CardNumber = txtCardNumber.Text; gateway.CardExpiration = ddExpireMonth.SelectedValue + ddExpireYear.SelectedValue; gateway.ChargeTotal = cart.OrderTotal; gateway.CardSecurityCode = txtCardSecurityCode.Text; gateway.CardOwnerFirstName = txtCardOwnerFirstName.Text; gateway.CardOwnerLastName = txtCardOwnerLastName.Text; gateway.CardOwnerCompanyName = cart.OrderInfo.BillingCompany; gateway.CardBillingAddress = cart.OrderInfo.BillingAddress1 + " " + cart.OrderInfo.BillingAddress2; gateway.CardBillingCity = cart.OrderInfo.BillingCity; gateway.CardBillingState = cart.OrderInfo.BillingState; gateway.CardBillingPostalCode = cart.OrderInfo.BillingPostalCode; gateway.CardBillingCountry = cart.OrderInfo.BillingCountry; gateway.CardBillingCountryCode = cart.OrderInfo.BillingCountry; gateway.CardBillingPhone = cart.OrderInfo.CustomerTelephoneDay; gateway.CustomerIPAddress = SiteUtils.GetIP4Address(); gateway.CurrencyCulture = currencyCulture; // this is where the actual request is made, it can timeout here bool executed = false; try { executed = gateway.ExecuteTransaction(); } catch (WebException ex) { if (commerceConfig.PaymentGatewayUseTestMode) { lblMessage.Text = ex.Message; } else { lblMessage.Text = WebStoreResources.PaymentGatewayCouldNotConnectMessage; } return; } string serializedCart = string.Empty; gateway.LogTransaction( siteSettings.SiteGuid, store.ModuleGuid, store.Guid, cart.CartGuid, cart.UserGuid, string.Empty, "WebStoreCheckout", serializedCart); //if (gateway is PayPalDirectPaymentGateway) //{ // // this is capturing of the serialized cart is not needed for other providers and I'm not sure its even needed for PayPal Direct // // it was needed for other paypal solutions. I just don't want to remove it until I'm sure // cart.SerializeCartOffers(); // serializedCart = SerializationHelper.SerializeToString(cart); // gateway.LogTransaction( // siteSettings.SiteGuid, // store.ModuleGuid, // store.Guid, // cart.CartGuid, // cart.UserGuid, // "WebStorePayPalDirect", // "DirectPayment", // serializedCart); //} //else //{ // gateway.LogTransaction( // siteSettings.SiteGuid, // store.ModuleGuid, // store.Guid, // cart.CartGuid, // cart.UserGuid, // string.Empty, // "WebStoreCheckout", // serializedCart); //} if (executed) { switch (gateway.Response) { case PaymentGatewayResponse.Approved: cart.LastUserActivity = DateTime.UtcNow; cart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address(); cart.OrderInfo.Completed = DateTime.UtcNow; StoreHelper.EnsureUserForOrder(cart); cart.Save(); //Order order = Order.CreateOrder(store, cart, gateway, store.DefaultCurrency, "CreditCard"); Order order = Order.CreateOrder(store, cart, gateway, siteSettings.GetCurrency().Code, "CreditCard"); StoreHelper.ClearCartCookie(cart.StoreGuid); // send confirmation email try { // this also happens in StoreHelper.ConfirmOrder //Module m = new Module(store.ModuleId); //Order.EnsureSalesReportData(m.ModuleGuid, pageId, moduleId); StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); GoogleCheckoutLog.DeleteByCart(order.OrderGuid); } catch (Exception ex) { log.Error("error sending confirmation email", ex); } // redirect to order details string redirectUrl = SiteRoot + "/WebStore/OrderDetail.aspx?pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&orderid=" + order.OrderGuid.ToString(); //TODO: if we charged a card here we can safely delete any paypal log or googlecheckout logs // need methods to delete those by carguid if (WebStoreConfiguration.LogCardTransactionStatus) { log.Info("accepted transaction " + gateway.ChargeTotal.ToString("c") + " " + gateway.ResponseCode + " " + gateway.ResponseReason); } WebUtils.SetupRedirect(this, redirectUrl); return; case PaymentGatewayResponse.Declined: lblMessage.Text = WebStoreResources.TransactionDeclinedMessage; if ((WebStoreConfiguration.LogCardTransactionStatus) || (WebStoreConfiguration.LogCardFailedTransactionStatus)) { log.Info("declined transaction " + gateway.ChargeTotal.ToString("c") + " " + gateway.ResponseCode + " " + gateway.ResponseReason); } break; case PaymentGatewayResponse.Error: if (gateway.UseTestMode) { if (gateway.LastExecutionException != null) { lblMessage.Text = gateway.LastExecutionException.ToString(); } else { // TODO: should not show user real messages? Mask CCNumber and login credentials in the gateways RawResponse property ... those shouldn't be logged either lblMessage.Text = gateway.RawResponse; } } else { lblMessage.Text = WebStoreResources.TransactionErrorMessage; if ((WebStoreConfiguration.LogCardTransactionStatus) || (WebStoreConfiguration.LogCardFailedTransactionStatus)) { if (gateway.LastExecutionException != null) { log.Info("transaction error " + gateway.LastExecutionException.ToString()); } } } break; case PaymentGatewayResponse.NoRequestInitiated: lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage; break; } } else { lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage; if (gateway.LastExecutionException != null) { if (commerceConfig.PaymentGatewayUseTestMode) { lblMessage.Text = gateway.LastExecutionException.ToString(); } } } } btnMakePayment.Text = WebStoreResources.PaymentButton; }
public override void HandleOrderStateChangeNotification( string requestXml, OrderStateChangeNotification notification) { GoogleCheckoutLog gLog = new GoogleCheckoutLog(); Guid orderGuid = GoogleCheckoutLog.GetCartGuidFromOrderNumber(notification.googleordernumber); gLog.RawResponse = requestXml; gLog.NotificationType = "OrderStateChangeNotification"; gLog.ProviderName = "WebStoreGCheckoutNotificationHandlerProvider"; gLog.SerialNumber = notification.serialnumber; gLog.OrderNumber = notification.googleordernumber; gLog.FinanceState = notification.newfinancialorderstate.ToString(); gLog.FullfillState = notification.newfulfillmentorderstate.ToString(); gLog.GTimestamp = notification.timestamp; gLog.AvsResponse = notification.reason; gLog.CartGuid = orderGuid; gLog.Save(); if (orderGuid == Guid.Empty) { return; } Order order = new Order(orderGuid); if (order.OrderGuid != orderGuid) { return; } Store store = new Store(order.StoreGuid); if (store.Guid != order.StoreGuid) { return; } gLog.SiteGuid = store.SiteGuid; gLog.UserGuid = order.UserGuid; gLog.CartGuid = order.OrderGuid; gLog.StoreGuid = order.StoreGuid; gLog.Save(); if (notification.newfinancialorderstate == FinancialOrderState.CHARGED) { order.StatusGuid = OrderStatus.OrderStatusFulfillableGuid; order.Save(); if (!order.HasShippingProducts()) { // order only has download products so tell google the order is fulfilled try { CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig(); string gEvironment; if (commerceConfig.GoogleEnvironment == GCheckout.EnvironmentType.Sandbox) { gEvironment = "Sandbox"; } else { gEvironment = "Production"; } GCheckout.OrderProcessing.DeliverOrderRequest fulfillNotification = new GCheckout.OrderProcessing.DeliverOrderRequest( commerceConfig.GoogleMerchantID, commerceConfig.GoogleMerchantKey, gEvironment, notification.googleordernumber); fulfillNotification.Send(); StoreHelper.ConfirmOrder(store, order); PayPalLog.DeleteByCart(order.OrderGuid); log.Info("Sent DeliverOrderRequest to google api for google order " + notification.googleordernumber); } catch (Exception ex) { log.Error(ex); } } } }