14.1.10

Google Checkout code

window.parent.document.getElementById('lblPageHead').innerHTML = '<% =page_title %>'
function ClToolTip() {

var tooltip1 = $find("<%=RadDependent.ClientID%>");
tooltip1.hide();


}
==========================
gc notification:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gc_notification.aspx.cs"
Inherits="customer_gc_notification" %>




Untitled Page














=============
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using GCheckout;
using GCheckout.AutoGen;
using GCheckout.Util;
using GCheckout.OrderProcessing;
using Customer.order;
using System.IO;
using emailclient;
using settings.templates;
public partial class customer_gc_notification : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetNotification();
}


}
private void GetNotification()
{
Stream RequestStream = Request.InputStream;
StreamReader RequestStreamReader = new StreamReader(RequestStream);
string RequestXml = RequestStreamReader.ReadToEnd();
RequestStream.Close();
OrderBOL objBll;
Orders objBol;
switch (EncodeHelper.GetTopElement(RequestXml))
{
case "new-order-notification":
NewOrderNotification objNewOrd = (NewOrderNotification)EncodeHelper.Deserialize(RequestXml, typeof(NewOrderNotification));
objBll = new OrderBOL();
objBol = new Orders();
objBol.Googleorder_id = objNewOrd.googleordernumber;
objBol.Customer_Id = objNewOrd.buyerid.ToString();
objBol.CustomerName = objNewOrd.buyerbillingaddress.contactname.ToString();
objBol.BillingName = objNewOrd.buyerbillingaddress.contactname.ToString();
objBol.BillingCompanyName = objNewOrd.buyerbillingaddress.companyname.ToString();
objBol.BillingEmail = objNewOrd.buyerbillingaddress.email.ToString();
objBol.BillingPhone = objNewOrd.buyerbillingaddress.phone.ToString();
objBol.BillingFax = objNewOrd.buyerbillingaddress.fax.ToString();
objBol.BillingAddress1 = objNewOrd.buyerbillingaddress.address1.ToString();
objBol.BillingAddress2 = objNewOrd.buyerbillingaddress.address2.ToString();
objBol.BillingCity = objNewOrd.buyerbillingaddress.city.ToString();
objBol.BillingCountry = objNewOrd.buyerbillingaddress.countrycode.ToString();
objBol.BillingRegion = objNewOrd.buyerbillingaddress.region.ToString();
objBol.BillingPostalCode = objNewOrd.buyerbillingaddress.postalcode.ToString();
objBol.OrderTotal = Convert.ToDecimal(objNewOrd.ordertotal.Value);
objBol.UpdatedDate = Convert.ToDateTime(objNewOrd.timestamp);
objBol.Status = false;
objBol.Discount = 0;
objBol.DiscountType = "Discount";
objBol.advertiser_fk = 0;
objBol.Tax = 0;
foreach (Item ThisItem in objNewOrd.shoppingcart.items)
{
if (ThisItem.unitprice.Value > 0)
{
Order_Item objItem = new Order_Item();
objItem.Name = ThisItem.itemname;
objItem.quantity = ThisItem.quantity;
objItem.Price = ThisItem.unitprice.Value;
objItem.Googleorder_id = objBol.Googleorder_id;
string[] st = ThisItem.itemdescription.Split(',');
objBol.Itr_Fk = st[0];
objItem.RetrunDocId =Convert .ToInt64 ( st[1]);
objItem.Service_fk = Convert.ToInt16(st[2]);
hdnItrId.Value = objBol.Itr_Fk;
hdnReturnId.Value = objItem.RetrunDocId.ToString();
objBll.save_Orders_Items(objItem);
objItem = null;

}
else
{
//Use This area for save discount
objBol.DiscountType = ThisItem.itemname.ToString();
objBol.Discount = Convert.ToDecimal(ThisItem.unitprice.Value);
objBol.advertiser_fk = Convert.ToInt16(ThisItem.itemdescription);
}
}
string retval= objBll.save_Orders(objBol);
SendMail(objBol, retval);
objBol = null;
objBll = null;
break;
case "risk-information-notification":
objBll = new OrderBOL();
objBol = new Orders();
RiskInformationNotification objNewOrd1 = (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.
objBol.Googleorder_id = objNewOrd1.googleordernumber;
objBol.AVS = objNewOrd1.riskinformation.avsresponse;
objBol.CVN = objNewOrd1.riskinformation.cvnresponse;
bool SellerProtection = objNewOrd1.riskinformation.eligibleforprotection;
objBol.Status = false;
objBol.charge_amount = 0;
objBll.UpdateOrderStatus(objBol);
objBol = null;
objBll = null;
break;
case "order-state-change-notification":
OrderStateChangeNotification N3 = (OrderStateChangeNotification)EncodeHelper.Deserialize(RequestXml, typeof(OrderStateChangeNotification));
// The order has changed either financial or fulfillment state in Google's system.
string OrderNumber3 = N3.googleordernumber;
string NewFinanceState = N3.newfinancialorderstate.ToString();
string NewFulfillmentState = N3.newfulfillmentorderstate.ToString();
string PrevFinanceState = N3.previousfinancialorderstate.ToString();
string PrevFulfillmentState = N3.previousfulfillmentorderstate.ToString();
break;
case "charge-amount-notification":
objBll = new OrderBOL();
objBol = new Orders();
ChargeAmountNotification objNewOrd3 = (ChargeAmountNotification)EncodeHelper.Deserialize(RequestXml, typeof(ChargeAmountNotification));
// Google has successfully charged the customer's credit card.
objBol.Googleorder_id = objNewOrd3.googleordernumber;
objBol.Status = true;
objBol.CVN = "";
objBol.AVS = "";

decimal ChargedAmount = objNewOrd3.latestchargeamount.Value;
objBol.charge_amount = ChargedAmount;
objBll.UpdateOrderStatus(objBol);
objBll = null;
objBol = null;
break;
case "refund-amount-notification":
RefundAmountNotification N5 = (RefundAmountNotification)EncodeHelper.Deserialize(RequestXml, typeof(RefundAmountNotification));
// Google has successfully refunded the customer's credit card.
string OrderNumber5 = N5.googleordernumber;
decimal RefundedAmount = N5.latestrefundamount.Value;
break;
case "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.
string OrderNumber6 = N6.googleordernumber;
decimal ChargebackAmount = N6.latestchargebackamount.Value;
break;
}

}
#region Mail Sent
public void SendMail(Orders objOrder,string EmailAddress)
{
try
{
TemplateManager objTemp = new TemplateManager();
string emailfromName, emailfromId, emailpassword, emailSubject, body;
objTemp.TemplateType = "CUST_ORD";
objTemp = objTemp.fnDisplaySaleTemplateById(objTemp);
emailfromName = objTemp.FromName;
emailfromId = objTemp.FromEmail;
emailpassword = objTemp.Password;
emailSubject = objTemp.TemplateSubject;
body = objTemp.TemplateBody;
body = body.Replace("[Title]", "");
body = body.Replace("[FirstName]", objOrder.CustomerName);
body = body.Replace("[MiddleName]", "");
body = body.Replace("[LastName]", "");
body = body.Replace("[Address]", objOrder.BillingAddress1 + objOrder.BillingAddress2);
body = body.Replace("[City]", objOrder.BillingCity);
body = body.Replace("[State]", "");
body = body.Replace("[Country]", objOrder.BillingCountry);
body = body.Replace("[ZipCode]", objOrder.BillingPostalCode);
body = body.Replace("[Email]", objOrder.BillingEmail);
body = body.Replace("[MobilePhone]", "");
body = body.Replace("[Phone]", objOrder.BillingPhone);
#region Sent Mail

smtpsettings objsmtpsettings = new smtpsettings(objTemp.OutMail[0].OutMailServer, Convert.ToInt32(objTemp.OutMail[0].OutMailPort), emailfromId, emailpassword, true);
SMTPClient objSMTPClient = new SMTPClient(objsmtpsettings);
objSMTPClient.Recepients = EmailAddress;
if (!string.IsNullOrEmpty(objTemp.BCCEmail))
{
objSMTPClient.BCC = objTemp.BCCEmail;
}
if (!string.IsNullOrEmpty(objTemp.CCEmail))
{
objSMTPClient.CC = objTemp.CCEmail;
}
objSMTPClient.SenderName = emailfromName;
objSMTPClient.Subject = emailSubject;
objSMTPClient.Content = body;
objSMTPClient.SendMessage(objSMTPClient);
objsmtpsettings = null;
objSMTPClient = null;
#endregion
SendAdminMail(objOrder);
}
catch
{
}


}
public void SendAdminMail(Orders objOrder)
{
try
{
TemplateManager objTemp = new TemplateManager();
string emailfromName, emailfromId, emailpassword, emailSubject, body;
objTemp.TemplateType = "ADM_ORD";
objTemp = objTemp.fnDisplaySaleTemplateById(objTemp);
emailfromName = objTemp.FromName;
emailfromId = objTemp.FromEmail;
emailpassword = objTemp.Password;
emailSubject = objTemp.TemplateSubject;
body = objTemp.TemplateBody;
body = body.Replace("[Title]", "");
body = body.Replace("[FirstName]", objOrder.CustomerName);
body = body.Replace("[MiddleName]", "");
body = body.Replace("[LastName]", "");
body = body.Replace("[Address]", objOrder.BillingAddress1 + objOrder.BillingAddress2);
body = body.Replace("[City]", objOrder.BillingCity);
body = body.Replace("[State]", "");
body = body.Replace("[Country]", objOrder.BillingCountry);
body = body.Replace("[ZipCode]", objOrder.BillingPostalCode);
body = body.Replace("[Email]", objOrder.BillingEmail);
body = body.Replace("[MobilePhone]", "");
body = body.Replace("[Phone]", objOrder.BillingPhone);
#region Sent Mail
if (objTemp.ToEmai != null)
{
for (int icount = 0; icount < objTemp.ToEmai.Count; icount++)
{
smtpsettings objsmtpsettings = new smtpsettings(objTemp.OutMail[0].OutMailServer, Convert.ToInt32(objTemp.OutMail[0].OutMailPort), emailfromId, emailpassword, true);
SMTPClient objSMTPClient = new SMTPClient(objsmtpsettings);
objSMTPClient.Recepients = objTemp.ToEmai[icount].Email;

objSMTPClient.SenderName = emailfromName;
objSMTPClient.Subject = emailSubject;
objSMTPClient.Content = body;

objSMTPClient.SendMessage(objSMTPClient);
objsmtpsettings = null;
objSMTPClient = null;
}
}


#endregion
}
catch
{
}

}
#endregion
}

===============================
public Boolean fnActive(string Module, string Role)
{
string ret = "false";
string resourcefile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "Resources/Roles.xml");
XPathDocument objdoc = new XPathDocument(resourcefile);
XPathNavigator objnav;
objnav = objdoc.CreateNavigator();
XPathNodeIterator objitr;
XPathExpression objexp;
objexp = objnav.Compile("//Table[Name='" + Module + "' and Role='" + Role + "']/Active");
objitr = objnav.Select(objexp);
while (objitr.MoveNext())
{
ret = objitr.Current.ToString();
}

return Convert.ToBoolean(ret);
}

No comments: