Web Store Integration

Credit Card integration in the Web Store is accomplished through the use of a business object method in the busInvoice class that provides the Credit Card processing. This method runs on a currently selected invoice and fills the invoice fields with the result values of the credit card processing. The provider for the Invoice object processing method is retrieved based on settings configured in the Configuration file.

There are two places where processing can occur in the Web app as well as in the offline application. In the Web app you can process either as part of the order process in real-time or through the admin interface as a post process Admin operation.

Online Processing

Online processing works well if you have electronic products that can be immediately released. The Web Store actually facilitates this process by allowing you to mark items in inventory that can be immediately confirmed via the AutoReg field. You can use the RegText Field to hold registration information and immediately confirm an order's items.

This process takes in the OrderForm.aspx page and the following code:

...btnSubmitOrder

... Validate User Input

... Validate Business Object properties

// *** Optional Credit Card Processing
// *** the method decides whether CC processing actually takes place
if ( !this.ProcessCreditCard() ) 
{
	string Error = Invoice.ErrorMessage;
	this.ShowError("Credit Card Processing failed: " + Error);
	return;
}

// *** Save the invoice
Invoice.Save();

... Confirmation code


bool ProcessCreditCard() 
{
	// *** See if we're On to do online processing
	// *** This logic checks to see whether items  are shippable without manual validation
	// *** If all are then the order is processed online. Otherwise it's simply submitted
	// *** and processed offline later.
	if (!App.Configuration.ccProcessCardsOnline)
		return true;

	
	// *** Check to see if this order can be processed without
	// *** manual confirmation (such as upgrades etc.)
	// *** YOU MAY WANT TO REMOVE THIS LINE IF YOU ALWAYS PROCESS CARDS
	if ( !Invoice.CanAutoProcessCreditCards() ) 
		return true;

	// *** Process the actual card for this invoice
	if (!Invoice.ProcessCreditCard() ) 
	{
		// *** Let the Page handle the error
		// *** Invoice.ErrorMessage has parsed error info
		return false;
	}

	// *** Confirm the order items
	this.Invoice.SendEmailConfirmation();

	return true;
}

The key is the ProcessCard method which first checks to see if you've enabled credit card processing in the .Config file. You must have set up this as well as the provider info before you can process cards. If you have the next check is to call CanAutoProcessCreditCards. This method runs through each item in the order and checks to see if this item's RegAuto flag is set. If all items have this flag set it means the order can be fully confirmed without operator intervention.

If you want to automatically charge cards regardless of this condition simply remove that line of code and let the code go directly to ProcessCreditCard() which uses the code shown in the Using the Credit Card PRocessing Classes topic. This code runs the credit card and fills the fields of the Invoice class - specifically the Invoice.DataRow["ccResult"], ccResultx and ccError fields. The method returns true or false and if false returns an ErrorMessage that describes the Credit Card failure. This error is echoed back to the user.

Note that here the order is not saved until the CC Processing goes through or the code above decides that this order cannot be processed automatically (both cases return true!).

Admin Processing

You can also process credit cards after the order has been placed. You can simply turn off the ccProcessCardsOnline option in the Store Configuration and then process cards from the Invoice List admin interface. First pick an invoice from the list:

Then when the invoice is displayed you can actually click the CC Processing button to process the card:

Here the card was processed and the card declined because I actually didn't provide a valid login to my card provider. Note that on this form you can also send the customer a confirmation email which as with the online sample will go through each of the lineitems and send the Registration Notice defined in the Items table to the customer's email address.

If the order was declined you can also send a notification of a declined order which will send a note for the reason of the decline to the customer's email address.

This admin interface provides more control over the process of order management as you can review the order properly before committing to accepting a charge from the customer.

Summary

You can of course choose to perform these task with different conditions. For example, you may decide to simply charge customers on the site and ship orders later - always. Or you may always process orders offline. It's really up to you but you may have to make some slight changes to the default order of things. However, since the methods exposed in the front end are very modular this should be very easy to do.

© West Wind Technologies, 1996-2018 • Updated: 08/27/04
Comment or report problem with topic