You can download the files below or create them by running the command:
wsdl2ruby.rb --wsdl https://www.usaepay.com/soap/gate/*********/usaepay.wsdl --type client
for Sandbox Server use Sandbox wsdl link. You can generate a link in the Developer Center
File | Version | Release Date | Description |
---|---|---|---|
Download usaepay_ruby_live.zip | 1.0.0 | 3/21/11 | Library for Live/Production |
Download usaepay_ruby_sandbox.zip | 1.0.0 | 3/21/11 | Library for Sandbox |
In classes that are going to use the USAePay SOAP methods or object, you need to include the appropriate classes. The following will import all usaepay objects at once:
require 'usaepayDriver'
If you place files in another directory, you should specify the correct path to usaepayDriver.rb
All calls to the USAePay SOAP servers are handled by a “client” object of type “UeSoapServerPortType”. To instantiate a client:
# Instantiate client @client=UeSoapServerPortType.new
A “token” object (of type UeSecurityToken) is required by all SOAP methods in the USAePay API. It is used to identify the merchant.
# Create security token require 'digest' def getToken(key,pin) token=UeSecurityToken.new token.clientIP = "123.123.123.123" hash=UeHash.new t=Time.now seed = "#{t.year}#{t.month}#{t.day}#{t.hour}#{rand(1000)}" prehash = "#{key}#{seed}#{pin.to_s.strip}" hash.seed=seed hash.type="sha1" hash.hashValue=Digest::SHA1.hexdigest(prehash).to_s token.pinHash = hash token.sourceKey=key return token end token=getToken("YOUR_SOURCE KEY","1234")
SOAP methods are called using the client object. Below is an example for calling the runTransaction method. For further examples see the SOAP API documentation.
request=TransactionRequestObject.new request.accountHolder="TesterJones" request.command="sale" details=TransactionDetail.new details.amount="1.00" details.description="example sale" request.details=details creditcard=CreditCardData.new creditcard.avsStreet="123 main st." creditcard.avsZip="90010" creditcard.cardNumber="4444555566667779" creditcard.cardExpiration="1212" request.creditCardData=creditcard @client=UeSoapServerPortType.new response=@client.runTransaction(token,request) p "RefNum:#{response.refNum}"
For additional documentation please see the main SOAP API Documenation. It includes a description of all methods and their parameters as well as examples.
Make sure that you have soap4r installed or install it by running :
gem install soap4r --include-dependencies
and add the following to /config/environment.rb:
require 'rubygems' gem 'soap4r'
For questions please email mailto:devsupport@usaepay.com