NICEPAY API
...
API Credit Card
Cancel - API Credit Card
9 min
about cancel api credit card this {{api}} uses by {{merchant}} to cancel {{the}} paid {{transaction}} if you cancel before {{the}} settlement {{process}} is complete, then {{the}} {{transaction}} is considered void and {{the}} {{transaction}} funds will be returned to your {{customer}} however, cancellations after {{the}} settlement {{process}} is complete are included in {{the}} refund category {{please}} visit docid 3qalqxg5pvrrg7euemdy {{page}} to find out more about {{the}} terms void or refund cancel api credit card the {{cc}} cancel {{api}} uses to cancel {{the}} {{process}} of {{payment}} s via {{cc}} api end point /nicepay/direct/v2/cancel request method post post header content type application/json merchant token sha256( timestamp + imid + txid + amt + merchantkey ) request parameters for cancel api credit card the following is a list of request {{parameter}} s in {{the}} cancel {{cc}} {{api}} to {{process}} cancel {{transaction}} s for {{cc}} {{paymethod}} s this {{parameter}} s uses through {{the}} {{api}} {{testing}} platform parameter type size description example / notes timestamp required required n 14 {{api}} request timestamp 20221214111239 txid required required an 30 transaction id ionpaytest01202212141146401456 imid required required an 10 {{merchant}} id ionpaytest paymethod required required n 2 docid\ ek 0djw7nuhytcda4sa3p 01 canceltype required required n 2 docid\ ly9czdrbjtw3rjv3l7r6v 2 merchanttoken required required an 255 {{merchant}} token ff139e49606387091cd9baeadff3161aff6afd9406e1f481e0fdb8b46d1ae5ae referenceno ans 40 reference number ordno20221214111208 amt required required n 12 {{paymentproduct}} amount 1000 cancelmsg an 255 cancel message cancellation of transaction {{cc}} cancelserverip an 15 server ip 127 0 0 1 canceluserid an 30 user id admin canceluserip an 15 user ip 127 0 0 1 canceluserinfo an 100 user information test cancel cancelretrycnt 	 n 2 retry count 5 worker an 10 worker worker response parameter for cancel api credit card the following is a list of response parameter or {{the}} result from {{the}} request parameter for {{cc}} cancel handling parameter type size description example / notes resultcd n 4 docid 2r5sr3xvppu1eju1nitg https //app archbee com/docs/36sm2oxriwwbi9inlqmtp/wpcemazro xvnxz 1zaib 0000 resultmsg an 255 result message docid 4 fpewlvczfhcvygxwck9 success txid an 30 transaction id ionpaytest01202212141146401456 referenceno ans 40 {{merchant}} order number ordno20221214111208 transdt n 8 transaction date 20221214 transtm n 6 transaction time 114640 amt n 12 amount 5000 cancelreferenceno optional for cc optional for cc an 40 {{merchant}} cancel number ordno20221214111208 acquirerdata only for cc only for cc array 20 a dynamic array consisting of a unique reference number rrn that is provided by {{the}} {{bank}} ing {{partner}} when a refund is {{process}} ed this reference number can be used by {{the}} {{customer}} to track {{the}} {{status}} of {{the}} refund with {{the}} {{bank}} "acquirerdata" { "rrn" "332608321717" } sample parameter for cancel api credit card request parameter curl curl location 'https //dev nicepay co id/nicepay/direct/v2/cancel' \\ \ header 'content type application/json' \\ \ data '{ "timestamp" "20251008131011", "paymethod" "01", "txid" "ionpaytest01202509241944339756", "imid" "ionpaytest", "merchanttoken" "45505e04460a30418c425506e6b53295cc548b7ec11dd6685b0bf669e26c8db6", "referenceno" "ordno20250924194433", "amt" "10000", "canceltype" "2", "cancelmsg" "cancellation of transaction", "cancelserverip" "127 0 0 1", "canceluserid" "", "canceluserip" "127 0 0 1", "canceluserinfo" "", "cancelretrycnt" "", "worker" "" }' node js const config = { isproduction false, privatekey cons privatekey, clientsecret cons clientsecret, clientid cons clientid, iscloudserver false, merchantkey cons merchantkey, }; let parametercancel = { timestamp "20251008131011", paymethod "01", txid "ionpaytest01202509241944339756", imid "ionpaytest", merchanttoken "45505e04460a30418c425506e6b53295cc548b7ec11dd6685b0bf669e26c8db6", referenceno "ordno20250924194433", amt "10000", canceltype "2", cancelmsg "cancellation of transaction", cancelserverip "127 0 0 1", canceluserid "", canceluserip "127 0 0 1", canceluserinfo "", cancelretrycnt "", worker "", }; let secondversion = new secondapiversion(config); response = secondversion requestapi(parametercancel, "/direct/v2/cancel"); nicepayconfig configcc = nicepay builder() isproduction(false) iscloudserver(false) partnerid("ionpaytest") build(); string txid = "ionpaytest01202509241944339756"; // from json string amount = "10000"; string reffno = "ordno20250924194433"; cancel requestcancel = cancel builder() timestamp("20251008131011") txid(txid) referenceno(reffno) merchanttoken( "20251008131011", "ionpaytest", txid, amount, "your merchant key" ) imid("ionpaytest") paymethod("01") canceltype("2") amt(amount) cancelmsg("cancellation of transaction") canceluserip("127 0 0 1") cancelserverip("127 0 0 1") canceluserinfo("") cancelretrycnt("") worker("") build(); nicepayresponsev2 result = v2cancelservice callv2canceltransaction(requestcancel, configcc); bodycancel = ( buildercancel buildcancel() setpaymethod("01") settxid("ionpaytest01202509241944339756") setreferenceno("ordno20250924194433") setcanceluserid("") setcanceltype("2") setcancelmsg("cancellation of transaction") setamt("10000") setcancelserverip("127 0 0 1") setcanceluserip("127 0 0 1") setcanceluserinfo("") setcancelretrycnt("") setworker("") build() ) environment = ( builderenvironment buildenvironment() iscloud(true) isproduction(false) build() ) response = servicenicepay servicecancel(datagenerator getcancelbody(bodycancel jsoncancel()), environment) c# string merchantkey = config merkey; string clientid = config clientid; string timestamp = "20251008131011"; string amount = "10000"; string txid = "ionpaytest01202509241944339756"; string referenceno = "ordno20250924194433"; bool isproduction = false; bool iscloudserver = false; // ✅ build merchant token (keep original logic) var builder = new merchanttokenbuilder() settimestamp(timestamp) setimid(clientid) settxid(txid) setamount(amount) setmerchantkey(merchantkey); string merchanttoken = builder buildcancelmerchanttoken(); // ✅ build cancel request body var bodybuilder = new nicepayrequestbuilder() setcancel( imid "ionpaytest", timestamp timestamp, txid txid, amt amount, merchanttoken merchanttoken, paymethod "01", canceltype "2", cancelmsg "cancellation of transaction", canceluserid "", cancelserverip "127 0 0 1", cancelretrycnt "" ); // ✅ prepare api endpoint and send request apiendpoints apiendpoints = new apiendpoints(); dictionary\<string, object> payload = bodybuilder build(); string jsonpayload = newtonsoft json jsonconvert serializeobject(payload, newtonsoft json formatting indented); var registrationservice = new nicepayregistrationservice(apiendpoints, isproduction, iscloudserver); var result = await registrationservice sendpostasync(apiendpoints cancelv2, payload); laravel protected $useprod = false; protected $usecloud = false; protected $cancel endpoint = "/nicepay/direct/v2/cancel"; $url = httputil getnicepaydomain($this >useprod, $this >usecloud) $this >cancel endpoint; // request body parameter $timestamp = "20251008131011"; $txid = "ionpaytest01202509241944339756"; $reference no = "ordno20250924194433"; $amt = "10000"; $merchant token = "45505e04460a30418c425506e6b53295cc548b7ec11dd6685b0bf669e26c8db6"; $body = \[ "timestamp" => $timestamp, "txid" => $txid, "imid" => "ionpaytest", "referenceno" => $reference no, "paymethod" => "01", "merchanttoken" => $merchant token, "amt" => $amt, "cancelmsg" => "cancellation of transaction", "canceltype" => "2", "cancelserverip" => "127 0 0 1", "canceluserid" => "", "canceluserip" => "127 0 0 1", "canceluserinfo" => "", "cancelretrycnt" => "", "worker" => "" ]; $response = httputil postjsonrequest($url, $body); php native $config = $this >configv2; $timestamp = "20251008131011"; $txid = "shopeetest01202410111242218557"; $reffno = "ordcancel20251008131011"; $imid = "shopeetest"; $amount = "1000"; $requestbody = cancel builder() >settimestamp($timestamp) >setpaymethod("01") >settxid($txid) >setimid($imid) >setmerchanttoken($timestamp, $imid, $txid, $amount, $this >merchantkey) >setreferenceno($reffno) >setamt($amount) >setcanceltype("2") >setcancelmsg("cancelation of card trans with php native") >setcanceluserip("127 0 0 1") >setcanceluserid("") >setcanceluserinfo("") >setcancelretrycnt("") >setworker("") >build(); $cardservice = new v2cardservice($config); $response = $cardservice >cancel($requestbody); val request directv2cancel = directv2cancel builder() timestamp("20251008131011") txid("ionpaytest01202509241944339756") imid("ionpaytest") merchantkey("your merchant key") referenceno("ordno20250924194433") amt("10000") paymethod("01") canceltype("2") build() val response nicepayresponsev2 = v2cardservice cancel(request, config)!! codeigniter $config = $this >configv2; $timestamp = "20251008131011"; $txid = "ionpaytest01202509241944339756"; $amount = "10000"; $reffno = "ordno20250924194433"; $requestbody = cancel builder() >settimestamp($timestamp) >setimid($this >imid) >settxid($txid) >setreferenceno($reffno) >setmerchanttoken($timestamp, $this >imid, $txid, $amount, $this >merchantkey) >setpaymethod("01") >setcanceltype("2") >setamt($amount) >build(); $v2vaservice = new v2vaservice($config); $response = $v2vaservice >cancel($requestbody); response parameter sample response { "txid" "ionpaytest01202509241944339756", "referenceno" "ordno20250924194433", "resultcd" "0000", "resultmsg" "success", "transdt" "20250924", "transtm" "194433", "description" "this is testing transaction", "amt" "10000", "cancelreferenceno" "ordno20250924194433", "acquirerdata" { "rrn" null } }