Re: hToken validation failed on Helloworld

roywang
New Contributor

hToken validation failed on Helloworld

hi, 
i cannot get a 200 response on hellow world. please help me.Thinks

this response is:
{"responseStatus":{"status":401,"code":"9159","severity":"ERROR","message":"Token Validation Failed","info":""}}

 

public static void main(String[] args) throws Exception {

    // THIS IS EXAMPLE ONLY how will apiKey and password look like
    // apiKey = "1WM2TT4IHPXC8DQ5I3CH21n1rEBGK-Eyv_oLdzE2VZpDqRn_U";
    // sharedSecret = "19JRVdej9";
    String apiKey = "QOUJBTIX657HYIY2ORN5216Q7wlByIREz2h2Yzhq86TnQ2Axk";
    String sharedSecret = "/AGLtAK2LG9L-EqF}-Vv0LqL}13OUPq{VksIa$it";
    String queryString = "apiKey=" + apiKey;

    String resourcePath = "v3/payouts";
    String requestBody = "{\n" +
            "  \"recipientDetail\": {\n" +
            "    \"lastName\": \"smith\",\n" +
            "    \"firstName\": \"Jessica\",\n" +
            "    \"bank\": {\n" +
            "      \"bankCode\": \"800554\",\n" +
            "      \"bankCodeType\": \"SORT_CODE\",\n" +
            "      \"accountNumberType\": \"DEFAULT\",\n" +
            "      \"accountName\": \"Money Market\",\n" +
            "      \"countryCode\": \"GBR\",\n" +
            "      \"bankName\": \"Barclays\",\n" +
            "      \"accountNumber\": \"6970093\",\n" +
            "      \"currencyCode\": \"GBP\"\n" +
            "    },\n" +
            "    \"address\": {\n" +
            "      \"country\": \"GBR\",\n" +
            "      \"city\": \"London\",\n" +
            "      \"postalCode\": \"675456\",\n" +
            "      \"addressLine1\": \"123 Main St\",\n" +
            "      \"state\": \"CF\"\n" +
            "    },\n" +
            "    \"type\": \"I\"\n" +
            "  },\n" +
            "  \"senderDetail\": {\n" +
            "    \"address\": {\n" +
            "      \"country\": \"USA\",\n" +
            "      \"city\": \"Washington\",\n" +
            "      \"addressLine1\": \"addressline1\"\n" +
            "    },\n" +
            "    \"name\": \"Ben\",\n" +
            "    \"type\": \"C\",\n" +
            "    \"senderAccountNumber\": \"senderAccountNumber\"\n" +
            "  },\n" +
            "  \"payoutMethod\": \"B\",\n" +
            "  \"transactionDetail\": {\n" +
            "    \"initiatingPartyId\": 1002,\n" +
            "    \"businessApplicationId\": \"FD\",\n" +
            "    \"statementNarrative\": \"advancepayment\",\n" +
            "    \"transactionAmount\": 1.5,\n" +
            "    \"transactionCurrencyCode\": \"GBP\",\n" +
            "    \"settlementCurrencyCode\": \"GBP\",\n" +
            "    \"clientReferenceId\": \"888852397088\",\n" +
            "    \"senderSourceOfFunds\": \"01\"\n" +
            "  }\n" +
            "}";

    System.out.println("START Sample Code for Api Key-Shared Secret (X-Pay-Token)");
    URL url = new URL("https://sandbox.api.visa.com/visapayouts/v3/payouts?"  + queryString);

    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/json");
    con.setRequestProperty("Accept", "application/json");

    String xPayToken = generateXpaytoken(resourcePath, queryString, requestBody, sharedSecret);
    con.setRequestProperty("x-pay-token", xPayToken);

    int status = con.getResponseCode();
    System.out.println("Http Status: " + status);

    BufferedReader in;
    if (status == 200) {
        in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    } else {
        in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
        System.out.println("Api Key-Shared Secret (X-Pay-Token) test failed");
    }
    String response;
    StringBuffer content = new StringBuffer();
    while ((response = in.readLine()) != null) {
        content.append(response);
    }
    in.close();
    con.disconnect();

    System.out.println(content.toString());
    System.out.println("END Sample Code for Api Key-Shared Secret (X-Pay-Token)");
}

 

 
5 REPLIES 5
SyedSa
Community Moderator

