From the monthly archives:

March 2006

‹%@ Page Language=”C#” MasterPageFile=”~/MasterAdmin.master” AutoEventWireup=”true” CodeFile=”admin2_testimonial.aspx.cs” Inherits=”admin2_testimonial” Title=”Untitled Page” %›
‹asp:Content ID=”Content1″ ContentPlaceHolderID=”leftcontent” Runat=”Server”›
‹asp:GridView ID=”gv” runat=”server” AutoGenerateColumns=”False” DataKeyNames=”idTestimonial” DataSourceID=”ds_view” OnSelectedIndexChanged=”gv_SelectedIndexChanged”›
‹Columns›
‹asp:CommandField ShowSelectButton=”True” /›
‹asp:HyperLinkField DataTextField=”idTestimonial” Text=”Select” /›
‹asp:BoundField DataField=”idTestimonial” HeaderText=”idTestimonial” InsertVisible=”False”
ReadOnly=”True” SortExpression=”idTestimonial” /›
‹asp:BoundField DataField=”company” HeaderText=”company” SortExpression=”company” /›
‹/Columns›
‹/asp:GridView›

‹asp:DetailsView ID=”dv” runat=”server” AutoGenerateRows=”False” DataKeyNames=”idTestimonial” DataSourceID=”ds_edit”›
‹Fields›
‹asp:TemplateField HeaderText=”idTestimonial” InsertVisible=”False” SortExpression=”idTestimonial“›
‹EditItemTemplate›
‹asp:Label ID=”Label1″ runat=”server” Text=’‹%# Eval(”idTestimonial“) %›’›‹/asp:Label›
‹/EditItemTemplate›
‹ItemTemplate›
‹asp:Label ID=”Label1″ runat=”server” Text=’‹%# Bind(”idTestimonial“) %›’›‹/asp:Label›
‹/ItemTemplate›
‹/asp:TemplateField›
‹asp:BoundField DataField=”firstName” HeaderText=”firstName” SortExpression=”firstName” /›
‹asp:BoundField DataField=”lastName” HeaderText=”lastName” SortExpression=”lastName” /›
‹asp:BoundField DataField=”email” HeaderText=”email” SortExpression=”email” /›
‹asp:BoundField DataField=”phone” HeaderText=”phone” SortExpression=”phone” /›
‹asp:BoundField DataField=”company” HeaderText=”company” SortExpression=”company” /›
‹asp:BoundField DataField=”website” HeaderText=”website” SortExpression=”website” /›
‹asp:BoundField DataField=”street” HeaderText=”street” SortExpression=”street” /›
‹asp:BoundField DataField=”city” HeaderText=”city” SortExpression=”city” /›
‹asp:BoundField DataField=”state” HeaderText=”state” SortExpression=”state” /›
‹asp:BoundField DataField=”zip” HeaderText=”zip” SortExpression=”zip” /›
‹asp:BoundField DataField=”testimonial” HeaderText=”testimonial” SortExpression=”testimonial” /›
‹asp:CheckBoxField DataField=”phoneReference” HeaderText=”phoneReference” SortExpression=”phoneReference” /›
‹asp:CheckBoxField DataField=”emailReference” HeaderText=”emailReference” SortExpression=”emailReference” /›
‹asp:CheckBoxField DataField=”approved” HeaderText=”approved” SortExpression=”approved” /›
‹asp:CommandField ShowEditButton=”True” /›
‹/Fields›
‹/asp:DetailsView›
‹asp:SqlDataSource ID=”ds_view” runat=”server” ConnectionString=”‹%$ ConnectionStrings:ryason %›”
SelectCommand=”SELECT [idTestimonial], [company] FROM [testimonial]“›‹/asp:SqlDataSource›
‹asp:SqlDataSource ID=”ds_edit” runat=”server” ConnectionString=”‹%$ ConnectionStrings:ryason %›”
DeleteCommand=”DELETE FROM [testimonial] WHERE [idTestimonial] = @idTestimonial
InsertCommand=”INSERT INTO [testimonial] ([firstName], [lastName], [email], [phone], [company], [website], [street], [city], [state], [zip], [testimonial], [phoneReference], [emailReference], [approved]) VALUES (@firstName, @lastName, @email, @phone, @company, @website, @street, @city, @state, @zip, @testimonial, @phoneReference, @emailReference, @approved)”
SelectCommand=”SELECT * FROM [testimonial] where idTestimonial=@idTestimonial

