### ASP Charge 组件的例程

ASP Charge 为一组件（又是外国人的），你可以在本网页的组件搜索中找到它。下面是它的一个使用例子。
< HTML >
< HEAD >
< TITLE >ASPCharge Test Form< /TITLE >
< /HEAD >
< CENTER >
< H1 >ASPCharge Test Form< /H1 >
< /CENTER >
< %If Request.ServerVariables("Content_Length") >0 Then
Set charger = Server.CreateObject( "ASPCharge.CC" )
charger.ICVerifyCommand = "c:\inetpub\icverify\icverify.cmd"
charger.Logging = "c:\inetpub\icverify"
charger.DataDir = "c:\inetpub\icverify\datadir"
charger.Timeout = 45
charger.Name = Trim(Request("First")) + " " + Trim(Request("Last"))
charger.ProductCode = Trim(Request("Product"))
charger.Address = Trim(Request("Address1"))
charger.City = Trim(Request("City"))
charger.State = Trim(Request("State"))
charger.Zip = Trim(Request("Zip"))
charger.Country = Trim(Request("Country"))
charger.Amount = Trim(Request("Cost"))
charger.CCType = Trim(Request("CCType"))
charger.CCNum = Trim(Request("CCNum"))
charger.CCMonth = Trim(Request("CCMon"))
charger.CCYear = Trim(Request("CCYear"))
charger.TestMode=0
charger.Go()
CCError=charger.LastError
if charger.Cleared = "Y" Then
Response.Write("Thank you," & Request("First") & " for purchasing a " & Request("Product") & ". We appreciate your business.< P >")
Application("NextTestLicense") = Application("NextTestLicense") + 1
Response.Write("Your unique order number is " & Application("NextTestLicense"))
elseif charger.Cleared = "N" Then
Response.Write("I'm sorry your card was declined.")
elseif charger.Cleared = "X" Then
if charger.LastError = 1006 Then
Response.Write("ASPCharge detected a duplicate charge and did not charge the credit card.")
else
Response.Write("ASPCharge responded with a code of " & charger.LastError & "< BR >")
Response.Write("The code: " & charger.LastErrorMsg)
end if
else
Response.Write("This shouldn't ever be seen!")
end if
Response.Write("< P >")
else
% >
< CENTER >
< FONT SIZE="+3" >Pretend to buy a Blue Squirrel Coffee Mug< /FONT >
< BR >
< FONT SIZE="2" COLOR="Red" >Not Real - Credit card will not be charged.< BR >Try valid or invalid information and see how ASPCharge responds.< BR >Note: ASPCharge will be in test-mode and will not contact the clearinghouse.< BR >These are just sample responses. All messages can be customized.< /FONT >
< P >
< /CENTER >
< FORM ACTION="< %=Request.ServerVariables("SCRIPT_NAME")% >" METHOD=POST >
< table border=0 width=610 >
< tr >
< th align=right >First:< /th >
< th align=left >< INPUT type="text" size="20" name="First" >< /th >
< td > < /td >
< th align=right >Last:< /th >
< th align=left >< INPUT type="text" size="20" name="Last" >< /th >
< /tr >
< tr >
< th align=right >E-mail:< /th >
< th align=left >< INPUT type="text" size="20" name="Email" >< /th >
< td > < /td >
< th align=right >Phone:< /th >
< th align=left >< INPUT type="text" size="20" name="Phone" >< /th >
< /tr >
< tr >
< th align=right >Address:< /th >
< th align=left >< INPUT type="text" size="20" name="Address1" >< /th >
< td > < /td >
< th align=right >Address:< /th >
< th align=left >< INPUT type="text" size="20" name="Address2" >< /th >
< /tr >
< tr >
< th align=right >City:< /th >
< th align=left >< INPUT type="text" size="20" name="City" >< /th >
< td > < /td >
< th align=right >State:< /th >
< th align=left >< INPUT type="text" size="20" name="State" >< /th >
< /tr >
< tr >
< th align=right >Postal Code:< /th >
< th align=left >< INPUT type="text" size="20" name="Zip" >< /th >
< td > < /td >
< th align=right >Country:< /th >
< th align=left >< INPUT type="text" size="20" name="Country" value="United States" >< /th >
< /tr >
< /table >
< INPUT TYPE="HIDDEN" NAME="Product" VALUE="Blue Squirrel Coffee Mug" >
< INPUT TYPE="HIDDEN" NAME="Cost" VALUE="12.95" >
< HR >
< DD >< STRONG >Charge To:< /STRONG >
< SELECT NAME="CCType" >
< OPTION SELECTED="SELECTED" VALUE="MasterCard" >MasterCard
< /OPTION >
< OPTION VALUE="Visa" >Visa
< /OPTION >
< OPTION VALUE="American Express" >American Express
< /OPTION >
< OPTION VALUE="Discover" >Discover Card
< /OPTION >
< OPTION VALUE="Novus" >Novus
< /OPTION >
< /SELECT >
< DD >
< INPUT TYPE="text" NAME="CCNum" SIZE=32 MAXLENGTH="120" > Credit Card #
< DD >< select name="CCMon" size=1 >
< option >(month)< /option >< option >01< /option >< option >02< /option >< option >03< /option >< option >04< /option >< option >05< /option >< option >06< /option >
< option >07< /option >< option >08< /option >< option >09< /option >< option >10< /option >< option >11< /option >< option >12< /option >< /select >
< select name="CCYear" size=1 >
< option >(year)< /option >< option >97< /option >< option >98< /option >< option >99< /option >< option >00< /option >< option >01< /option >< /select >
expiration date (month / year)
< /DL >
< INPUT TYPE=submit VALUE="Register" > < INPUT TYPE=reset VALUE="Clear" >
< %end if% >
< /HTML >