ASP Sample Shopping Cart Check-Out Code in VBScript
(Note: Click here to download a fully working ASP/VBScript
web page that demonstrates calling I-Bill IT
from ASP/VBScript on your site.)
Using I-Bill IT, on a classic ASP page with VBScript
is quite simple. There are two different paths to creating a payment depending
upon the needs of your site. The easy way is to use the SubmitCreditCardPayment()
method of the BillIt object. The code looks like this:
Dim oBillit
Dim oResp
' Create the BillIt object and set login credentials
Set oBillIt = Server.CreateObject("ITDevWorks.BillIt.BillIt")
oBillIt.MerchantId = "xxxxxxxxxxxxxxx"
oBillIt.TransactionKey = "xxxxxxxxxxxxxxx"
' Submit the actual payment
Set oResp = oBillit.SubmitCreditCardPayment(_
249.99, "4111111111111111", CDate("12/31/2010"), "111")
On the other hand, to take full advantage of the features that I-Bill
IT offers, create a Payment object, set properties on it to suit your site's needs,
then call the Payment.Submit() method.
const AUTHNET_API_LOGIN = "<your-merchant-api-login-here>"
const AUTHNET_TRANSACTION_KEY = "<your-transaction-key-here>"
Function MakePayment()
Dim oBillIt
Dim pmt
'
' Create the BillIt object
'
Set oBillIt = Server.CreateObject("ITDevWorks.BillIt.BillIt")
'
' Set the login credentials
'
oBillIt.MerchantId = AUTHNET_API_LOGIN
oBillIt.TransactionKey = AUTHNET_TRANSACTION_KEY
'
' Create the Payment object
'
Set oPmt = oBillIt.CreatePayment()
'
' This reduces the chances of getting "A duplication
' transaction has already been submitted" responses
' from the gateway when doing testing.
'
oPmt.DuplicateCheckTimeout = 1
'
' Add some products to the list of purchased items.
'
oPmt.OrderLineItems.Add "ITM0496", "Digital Camera", _
"10 Megapixel digital camera", 1, 249.99, False
oPmt.OrderLineItems.Add "ITM0395", "Camera Carry Bag", _
"Nylon camera carrying case", 1, 49.99, False
oPmt.OrderLineItems.Add "ITM9655", "AA Btry 4-pack", _
"Package of 4 AA Alkaline batteries", 4, 3.99, False
'
' Add the shipping costs for each item
'
oPmt.Freight.Add 7.99, "Digital camera S&H", ""
oPmt.Freight.Add 3.99, "Camera carrying case S&H", ""
oPmt.Freight.Add 4.99, "Batteries S&H", ""
'
' NOTE: The following line of code must be called.
' The OrderLineItem, Tax, Freight, and Duty collections
' do not automatically set the amount that will be billed.
'
oPmt.Amount = oPmt.CalculateTotalAmount(True, True, True, False)
'
' Set the credit card properties
'
oPmt.CreditCardNumber = "4111111111111111"
oPmt.CreditCardExpiration = CDate("12/31/2008")
oPmt.CreditCardCode = "111"
'
' Set the customer properties (optional for most payments)
'
oPmt.CustomerBillTo.FirstName = "John"
oPmt.CustomerBillTo.LastName = "Doe"
oPmt.CustomerEmail = "johnd@somecompany.com"
oPmt.CustomerPhone = "(425)555-6789"
'
' Submit the payment to the Authorize.Net gateway
'
Set MakePayment = oPmt.Submit()
End Function
There is no requirement to use .OrderLineItems or any of the .Tax, .Freight, or .Duty
collections, but doing so can capture much more detail about transactions in your
Authorize.net account. By caching the Payment object, the OrderLineItems collection
can also be your in-session shopping cart data store. Every object in I-Bill IT
supports a .UserData property, which allows you to attach any data of your own to
it. For the OrderLineItems collection, you could store the CartId from your
database, or even a whole object representing the persisted cart in your database.
The I-Bill IT control gives you the flexibility to create your own shopping cart the way you want.
Use it to build a reliable e-commerce site while simplifying your development effort and shortening your time
to market. To test I-Bill IT, try our trial version.