NICEPAY API
API SNAP BI
SNAP API Testing
6 min
swagger for snap api testing api testing proceeds to testing several payment method using api snap before setup on the system several api snap available for swagger testing format such as true false 196,243false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type false unhandled content type snap api testing guidance the following is the steps to proceed with the snap api testing generate access token that will be used on authorization part fill in the available header parameter and body parameter form press the try it button to send the request parameter and get response parameter response parameter could be seen on the bottom right side of the display x signature guidance asymmetric x signature asymmetric uses to request access token header this token has the following term sha256withrsa (private key, stringtosign) stringtosign = client id + “|” + x timestamp symmetric x signature symmetric uses as header to request parameter on every api sent to the nicepay system following is the sample steps to generate x signature construct encoderequestbody using payload, hexencode dan sha256 lowercase(hexencode(sha256(minify(requestbody)))) construct payload signature concat at field using " " separator httpmethod\ endpointurl\ accesstoken\ encoderequestbody\ timestamp 1\ sample url post /apiservice/snp/balance/v1 0/balanceinquiry\ xuuiu8trx095hprev3tzqtqbks2sxe0c5gtpgx3nawz1zomfztsfyw 72f1819b4d501755ff9 b16c6762a9181d93b95cd728fd12c546fe6f55c77a73e 2022 06 14t22 30 15+07 00; 2 sample generate sample generate hmac sha512 for payload string payload="{\n \\"partnerreferenceno\\" \\"20220321 bal 002\\",\n \\"accountno\\" \\"701075323\\",\n \\"balancetypes\\" \[\n \\"balance\\"\n ]\n}"; string requestbody = ""; string hexencode = ""; requestbody = payload replaceall("\[\n\r\t]", "") hexencode=java security messagedigest getinstance("sha256") digest(requestbody getbytes("utf 8")) encodehex() hexencode = 'd13a7de69cd481a2e45d9d82d0c920ea7ede4d7547b5b115922c55ff3c0da285' string stringtosign = "post" + " " + "/apiservice/snp/balance/v1 0/balanceinquiry" + " " + "xuuiu8trx095hprev3tzqtqbks2sxe0c5gtpgx3nawz1zomfztsfyw" + " " + hexencode + " " + "2022 06 14t22 22 31+07 00" 3 sample create hash sample create hash secretkeyspec secretkey = new secretkeyspec(clientsecret getbytes(),"hmacsha512"); mac hmac = mac getinstance("hmacsha512") hmac init(secretkey) 4 sample signature base64 base64 encoder = base64 getencoder() string hmacasbase64 = encoder encodetostring(hmac dofinal(string2hash getbytes("utf 8"))) 5 sample result the result are x signature myyscwbs00bm0tjq/xy7uu1goh8qxjyyslo88rfrhq+mlyqkmtq nkmlzdps+