Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:soap-1.6:howto:ruby [2012/08/04 11:51] (current)
tem created
Line 1: Line 1:
 +====== Ruby SOAP Guide ======
 +
 +====== Downloads ======
 +
 +You can download the files below or create them by running the command:
 +<code>
 +wsdl2ruby.rb --wsdl https://www.usaepay.com/soap/gate/*********/usaepay.wsdl --type client
 +</code>
 +for Sandbox Server use Sandbox wsdl link. You can generate a link in the [[https://www.usaepay.com/developer/|Developer Center]] 
 +
 +^File  ^Version ^Release Date ^ Description ^
 +|{{:developer:soap-1.4:howto:usaepay_ruby_live.zip|Download usaepay_ruby_live.zip}} | 1.0.0 | 3/21/11 | Library for Live/Production | 
 +|{{:developer:soap-1.4:howto:usaepay_ruby_sandbox.zip|Download usaepay_ruby_sandbox.zip}} | 1.0.0 | 3/21/11 | Library for Sandbox |
 +
 +====== Usage ======
 +
 +=====  Step 1: Import Classes =====
 +
 +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:
 +
 +<code ruby>
 +require 'usaepayDriver'
 +</code>
 +
 +If you place files in another directory, you should specify the correct path to usaepayDriver.rb 
 +
 +===== Step 2: Instantiate client Object =====
 +
 +All calls to the USAePay SOAP servers are handled by a "client" object of type "UeSoapServerPortType".  To instantiate a client:
 +
 +<code ruby>
 +# Instantiate client
 +@client=UeSoapServerPortType.new
 +</code>
 +
 +===== Step 3: Generate Security Token =====
 +
 +A "token" object (of type UeSecurityToken) is required by all SOAP methods in the USAePay API.  It is used to identify the merchant.  
 +
 +<code ruby>
 +# 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")
 +</code>
 +
 +===== Step 4: Calling a SOAP Method =====
 +
 +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.
 +
 +<code ruby>
 +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}" 
 +
 +</code>
 +
 +====== Additional Documentation ======
 +
 +For additional documentation please see the main [[http://wiki.usaepay.com/developer/soap-1.4/objects/transactionresponse|SOAP API Documenation]].  It includes a description of all methods and their parameters as well as examples.
 +
 +====== Troubleshooting ======
 +===== uninitialized constant SOAP::Mapping::EncodedRegistry =====
 +Make sure that you have soap4r installed or install it by running : 
 +<code>
 +gem install soap4r --include-dependencies
 +</code>
 +
 +and add the following to /config/environment.rb:
 +<code>
 +require 'rubygems'
 +gem 'soap4r' 
 +</code>
 +
 +For questions please email [[mailto:devsupport@usaepay.com]]
  
 
developer/soap-1.6/howto/ruby.txt · Last modified: 2012/08/04 11:51 by tem
 

Wiki Login| Wiki Index | Update Profile| Un/ Subscribe to Changes

USA ePay and the USA ePay logo are registered trademarks of GorCorp Inc.
Copyright © 2008, GorCorp Inc., All Rights Reserved