# Help with some PayPal SOAP code

**URL:** <https://www.ruby-forum.com/t/help-with-some-paypal-soap-code/52612>\
**Category:** Ruby\
**Created:** [January 17, 2006, 1:58am UTC](https://www.ruby-forum.com/t/help-with-some-paypal-soap-code/52612 "2006-01-17T01:58:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Dodson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@Jonathan\_Dodson](https://www.ruby-forum.com/u/Jonathan_Dodson)\
**Post date:** [January 17, 2006, 1:58am UTC](https://www.ruby-forum.com/t/help-with-some-paypal-soap-code/52612/1 "2006-01-17T01:58:05Z")

</div>

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:

10006  
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.

[http://wiki.rubyonrails.org/rails/pages/PayPalWebServices](http://wiki.rubyonrails.org/rails/pages/PayPalWebServices)

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

class RequesterCredentialsHandler \< SOAP::Header::SimpleHandler  
HeaderName = XSD::QName.new(‘urn:ebay:api:PayPalAPI’,  
‘RequesterCredentials’)  
CredentialsName =  
XSD::QName.new(‘urn:ebay:apis:eBLBaseComponents’, ‘Credentials’)  
UsernameName = XSD::QName.new(nil, ‘Username’)  
PasswordName = XSD::QName.new(nil, ‘Password’)  
SubjectName = XSD::QName.new(nil, ‘Subject’)

def initialize(username, password, subject)  
super(HeaderName)  
@username, @password, @subject = username, password, subject  
end

def on\_simple\_outbound  
{CredentialsName =\> {UsernameName =\> @username, PasswordName =\>  
@password,  
SubjectName =\> @subject}}  
end  
end

ENDPOINT\_URL = “[https://api.sandbox.paypal.com/2.0/](https://api.sandbox.paypal.com/2.0/)”

soap = PayPalAPIAAInterface.new(ENDPOINT\_URL)

# load SSL/Key properties

soap.options[‘protocol.http.ssl\_config.verify\_mode’] =  
OpenSSL::SSL::VERIFY\_PEER  
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 \<\<  
RequesterCredentialsHandler.new(‘_username_’,‘_password_’,‘_email_’)

soap.wiredump\_dev = STDERR if $DEBUG

#setup the direct payment request  
request = DoDirectPaymentReq.new  
dprequest = DoDirectPaymentRequestDetailsType.new

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 = PayerInfoType.new  
dppayer\_info.PayerName = PersonNameType.new(‘Wingritch’, ‘Bill’)  
dppayer\_address = AddressType.new  
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 = CreditCardDetailsType.new(“MasterCard”)  
dpcredit\_card.ExpYear=2010  
dpcredit\_card.ExpMonth=10  
dpcredit\_card.CreditCardNumber=“4276445055121314”  
dpcredit\_card.CardOwner = dppayer\_info

#create a payment details  
dppayment\_details = PaymentDetailsType.new  
ns = “urn:ebay:apis:eBLBaseComponents”  
otqname = XSD::QName.new(ns, “OrderTotal”)  
otele = SOAP::SOAPElement.new(otqname, “50”)  
otele.extraattr[“currencyID”] = “USD”  
dppayment\_details.OrderTotal = otele

ip\_address = “70.89.189.52”

#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

---

<div class="post-metadata">

**Author:** ![Jonathan\_Dodson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/858c86/32.png) [@Jonathan\_Dodson](https://www.ruby-forum.com/u/Jonathan_Dodson)\
**Post date:** [January 17, 2006, 7:14am UTC](https://www.ruby-forum.com/t/help-with-some-paypal-soap-code/52612/2 "2006-01-17T07:14:29Z")

</div>

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  
directory.  
I use stock packages, but sometimes it just doesn’t work well.

Tsume
