I am trying to
PayPal is in their own little world when it comes to authenticating their
webservice users. When you sign up they provide you with a client
certificate. Their client SSL certificate is not like a normal certificate,
Its something they generate on their own without the use of a third party
certificate authority. When you hit their server via a browser
(https://api.sandbox.paypal.com/wsdl/PayPalSvc.wsdl) you have to manually
select the client certificate to use.
When I use cfinvoke:
webservice = "http://api.sandbox.paypal.com/wsdl/PayPalSvc.wsdl"
method = "TransactionSearchRequest"
argumentCollection="#starguments#"
username = "myusername"
password = "mypassword"
returnVariable="result"
>
I get this error:
Could not generate stub objects for web service invocation.
Name: https://api.sandbox.paypal.com/wsdl/PayPalSvc.wsdl. WSDL:
https://api.sandbox.paypal.com/wsdl/PayPalSvc.wsdl.
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
So I go back and forth trying everything under the sun to get coldfusion to
use the certificate. The most promising thing I found was an article that
told you how to install a certificate in the coldfuision http engine using a
keytool utility that comes with coldfusion but that didn't work either.
So I talk to paypal tech support some more and they make it so I can hit the
WSDL file without the ssl and then I get errors like this:
Web service operation "TransactionSearchRequest" with parameters
{STARTDATE={2004-07-12},} could not be found.
This happens because they don't format their WSDL in a way that is
compatible with coldfusions cfinvoke tag.
So then they send me a php example on how to bypass the WSDL by hard-coding
the SOAP envelope and sending it to their server:
// details.php
// A simple PHP example that access the transaction details of a PayPal
// transaction
// By Dave Burchell, PayPal Developer Technical Support, July 2004
// For more about the PayPal API, see http://developer.paypal.com/
// please provide the parameters below
$username = "";
$password = "";
$transid = "";
$sslcertpath = "";
$SOAPrequest = <<< End_Of_Quote
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
SOAP-ENV:mustUnderstand="1">
$username
$password
xsi:type="ns:GetTransactionDetailsRequestType">
1.0
$transid
End_Of_Quote;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.sandbox.paypal.com/2.0/");
curl_setopt($ch, CURLOPT_SSLCERT, $sslcertpath);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $SOAPrequest);
curl_exec ($ch);
if (curl_error($ch))
printf("Error %s: %s", curl_errno($ch), curl_error($ch));
curl_close ($ch);
?>
Of course I cant do this with cfhttp because there is not way for me to tell
CFHTTP which client certificate to use, Thus the move to
msxml2.ServerXMLHTTP.3.0, but I can't figure out how to use the setOption
function with coldfusion. I have used this object for other APIs int the
past but I have never had to specify a certificate.
Here is the microsoft documentation for the setOption method used in my code
below:
http://msdn.microsoft.com/library/default.asp?url="">
/xmmthsetoption.asp
Here is my code:
encoding=""UTF-8""?>
xmlns:xsi=""http://www.w3.org/1999/XMLSchema-instance""
xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/""
xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:xsd=""http://www.w3.org/1999/XMLSchema""
SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">
NV:Header>
SOAP-ENV:mustUnderstand=""1"">
xmlns=""urn:ebay:apis:eBLBaseComponents"">#username#
ssword>#password#<
/SOAP-ENV:Header>
xmlns=""urn:ebay:api:PayPalAPI"">
xsi:type=""ns:GetTransactionDetailsRequestType"">
xsi:type=""xsd:string"">1.0
xsi:type=""ebl:TransactionId"">#transactionID#
onDetailsRequest>
ope>">
action="">
name="objServerXMLHttp"
class="msxml2.ServerXMLHTTP.3.0">
objServerXMLHttp.setOption(3,"LOCAL_MACHINE\My\scotttest_api1.dealtree.com")
>
"https://api.sandbox.paypal.com/2.0/", False)>
I get this error:
An exception occurred when executing a Com method.
The cause of this exception was that: AutomationException: 0x80070057 - One
or more arguments are invalid.
The error occurred in H:\wwwroot\Process\PayPalAPI\test.cfm: line 39
37 : class="msxml2.ServerXMLHTTP.3.0">
38 :
39 :
objServerXMLHttp.setOption(3,"Local_Machine\My\scotttest_api1.dealtree.com")
>
40 :
41 :
SO, then I try using the WinHttp.WinHttpRequest.5.1
because the syntax for setting a client certificate seems a little easier:
http://msdn.microsoft.com/library/default.asp?url="">
p/winht