2

I have a Visa Payment Gateway example in PHP:

$authString = $userId.":".$password;
$authStringBytes = utf8_encode($authString);
$authloginString = base64_encode($authStringBytes);
$authHeader = "Authorization:Basic ".$authloginString;
echo "<strong>URL:</strong><br>".$url. "<br><br>";
$header = (array("Accept: application/json", "Content-Type: application/json", $authHeader));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBodyString); 
curl_setopt($ch, CURLOPT_SSLCERT, $certificatePath);
curl_setopt($ch, CURLOPT_SSLKEY, $privateKey);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

I am trying to convert the PHP code to ColdFusion. How can I pass the CURLOPT_SSLKEY option via cfhttpparam? This is my code so far:

<cfhttp method="get" url="https://sandbox.api.visa.com/vdp/helloworld" 
        clientcert="C:\ColdFusion10\cfusion\wwwroot\visa\myapp_keyAndCertBundle.p12"
        clientcertpassword="theCertPassword" 
        result="res">

    <cfhttpparam type="header" name="Accept" value="application/json">
    <cfhttpparam type="header" name="Content-Type" value="application/json" />  
    <cfhttpparam type="body" value="Authorization:Basic#authloginString#">
</cfhttp>

cfhttp result output: enter image description here

cfprabhu
  • 5,267
  • 2
  • 21
  • 30
  • What happens when you try the code above? Side note, for basic authentication you can use the `user` and `password` attributes. – Leigh Jul 02 '16 at 20:06
  • I want to pass the CURLOPT_SSLKEY on cf http. Because I passed the p12 certificate on cfhttp but how can I pass the private key? – cfprabhu Jul 02 '16 at 20:09
  • No option on cfhttp. Above code produce the error. – cfprabhu Jul 02 '16 at 20:10
  • Does not the .p12 file contain the private key? *I want to pass the CURLOPT_SSLKEY* I understand, but you did not answer my question: what is the result of the code above? If you are getting an error, please [edit the question](http://stackoverflow.com/posts/38162764/edit) to include the error message. – Leigh Jul 02 '16 at 20:13
  • 2
    BTW, you *really* should not have your client cert inside your web root. Put it someplace where it is not reachable. – Tomalak Jul 02 '16 at 20:27
  • How can I pass the private key on cfhttp? – cfprabhu Jul 02 '16 at 20:28
  • The error message is says it did not find the credentials. I noticed there is no space after "Basic" in the authorization header. May be related. Also, did you try passing the credentials the way I [suggested above](http://stackoverflow.com/questions/38162764/visa-payment-gateway-api-in-coldfusion#comment63756038_38162764). – Leigh Jul 03 '16 at 17:10
  • I tried but got same error message. – cfprabhu Jul 04 '16 at 06:14
  • Maybe the account is locked out? *"...If you enter an incorrect password several times, your account will be locked out."*. Try resetting your password and [verifying the credentials with Soap UI first](https://developer.visa.com/guides/vdpguide#sandbox_testing). – Leigh Jul 04 '16 at 13:49
  • No. If we pass the private key it will be working otherwise it is not working. – cfprabhu Jul 04 '16 at 14:20
  • Working *where*? SoapUI? If so, I am out of ideas. – Leigh Jul 05 '16 at 13:36
  • Yes. It is working on soapUI. – cfprabhu Jul 05 '16 at 13:38
  • Should the authorization parameter not be of type header, like: ? @Leigh's suggestion of using username and password attributes in the cfhttp tag itself should generate the same header (but I think it should be username not user?). – GumbyG Jul 29 '16 at 19:38

0 Answers0