| West Wind Web Store .NET 2.0 |
Web Store Integration
|
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.
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!).

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.
Last Updated: 8/27/2004 |
Send topic feedback