Forum: Ruby Help with some PayPal SOAP code

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
38a3e61877cbda2162b8f29572ee87c4?d=identicon&s=25 Jonathan Dodson (Guest)
on 2006-01-17 01:58
(Received via mailing list)
I am having issues with PayPal's SOAP API layer.  I am using Ruby 1.8.3
in Ubuntu Breezy.

I downloaded soap4r and used the wsdl2ruby.rb to create
'defaultDriver.rb' and other files to map to the PayPal SOAP API.

I am connecting to the sandbox test server with a account and password
and have the certificates and keys in the right spots.

I am getting this following error returned from the SOAP request:

Version is not supported

The first error 10006 is a PayPal error basically saying what the
following line says.  Version not supported means that I need to set the
version in the Request, but I can't see where to set that in the files
that wsdl2ruby.rb created.  Here is the script I am trying to
run(basically a customer trying to purchase something using the Direct
Payment API method).

The credit card number is fake btw, i am just trying to sucessfully
connect at this point.  I have the correct username/passwords, i ommited
them in my example.

I have taken much of my methods from this howto, but the author uses a
different PayPal API method than I do, and when I run his script, I
cannot set the version either.

require 'http-access2'
require 'soap/wsdlDriver'
require 'soap/header/simplehandler'
require 'defaultDriver.rb'

class RequesterCredentialsHandler < SOAP::Header::SimpleHandler
   HeaderName ='urn:ebay:api:PayPalAPI',
   CredentialsName ='urn:ebay:apis:eBLBaseComponents', 'Credentials')
   UsernameName =, 'Username')
   PasswordName =, 'Password')
   SubjectName =, 'Subject')

   def initialize(username, password, subject)
     @username, @password, @subject = username, password, subject

   def on_simple_outbound
     {CredentialsName => {UsernameName => @username, PasswordName =>
       SubjectName => @subject}}


soap =

# load SSL/Key properties
soap.options['protocol.http.ssl_config.verify_mode'] =
soap.options['protocol.http.ssl_config.ca_file'] = 'api_cert_chain.crt'
soap.options['protocol.http.ssl_config.client_cert'] = 'cert'
soap.options['protocol.http.ssl_config.client_key'] = 'key'

soap.headerhandler <<'*username*','*password*','*email*')

soap.wiredump_dev = STDERR if $DEBUG

#setup the direct payment request
request =
dprequest =

request.DoDirectPaymentRequest = dprequest
#request.DoDirectPaymentRequest.Version = "2.0"

#set the payment action
dppay_action = PaymentActionCodeType::Sale

#lets set a new payer info object
dppayer_info =
dppayer_info.PayerName ='Wingritch', 'Bill')
dppayer_address =
dppayer_address.Street1 = "123 Sw Street Ave"
dppayer_address.CityName = "Portland"
dppayer_address.StateOrProvince = "OR"
dppayer_address.Country = "US"
dppayer_address.PostalCode = "97045"
dppayer_info.Address = dppayer_address

#lets get the credit card details setup to put in the payment request
dpcredit_card ="MasterCard")
dpcredit_card.CardOwner = dppayer_info

#create a payment details
dppayment_details =
ns = "urn:ebay:apis:eBLBaseComponents"
otqname =, "OrderTotal")
otele =, "50")
otele.extraattr["currencyID"] = "USD"
dppayment_details.OrderTotal = otele

ip_address = ""

#now lets set all the information in the request for sending
dprequest.PaymentAction = dppay_action
dprequest.CreditCard = dpcredit_card
dprequest.PaymentDetails = dppayment_details
dprequest.IPAddress = ip_address
dprequest.MerchantSessionId = "merchant_session_id"

puts "request"
dp_response =  soap.doDirectPayment(request)
puts "response"
puts dp_response.errors.severityCode
puts dp_response.errors.errorCode
puts dp_response.errors.longMessage
puts dp_response.errors.shortMessage
19f65b7dca6831edf989224b5ebd3fe0?d=identicon&s=25 unknown (Guest)
on 2006-01-17 07:14
(Received via mailing list)
On Tuesday 17 January 2006 06:29 am, Jonathan Dodson wrote:
> I am having issues with PayPal's SOAP API layer.  I am using Ruby 1.8.3
> in Ubuntu Breezy.

Note: You are not using ruby 1.8.3, you are using a cvs version from
06-23-2005. 1.8.2 basically with some patches.

I recommend downloading the latest ruby and installing to a private
I use stock packages, but sometimes it just doesn't work well.

This topic is locked and can not be replied to.