I'm trying to intigrate First data Payment Getway in my site
Config file for FirstData Payment Gateway
define("FDAPI_URL","https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl");
define("FD_USERPWD","WSXXXXXXXX._.1:XXXXXXXX");
define("FD_SSLCERT", "/home/flagcases/domains/usaflagcases.com/public_html/certificate/WSXXXXXXXX._.1.pem");
define("FD_SSLKEY","/home/flagcases/domains/usaflagcases.com/public_html/certificate/WSXXXXXXXX._.1.key");
define("FD_SSLKEYPASSWD", "ckp_XXXXXXXX");
$ch = curl_init(FDAPI_URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, FD_USERPWD);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLCERT, FD_SSLCERT);
curl_setopt($ch, CURLOPT_SSLKEY, FD_SSLKEY);
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, FD_SSLKEYPASSWD);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
if ($result === false)
{
echo curl_error($ch);
}
Alway I got Curl Error
unable to use client certificate (no key found or wrong pass phrase?) Curl Error
Please try to add WSXXXXXXXX..1.p12 might be help you... Where you added WSXXXXXXXX..1.pem and WSXXXXXXXX._.1.key
Related
I am trying to implement paypal refund using php curl.
This is my code.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.paypal.com/v1/oauth2/token");
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Accept-Language: en_US'
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
$result = curl_exec($ch);
$json = json_decode($result);
$access_token=$json->access_token;
curl_close($ch);
$ch=curl_init();
$headers=array('Content-Type: application/json','Authorization: Bearer '.$access_token);
curl_setopt($ch,CRULOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_URL, "https://api.paypal.com/v1/payments/sale/".$paypal_transaction_id."/refund");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{}");
$result = curl_exec($ch);
$result_array=json_decode($result,true);
I got the access token successfully.
But, the following error occurs in refund.
"Authentication failed due to invalid authentication credentials or a
missing Authorization header."
What's wrong with my code?
Or
My PayPal account is a business account and there is no problem with receiving money (using php paypal api).
Look at https://developer.paypal.com/docs/platforms/get-started/ it says you need to fill out the PayPal Marketplaces and Platforms form to be approved.
Is this the problem?
Haha, I found the error.
It's just spell error.(curl_setopt($ch,CRULOPT_HTTPHEADER,$headers);)
not CRULOPT_HTTPHEADER , is CURLOPT_HTTPHEADER
and I have change code more simply.(using API v2)
$ch=curl_init();
$headers=array('Content-Type: application/json','Authorization: Basic '.base64_encode($clientId.':'.$secret));
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
$refund_url="https://api.paypal.com/v2/payments/captures/".$order['paypal_txn_id']."/refund";
curl_setopt($ch, CURLOPT_URL, $refund_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{}");
$result = curl_exec($ch);
$result_array=json_decode($result,true);
curl_close($ch);
We set up a PayPal express checkout about 2 weeks ago which worked perfectly until a couple of days ago it didn't.
On PayPal the transactions is ok but when I try to log in with cURL to check the transaction the inital merchant/client login fails but cURL shows no error.
I know that PayPal is upgrading to TLS 1.2 and HTTP/1.1 but I did the test check were our server/site passed.
This is how I initated the communication with paypal (this worked until now):
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://paypal.com/v1/oauth2/token');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'CLIENT_ID:SECRET');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
$result = curl_exec($ch);
Now if I print out $result its empty, if I print out curl_errno its 0 and curl_error also empty
so because of TLS 1.2 I modified the code like this
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://paypal.com/v1/oauth2/token');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'CLIENT_ID:SECRET');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
$result = curl_exec($ch);
but it fails exactly the same as the previous code.
What could be the problem?
or is it possible that if the login is ok the result is empty?
I integrating Paypal adaptive payment for my site.Itz works perfect in local.but when I tried it in live server it shows me an error.I came to know that the error is due to the curl SSL Connect error.
Can anyone help me with this?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiUrl.$call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
return json_decode(curl_exec($ch), TRUE);
print_r( json_decode(curl_exec($ch), TRUE) );
echo '<pre>';print_r( curl_getinfo($ch) ); echo '</pre>'; echo '<br>';
Try to make ssl verifier false like below. It might help you.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
EDIT
curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);
I am using curl library to get the XML but getting error of connection with host. Following is my code, I have just removed the credentials.
$url="https://interface.callport.net:8080/P-RVWR-drcm01-cti/call/2142100570";
$curl_post_data = array(
"query_type" => 'caller_info',
"dnis" => '8883874944',
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, base64_encode('webapi#fastfix:color43t'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post_data);
$result = curl_exec($ch);
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo $result;
}
curl_close($ch);
It's SSL so this usually fixes the problem. cURL does not verify the certificate then.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
[edit] I solved the problems. First the SSL as described above, then I removed the base64 encoding of the username and password, changed so the data is sent by GET instead of POST and lastly fixed the headers.
$url="https://interface.callport.net:8080/P-RVWR-drcm01-cti/call/2142100570?query_type=caller_info&dnis=8883874944";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'webapi#fastfix:color43t');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
I am integrating with FirstData wsdl. following the First Data Global Gateway
Web Service API
Integration Guide
. $kslocation is path to .key file. $kslocation is the path to .pem file and all these paths are valid.
$ch = curl_init($wsdl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$userid:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLCERT, $pemlocation);
curl_setopt($ch, CURLOPT_SSLKEY, $kslocation);
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $keyname);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
echo curl_error($ch)."\n";
curl_close($ch);
is giving me error.
SSL read: error:1409441B:SSL routines:SSL3_READ_BYTES:tlsv1
alert decrypt error, errno 0
The problem was I was using the test account url. I changed it to the live url and it worked.