Re: hToken validation failed on Helloworld

Hi @roywangThank you for reaching out. One of our agents will get back to you soon. Until then, if any community members know a solution, please feel free to reply to this thread.

roywang
New Contributor

Re: hToken validation failed on Helloworld

I have resolved the previous issue, but I have encountered a new problem. When interacting with the https://sandbox.api.visa.com/visapayouts/v3/payouts API, the response returned is {"status":"BAD_REQUEST","code":"NPPS012","message":"Bad request"}. Please help me.

1.Request Header
x-pay-token: xv2:1711362460:bb16f1eba46b3106cabb00e1bbe63e47e92df1302c4c9bb83e1a56633952a1d6
keyId: 517db977-904b-42b5-8f17-c4ecad131836
Content-Type: application/json
User-Agent: PostmanRuntime/7.37.0
Accept: */*
Postman-Token: e832e530-2190-471b-8871-20bf5a4d7b90
Host: sandbox.api.visa.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 2010

2.Request Body (unencrypted)
{
"transactionDetail": {
"status": "PAYMENT_SENT",
"payoutId": "5003f6a0-2c44-11b2-aa57-47378ae53313_1",
"endToEndId": "5003f6a02c4411b2aa5747378ae5331",
"payoutSpeed": "standard",
"returnAmount": 12.34,
"fundingStatus": "FUNDED",
"serviceDetail": {
"traceable": true,
"recallable": true,
"paymentRail": "ACH"
},
"returnDateTime": "2019-08-24T14:15:22Z",
"returnPayoutId": "5003f6a0-2c44-11b2-aa57-47378ae53313_1",
"fxConversionRate": 0.07,
"settlementAmount": 12.34,
"clientReferenceId": "string",
"destinationAmount": 12.34,
"initiatingPartyId": 100111,
"transactionAmount": 12.34,
"returnCurrencyCode": "USD",
"returnSourceAmount": 12.34,
"expectedPostingDate": "1980-02-01",
"returnReasonDetails": {
"code": "RE101",
"description": "string"
},
"transactionDateTime": "2019-08-24T14:15:22Z",
"returnConversionRate": 0.07,
"settlementCurrencyCode": "USD",
"destinationCurrencyCode": "USD",
"transactionCurrencyCode": "USD",
"returnSourceCurrencyCode": "USD"
}
}

3. Response Header (include the x-correlation-id)
Server: nginx
Date: Mon, 25 Mar 2024 10:28:46 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 65
Connection: keep-alive
X-SERVED-BY: b47978c55q8
X-CORRELATION-ID: 1711362526_449_190813240_b47978c55q8_VDP_WS
X-APP-STATUS: 400
X-ERROR-ORIGIN: 9300
Cache-Control: no-cache, no-store, must-revalidate
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000;includeSubdomains
Pragma: no-cache
Expires: -1

4. Response Body (unencrypted)
{"status":"BAD_REQUEST","code":"NPPS012","message":"Bad request"}




API_Products
Visa Developer Support Specialist

Re: hToken validation failed on Helloworld

Hi @roywang,

 

Below is a working sample for the Visa Direct Payout API. Please replace **** with 1312 in the accountNumber field.

End Point https://sandbox.api.visa.com/visapayouts/v2/payouts
Method POST
Request
{
"recipientDetail": {
"firstName": "Sam",
"lastName": "Smith",
"cityOfBirth": "Delhi",
"bank": {
"branchCode": "202212",
"bankCode": "9874",
"bankCodeType": "DEFAULT",
"accountNumberType": "DEFAULT",
"accountName": "Money Market",
"countryCode": "356",
"accountType": "1",
"bankName": "Berlin Bank",
"accountNumber": "2031242****",
"currencyCode": "356"
},
"address": {
"country": "356",
"city": "Delhi",
"postalCode": "401301",
"addressLine1": "address Line 1",
"addressLine2": "address Line 2",
"state": "765"
},
"countryOfBirth": "356",
"contactEmail": abc@visa.com,
"contactNumber": "123456789",
"dateOfBirth": "1989-01-01",
"type": "I",
"payoutMethod": "B"
},
"senderDetail": {
"senderReferenceNumber": "2628176127",
"cityOfBirth": "Delhi",
"address": {
"country": "356",
"city": "Delhi",
"postalCode": "26281",
"addressLine1": "address line1",
"addressLine2": "address line2",
"state": "Delhi"
},
"countryOfBirth": "356",
"contactEmail": abc@visa.com,
"name": "John Smith",
"contactNumber": "123456789",
"beneficiaryRelationship": "partner",
"dateOfBirth": "1989-01-01",
"sourceOfFunds": "01",
"type": "C",
"sourceOfIncome": "business"
},
"originatorDetail": {
"paymentFacilitator": {
"country": "840",
"name": "ABC Corp",
"id": "123476876"
},
"originatorName": "Visa Inc. GER",
"bankId": "408999",
"address": {
"country": "356",
"postalCode": "94404",
"state": "CA",
"addressLine": "Street 1"
},
"originatorBIC": "CTBAAU2S",
"merchantCategoryCode": "6012",
"bankBIC": "CTBAAU2S",
"originatorId": "CAIDCode77765"
},
"transactionDetail": {
"systemTraceAuditNumber": "198333",
"localTransactionDateTime": "2021-12-14T01:09:58",
"businessApplicationId": "FD",
"statementNarrative": "Advance payment",
"transactionAmount": "1000",
"purposeOfPayment": "ANN",
"transactionCurrencyCode": "840",
"additionalData": [
{
"name": "Name1",
"value": "Value1"
},
{
"name": "Name2",
"value": "Value2"
}
],
"retrievalReferenceNumber": "134820403397",
"clientReferenceId": "1aehjh33-2114wd-333s",
"endToEndId": "34214235345",
"payoutSpeed": "standard"
}
}

Response
{
"_links": {"self": {
"href": "visapayouts/v2/payouts",
"type": "POST"
}},
"originatorDetail": {
"bankId": "408999",
"originatorId": "CAIDCode77765"
},
"transactionDetail": {
"systemTraceAuditNumber": "198333",
"transactionIdentifier": "793836168195902",
"retrievalReferenceNumber": "134820403397",
"endToEndId": "34214235345",
"payoutId": "49ace9c0-2cbb-11b2-67e3-fd16a805ef10_1",
"clientReferenceId": "1aehjh33-2114wd-333s",
"originalResponseCode": "00",
"payoutSpeed": "STANDARD",
"responseCode": "94",
"settlement": {
"amount": 1000,
"currencyCode": "840"
},
"transmissionDateTime": "2021-12-14T11:05:00.000Z",
"destinationCurrencyCode": "840",
"expectedPostingDate": "2020-05-22",
"transactionAmount": 1000,
"transactionCurrencyCode": "840",
"destinationAmount": 1000
}
}

Response Header
Status Code: 200 OK
Server : nginx
Date : Tue, 14 Dec 2021 16:18:54 GMT
Content-Type : application/json;charset=UTF-8
Content-Length : 1491
Connection : keep-alive
X-SERVED-BY : l55c014
X-CORRELATION-ID : 1639498734_232_1306012451_l55c014_VDP_WS
X-APP-STATUS : 200
encrypted : true
Content-Language : en-US
Cache-Control : no-cache, no-store, must-revalidate
X-Frame-Options : SAMEORIGIN
X-XSS-Protection : 1; mode=block
X-Content-Type-Options : nosniff
Pragma : no-cache
Expires : -1
X-XSS-Protection : 1; mode=block
X-Content-Type-Options : nosniff
Strict-Transport-Security : max-age=31536000;includeSubdomains;always




Thanks,

Tee



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

roywang
New Contributor

Re: hToken validation failed on Helloworld

Hello, I have encountered similar problems with other interfaces as well. I am in the sandbox environment. Since there are no test data available on the webpage, I directly used the data examples from your interface documentation. However, the interfaces all return {"status":"BAD_REQUEST","code":"NPPS012","message":"Bad request"}. Do you have any test data available in the sandbox for Direct Account and Wallet related interfaces, or an out-of-the-box SDK? Please help me, this interface has really frustrated me. My data: apiKey EQMI25NOJX7VF1A038VL219k8GbCNsf9oR5MsOZYrf4i6U94Y SharedSecret: pweKkprRos60XmrZx-gqCfSnNV+jn2Y{-XEa4xnz Translate the above text into English.

 

0.url
https://sandbox.api.visa.com/visapayouts/v3/payouts?apiKey=EQMI25NOJX7VF1A038VL219k8GbCNsf9oR5MsOZYrf4i6U94Y

1.Request Header
x-pay-token: xv2:1711504228:c9decd5df126289a04ceeb7379b1f7570beffe93c8d65eb8639b60910fe3f5b0
keyId: 8deefc22-05d6-48b0-810c-b3a04228a226
Content-Type: application/json
User-Agent: PostmanRuntime/7.37.0
Accept: */*
Postman-Token: e5c50899-940e-4eb6-bfb5-e26981c0d495
Host: sandbox.api.visa.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 2004