UpdateCommand=”UPDATE [testimonial] SET [firstName] = @firstName, [lastName] = @lastName, [email] = @email, [phone] = @phone, [company] = @company, [website] = @website, [street] = @street, [city] = @city, [state] = @state, [zip] = @zip, [testimonial] = @testimonial, [phoneReference] = @phoneReference, [emailReference] = @emailReference, [approved] = @approved WHERE [idTestimonial] = @idTestimonial“›
‹SelectParameters›
‹asp:ControlParameter ControlID=”gv” DefaultValue=”7″ Name=”idTestimonial” PropertyName=”SelectedValue” Type=”int32″ /›
‹/SelectParameters›
‹DeleteParameters›
‹asp:Parameter Name=”idTestimonial” Type=”Int32″ /›
‹/DeleteParameters›
‹UpdateParameters›
‹asp:Parameter Name=”firstName” Type=”String” /›
‹asp:Parameter Name=”lastName” Type=”String” /›
‹asp:Parameter Name=”email” Type=”String” /›
‹asp:Parameter Name=”phone” Type=”String” /›
‹asp:Parameter Name=”company” Type=”String” /›
‹asp:Parameter Name=”website” Type=”String” /›
‹asp:Parameter Name=”street” Type=”String” /›
‹asp:Parameter Name=”city” Type=”String” /›
‹asp:Parameter Name=”state” Type=”String” /›
‹asp:Parameter Name=”zip” Type=”String” /›
‹asp:Parameter Name=”testimonial” Type=”String” /›
‹asp:Parameter Name=”phoneReference” Type=”Boolean” /›
‹asp:Parameter Name=”emailReference” Type=”Boolean” /›
‹asp:Parameter Name=”approved” Type=”Boolean” /›
‹asp:Parameter Name=”idTestimonial” Type=”Int32″ /›
‹/UpdateParameters›
‹InsertParameters›
‹asp:Parameter Name=”firstName” Type=”String” /›
‹asp:Parameter Name=”lastName” Type=”String” /›
‹asp:Parameter Name=”email” Type=”String” /›
‹asp:Parameter Name=”phone” Type=”String” /›
‹asp:Parameter Name=”company” Type=”String” /›
‹asp:Parameter Name=”website” Type=”String” /›
‹asp:Parameter Name=”street” Type=”String” /›
‹asp:Parameter Name=”city” Type=”String” /›
‹asp:Parameter Name=”state” Type=”String” /›
‹asp:Parameter Name=”zip” Type=”String” /›
‹asp:Parameter Name=”testimonial” Type=”String” /›
‹asp:Parameter Name=”phoneReference” Type=”Boolean” /›
‹asp:Parameter Name=”emailReference” Type=”Boolean” /›
‹asp:Parameter Name=”approved” Type=”Boolean” /›
‹/InsertParameters›
‹/asp:SqlDataSource›

‹/asp:Content›

‹asp:Content ID=”Content2″ ContentPlaceHolderID=”rightcontent” Runat=”Server”›
‹/asp:Content›

{ 0 comments }

‹%@ Page Language=”C#” MasterPageFile=”~/MasterAdmin.master” AutoEventWireup=”true” CodeFile=”admin_testimonial.aspx.cs” Inherits=”admin_testimonial” Title=”Untitled Page” %›
‹asp:Content ID=”idContent” ContentPlaceHolderID=”leftcontent” runat=”server”

‹asp:sqldatasource id=”ds_view” runat=”server” connectionstring=”"›”
SelectCommand=”SELECT [idTestimonial], [company] FROM [testimonial]“›

‹/asp:SqlDataSource›

