NICEPAY API
...
API Virtual Account SNAP
Registration - API Virtual Account SNAP
12 min
about registration api virtual account snap this api with the snap standards uses to request registration before executing payment using the virtual account payment method if you want to see a general explanation of virtual account payment methods, you can visit docid\ ie9rxfmm gpysjakmrbvl for integration settings for fix open and nicepay inquiry virtual account features, you can visit the page docid\ cadfseimkqmertral3p4u virtual account length number specification as explained on the docid\ zf1ak3ppg5z1my1oevy7a , the length of the va number that can be created varies from each bank the length of the va can be determined according to business needs as long as the va number does not exceed the maximum length capacity that includes the nicepay and bank prefix the following is a table of requirements for va length number for some banks bank nicepay + bank prefix length max total va bca 8 23 bri 8 18 mandiri 8 19 maybank 8 16 bni 7 16 permata & syariah 7 16 cimb 7 19 danamon 7 16 hana 7 16 bjb 7 16 bnc 11 19 dki 9 16 note nicepay+bank prefix length is the number length requirement for nicepay and bank prefix numbers a case study if you as a merchant want to integrate mandiri bank va, then you are required to provide a space of 8 digits for the va prefix which consists of the nicepay and bank prefix later, the number after the prefix will be divided into 2 types according to the type of va you want to create fixed va you can customize the number after the va prefix number that nicepay refers to as the customer id or merfixacctid with a note that the number is no longer than the maximum 19 digits length for va numbers from bank mandiri normal va you cannot customize the number after the va prefix number because that number will be generated automatically and randomly by the system with a note that the number is no longer than the maximum 19 digits length for va numbers from bank mandiri the default length of va number is 16 digits unless there are a special schemes from banks, nicepay, and merchants although each bank may have different length of the va number, merchants are considered to be able to accommodate a va number lengths maximum of 30 digits in a row registration api virtual account snap please request the access token firsthand before doing the authentication through the docid 92feymrqs iebhxrfgxuq section service code 27 api endpoint /api/v1 0/transfer va/create va http method post description to request the va transaction process content type application/json request registration header parameter parameter type length required description example content type string mandatory application / json authorization string mandatory bearer “ access token ” x timestamp string mandatory using iso 8601 as timestamp format transaction date time, in format yyyymmddthh\ mm\ ss+07 00 time must be in gmt+7 (jakarta time) 2022 03 21t10 11 40+07 00 x signature string mandatory signature will be generated by merchant docid\ uzex33relyenkogbjjnyp x partner id string 20 mandatory x partner id = client id x external id string 40 mandatory unique reference number ( 41807553358950093184 ) channel id string mandatory unique channel merchant credential id number client id + "01" = channel id "ionpaytest" + "01" = "ionpaytest01" ionpaytest01 request registration body parameter for partnerserviceid and virtualaccountno parameters can send with an empty value parameter type length required description partnerserviceid string 20 mandatory partner service id / prefix customerno string 40 mandatory customer number (mandatory for fix type) virtualaccountno string 25 mandatory virtual account number virtualaccountname string 100 mandatory virtual account name trxid string 40 mandatory transaction id (reference number from merchant) totalamount object optional "totalamount" { } value string 12 mandatory transaction amount currency string 3 mandatory currency additionalinfo object optional "additionalinfo" { } bankcd string 4 mandatory docid 5pxu cbdxvy2biili8 cv goodsnm string 200 mandatory goods name dbprocessurl string mandatory notification url vacctvaliddt string 8 optional virtual account valid date vacctvalidtm string 6 optional virtual account valid time msid string 20 optional merchant seller id msfee string 7 optional merchant seller fee msfeetype string 2 optional merchant seller fee type mbfee string 7 optional merchant balance fee mbfeetype string 2 optional merchant balance fee type response registration parameter parameter type length required description responsecode string mandatory docid\ bjr4kjamzcknln 5zrnvw responsemessage string mandatory response message virtualaccountdata object mandatory "virtualaccountdata" { , "totalamount" { } } partnerserviceid string 20 conditional partner service id / prefix (mandatory for fix type) customerno string 40 mandatory customer number (mandatory for fix type) virtualaccountno string 25 mandatory virtual account number virtualaccountname string 100 mandatory virtual account name trxid string 40 mandatory from create va request (reference number from merchant) totalamount object optional "totalamount" { } value string 12 mandatory transaction amount currency string 3 mandatory currency additionalinfo object optional optional "additionalinfo" { } bankcd string 4 mandatory docid 5pxu cbdxvy2biili8 cv txidva string 30 mandatory transaction id of virtual account goodsnm string 200 mandatory goods name vacctvaliddt string 8 mandatory virtual account valid date vacctvalidtm string 6 mandatory virtual account valid time msid string 20 optional merchant seller id msfee string 7 optional merchant seller fee msfeetype string 2 optional merchant seller fee type mbfee string 7 optional merchant balance fee mbfeetype string 2 optional merchant balance fee type sample parameter for registration api virtual account snap request parameter curl curl x post "https //dev nicepay co id/nicepay/api/v1 0/transfer va/create va" \\ h "content type application/json" \\ h "authorization bearer eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8=" \\ h "x timestamp 2024 04 30t10 11 40+07 00" \\ h "x signature ufbw7r8rhw79ioiv/hlv607m60qzaybv8uzmbsryb6/thlo/fhqvp4xryeluehoss9o+qs6vwtkb/ygtucc+tq==" \\ h "x partner id ionpaytest" \\ h "x external id txid202410142300021707638093" \\ h "channel id ionpaytest" \\ d '{ "partnerserviceid" "", "customerno" "", "virtualaccountno" "", "virtualaccountname" "john doe", "trxid" "2022020100000000000001", "totalamount" { "value" "10000 00", "currency" "idr" }, "additionalinfo" { "bankcd" "bmri", "goodsnm" "john doe", "dbprocessurl" "https //testing co id/", "vacctvaliddt" "", "vacctvalidtm" "", "msid" "", "msfee" "", "msfeetype" "", "mbfee" "", "mbfeetype" "" } }' node js const config = { isproduction false, privatekey cons privatekey, clientsecret cons clientsecret, clientid cons clientid, iscloudserver false, }; const parameter = { body { partnerserviceid "", customerno "", virtualaccountno "", virtualaccountname "john doe", trxid "2022020100000000000001", totalamount { value "10000 00", currency "idr", }, additionalinfo { bankcd "bmri", goodsnm "john doe", dbprocessurl "https //testing co id/", vacctvaliddt "", vacctvalidtm "" }, }, headers { x external id "txid202410142300021707638093", channel id "ionpaytest", }, }; let snap = new snap(config); let endpoint = `/api/v1 0/transfer va/create va`; let response = snap requestsnaptransaction(parameter, endpoint, accesstoken, "post"); config = nicepay builder() isproduction(false) clientsecret(data client secret) partnerid(partner id) externalid(data external id) timestamp("2024 04 30t10 11 40+07 00") privatekey(data private key) build(); var accesstoken = optional ofnullable((nicepayresponse) gettoken()) map(nicepayresponse getaccesstoken) orelsethrow(() > new illegalargumentexception("token is null")); virtualaccount virtualaccount = virtualaccount builder() partnerserviceid("") customerno("") virtualaccountno("") virtualaccountname("john doe") trxid("2022020100000000000001") totalamount("10000 00","idr") additionalinfo(new hashmap\<string, object>() { { put("bankcd","bmri"); put("goodsnm", "john doe"); put("dbprocessurl", "https //testing co id/"); put("vacctvaliddt", ""); put("vacctvalidtm", ""); put("msid", ""); put("msfee", ""); put("msfeetype", ""); put("mbfee", ""); put("mbfeetype", ""); } }) build(); nicepayresponse response = snapvaservice callgeneratedva(virtualaccount, accesstoken, config); bodycreatetoken = ( builderaccesstoken buildaccesstoken() setgranttype("client credentials") setadditionalinfo("") build() ) totalamount = { "value" "10000 00", "currency" "idr" } additionalinfo = { "bankcd" "bmri", "goodsnm" "john doe", "dbprocessurl" "https //testing co id/", "vacctvaliddt" "", "vacctvalidtm" "", "msid" "", "msfee" "", "msfeetype" "", "mbfee" "", "mbfeetype" "" } bodycreateva = ( buildervirtualaccount buildcreateva() setpartnerserviceid("") setcustomerno("") setvirtualaccountno("") setvirtualaccountname("john doe") settrxid("2022020100000000000001") settotalamount(totalamount) setadditionalinfo(additionalinfo) build() ) environment = ( builderenvironment buildenvironment() iscloud(false) isproduction(false) build() ) result = snapservice servicetransaction( bodycreatetoken jsonaccesstoken(), bodycreateva jsonvacreate(), constantsendpoints createva(), environment ) c# testingconstantservice config = new testingconstantservice(); string clientid = config clientid; string privatekey = config privatekey; string timestamp = "2024 04 30t10 11 40+07 00"; string clientsecret = config clientsecret; string channelid = "ionpaytest"; string externalid = "txid202410142300021707638093"; bool isproduction = false; bool iscloudserver = false; string accesstoken = accesstokenobject accesstoken; apiendpoints apiendpoints = new apiendpoints(); apiservice vaservice = new apiservice(apiendpoints, clientsecret, clientid, channelid, isproduction, iscloudserver); var bodybuilder = new virtualaccountbuilder() setvirtualaccountsnap( partnerserviceid "", customerno "", virtualaccountno "", virtualaccountname "john doe", trxid "2022020100000000000001", value "10000 00", currency "idr", bankcd "bmri", goodsnm "john doe", dbprocessurl "https //testing co id/", vacctvaliddt "", vacctvalidtm "", msid "", msfee "", msfeetype "", mbfee "", mbfeetype "" ) build(); string createresponse = await vaservice sendpostrequest(apiendpoints createva, accesstoken, timestamp, bodybuilder, externalid); laravel protected $useprod = false; protected $usecloud = false; protected $create va endpoint = "/api/v1 0/transfer va/create va"; protected $client id = "client key merchant"; protected $key = " private key merchant"; protected $client secret = " client secret merchant"; protected $access token = " access token merchant"; $url = httputil getnicepaydomain($this >useprod, $this >usecloud) "/nicepay" $this >create va endpoint; $helper = new helpers(); $http method = "post"; $date = carbon now(); $x time stamp = $date >toiso8601string(); $time stamp = $date >format("ymdhis"); $partner id = $this >client id; $client secret = $this >client secret; $access token = $helper >generateaccesstoken($this >client id, $this >key); $external id = "txid202410142300021707638093"; $totalamount = \[ "value" => "15000 00", "currency" => "idr" ]; $additionalinfo = \[ "bankcd" => "cena", "goodsnm" => "cena", "dbprocessurl" => "https //ptsv2 com/t/jhon/post", "vacctvaliddt" => "", "vacctvalidtm" => "", "msid" => "", "msfee" => "", "mbfee" => "", "mbfeetype" => "" ]; $body = \[ "partnerserviceid" => "", "customerno" => "", "virtualaccountno" => "", "virtualaccountname" => "testing create virtual account nicepay", "trxid" => "2022020100000000000001", "totalamount" => $totalamount, "additionalinfo" => $additionalinfo ]; $string to sign = $helper >generatestringtosign( $http method, $this >create va endpoint, $access token, $body, $x time stamp ); $signature = $helper >hmacsha512encoded( $string to sign, $client secret, openssl algo sha512 ); $header = $helper >generateheader( $access token, $x time stamp, $signature, $partner id, $external id, $partner id "02" ); try { $response = httputil postjsonrequestwithheader($url, $body, $header); } catch (\exception $e) { echo "request failed " $e >getmessage(); } php native $timestamp = "2024 04 30t10 11 40+07 00"; $externalid = "txid202410142300021707638093"; $config = nicepay builder() >setisproduction(false) >setprivatekey($this >oldkeyformat) >setclientsecret($this >clientsecret) >setpartnerid($this >imidtest) >setexternalid($externalid) >settimestamp($timestamp) >build(); $virtualaccountbuilder = virtualaccount builder(); $parameter = $virtualaccountbuilder >setpartnerserviceid("") >setcustomerno("") >setvirtualaccountno("") >setvirtualaccountname("john doe") >settrxid("2022020100000000000001") >settotalamount("10000 00", "idr") >setadditionalinfo(\[ 'bankcd' => 'bmri', 'goodsnm' => 'john doe', 'dbprocessurl' => 'https //testing co id/', 'vacctvaliddt' => '', 'vacctvalidtm' => '', 'msid' => '', 'msfee' => '', 'msfeetype' => '', 'mbfee' => '', 'mbfeetype' => '' ]) >build(); $accesstoken = self getaccesstoken($config); $snapvaservice = new snapvaservice($config); $response = $snapvaservice >generateva($parameter, $accesstoken); val config nicepay = nicepay builder() isproduction(false) clientsecret(testingconstants ionpaytest client secret) partnerid("ionpaytest") externalid("txid202410142300021707638093") timestamp("2024 04 30t10 11 40+07 00") privatekey(testingconstants private key) build() val accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8=" val snapvirtualaccountservice snapvirtualaccountservice = snapvirtualaccountserviceimpl() val virtualaccount = snapvirtualaccount builder() partnerserviceid("1234") customerno("") virtualaccountno("") virtualaccountname("testvaname") trxid(default reference no) totalamount(default amount, "idr") additionalinfo( mapof( "bankcd" to "brin", "goodsnm" to "testgoodsnm", "dbprocessurl" to "https //merchant com/test", "vacctvaliddt" to "", "vacctvalidtm" to "", "msid" to "", "msfee" to "", "msfeetype" to "", "mbfee" to "", "mbfeetype" to "" ) ) build() val response nicepayresponse? = snapvirtualaccountservice createva(virtualaccount, accesstoken, config) codeigniter $const = new nicepaytestconst(); $this >clientsecret = $const imid test client secret; $this >oldkeyformat = $const imid test private key; $this >imidtest = $const imid test; $this >merchantkey = $const imid common merchant key; $timestamp = helper getformatteddate(); $config = nicepay builder() >setiscloudserver(iscloudserver true) >setprivatekey($this >oldkeyformat) >setclientsecret($this >clientsecret) >setpartnerid($this >imidtest) >setexternalid("txid202410142300021707638093") >settimestamp($timestamp) >build(); $virtualaccountbuilder = virtualaccount builder(); $parameter = $virtualaccountbuilder >setpartnerserviceid("") >setcustomerno("") >setvirtualaccountno("") >setvirtualaccountname("nicepay php test") >settrxid("2022020100000000000001") >settotalamount('10000 00', 'idr') >setadditionalinfo(\[ 'bankcd' => 'bmri', 'goodsnm' => 'jhon doe', 'dbprocessurl' => 'https //dev nicepay co id/ionpay client/paymentresult jsp', ]) >build(); $accesstoken = self getaccesstoken($config); $snapvaservice = new snapvaservice(); try { $response = $snapvaservice >generateva($parameter, $accesstoken, $config); } catch (\exception $e) { // handle exception if needed } response parameter sample response { "responsecode" "2002700", "responsemessage" "successful", "virtualaccountdata" { "partnerserviceid" "", "customerno" "", "virtualaccountno" "70014000091733551548", "virtualaccountname" "jhon doe", "trxid" "2022020100000000000001", "totalamount" { "value" "10000 00", "currency" "idr" }, "additionalinfo" { "msid" "", "msfee" "", "msfeetype" "", "mbfee" "", "mbfeetype" "", "bankcd" "bmri", "txidva" "ionpaytest02202410141733551548", "goodsnm" "jhon doe", "vacctvaliddt" "20241016", "vacctvalidtm" "173355" } } }