2.Request Body (unencrypted)
{
  "recipientDetail": {
    "lastName": "smith",
    "firstName": "Jessica",
    "bank": {
      "bankCode": "800554",
      "bankCodeType": "SORT_CODE",
      "accountNumberType": "DEFAULT",
      "accountName": "Money Market",
      "countryCode": "GBR",
      "bankName": "Barclays",
      "accountNumber": "6970093",
      "currencyCode": "GBP"
    },
    "address": {
      "country": "GBR",
      "city": "London",
      "postalCode": "675456",
      "addressLine1": "123 Main St",
      "state": "CF"
    },
    "type": "I"
  },
  "senderDetail": {
    "address": {
      "country": "USA",
      "city": "Washington",
      "addressLine1": "addressline1"
    },
    "name": "Ben",
    "type": "C",
    "senderAccountNumber": "senderAccountNumber"
  },
  "payoutMethod": "B",
  "transactionDetail": {
    "initiatingPartyId": 1002,
    "businessApplicationId": "FD",
    "statementNarrative": "advancepayment",
    "transactionAmount": 1.5,
    "transactionCurrencyCode": "GBP",
    "settlementCurrencyCode": "GBP",
    "clientReferenceId": "888852397088",
    "senderSourceOfFunds": "01"
  }
}

3. Response Header (include the x-correlation-id)

Server: nginx
Date: Wed, 27 Mar 2024 01:51:26 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 65
Connection: keep-alive
X-SERVED-BY: b47978c55-2b
X-CORRELATION-ID: 1711504285_961_127297332_b47978c55-2b_VDP_WS
X-APP-STATUS: 400
X-ERROR-ORIGIN: 9300
Cache-Control: no-cache, no-store, must-revalidate
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000;includeSubdomains
Pragma: no-cache
Expires: -1

4. Response Body (unencrypted)
{
    "status": "BAD_REQUEST",
    "code": "NPPS012",
    "message": "Bad request"
}

 

 

 

 

 

 

API_Products
Visa Developer Support Specialist

Re: hToken validation failed on Helloworld

Hi @roywang,

 

Regarding test data, we only have what's available on the portal. 




Thanks,

Tee



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