‹asp:GridView ID=”GridView1″ runat=”server”
AutoGenerateColumns=”False”
DataSourceID=”ds_view”
DataKeyNames=”idTestimonial”
SelectedIndex=”0″›
‹columns›
‹asp:templatefield›
‹itemtemplate›
‹asp:linkbutton commandname=”Select” runat=”server”›
‹%#Eval(”idTestimonial”) %›‹/asp:LinkButton›
‹/itemtemplate›
‹/asp:TemplateField›
‹/columns›

‹/asp:GridView›

‹asp:SqlDataSource ID=”ds_edit” runat=”server”
SelectCommand=”Select * from testimonial where idTestimonial=@idTestimonial” ConnectionString=”‹%$ ConnectionStrings:ryason %›”

‹selectparameters›
‹asp:controlparameter controlid=”GridView1″ name=”idTestimonial” propertyname=”SelectedValue”›
‹/selectparameters›
‹/asp:SqlDataSource›

‹asp:DetailsView ID=”details” DataSourceID=”ds_edit” runat=”server”
AutoGenerateRows=”false”
DataKeyNames=”idTestimonial”›
‹fields›
‹asp:templatefield›
‹headertemplate›Edit:‹/headertemplate›
‹itemtemplate›
‹asp:button commandname=”Edit” text=”Edit” runat=”server”›
‹/itemtemplate›
‹/asp:TemplateField›

‹asp:boundfield datafield=”idTestimonial” readonly=”true”›
‹/fields›
‹/asp:DetailsView›

‹/asp:Content›

{ 0 comments }

Vertical navigation menu using xml datasource

by Caroline Bogart on March 27, 2006

Q. How do I create a vertical navigation menu that has different contents than Web.sitemap?
A. The menu’s datasource is bound to an XmlDataSource. Its orientation is Vertical.

‹asp:Menu ID=”blogmenu” runat=”server”
Font-Size=”1px”
CssClass=”blogmenu”
DataSourceID=”ds_menu_blog”
StaticDisplayLevels=”1″
DisappearAfter=”0″
StaticMenuItemStyle-CssClass=”blogmenu”


‹DataBindings›
‹asp:MenuItemBinding
DataMember=”siteMapNode”
NavigateUrlField=”url”
TextField=”title”
ToolTipField=”description”
ValueField=”title”
Target=”_new”
Value=”title”
/›
‹/DataBindings›

‹/asp:Menu›

blogs.xml
‹?xml version=”1.0″ encoding=”utf-8″?›
‹siteMap xmlns=”http://schemas.microsoft.com/AspNet/SiteMap-File-1.0″›

‹siteMapNode url=”blogs.aspx”
title=”Blogs”
description=”blogs”›
‹siteMapNode url=”http://aspnetanswers.blogspot.com/”

title=”ASP.Net Answers”
description=”Bogart Computing, LLC” /›
‹siteMapNode url=”http://seo-web-marketing-programming.blogspot.com”
title=”SEO Programming”
description=”Bogart Computing, LLC” /›

‹/siteMapNode›
‹/siteMap›

{ 0 comments }

Q. How do I create a horizontal footer menu that has different contents than Web.sitemap?
A. The menu’s datasource is bound to an XmlDataSource. Its orientation is Horizontal.

web form

‹asp:Menu ID="Menu1" runat="server"
DataSourceID="ds_sitemap_footer"
DisappearAfter="0"
ItemWrap="True"
Orientation="Horizontal"
Width="800px"
DynamicHorizontalOffset="2" StaticDisplayLevels="2"

‹DataBindings›
‹asp:MenuItemBinding
DataMember="siteMapNode"
NavigateUrlField="url"
TextField="title"
ToolTipField="description"
ValueField="title" /›
‹/DataBindings›
‹/asp:Menu›

‹asp:XmlDataSource
ID="ds_sitemap_footer"
runat="server"
DataFile="~/footer.xml"
XPath="/*/*"
/›

footer.xml

‹?xml version="1.0" encoding="utf-8" ?›
‹siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" ›

‹siteMapNode url="Default.aspx"
title="Home"
description="Bogart Computing, LLC" ›

‹siteMapNode url="contact-nh-web-design-ecommerce-seo.aspx"
title="Contact"
description="Contact Bogart Computing"
/›

