Authorization Credemtials on NodeJS

Solved! Go to solution
surfchicken
Regular Visitor

Authorization Credemtials on NodeJS

I am just getting started with the Visa Developer SDK's - using NodeJS.

I have downloaded the example code, and gone through the auth pages to generate the following files

private_key.pem - this is the private key geneated when project is created

project_cert.pem - downloaded from the credentials tab in the developer portal

I have gone through the instructions to create the p12 file from openssl.

I have downloaded Digicert Global Root CA Cert and named as DigiCertGlobalRootCA.crt

 

I have then updated the credentials.json in the demo files with following settings

{
"apiKey": "{put your api key here}", Using Merchant Search api - so not sure what to put here
"sharedSecret": "", Not sure what should be here ?
"userId": "MO61AD8WB3AJHWFXYUJO21cTErZRKsAy4avyQA2n5ANFrOQvg",
"password": "gxqDD45qCT3YX27XpV0J5LP6XV1pns5q2lq",
"cert": "./cert/project_cert.pem",
"key": "./cert/private_key.pem",
"ca": "./cert/DigiCertGlobalRootCA.crt"
}


When I run the test file node merchantSearch_test.js , I get error "UNABLE_TO_GET_ISSUER_CERT_LOCALLY".  I am not sure what I am missing here - great to get some feedback

 

I have added both the Visa Development Platform Cert, and the DigiCert Global Root CA Cert to my Mac Keychain

 

Regards

Dave

5 REPLIES 5
jvenkata
Community Moderator

Re: Authorization Credemtials on NodeJS

Hi Dave,

 

Your configuration settings look good except for the CA cert. CA Cert should be in .cer format for Node JS. 

 

You can convert the .crt to .cer by following the below steps.

 

  • Double-click on the DigiCertGlobalRootCA.crt file to open it into the certificate display.
  • Select the Details tab, then select the Copy to file button.
  • Hit Next on the Certificate Wizard.
  • Select Base-64 encoded X.509 (.CER), then Next.
  • Select Browse (to locate a destination) and type in the filename DigiCertGlobalRootCA.
  • Hit Save. You now have the file DigiCertGlobalRootCA.cer

Thanks,

Jai

surfchicken
Regular Visitor

Re: Authorization Credemtials on NodeJS

Thanks Jai - that worked great

fredzilla
Helper

Re: Authorization Credemtials on NodeJS

I had a similar question and I appreciate the help. Sadly, I'm receiving a 500 response from the MerchantSearchAPI using the same example:

Response: {"statusCode":500,"body":"<?xml version='1.0' ?>\n<env:Envelope xmlns:env='<a href="http://schemas.xmlsoap.org/soap/envelope/'>\n<env:Body>\n<env:Fault>\n<faultcode>env:Client</faultcode>\n<faultstring>Internal" target="_blank">http://schemas.xmlsoap.org/soap/envelope/'>\n<env:Body>\n<env:Fault>\n<faultcode>env:Client</faultcode>\n<faultstring>Internal</a> Error</faultstring>\n</env:Fault>\n</env:Body>\n</env:Envelope>\n","headers":{"server":"nginx","content-type":"text/xml","content-length":"232","x-served-by":"l55c016","x-correlation-id":"1560296432_301_2121642068_l55c016_VDP_WS","x-backside-transport":"FAIL FAIL,FAIL FAIL","x-global-transaction-id":"2113414721","x-app-status":"500","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","x-cnection":"close","date":"Tue, 11 Jun 2019 23:40:32 GMT","connection":"close"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"sandbox.api.visa.com","port":443,"hostname":"sandbox.api.visa.com","hash":null,"search":null,"query":null,"pathname":"/merchantsearch/v1/search","path":"/merchantsearch/v1/search","href":"<a href="https://sandbox.api.visa.com/merchantsearch/v1/search"},"method":"POST","headers":{"User-Agent":"VDP_SampleCode_Nodejs","Authorization":"Basic" target="_blank">https://sandbox.api.visa.com/merchantsearch/v1/search"},"method":"POST","headers":{"User-Agent":"VDP_SampleCode_Nodejs","Authorization":"Basic</a> xxxxxxxxx","x-correlation-id":"iUlSHPZQooHU_SC","x-client-transaction-id":"abc123","accept":"application/json","content-type":"application/json","content-length":433}}}
fredzilla
Helper

Re: Authorization Credemtials on NodeJS

Solved!
For some reason I'm getting a useful response now.
It's incorrect but usable.
I'm getting a 200 (success) but the body describes an error in my parameters:

"status": {
  "statusDescription": "Message DateTime required in UTC 2008-09-19T00:00:00.000 format",
  "statusCode": "CDI098"
}



Not very RESTy but better than 500.

fredzilla
Helper

Re: Authorization Credemtials on NodeJS

Once I get past the datetime error I now see this:

{
        "merchantSearchServiceResponse": {
            "header": {
                "startIndex": "0",
                "numRecordsMatched": 0,
                "numRecordsReturned": 0,
                "requestMessageId": "Request_002",
                "messageDateTime": "2019-06-12T17:23:51.987",
                "responseMessageId": "64VDP2350220190612172351986",
                "endIndex": "0"
            },
            "status": {
                "statusDescription": "Internal Application Error",
                "statusCode": "CDI120"
            }
        }
    }