Beginning ASP.NET 1.1 E-Commerce

Another aspect of web development you all seem to be interested in is E-Commerce. We hope to be having some tailor made DMXzone articles coming up on this subject later this year, but for the moment we're going to introduce you one of the latest books on the subject.

Using ASP.NET and VB.NET, Beginning ASP.NET 1.1 E-Commerce, a recent Apress book by Cristian Darie and Karli Watson, builds a web site in three phases of increasing complexity. Starting with a simple PayPal based site, the book moves onto the development of a custom shopping basket and eventually details how to develop a bespoke order pipeline and handle credit card payments yourself.

Whilst more a Microsoft oriented book without specific Dreamweaver information (it concentrates mainly on the server side processing), nevertheless this book contains valuable information for anybody thinking of implementing a .NET e-commerce solution.

In the attached sample chapter, we are taught about credit card processing.

Order a copy from Amazon >>

Considering the DataCash XML API

You’ll be doing a lot of XML manipulation when communicating with DataCash, because you’ll need to create XML documents to send to DataCash, and extract data from XML responses. In this section, we will take a quick look at the XML required for the operations you’ll be performing, and the responses you can expect.

Pre-authentication Request

When you send a pre-authentication request to DataCash, you need to include the following information:

  • DataCash username (known as the DataCash Client)
  • DataCash password
  • A unique transaction reference number (explained later in this section)
  • The amount of money to be debited
  • The currency used for the transaction (USD, GBP, and so on)
  • The type of the transaction (for pre-authentication, the code pre is used)
  • The credit card number
  • The credit card expiry date
  • The credit card issue date (if applicable to the type of credit card being used)
  • The credit card issue number (if applicable to the type of credit card being used)

The reference number must be a number between 6 and 12 digits long, which you choose to uniquely identify the transaction with an order. Because you can’t use a short number, you can’t just use the order ID values you’ve been using until now for orders. However, you can use this order ID as the starting point for creating a reference number, simply by adding a high number, such as 1,000,000.

You can’t duplicate the reference number in any future transactions, so you can be sure that after a transaction is completed, it won’t execute again, which might otherwise result in charging the customer twice. This does mean, however, that if a credit card is rejected, you might need to create a whole new order for the customer, but that shouldn’t be a problem if required.


The XML request is formatted in the following way, with the values detailed previously shown in bold:

<?xml version="1.0" encoding="UTF-8"?>
<Request>
<Authentication>
<password>DataCash password</password>
<client>DataCash client</client>
</Authentication>
<Transaction>
<TxnDetails>
<merchantreference>Unique reference number</merchantreference>
<amount currency='Currency Type'>Cash amount</amount>
</TxnDetails>
<CardTxn>
<method>pre</method>
<Card>
<pan>Credit card number</pan>
<expirydate>Credit card expiry date</expirydate>
</Card>
</CardTxn>
</Transaction>
</Request>

 

Response to Pre-authentication Request

The response to a pre-authentication request includes the following information:

  • A status code number indicating what happened; 1 if the transaction was successful, or one of several other codes if something else happens. For a complete list of return codes for a DataCash server, see https://testserver.datacash.com/ software/returncodes.html.
  • A reason for the status, which is basically a string explaining the status in English. For a status of 1, this string is ACCEPTED.
  • An authentication code used to fulfill the transaction.
  • A reference code for use by DataCash.
  • The time that the transaction was processed.
  • The mode of the transaction, which is TEST when using the test account.
  • Confirmation of the type of credit card used.
  • Confirmation of the country that the credit card was issued in.
  • The authorization code used by the bank (for reference only).

The XML for this is formatted as follows:

<?xml version="1.0" encoding="utf-8"?>
<Response>
<status>Status code</status>
<reason>Reason</reason>
<merchantreference>Authentication code</merchantreference>
<datacash_reference>Reference number</datacash_reference>
<time>Time</time>
<mode>TEST</mode>
<CardTxn>
<card_scheme>Card Type</card_scheme>
<country>Country</country>
<authcode>Bank authorization code</authcode>
</CardTxn>
</Response>


Ian Blackham

Ian BlackhamFollowing a degree in Chemistry and a doctorate in Scanning Tunneling Microscopy, Ian spent several years wrestling with acronyms in industrial R&D (SEM with a side order of EDS, AFM and TEM augmented with a topping of XPS and SIMS and yet more SEM and TEM).

Feeling that he needed a career with more terminology but less high voltages, Ian became a technical/commissioning editor with Wrox Press working on books as diverse as Beg VB Application Development and Professional Java Security. After Wrox's dissolution and a few short term assignments Ian became content manager at DMXzone.

Ian is a refugee from the industrial Black Country having slipped across the border to live in Birmingham. In his spare time he helps out with the website of a local history society, tries to makes sure he does what his wife Kate says, and worries that the little 'un Noah is already more grown up than he is.

See All Postings From Ian Blackham >>