‹siteMapNode url="links-bogart-web-seo-design-programming.aspx"
title="Links"
description="Links" /›

‹siteMapNode url="bogart-computing-testimonials.aspx"
description="customer testimonials"
title="Testimonials" /›

‹/siteMapNode›
‹/siteMap›

{ 0 comments }

web.config Provider Declarative SqlDataSource

by Caroline Bogart on March 21, 2006

Q. How do I create a data-aware web control that automatically binds to the data?
A. Drag a datasource onto a form. Make it use your SQL Server/Database/Table. Make it generate SELECT, INSERT, UPDATE and DELETE commands. Save the connection string to web.config.

Put a SqlDataSource on a form.
Name it ds_yourDatasetName.

On the web design view, click the setup arrow to configure the database.
Choose New Connection.
Data Source: Microsoft SQL Server
Provider: .Net Framework Provider
Server Name: yourSqlServerName
Use Windows Authentication
Select the database: yourDatabaseName
Do you want to save the connection in the application configuration file?: yes. Save this string as: yourConnectionString.

Configure the Select statement:
Choose the table, select the columns.

Create the INSERT, UPDATE and DELETE statements:
If you click Advanced and the Statement Creation options are grayed out try adding a Primary Key to your table. Select Advanced, Generate INSERT, UPDATE, and DELETE statements.

Saving the connection string created this in web.config:

‹add name="yourConnectionString"
connectionString="Data Source=yourSqlServerName;
Initial Catalog=yourTable;
Integrated Security=True"
providerName="System.Data.SqlClient" /›

Put a data-aware (e.g., FormView) control on the form. Task menu, Choose Data Source: ds_yourDatasetName.

{ 0 comments }

Submit Programming Links

by Caroline on March 20, 2006

Google Sitemaps
“The Google Sitemaps program is two-way communication between webmasters and Google. You can give us information about your site so we can index it more effectively, and we can show you how we see your site and tell you about any trouble we’ve had crawling it. ”
google.com/webmasters/sitemaps

XML Sitemaps
xml-sitemaps.com

Google Submit URL
google.com/addurl

Web Site Designers Directory
1234-find-web-designers.org

a2z Web Designer Resource
a2zwebdesignresource.com

nh.com
nh.com

Web Design Firms
www.webdesignfirms.org

Top Design Firms
http://www.topdesignfirms.com/

Consultant Directory
http://www.consultant-directory.com/add_url02.php?c=110

Accoona
http://www.accoona.com/public/submit_website.jsp

Alexa
http://pages.alexa.com/help/webmasters/index.html#crawl_site

Ali Baba
http://www.alibabachalischor.com/add_url_form.asp

All The Web
http://www.alltheweb.com/add_url.php

Yahoo
http://submit.search.yahoo.com/free/request

Directory of Web Designers
http://www.directoryofwebdesigners.com/reg.php

Amfibi
http://addurl.amfibi.com/

Amidalla
http://www.amidalla.com/cgi-bin/amiadd.cgi?add

Axxas Search
http://www.axxasearch.com/submit-site.htm

Beamed
http://www.beamed.com/search/AddURL.html

New Hampshire dot com
http://www.newhampshire.com/directory/submit1.cfm

Marketing Tool
http://www.marketingtool.com/click/b.435.r.70392.u.83b605.html

Active Server Page Hits
http://www.asphits.com

Web Designers Directory / Programmers
http://www.web-designers-directory.org/programmers-asp.net.php

Xenion
http://www.xemion.com/new-hampshire-manchester-web-design.html

{ 0 comments }

Where PayPal Stuff Is

by Caroline on March 20, 2006

Q. What are the PayPal real-time and sandbox payment Post and payment Get URL’s?
A. Sign up for merchant emails at the real-time and sandbox merchant interfaces. In the sandbox merchant interface, sign up for a customer email as well. Send the payment to the Post or Get links. Verify at the _cmd-notify-validate links.

Real Time
PayPal Customer and merchant interface

Post request for payment

Get (Response.Redirect) send request for payment

