NICEPAY API
...
API Virtual Account SNAP
Cancel - API Virtual Account SNAP
9 min
about cancel api virtual account snap this api with snap standards uses to request transaction cancellation process on virtual account payment method merchant cancel virtual account api please request the access token firsthand before doing the authentication through the docid 92feymrqs iebhxrfgxuq section service code 31 api endpoint /api/v1 0/transfer va/delete va http method delete description to request va transaction cancellation process content type application/json request cancel 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 cancel body parameter 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 trxid string 40 mandatory transaction id (reference number from merchant) additionalinfo object mandatory "additionalinfo" { "totalamount" { }, } totalamount object mandatory "totalamount" { } value string 12 mandatory transaction amount currency string 3 mandatory currency txidva string 40 mandatory transaction id cancelmessage string 255 mandatory cancel message response cancel parameter parameter type length required description responsecode string mandatory docid\ bjr4kjamzcknln 5zrnvw responsemessage string mandatory docid\ bjr4kjamzcknln 5zrnvw virtualaccountdata object mandatory "virtualaccountdata" { } partnerserviceid string 20 mandatory partner service id / prefix customerno string 40 mandatory customer number (mandatory for fix type) virtualaccountno string 40 mandatory virtual account number trxid string 40 mandatory transaction id (reference number from merchant) additionalinfo object mandatory "additionalinfo" { , "totalamount" { } } txidva string 40 mandatory transaction id cancelmessage string 200 mandatory cancel message cancelvatime string 8 mandatory cancel virtual account time totalamount object mandatory "totalamount" { } value string 12 mandatory transaction amount currency string 3 mandatory currency sample parameter for cancel api virtual account snap request parameter curl curl x post "https //www nicepay co id/nicepay/api/v1 0/transfer va/delete va" \\ h "content type application/json" \\ h "authorization bearer eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8=" \\ h "x timestamp 2024 12 31t10 11 40+07 00" \\ h "x signature ufbw7r8rhw79ioiv/hlv607m60qzaybv8uzmbsryb6/thlo/fhqvp4xryeluehoss9o+qs6vwtkb/ygtucc+tq==" \\ h "x partner id normaltest" \\ h "x external id txid202402111402271707638095" \\ h "channel id normaltest" \\ d '{ "partnerserviceid" "99123040", "customerno" "00007307", "virtualaccountno" "9912304000007307", "trxid" "2024123000000000000001", "additionalinfo" { "totalamount" { "value" "10000 00", "currency" "idr" }, "txidva" "normaltest02202401181001033629", "cancelmessage" "cancel virtual account" } }' node js const config = { isproduction false, privatekey cons privatekey, clientsecret cons clientsecret, clientid cons clientid, iscloudserver false, }; let parameterdelete = { body { partnerserviceid "99123040", customerno "00007307", virtualaccountno "9912304000007307", trxid "2024123000000000000001", additionalinfo { totalamount { value "10000 00", currency "idr", }, txidva "normaltest02202401181001033629", cancelmessage "cancel virtual account", }, }, headers { x external id "txid202402111402271707638095", channel id cons clientid, }, }; let endpoint = `/api/v1 0/transfer va/delete va`; let snap = new snap(config); let response = snap requestsnaptransaction(parameterdelete, endpoint, accesstoken, "delete"); config = nicepay builder() isproduction(false) clientsecret(client secret) partnerid(i mid) externalid("txid202402111402271707638095") timestamp("2024 12 31t10 11 40+07 00") privatekey(private key) build(); var accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; cancel requestdata = cancel builder() partnerserviceid("99123040") customerno("00007307") virtualaccountno("9912304000007307") totalamount("10000 00", "idr") trxid("2024123000000000000001") txidva("normaltest02202401181001033629") cancelmessage("cancel virtual account") build(); nicepayresponse result = snapcancelservice callservicevacancel(requestdata, accesstoken, config); bodycreatetoken = ( builderaccesstoken buildaccesstoken() setgranttype("client credentials") setadditionalinfo("") build() ) totalamount = { "value" "10000 00", "currency" "idr" } additionalinfo = { "txidva" "normaltest02202401181001033629", "totalamount" totalamount, "cancelmessage" "cancel virtual account" } bodycancelva = ( buildervirtualaccount buildcancelva() setpartnerserviceid("99123040") setcustomerno("00007307") setvirtualaccountno("9912304000007307") settrxid("2024123000000000000001") setadditionalinfo(additionalinfo) build() ) environment = ( builderenvironment buildenvironment() iscloud(false) isproduction(false) build() ) result = snapservice servicetransaction( bodycreatetoken jsonaccesstoken(), bodycancelva jsonvacancel(), constantsendpoints cancelva(), environment, "delete" ) c# testingconstant config = new testingconstant(); string clientid = config clientid; string privatekey = config privatekey; string timestamp = "2024 12 31t10 11 40+07 00"; string clientsecret = config clientsecret; string channelid = "normaltest"; bool isproduction = false; bool iscloudserver = false; string signature = signaturegeneratorutils generatesignature(privatekey, clientid, timestamp); // get access token var tokenrequester = new accesstokenrequester(); string accesstokenresponse = await tokenrequester getaccesstokenasync(clientid, signature, timestamp, isproduction, iscloudserver); dynamic accesstokenobject = jobject parse(accesstokenresponse); string accesstoken = accesstokenobject accesstoken; // setup nicepay api service apiendpoints apiendpoints = new apiendpoints(); apiservice vaservice = new apiservice(apiendpoints, clientsecret, clientid, channelid, isproduction, iscloudserver); string va no = "9912304000007307"; string trxid = "2024123000000000000001"; string amount = "10000 00"; string currency = "idr"; string txidva = "normaltest02202401181001033629"; string cancelmessage = "cancel virtual account"; var bodybuilder = new cancelbuilder() setcancelvasnap( partnerserviceid "99123040", virtualaccountno va no, trxid trxid, amountvalue amount, currency currency, txidva txidva, customerno "00007307", cancelmessage cancelmessage ) build(); string jsonpayload = newtonsoft json jsonconvert serializeobject(bodybuilder); console writeline("delete va request " + jsonpayload); // process delete va (post request) string externalid = "txid202402111402271707638095"; string deleteresponse = await vaservice senddeleterequest(apiendpoints deleteva, accesstoken, timestamp, bodybuilder, externalid); laravel $url = httputil getnicepaydomain($this >useprod, $this >usecloud) "nicepay/" $this >delete va endpoint; $helper = new helpers(); $http method = "delete"; $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 = $this >access token; $external id = "txid202402111402271707638095"; $totalamount = \[ "value" => "10000 00", "currency" => "idr" ]; $additionalinfo = \[ "totalamount" => $totalamount, "txidva" => "normaltest02202401181001033629", "cancelmessage" => "cancel virtual account" ]; $body = \[ "partnerserviceid" => "99123040", "customerno" => "00007307", "virtualaccountno" => "9912304000007307", "trxid" => "2024123000000000000001", "additionalinfo" => $additionalinfo, ]; $string to sign = $helper >generatestringtosign( $http method, $this >delete 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 deletejsonrequestwithheader($url, $body, $header); } catch (\exception $e) { echo "error deleting va " $e >getmessage(); } php native $config = nicepay builder() >setisproduction(false) >setclientsecret(testconst $client secret nt) >setpartnerid($this >imid) >setexternalid("extidcancel" $this >timestamp) >settimestamp($this >timestamp) >setprivatekey(testconst $key old format) >build(); $accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; $vacctno = "9912304000007307"; $reffno = "2024123000000000000001"; $txid = "normaltest02202401181001033629"; $amount = "10000 00"; $requestdata = cancel builder() >setpartnerserviceid("99123040") >setcustomerno("00007307") >setvirtualaccountno($vacctno) >settotalamount($amount, "idr") >settrxid($reffno) >settxidva($txid) >setcancelmessage("cancel virtual account") >build(); try { $snapvaservice = new snapvaservice($config); $response = $snapvaservice >cancel($requestdata, $accesstoken); } catch (exception $e) { echo "error cancelling va " $e >getmessage(); } val config nicepay = nicepay builder() isproduction(false) clientsecret(testingconstants normaltest client secret) partnerid(i mid normaltest) externalid("txid202402111402271707638095") timestamp("2024 12 31t10 11 40+07 00") privatekey(testingconstants private key) build() val accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8=" val reqdeleteva snapcancel = snapcancel builder() partnerserviceid("99123040") customerno("00007307") virtualaccountno("9912304000007307") cancelmessage("cancel virtual account") totalamount("10000 00", "idr") trxid("2024123000000000000001") txidva("normaltest02202401181001033629") build() val snapvirtualaccountservice snapvirtualaccountservice = snapvirtualaccountserviceimpl() val response nicepayresponse? = snapvirtualaccountservice deleteva(reqdeleteva, accesstoken, config) codeigniter $timestamp = helper getformatteddate(); $config = nicepay builder() >setisproduction(false) >setiscloudserver(true) >setprivatekey($this >oldkeyformat) >setclientsecret($this >clientsecret) >setpartnerid($this >imidtest) >setexternalid("txid202402111402271707638095") >settimestamp("2024 12 31t10 11 40+07 00") >build(); $deletevirtualaccountbuilder = deletevirtualaccount builder(); $parameter = $deletevirtualaccountbuilder >setpartnerserviceid("99123040") >setcustomerno("00007307") >setvirtualaccountno("9912304000007307") >settrxid("2024123000000000000001") >settotalamount("10000 00", "idr") >settxidva("normaltest02202401181001033629") >setcancelmessage("cancel virtual account") >build(); $accesstoken = self getaccesstoken($config); $snapvaservice = new snapvaservice(); try { $response = $snapvaservice >deleteva($parameter, $accesstoken, $config); } catch (\exception $e) { echo "error deleting va " $e >getmessage(); } response parameter sample response { "responsecode" "2003100", "responsemessage" "success", "virtualaccountdata" { "partnerserviceid" "99123040", "customerno" "00007307", "virtualaccountno" "9912304000007307", "trxid" "2024123000000000000001", "additionalinfo" { "txidva" "normaltest02202401181001033629", "cancelmessage" "cancel virtual account", "cancelvatime" "2024 12 31t10 11 40+07 00", "totalamount" { "value" "10000 00", "currency" "idr" } } } }