Re: Curl error: unable to set private key file: 'C:.....privateKey.pem' type PEM

Solved! Go to solution
fordiego44
Helper

Curl error: unable to set private key file: 'C:.....privateKey.pem' type PEM

Hi I am from Peru.

I have this error When I run the api "funds_transfer_api" in my local with XAMPP, using its files in PHP :

---------------------------------------------------------

Curl error: unable to set private key file: 'C:\xampp7\htdocs\PROYECTOS_2020\diego_visadirect\visa_direct\funds_transfer_api\privateKey.pem' type PEM

---------------------------------------------------------

I follow the tutorial in his page and I generate the "privateKey.pem" and I get the "cert.pem", and in his manual in PHP  I set this certificates for use the API, but I get the error. 

I tryed use the function cURL how show the page of PHP, and I get the same error. This is the code :

 

<?php
    
    $tuCurl = curl_init();
    curl_setopt($tuCurl, CURLOPT_URL, "https://sandbox.api.visa.com/visadirect/fundstransfer/v1/pullfundstransactions/123");
    curl_setopt($tuCurl, CURLOPT_PORT , 443);
    curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
    curl_setopt($tuCurl, CURLOPT_HEADER, 0);
    curl_setopt($tuCurl, CURLOPT_SSLCERT, realpath("cert.pem"));
    curl_setopt($tuCurl, CURLOPT_SSLKEY, realpath("privateKey.pem"));
    curl_setopt($tuCurl, CURLOPT_POST, 0);
    curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Content-Type:  application/json,application/octet-stream"));

    $tuData = curl_exec($tuCurl);
    if(!curl_errno($tuCurl)){
      $info = curl_getinfo($tuCurl);
      echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
    } else {
      echo 'Curl error: ' . curl_error($tuCurl);
    }

    curl_close($tuCurl);
    echo $tuData;
?>

  

4 REPLIES 4
fordiego44
Helper

Re: Curl error: unable to set private key file: 'C:.....privateKey.pem' type PEM

I fixed my problem, when a create my own private.key to create my cert.pem don´t work but When I generate automatically with the page of visa (the private key) its work. and Also work when i do method GET . 

When I do POST. I copy the sample parameters that show visa developer, but show an error 

-------------------------

string(141) "{"responseStatus":{"code":"9501","severity":"ERROR","message":"Invalid input found, please correct the input data","info":"","status":"400"}}"

------------------------- 

I think that I should change the structure the sample parametres of visa: 

 

 

curl_setopt($tuCurl, CURLOPT_POSTFIELDS, json_encode("{
                    'acquirerCountryCode': '840',
                    'acquiringBin': '408999',
                    'amount': '124.02',
                    'businessApplicationId': 'AA',
                    'cardAcceptor': {
                    'address': {
                    'country': 'USA',
                    'county': '081',
                    'state': 'CA',
                    'zipCode': '94404'
                    },
                    'idCode': 'ABCD1234ABCD123',
                    'name': 'Visa Inc. USA-Foster City',
                    'terminalId': 'ABCD1234'
                    },
                    'foreignExchangeFeeTransaction': '11.99',
                    'localTransactionDateTime': '2020-07-15T02:46:25',
                    'retrievalReferenceNumber': '330000550000',
                    'senderCardExpiryDate': '2015-10',
                    'senderCurrencyCode': 'USD',
                    'senderPrimaryAccountNumber': '4895142232120006',
                    'systemsTraceAuditNumber': '451001',
                    'addressVerificationData': {
                    'street': 'XYZ St',
                    'postalCode': '12345'
                    }
                    }"));

 

SLi
Visa Developer Support Specialist
Visa Developer Support Specialist

Re: Curl error: unable to set private key file: 'C:.....privateKey.pem' type PEM

Hi @fordiego44,

 

Great to hear that you have fixed your private key issue.

 

I tried the parameters that you were using and copied it to my testing tool and I was able to get a response successfully. Here's my post request and response:

 

End Point https://sandbox.api.visa.com/visadirect/fundstransfer/v1/pullfundstransactions
Method POST
Request
{
"amount": "124.02",
"localTransactionDateTime": "2020-07-15T02:46:25",
"cardAcceptor": {
"address": {
"country": "USA",
"zipCode": "94404",
"county": "081",
"state": "CA"
},
"idCode": "ABCD1234ABCD123",
"name": "Visa Inc. USA-Foster City",
"terminalId": "ABCD1234"
},
"acquirerCountryCode": "840",
"acquiringBin": "408999",
"retrievalReferenceNumber": "330000550000",
"senderCurrencyCode": "USD",
"addressVerificationData": {
"street": "XYZ St",
"postalCode": "12345"
},
"systemsTraceAuditNumber": "451001",
"businessApplicationId": "AA",
"senderPrimaryAccountNumber": "4895142232120006",
"foreignExchangeFeeTransaction": "11.99",
"senderCardExpiryDate": "2015-10"
}


Response
{
"transmissionDateTime": "2020-07-15T18:33:28.000Z",
"approvalCode": "98765X",
"cpsAuthorizationCharacteristicsIndicator": "3333",
"transactionIdentifier": 623422177635620,
"actionCode": "00",
"responseCode": "5"
}


Response Header
Status Code: 200 OK
Server : nginx
Date : Wed, 15 Jul 2020 18:33:28 GMT
Content-Type : application/json;charset=UTF-8
Content-Length : 202
Connection : keep-alive
X-SERVED-BY : l55c014
X-CORRELATION-ID : 1594838008_500_923262086_l55c014_VDP_WS
X-APP-STATUS : 200
X-APP-STATUS : 200
X-Backside-Transport : OK OK,OK OK
X-Global-Transaction-ID : 1adcbd165f0f4bf8f2d78181
X-Frame-Options : SAMEORIGIN
X-XSS-Protection : 1; mode=block
X-Content-Type-Options : nosniff
Strict-Transport-Security : max-age=2592000;includeSubdomains
Cache-Control : no-cache, no-store, must-revalidate
Pragma : no-cache
Expires : -1
Content-Language : en-US

 

I was using the VDC Playground tool to test. It can be downloaded from your project asset page. Details can be found here: https://community.developer.visa.com/t5/Developer-Tools/How-to-test-and-troubleshoot-APIs-with-the-V...


Best,
Stacey

Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.
fordiego44
Helper

Re: Curl error: unable to set private key file: 'C:.....privateKey.pem' type PEM

Thanks ! , I had to convert the structure JSON in structure array associative  and create a variable for save it. And I get  the response.
Have Visa Direct  a commision ? and if is it true, how many is the commission ?   I need to transference of my count to diferents cards count.

SLi
Visa Developer Support Specialist
Visa Developer Support Specialist

Re: Curl error: unable to set private key file: 'C:.....privateKey.pem' type PEM

Excellent!

There is no cost to you to use Visa Direct APIs in the sandbox. When you are ready to transition to production use of the Visa Direct APIs, there are fees for each of the APIs that are used. Fees are evaluated by application,  as they are a function of many elements, including the nature of your application and your relationship with any existing Visa partner(s).  We treat production applications on a case-by-case basis and work with you to determine appropriate pricing.  Please navigate to the below link for additional information on Visa Developer pricing.

https://developer.visa.com/pages/working-with-visa-apis/visa-developer-pricing

 

Currently, only Visa accounts can receive push payments from Visa Direct. Please navigate to the below link for information on what account types can receive Visa Direct payments/transfers.

https://developer.visa.com/capabilities/visa_direct/docs-getting-started#section0

 

 

 

 

 


Best,
Stacey

Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.