Post request for _cmd=notify-validate

Sandbox
PayPal customer and merchant interface

Order Processing

Get (Response.Redirect) processing

Post request for _cmd=notify-validate

{ 0 comments }

PayPal IPN Get Method Using ASP.Net, C#

by Caroline on March 16, 2006

Q. How do I take one-time, variable-amount, variable-reason web site payment using PayPal IPN, ASP.Net and C#?
A. Build a StringBuilder URL request and redirect the Response to PayPal.

This answer is the “get” method, because we’re going to redirect the response to PayPal using a query string.

Payment Form: make_payment.aspx
Create a web form that collects user input for:

  • payment purpose
  • amount

Anything else you collect on this form should be saved to the PayPal custom variable as demonstrated below. This data might be the customer’s name, address, email and company name.

protected void btnPay_Click(object sender, EventArgs e)

{ if (!Page.IsValid) { return;}

StringBuilder sbPayPal = new StringBuilder();
StringBuilder custom = new StringBuilder();
custom.Append(Server.UrlEncode(firstname.Text));
custom.Append(" ");
custom.Append(Server.UrlEncode(lastname.Text));
custom.Append(", ");
custom.Append(Server.UrlEncode(this.amount.Text));
custom.Append(",");
custom.Append(Server.UrlEncode(companyname.Text));
custom.Append(",");
custom.Append(Server.UrlEncode(email.Text));
custom.Append(",");
custom.Append(Server.UrlEncode(purpose.Text));
custom.Append(",");
if (sandbox.Checked) { sbPayPal.Append("https://www.sandbox.paypal.com/xclick/business=yoursandbox@emailhere.com");
} else {

// if you use this you'll really be paying me

sbPayPal.Append("https://www.paypal.com/xclick/business=caroline@bogartcomputing.com");}

sbPayPal.Append("&item_name=");
sbPayPal.Append(Server.UrlEncode(purpose.Text));
sbPayPal.Append("&quantity=1");
sbPayPal.Append("&custom=");
sbPayPal.Append(custom.ToString());
sbPayPal.Append("&amount=");
sbPayPal.Append(Server.UrlEncode(amount.Text));
sbPayPal.Append("&invoice=");
sbPayPal.Append(System.Guid.NewGuid().ToString());
sbPayPal.Append("&
nonote=1");
sbPayPal.Append("&no_shipping=1");
sbPayPal.Append("&return=");
sbPayPal.Append("http://bogartcomputing.com/payment_thankyou.aspx");
sbPayPal.Append("&
cancel_return=");
sbPayPal.Append("http://bogartcomputing.com/payment_cancel.aspx");
sbPayPal.Append("notify_url=");
sbPayPal.Append("http://bogartcomputing.com/YOUR_IPN_Form.aspx");
Response.Redirect(sbPayPal.ToString());
Response.Write(Server.UrlDecode(sbPayPal.ToString().Replace("&", " ")));
}

Cancellation Form: payment_cancel.aspx
Create a web form that statically informs the user that the payment was cancelled.

Payment Cancellation Your payment was not processed. Click here to make a payment

Thank You Form: payment_thankyou.aspx
Create a web form that accepts a post (Request.Form) to:

  • display payment details
  • statically inform the customer that he will receive an email when the payment is confirmed

if (Request.Form.Keys.Count>0)

{

try {

lblPaymentDate.Text=FormItem("payment_date");
lblTransactionType.Text= FormItem("txn_type");
lblLastName.Text= FormItem("last_name");
lblResidenceCountry.Text= FormItem("residence_country");
lblItemName.Text= FormItem("item_name");
lblPaymentGross.Text= FormItem("payment_gross");
lblMcCurrency.Text= FormItem("mc_currency");
lblBusiness.Text= FormItem("business");
lblPaymentType.Text= FormItem("payment_type");
lblVerifySign.Text= FormItem("verify_sign");
lblPayerStatus.Text= FormItem("payer_status");
lblTax.Text= FormItem("tax");
lblPayerEmail.Text= FormItem("payer_email");
lblTransactionID.Text= FormItem("txn_id");
lblQuantity.Text= FormItem("quantity");
lblReceiverEmail.Text=FormItem("receiver_email");
lblFirstName.Text= FormItem("first_name");
lblPayerID.Text= FormItem("payer_id");
lblReceiverId.Text= FormItem("receiver_id");
lblMemo.Text= FormItem("memo");
lblItemNumber.Text= FormItem("item_number");
lblPaymentStatus.Text= FormItem("payment_status");
lblPaymentFee.Text= FormItem("payment_fee");
lblMcFee.Text= FormItem("mc_fee");
lblShipping.Text= FormItem("shipping");
lblMcGross.Text= FormItem("mc_gross");
lblCustom.Text= FormItem("custom");
lblPendingReason.Text=FormItem("pending_reason");
lblAddressName.Text=FormItem("address_name");
lblAddressStreet.Text=FormItem("address_street");
lblAddressCity.Text=FormItem("address_city");
lblAddressStatus.Text=FormItem("address_status");
lblAddressState.Text=FormItem("address_state");
lblAddressZip.Text=FormItem("address_zip");
lblAddressCountryCode.Text=FormItem("address_country_code");
lblAddressCountry.Text=FormItem("address_country");
lblAddressCountry.Text=FormItem("address_country");
lblInvoice.Text=FormItem("invoice");
lblMcCurrency.Text=FormItem("mc_currency");
} catch (System.Exception ex) { Response.Write(ex.Message);
} }

Create an IPN (Instant Payment Notification) Form: YOUR_IPN_form.aspx

PayPal will post to this page when it has processed the transaction. You will check that the transaction is verified (the post to the page really came from PayPal) and not a duplicate (you’ve already processed this txn_id).

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Text;
using System.Net.Mail;
public partial class payment_notify : System.Web.UI.Page { TextWriter log = null;
mail m = null;
StringBuilder sb = null;
string txn_id, txn_type, payment_date, last_name, residence_country, item_name, payment_gross;
string item_number, payment_status, payment_fee, mc_fee, shipping, mc_gross, custom, pending_reason, address_name, address_street, address_city, address_state, address_status, address_zip, address_country, address_country_code, invoice, quantity, receiver_email, first_name, payer_id, receiver_id, memo, mc_currency, business, payment_type, verify_sign, payer_status, tax, payer_email;
StringBuilder merchantMsg;
StringBuilder customerMsg;
protected void Page_Load(object sender, EventArgs e) { try { // writes local log file CreateLog();
} catch (System.Exception logex) { Response.Write(logex.Message);
return;
} try { // sends me notice that ipn script has been triggered // TriggerEmail();
} catch (System.Exception teex) { Response.Write(teex.Message);
return;
} try { // checks Request.Form data against call to PayPal // checks txn_id against local database if (IsValidIPN() && !IsDupeTxn()) { // send message to merchant, customer that payment string is valid. // Doesn't mean payment is done, it means transaction has processed, perhaps to completion, to cancellation, to denial. CreateMessages();
SendMessages();
} } catch (System.Exception allex) { Response.Write(allex.Message);
return;
} finally { try { log.Flush();
log.Close();
} catch (System.Exception ioex) { Response.Write(ioex.Message);
} } } private void SendDebugMessage(string subject, string body) { try { m = new mail();
m.Body=body;
m.From="caroline@bogartcomputing.com";
m.FromDisplayName="web site paypal ipn debug msg";
m.IsBodyHtml=true;
m.Subject=subject;
m.To="ctbogart@yahoo.com";
m.send();
} catch {} } private void CreateMessages() { // PayPal has posted to this page. Get the Request.Form items. // Build customer and merchant email messages. log.WriteLine("CreateMessages()");
StringBuilder ctemp=new StringBuilder();
StringBuilder mtemp = new StringBuilder();
StringBuilder sb = new StringBuilder();
// merchant txn details invoice =FormItem("invoice");
item_number = FormItem("item_number");
item_name = FormItem("item_name");
quantity = FormItem("quantity");
memo = FormItem("memo");
custom = FormItem("custom");
sb.Append("Invoice: ");
sb.Append(invoice);
sb.Append("
");
sb.Append("Item Number: ");
sb.Append(item_number);
sb.Append("
");
sb.Append("Quantity: ");
sb.Append(quantity);
sb.Append("
");
sb.Append("Memo from buyer: ");
sb.Append(memo);
sb.Append("
");
ctemp.Append(sb.ToString());
mtemp.Append(sb.ToString());
// paypal txn details payment_date =FormItem("payment_date");
verify_sign = FormItem("verify_sign");
payment_status = FormItem("payment_status");
pending_reason =FormItem("pending_reason");
txn_id = FormItem("txn_id");
txn_type = FormItem("txn_type");
business = FormItem("business");
receiver_email = FormItem("receiver_email");
receiver_id = FormItem("receiver_id");
sb = new StringBuilder();
sb.Append("Payment date: ");
sb.Append(payment_date);
sb.Append("
");
ctemp.Append(sb.ToString());
mtemp.Append(sb.ToString());
mtemp.Append("Verify sign: ");
mtemp.Append(verify_sign);
mtemp.Append("
");
mtemp.Append("Payment status: ");
mtemp.Append(payment_status);
mtemp.Append("
");
mtemp.Append("Pending reason: ");
mtemp.Append(pending_reason);
mtemp.Append("
");
mtemp.Append("Transaction ID: ");
mtemp.Append(txn_id);
mtemp.Append("
");
mtemp.Append("Transaction Type: ");
mtemp.Append(txn_type);
mtemp.Append("
");
mtemp.Append("Business (email): ");
mtemp.Append(business);
mtemp.Append("
");
mtemp.Append("Receiver Email: ");
mtemp.Append(receiver_email);
mtemp.Append("
");
mtemp.Append("Receiver ID: ");
mtemp.Append(receiver_id);
mtemp.Append("
");
// paypal money details mc_currency = FormItem("mc_currency");
payment_gross = FormItem("payment_gross");
mc_gross = FormItem("mc_gross");
payment_type = FormItem("payment_type");
tax = FormItem("tax");
shipping = FormItem("shipping");
payment_fee = FormItem("payment_fee");
mc_fee = FormItem("mc_fee");
sb = new StringBuilder();
sb.Append("Currency: ");
sb.Append(mc_currency);
sb.Append("
");
sb.Append("Tax: ");
sb.Append(tax);
sb.Append("
");
sb.Append("Shipping: ");
sb.Append(shipping);
sb.Append("
");
sb.Append("Amount: ");
sb.Append(mc_gross);
sb.Append("
");
sb.Append("Payment Type: ");
sb.Append(payment_type);
sb.Append("
");
ctemp.Append(sb.ToString());
mtemp.Append(sb.ToString());
mtemp.Append("Fee: ");
mtemp.Append(mc_fee);
sb.Append("
");
// customer details last_name = FormItem("last_name");
first_name = FormItem("first_name");
address_name =FormItem("address_name");
address_street =FormItem("address_street");
address_city =FormItem("address_city");
address_status =FormItem("address_status");
address_state =FormItem("address_state");
address_zip =FormItem("address_zip");
address_country = FormItem("address_country");
address_country_code = FormItem("address_country_code");
residence_country = FormItem("residence_country");
payer_id = FormItem("payer_id");
payer_status = FormItem("payer_status");
payer_email = FormItem("payer_email");
sb = new StringBuilder();
sb.Append("Customer: ");
sb.Append(first_name);
sb.Append(" ");
sb.Append(last_name);
sb.Append("
");
sb.Append("Addressed To: ");
sb.Append(address_name);
sb.Append("
");
sb.Append(address_street);
sb.Append("
");
sb.Append(address_city);
sb.Append(", ");
sb.Append(address_state);
sb.Append(" ");
sb.Append(address_zip);
sb.Append("
");
sb.Append(address_country);
sb.Append(" (");
sb.Append(address_country_code);
sb.Append(")");
sb.Append("
");
ctemp.Append(sb.ToString());
mtemp.Append(sb.ToString());
mtemp.Append("Residence Country: ");
mtemp.Append(residence_country);
mtemp.Append("
");
mtemp.Append("Payer ID: ");
mtemp.Append(payer_id);
mtemp.Append("
");
mtemp.Append("Payer Status: ");
mtemp.Append(payer_status);
mtemp.Append("
");
mtemp.Append("Payer Email: ");
mtemp.Append(payer_email);
mtemp.Append("
");
customerMsg=new StringBuilder();
customerMsg.Append("Dear ");
customerMsg.Append(first_name);
customerMsg.Append(" ");
customerMsg.Append(last_name);
customerMsg.Append(",
");
customerMsg.Append("Thank you for your purchase. Your details are below.
");
customerMsg.Append(ctemp.ToString());
merchantMsg=new StringBuilder();
merchantMsg.Append("To: ");
merchantMsg.Append(business);
merchantMsg.Append("
");
merchantMsg.Append("
");
merchantMsg.Append("Custom pass through data: ");
merchantMsg.Append(custom);
merchantMsg.Append("
");
merchantMsg.Append(mtemp.ToString());
log.WriteLine(customerMsg.ToString());
log.WriteLine(merchantMsg.ToString());
} private void SendMessages() { log.WriteLine("SendMessage");
try

{

m = new mail();
m.Body=customerMsg.ToString();
m.From="caroline@bogartcomputing.com";
m.FromDisplayName="Bogart Computing Payment Received";
m.IsBodyHtml=true;
m.Subject="Bogart Computing PayPal Payment Received";
m.To=payer_email;
log.WriteLine("Sending customer email");
log.WriteLine(m.To.ToString());
m.send();
m.Body=merchantMsg.ToString();
m.To=business;
log.WriteLine("sending merchant email");
log.WriteLine(m.To.ToString());
m.send();
} catch (System.Exception smex)

{

log.WriteLine(smex.Message);
}

}

private bool IsDupeTxn()

{ return false;
}

private void CreateLog()

{

try

{

StringBuilder logname=new StringBuilder();
logname.Append(Request.MapPath("."));
logname.Append("\\log_");
logname.Append(DateTime.Now.Ticks.ToString());
logname.Append(".txt");
string filename = logname.ToString();
log = new StreamWriter(filename);
log.WriteLine(DateTime.Now.ToString());
log.WriteLine("Form");
log.Write(Request.Form.ToString());
} catch (System.Exception logex) { try { SendDebugMessage("IPN create log failed", logex.Message);
} catch { } throw logex;
} } private void TriggerEmail() { log.WriteLine("TriggerEmail()");
try { // send me note that ipn was triggered // inform owner that ipn is triggered mail m = new mail();
m.From="caroline@bogartcomputing.com";
m.FromDisplayName="Bogart Computing web site";
m.To="caroline@bogartcomputing.com";
m.Subject="bogart computing ipn triggered";
m.IsBodyHtml=true;
m.Body=Request.Form.ToString().Replace("&", "
");
log.WriteLine("about to send email cb notification start email");
try { m.send();
} catch (System.Exception ex) { log.WriteLine(ex.Message);
throw ex;
} } catch (System.Exception mex) { throw mex;
} } private bool IsValidIPN() { log.WriteLine("IsValidIPN()");
try { // ask PayPal if this is a valid IPN string value, response;
string form = Request.Form.ToString();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr");
req.Method = "POST";
req.ContentType="application/x-www-form-urlencoded";
value=form + "&cmd=_notify-validate";
req.ContentLength=value.Length;
log.WriteLine("create streamout");
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
streamOut.Write(value);
streamOut.Close();
log.WriteLine("create streamin");
StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
// response from PayPal response = streamIn.ReadToEnd();
streamIn.Close();
log.WriteLine(response);
return (response.ToLower()=="verified");
} catch (System.Exception ex) { log.WriteLine(ex.Message);
throw ex;
} } private string FormItem(string formAddress) { string result;
try { result=Server.HtmlEncode(Request.Form[formAddress]);
} catch { result=”N/A”;
} if (result==null) { result=”N/A”;
} return result;
} }

{ 0 comments }