How To: Integrate Credit Card and ACH (e-check) processing into a Flex / Actionscript Flash system

This is the eighth part in a series of postings on how to integrate credit card and ACH/E-check transactions into various systems. This installment demonstrates code used for processing payments (credit card and/or ACH) within a Flex / ActionScript Flash application.

This was taken from the NELiX TransaX FleXport toolkit documentation. Credit card integration examples can be downloaded on the NELiX TransaX FleXport page.

Assumptions:
- Using NELiX TransaX Payment Gateway
- Communicating using NELiX TransaX Webservice

Follow these steps.

1. Create a new project.

2. Open “Data->Import Web Service” menu

Image: (NelixExmaples\doc\images\flex\01.jpg)

3. Change port to “RoXAIPSoap”and click “Finish”.
WebService files will be generated automatically.

Image: (NelixExmaples\doc\images\flex\02.jpg)

4. Add import directives in your project:

import com.nelixtransax.Responses;
import com.nelixtransax.Params;
import com.nelixtransax.ProcessTransaction_request;
import com.nelixtransax.ProcessTransactionResultEvent;
import com.nelixtransax.RoXAPI;

5. Initialize WebService:

private var ws:RoXAPI = new RoXAPI(null, null);

6. Add event listeners:

private function OnNelixWSButtonClick():void
{
ws.addEventListener(ProcessTransactionResultEvent.ProcessTransaction_RESULT, OnNelixWSSucces);

var params:Params = new Params();
var token:AsyncToken = ws.processTransaction(params);
token.addEventListener(FaultEvent.FAULT, OnFault);
}

private function OnNelixWSSucces(event:ProcessTransactionResultEvent):void
{
var a:com.nelixtransax.Responses = ws.processTransaction_lastResult;
Alert.show("Succes!");
}

private function OnFault(event:FaultEvent):void
{
Alert.show("Error #" + event.fault.errorID.toString() + ": " + event.fault.message );
}

7. Fill parameters:

private function FillParams(wsParams:Params):void
{
wsParams.TransactionType = TransactionType.selectedItem.toString();
wsParams.GatewayUserName = GatewayUserName.text;
wsParams.GatewayPassword = GatewayPassword.text;
wsParams.IPAddress = "127.0.0.1";

wsParams.Merchant_Defined_Field_1 = Merchant_Defined_Field_1.text;
wsParams.Merchant_Defined_Field_2 = Merchant_Defined_Field_2.text;

if(TransactionType.selectedItem.toString() == "void")
wsParams.TransactionID = TransactionID.text;

if(TransactionType.selectedItem.toString() == "refund")
{
wsParams.Amount = Amount.text;
wsParams.TransactionID = TransactionID.text;
}

if (TransactionType.selectedItem.toString() == "capture" )
{
wsParams.Amount = Amount.text;
wsParams.TransactionID = TransactionID.text;
wsParams.OrderID = OrderID.text;
wsParams.Tracking_Number = Tracking_Number.text;
wsParams.Shipping_Carrier = Shipping_Carrier.text;
}

if (TransactionType.selectedItem.toString() == "update")
{
wsParams.TransactionID = TransactionID.text;
wsParams.Tracking_Number = Tracking_Number.text;
wsParams.Shipping_Carrier = Shipping_Carrier.text;
}

if (Customer_Vault_Action.selectedItem.toString() == "delete_customer")
{
wsParams.Customer_Vault_Action = Customer_Vault_Action.selectedItem.toString();
wsParams.Customer_Vault_ID = Customer_Vault_ID.text;
}

if(TransactionType.selectedItem.toString() == "sale" || TransactionType.selectedItem.toString() == "auth" || Customer_Vault_Action.selectedItem.toString() == "add_customer" || Customer_Vault_Action.selectedItem.toString() == "update_customer" )
{
wsParams.PaymentType = PaymentType.selectedItem.toString();

if(Customer_Vault_Action.selectedItem.toString() == "add_customer" || Customer_Vault_Action.selectedItem.toString() == "update_customer" )
{
wsParams.Customer_Vault_Action = Customer_Vault_Action.selectedItem.toString();
}
wsParams.Customer_Vault_ID = Customer_Vault_ID.text;

if (wsParams.PaymentType == "creditcard")
{
wsParams.CCNumber = CCNumber.text;
wsParams.CCExpDate = CCExpDate.text;
wsParams.CVV = CVV.text;
}
if(wsParams.PaymentType == "check")
{
wsParams.CheckName = CheckName.text;
wsParams.CheckABA = CheckABA.text;
wsParams.CheckAccount = CheckAccount.text;
wsParams.AccountHolderType = AccountHolderType.selectedItem.toString();
wsParams.AccountType = AccountType.selectedItem.toString();
wsParams.SecCode = SecCode.selectedItem.toString();
}

wsParams.Payment_Plan_SKU = Payment_Plan_SKU.text;

wsParams.Amount = Amount.text;
wsParams.Tax = Tax.text;
wsParams.Shipping = Shipping.text;
wsParams.OrderDescription = OrderDescription.text;
wsParams.OrderID = OrderID.text;
wsParams.PONumber = PONumber.text;

wsParams.FirstName = FirstName.text;
wsParams.LastName = LastName.text;
wsParams.Company = Company.text;
wsParams.Address1 = Address1.text;
wsParams.Address2 = Address2.text;
wsParams.City = City.text;
wsParams.State = State.text;
wsParams.Zip = Zip.text;
wsParams.Country = Country.text;
wsParams.Phone = Phone.text;
wsParams.Fax = Fax.text;
wsParams.EMail = EMail.text;
wsParams.Website = Website.text;

wsParams.ShippingFirstName = ShippingFirstName.text;
wsParams.ShippingLastName = ShippingLastName.text;
wsParams.ShippingCompany = ShippingCompany.text;
wsParams.ShippingAddress1 = ShippingAddress1.text;
wsParams.ShippingAddress2 = ShippingAddress2.text;
wsParams.ShippingCity = ShippingCity.text;
wsParams.ShippingState = ShippingState.text;
wsParams.ShippingZip = ShippingZip.text;
wsParams.ShippingCountry = ShippingCountry.text;
wsParams.ShippingEmail = ShippingEmail.text;

wsParams.ProcessorID = ProcessorID.text;
wsParams.Descriptor = Descriptor.text;
wsParams.DescriptorPhone = DescriptorPhone.text;
}
}


If you need any assistance with payment processing integration with your Flex /ActionScript Flash system, we are here to help!

Download Flex / ActionScript flash credit card and ACH (e-check) integration examples.
Flash /ActionScript credit card integration examples also available.



Comments

Popular posts from this blog

VB6 / Visual Basic 6 - credit card and ACH procecessing