Using the Credit Card Processing Classes

The process of charging cards is based on a few key tasks:

Since the classes provide a common base class interface through the ccProcessing class, the logic for all providers is very similar. You use the ccProcessing.CreateProcessor() method to create an instance of the appropriate provider and then set properties to provide the actual credit card account and processing information. Note that while most properties are common to all providers, some properties may be treated differently by each provider. The ccProcessing class provides as much commonality as possible so the simple properties can be used. However check the documentation for the specific provider to make sure the appropriate properties get set.

The following example is taken from the busInvoice object and demonstrates generic usage of both the ccAccessPoint and ccPayFlowPro classes in a business object:

public bool ProcessCreditCard() { bool Result = false; wws_invoiceRow Inv = this.Entity; wws_customersRow Cust = this.Customer.Entity; ccProcessing CC = null; ccProcessors CCType = App.Configuration.CCProcessor; try { // *** Create an instance of the appropriate Provider CC = ccProcessor.CreateProcessor( CCType ); if (CC == null) return false; //CC.UseTestTransaction = true; // *** Disable this for testing to get provider response CC.UseMod10Check = true; CC.Timeout = App.Configuration.CCConnectionTimeout; CC.HttpLink = App.Configuration.CCHostUrl; CC.MerchantId = App.Configuration.CCMerchantId; CC.LogFile = App.Configuration.CCLogFile; CC.ReferingUrl = App.Configuration.CCReferingOrderUrl; CC.OrderId = Inv.Invno.TrimEnd() + "_" + DateTime.Now.ToString(); //CC.Name = Cust.Firstname.TrimEnd() + " " + Cust.Lastname.TrimEnd(); CC.Firstname = Cust.Firstname.TrimEnd(); CC.Lastname = Cust.Lastname.TrimEnd(); CC.Company = Cust.Company.TrimEnd(); CC.Address = Cust.Address.TrimEnd(); CC.State = Cust.State.TrimEnd(); CC.City = Cust.City.TrimEnd(); CC.Zip = Cust.Zip.TrimEnd(); CC.Country = Cust.Country.TrimEnd(); CC.Phone = Cust.Phone.TrimEnd(); CC.Email = Cust.Email.TrimEnd(); CC.OrderAmount = Inv.Invtotal; CC.TaxAmount = Inv.Tax; CC.CreditCardNumber = Inv.Cc.TrimEnd(); CC.CreditCardExpiration = Inv.Ccexp.TrimEnd(); CC.SecurityCode = Inv.Ccsecurity.TrimEnd(); CC.Comment = "West Wind Technologies Order # " + Inv.Invno.TrimEnd(); Result = CC.ValidateCard(); Inv.Ccresult = CC.ValidatedResult; if (!Result) { this.ErrorMessage = CC.ValidatedMessage; Inv.Ccerror = this.ErrorMessage; } // *** Always write out the raw response if (wwUtils.Empty(CC.RawProcessorResult)) Inv.Ccresultx = CC.ValidatedMessage; else Inv.Ccresultx = CC.RawProcessorResult; } catch(Exception ex) { this.SetError(ex.Message); Inv.Ccresult = "FAILED"; Inv.Ccresultx = "Processing Error: " + ex.Message; Inv.Ccerror = "Processing Error: " + ex.Message; return false; } return Result; }

The properties for the processing are fairly straight forward. You provide name, address, credit card expiration date. The Expiration Date should always be provided in 12/2003 format of MM/YYYY. State codes are two letter codes, country values are 2 letter Country ISO codes.

The ValidateCard() method then takes all the input processes it and sets various result properties:

Logging

If you set LogFile property to a file name on disk you can cause the classes to automatically log each card process request result to a file. The filename must point at fully qualified OS path and the application must have rights to write to the file specified.



 Last Updated: 9/11/2007 | Send topic feedback