ColdFusion
Sample ColdFusion code
Hash obtained
#x_fp_hash#
exact4r is a Ruby Gem providing access to our Web Services API allowing for submission of financial transactions via REST, JSON or SOAP.
First, download and install the Ruby Transaction Processing GEM. To submit requests to our transaction processing service, you must first have a Gateway ID, and a password.
Test logins are as follows:
Account 1: :gateway_id => "A00049-01", :password => "test1"
Account 2: :gateway_id => "A00427-01", :password => "testus"
require 'rubygems'
require 'exact4r'
# build a purchase request
request = EWS::Transaction::Request.new({
:transaction_type => :purchase,
:amount => 10.50,
:cardholder_name => "Simon Brown",
:cc_number => "4111111111111111",
:cc_expiry => "1012", # MUST be MMYY format
:gateway_id => "XXXXXXX", # which gateway to submit the request to
:password => "YYYYYY" # your password for that gateway
})
transporter = EWS::Transporter.new
response = transporter.submit(request) # submits using REST (XML) by default
# submit using JSON, or
response = transporter.submit(request, :json)
# submit using SOAP, or
response = transporter.submit(request, :soap)
# submit explicitly via REST
response = transporter.submit(request, :rest)
# The response object is independent of type of transport chosen.
# We decode the payload into a regular object
response.transaction_tag # 1234
response.exact_resp_code # "00"
response.exact_message # "Transaction Normal"
response.bank_resp_code # "00"
response.bank_message # "APPROVED"
require 'rubygems'
require 'exact4r'
# build a purchase request
request = EWS::Transaction::Request.new({
:transaction_type => :purchase,
:amount => 10.50,
:cardholder_name => "Simon Brown",
:cc_number => "4111111111111111",
:cc_expiry => "1012", # MUST be MMYY format
:gateway_id => "XXXXXXX", # which gateway to submit the request to
:password => "YYYYYY" # your password for that gateway
})
transporter = EWS::Transporter.new
response = transporter.submit(request) # submits using REST (XML) by default
# you need to know the transaction tag of the transaction you are looking for
find_request = EWS::Transaction::Request.new({
:transaction_type => :transaction_details,
:transaction_tag => response.transaction_tag,
:gateway_id => "XXXXXXX",
:password => "YYYYYY"
})
find_response = transporter.submit(find_request, :json) # again, can choose your transport type as before
find_response.cc_number # 4111111111111111
find_response.amount # 10.50
require 'rubygems'
require 'exact4r'
# The transporter object can be re-used across multiple transactions, so set it up once
# and forget about it.
# In this example, we will continue to use E-xact's default web-service URL, but we
# will specify a default transport_type of :soap
transporter = EWS::Transporter.new("https://api.e-xact.com/", {:transaction_type => :soap})
# now let's submit do a recurring seed purchase...
rsp_req = EWS::Transaction::Request.new({
:transaction_type => :recurring_seed_purchase,
:amount => 12.00,
:cardholder_name => "Simon Brown",
:cc_number => "4111111111111111",
:cc_expiry => "1012",
:gateway_id => "XXXXXX",
:password => "YYYYYY"
})
rsp_resp = transporter.submit(rsp_req)
raise "Seed Purchase failed" unless rsp_resp.approved?
# ...then do multiple refunds against it
1.upto(10) do
rf_req = EWS::Transaction::Request.new({
:transaction_type => :tagged_refund,
:transaction_tag => rsp_resp.transaction_tag, # need to know which transaction we're refunding against...
:authorization_num => rsp_resp.authorization_num, # and its authorization_num
:amount => 1.00, # refund a dollar at a time
:gateway_id => "XXXXXX",
:password => "YYYYYY"
})
rf_resp = transporter.submit(rf_req)
raise "Refund failed: #{rf_resp.exact_resp_code}, #{rf_resp.exact_message}" unless rf_resp.approved?
end
Run all test in spec/ folder (default)
Generate rdoc html in doc/
Build gem
Hash obtained
#x_fp_hash#
You can use a java client library called exact4j to process transactions in a java environment quickly and easily.
Use the following test credentials:
ExactID = A00049-01
Password = test1
final Transporter trans = new Transporter("https://api.e-xact.com", null);
final Request request = new Request(TransactionType.Purchase);
//required fields
request.setExactId(exactID);
request.setPassword(password);
request.setAmount(dollarAmount);
request.setCardholderName(cardHoldersName);
request.setCardNumber(card_Number);
request.setCardExpiryDate(expiry_Date); //MMYY format
//optional fields
request.setUserName(userName);
request.setClientEmail(client_Email);
request.setReference3(reference_3);
request.setCustomerRef(customer_Ref);
request.setReferenceNo(reference_No);
request.setLanguage(com.exact.ews.transaction.enums.Language.English);
try {
resp = trans.submit(request);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Submitting purchase failed");
}
System.out.println(resp.getExactResponseCode());
final Transporter trans = new Transporter("https://api.e-xact.com", null);
final Request request = new Request(TransactionType.Refund);
//required fields
request.setExactId(exactID);
request.setPassword(password);
request.setAmount(dollarAmount);
request.setCardholderName(cardHoldersName);
request.setCardNumber(card_Number);
request.setCardExpiryDate(expiry_Date); //MMYY format
request.setUserName(userName);
request.setClientEmail(client_Email);
request.setReference3(reference_3);
request.setCustomerRef(customer_Ref);
request.setReferenceNo(reference_No);
request.setLanguage(com.exact.ews.transaction.enums.Language.English);
try {
resp = trans.submit(request);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Submitting refund failed");
}
System.out.println(resp.getExactResponseCode());
final Transporter trans = new Transporter("https://api.e-xact.com", null);
final Request request = new Request(TransactionType.PreAuth);
//required fields
request.setExactId(exactID);
request.setPassword(password);
request.setAmount(dollarAmount);
request.setCardholderName(cardHoldersName);
request.setCardNumber(card_Number);
request.setCardExpiryDate(expiry_Date); //MMYY format
request.setUserName(userName);
request.setClientEmail(client_Email);
request.setReference3(reference_3);
request.setCustomerRef(customer_Ref);
request.setReferenceNo(reference_No);
request.setLanguage(com.exact.ews.transaction.enums.Language.English);
try { resp = trans.submit(request);
} catch (Exception e) { e.printStackTrace();
System.out.println("Submitting preauth failed");
}
System.out.println(resp.getExactResponseCode());
System.out.println("Authorization num: " + resp.getRequest().getAuthorizationNum());
if (authNum == null) {
throw new IllegalArgumentException("Exception - authNum nil while trying completion");
}
//preauth-completion
final Transporter trans = new Transporter("https://api.e-xact.com", null);
final Request request = new Request(TransactionType.PreAuthCompletion);
//required fields
request.setExactId(exactID);
request.setPassword(password);
request.setAmount(dollarAmount);
request.setCardholderName(cardHoldersName);
request.setCardNumber(card_Number);
request.setCardExpiryDate(expiry_Date); //MMYY format
request.setAuthorizationNum(authNum);
request.setUserName(userName);
request.setClientEmail(client_Email);
request.setReference3(reference_3);
request.setCustomerRef(customer_Ref);
request.setReferenceNo(reference_No);
request.setLanguage(com.exact.ews.transaction.enums.Language.English);
try {
resp = trans.submit(request);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Submitting preauth completion failed");
}
System.out.println(resp.getExactResponseCode());
System.out.println("Authorization num: " + resp.getRequest().getAuthorizationNum());
E-xact Transactions: Websecure Payment Form Example - php ![]()
E-xact Transactions: Websecure Payment Form Example - php
Disclaimer: this sample program is meant for guidance. There are no warranties about its functionality. Click the "Pay" button to submit a test request to https://checkout.e-xact.com/pay.
Processing credit card payments with your PHP application and VersaPay is easy! To process a transaction with your PHP application, review the sample code:
"", "Ecommerce_Flag"=>"", "XID"=>"", "ExactID"=>$_POST["ddlPOS_ExactID"], //Test Gateway Username CAD="A00049-01" "CAVV"=>"", "Password"=>"test1", //Test Gateway Password CAD="test1" "CAVV_Algorithm"=>"", "Transaction_Type"=>$_POST["ddlPOS_Transaction_Type"], //Transaction Code I.E. Purchase="00" Pre-Authorization="01" etc. "Reference_No"=>$_POST["tbPOS_Reference_No"], "Customer_Ref"=>$_POST["tbPOS_Customer_Ref"], "Reference_3"=>$_POST["tbPOS_Reference_3"], "Client_IP"=>"", //This value is only used for fraud investigation. "Client_Email"=>$_POST["tb_Client_Email"], //This value is only used for fraud investigation. "Language"=>$_POST["ddlPOS_Language"], //English="en" French="fr" "Card_Number"=>$_POST["tbPOS_Card_Number"], //For Testing, Use Test#s VISA="4111111111111111" MasterCard="5500000000000004" etc. "Expiry_Date"=>$_POST["ddlPOS_Expiry_Date_Month"] . $_POST["ddlPOS_Expiry_Date_Year"], //This value should be in the format MM/YY. "CardHoldersName"=>$_POST["tbPOS_CardHoldersName"], "Track1"=>"", "Track2"=>"", "Authorization_Num"=>$_POST["tbPOS_Authorization_Num"], "Transaction_Tag"=>$_POST["tbPOS_Transaction_Tag"], "DollarAmount"=>$_POST["tbPOS_DollarAmount"], "VerificationStr1"=>$_POST["tbPOS_VerificationStr1"], "VerificationStr2"=>"", "CVD_Presence_Ind"=>"", "Secure_AuthRequired"=>"", // Level 2 fields "ZipCode"=>$_POST["tbPOS_ZipCode"], "Tax1Amount"=>$_POST["tbPOS_Tax1Amount"], "Tax1Number"=>$_POST["tbPOS_Tax1Number"], "Tax2Amount"=>$_POST["tbPOS_Tax2Amount"], "Tax2Number"=>$_POST["tbPOS_Tax2Number"], "SurchargeAmount"=>$_POST["tbPOS_SurchargeAmount"], //Used for debit transactions only "PAN"=>$_POST["tbPOS_PAN"] //Used for debit transactions only ); $trxn = array("Transaction"=>$trxnProperties); $client = new SoapClient ("https://secure2.e-xact.com/vplug-in/transaction/rpc-enc/service.asmx?wsdl"); $trxnResult = $client->__soapCall('SendAndCommit', $trxn); if($client->fault){ // there was a fault, inform print "FAULT: Code: {$client->faultcode}
"; print "String: {$client->faultstring} "; $trxnResult["CTR"] = "There was an error while processing. No TRANSACTION DATA IN CTR!"; } //Uncomment the following commented code to display the full results. echo "Transaction Properties BEFORE Processing
"; echo "
| Property | Value |
| $key | :$value |
| Property | Value |
| $key | :$value |
How hosted checkout works:
Instructions of how to integrate hosted checkout into your application:
To generate x_fp_hash using C#, please see the snippet below:
Sample code for generating the hash for HCO using C#
To generate x_fp_hash using C#, please see the snippet below:
using System;
using System.Security;
using System.Security.Cryptography;
using System.Text;
class CalculateHash {
static void Main() {
StringBuilder sb = new StringBuilder();
// x_login^x_fp_sequence^x_fp_timestamp^x_amount^x_currency
String x_login = "WSP-ACTIV-70";
String x_fp_sequence = "123";
String x_fp_timestamp = "1228774539";
String x_amount = "100.00";
String x_currency = ""; // default empty
sb.Append(x_login)
.Append("^")
.Append(x_fp_sequence)
.Append("^")
.Append(x_fp_timestamp)
.Append("^")
.Append(x_amount)
.Append("^")
.Append(x_currency);
// Convert string to array of bytes.
byte[] data = Encoding.UTF8.GetBytes(sb.ToString());
// key
byte[] key = Encoding.UTF8.GetBytes("V0WX5fK~o6eEhr7hbs3ZeyxS");
// Create HMAC-MD5 Algorithm;
HMACMD5 hmac = new HMACMD5(key);
// Compute hash.
byte[] hashBytes = hmac.ComputeHash(data);
// Convert to HEX string.
String x_fp_hash = System.BitConverter.ToString(hashBytes).Replace("-", "");
String msg = String.Format("x_login = {0}, x_fp_sequence = {1}, x_fp_timestamp = {2},
x_amount = {3}, x_currency= {4}.\n x_fp_hash = {5}", x_login, x_fp_sequence,
x_fp_timestamp, x_amount, x_currency, x_fp_hash);
System.Console.WriteLine(msg);
}
}