NICEPAY API
...
API QRIS SNAP
Refund Transaction - API QRIS SNAP
11 min
tentang refund transaction api qris snap api dengan standar snap ini digunakan untuk melakukan proses pengembalian dana transaksi pada metode pembayaran qris refund transaction api qris snap silakan mengajukan akses token terlebih dahulu sebelum menggunakan refund transaction api melalui bagian docid\ gcgqbiyxg1etcd0ji9chx service code 78 api endpoint /nicepay/api/v1 0/qr/qr mpm refund http method post description refund transaction qris api content type application/json request header parameter for refund transaction api qris snap nama parameter header tipe kebutuhan deskripsi contoh content type string (127) mandatory type of the content application/json x timestamp string (25) 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 authorization string (variable) mandatory "bearer" + { access token } x signature string (variable) mandatory signature will be generated by merchant docid\ uzex33relyenkogbjjnyp x partner id string (20) mandatory nicepay client id ( mid ) ionpaytest x external id string (40) mandatory unique messaging reference id generated by merchant numeric string reference number that should be unique in every transaction in one day channel id string (20) mandatory unique channel merchant credential id number client id + "01" = channel id "ionpaytest" + "01" = "ionpaytest01" ionpaytets01 request body parameter for refund transaction api qris snap nama parameter bi tipe parameter kebutuhan parameter nicepay deskripsi contoh originalreferenceno string (40) mandatory txid nicepay transaction id or identifier ionpaytest08202106091121206416 originalpartnerreferenceno string (40) mandatory referenceno unique transaction id from merchant ncpy20221017161458 partnerrefundno string (40) mandatory merreferencerefundno merchant refund reference number ncpy20221017161458 merchantid string (10) mandatory imid nicepay merchant id ionpaytest externalstoreid string (32) mandatory storecd merchant id from acquirer pay side nicepay refundamount object mandatory "refundamount" { "value" , "currency" }, value string (12) mandatory amt transaction amount note amount format, currently only supported idr (indonesian currency rupiah) then value includes 2 decimal digits which are seperated by a dot ( ) 10000 00 currency string (3) mandatory currency default value idr idr reason string (256) mandatory cancelmsg reason of cancel refund trans additionalinfo object mandatory "additionalinfo" { "canceltype" "1" } canceltype string (2) mandatory canceltype 1 full cancellation 2 partial cancellation 1 response parameter for refund transaction api qris snap nama parameter bi tipe parameter kebutuhan parameter nicepay deskripsi contoh responsecode string (7) mandatory responsecd error code to specify the error returned docid\ lkqjxsl5cmkdxyxxhyyss 2007800 responsemessage string (150) mandatory responsemsg debug message to provide more information successful originalreferenceno string (40) mandatory canceltxid nicepay transaction id or identifier that need to be cancelled ncpy20221017161458 originalpartnerreferenceno string (40) mandatory referenceno unique transaction id from merchant ionpaytest08202106091121206416 referenceno string (40) mandatory txid unique refund id from nicepay ionpaytest08202106091121206416 partnerrefundno string (40) mandatory merreferencerefundno merchant refund reference number ncpy20221017161458 refundamount object mandatory "refundamount" { "value" "10000 00", "currency" "idr" } value string (12) mandatory amt transaction amount note amount format, currently only supported idr (indonesian currency rupiah) then value includes 2 decimal digits which are seperated by a dot ( ) 10000 00 currency string (3) mandatory currency default value idr idr refundtime string (25) mandatory transdt , transtm update time of the individual refund the value will be returned for successful invalidate request using iso 8601 timestamp format ( yyyy mm ddthh\ mm\ ss ) 2022 07 20t07 15 00+07 00 additionalinfo object mandatory "additionalinfo" { "canceltrxsn" "07202210051341224326" } canceltrxsn string (32) mandatory refund transaction number from acquirer side 07202210051341224326 sample parameter for refund transaction api qris snap request parameter curl curl x post \\ 'https //dev nicepay co id/nicepay/api/v1 0/qr/qr mpm refund' \\ 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 ionpaytest' \\ h 'x external id exid202402111402271707638098' \\ h 'channel id ionpaytest' \\ d '{"originalreferenceno" "ncpy20221017161458","originalpartnerreferenceno" "ionpaytest08202106091121206416","partnerrefundno" "ncpy20221017161458","merchantid" "ionpaytest","externalstoreid" "nicepay","refundamount" {"value" "10000 00","currency" "idr"},"reason" "refund trans","additionalinfo" {"canceltype" "1"}}' node js // data from the qris refund request const partnerid = "ionpaytest"; const channelid= "ionpaytest"; const externalid = "exid202402111402271707638098"; const timestamp = "2024 12 31t10 11 40+07 00"; const accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; // step 1 configure the config const config = { isproduction false, privatekey "merchant private key", clientsecret "merchant client secret", clientid partnerid, iscloudserver false, }; // step 2 define the qris refund request parameters let parameterrefund = { body { originalreferenceno "ncpy20221017161458", originalpartnerreferenceno "ionpaytest08202106091121206416", partnerrefundno "ncpy20221017161458", merchantid partnerid, externalstoreid "nicepay", refundamount { value "10000 00", currency "idr", }, reason "refund trans", additionalinfo { canceltype "1", }, }, headers { x timestamp timestamp, x partner id partnerid, x external id externalid, channel id channelid, }, }; // step 3 execute the refund request let endpoint = `/api/v1 0/qr/qr mpm refund`; let snap = new snap(config); let response = snap requestsnaptransaction(parameterrefund, endpoint, accesstoken, "post");string accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; // step 1 initialize the nicepay configuration nicepay config = nicepay builder() isproduction(false) clientsecret("your client secret") // placeholder for actual secret partnerid("ionpaytest") externalid("exid202402111402271707638098") timestamp("2024 12 31t10 11 40+07 00") privatekey("your private key") // placeholder for actual key build(); // step 2 define the qris refund request body cancel requestdata = cancel builder() merchantid("ionpaytest") externalstoreid("nicepay") originalreferenceno("ncpy20221017161458") originalpartnerreferenceno("ionpaytest08202106091121206416") partnerrefundno("ncpy20221017161458") reason("refund trans") refundamount("10000 00", "idr") additionalinfo(map of("canceltype", "1")) build(); // step 3 execute the qris refund nicepayresponse result = snapcancelservice callserviceqrisrefund(requestdata, accesstoken, config); client id = "ionpaytest" external store id = "nicepay" original ref no = "ncpy20221017161458" original partner ref no = "ionpaytest08202106091121206416" partner refund no = "ncpy20221017161458" refund reason = "refund trans" refund value = "10000 00" bodycreatetoken = ( builderaccesstoken buildaccesstoken() setgranttype("client credentials") setadditionalinfo("") build() ) refundamount = { "value" refund value, "currency" "idr" } additionalinfo = { "canceltype" "1" } bodyqrisinquiry = ( builderqris buildqrisrefund() setmerchantid(client id) setexternalstoreid(external store id) setoriginalreferenceno(original ref no) setoriginalpartnerreferenceno(original partner ref no) setpartnerrefundno(partner refund no) setrefundamount(refundamount) setreason(refund reason) setadditionalinfo(additionalinfo) build() ) environment = (builderenvironment buildenvironment() iscloud(false) isproduction(false) build()) result = snapservice servicetransaction(bodycreatetoken jsonaccesstoken(), bodyqrisinquiry jsonqrisrefund(), constantsendpoints refundqris(), environment) c# const string new client id = "ionpaytest"; const string new external id = "exid202402111402271707638098"; const string new channel id = "ionpaytest"; const string refund amount = "10000 00"; const string refund currency = "idr"; const string original ref no = "ncpy20221017161458"; const string original partner ref no = "ionpaytest08202106091121206416"; const string external store id = "nicepay"; const string cancel type = "1"; const string reason = "refund trans"; testingconstant config = new testingconstant(); string privatekey = ; string timestamp = datetimeoffset now\ tostring("yyyy mm ddthh\ mm\ sszzz"); string clientsecret = config clientsecret; string channelid = new channel id; string random = signaturegeneratorutils generaterandomnumberstring(8); bool isproduction = false; bool iscloudserver = true; string signature = signaturegeneratorutils generatesignature(privatekey, new client id, timestamp); var tokenrequester = new accesstokenrequester(); string accesstokenresponse = await tokenrequester getaccesstokenasync(new client id, signature, timestamp, isproduction, iscloudserver); dynamic accesstokenobject = jobject parse(accesstokenresponse); string accesstoken = accesstokenobject accesstoken; console writeline("inquiry ewallet akses token " + accesstoken); apiendpoints apiendpoints = new apiendpoints(); apiservice qrisservice = new apiservice(apiendpoints, clientsecret, new client id, channelid, isproduction, iscloudserver); snapqrisservices snapqrisservices = new snapqrisservices(new client id); string createrequestbody = snapqrisservices generaterefundqris( originalreferenceno original ref no, originalpartnerreferenceno original partner ref no, merchantid new client id, partnerrefundno "rfnd" + random, externalstoreid external store id, value refund amount, canceltype cancel type, currency refund currency, reason reason ); string externalid = new external id; string createresponse = await qrisservice sendpostrequest(apiendpoints refundqris, accesstoken, timestamp, createrequestbody, externalid); console writeline("refund qris response " + createresponse); laravel protected $useprod = false; protected $usecloud = false; protected $refund qris endpoint = "/api/v1 0/qr/qr mpm refund"; // credential protected $client id = "ionpaytest"; protected $key = " private key merchant"; protected $client secret = " client secret merchant"; protected $access token = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; protected $store id = "nicepay"; $url = httputil getnicepaydomain($this >useprod, $this >usecloud) $this >refund qris endpoint; $helper = new helpers(); $http method = "post"; $x time stamp = "2024 12 31t10 11 40+07 00"; $partner id = $this >client id; $client secret = $this >client secret; $access token = $this >access token; $store id = $this >store id; $external id = "exid202402111402271707638098"; $channel id = "ionpaytest"; $refundamount = \[ "value" => "10000 00", "currency" => "idr" ]; $additionalinfo = \[ "canceltype" => "1" ]; $body = \[ "originalreferenceno" => "ncpy20221017161458", "originalpartnerreferenceno" => "ionpaytest08202106091121206416", "partnerrefundno" => "ncpy20221017161458", "merchantid" => $partner id, "externalstoreid" => $store id, "refundamount" => $refundamount, "reason" => "refund trans", "additionalinfo" => $additionalinfo ]; $string to sign = $helper >generatestringtosign( $http method, $this >refund qris 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, $channel id ); try { $response = httputil postjsonrequestwithheader($url, $body, $header); } catch (exception $e) { // handle exception } php native $config = nicepay builder() >setisproduction(false) >setprivatekey(" your private key ") >setclientsecret(" your client secret ") >setpartnerid("ionpaytest") >setexternalid("exid202402111402271707638098") >settimestamp("2024 12 31t10 11 40+07 00") >build(); $requestbody = cancel builder() >setoriginalreferenceno("ncpy20221017161458") >setoriginalpartnerreferenceno("ionpaytest08202106091121206416") >setpartnerrefundno("ncpy20221017161458") >setmerchantid("ionpaytest") >setexternalstoreid("nicepay") >setrefundamount("10000 00", "idr") >setreason("refund trans") >setadditionalinfo( \["canceltype" => "1"] ) >build(); $accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; $qrisservice = new snapqrisservice($config); $response = $qrisservice >refund($requestbody, $accesstoken);const val access token = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8=" // step 1 initialize the nicepay configuration var config nicepay = nicepay builder() isproduction(false) clientsecret("your client secret") partnerid("ionpaytest") externalid("exid202402111402271707638098") timestamp("2024 12 31t10 11 40+07 00") privatekey("your private key") // placeholder build() // step 2 define the qris refund request body val refundqris snapcancel = snapcancel builder() merchantid("ionpaytest") originalpartnerreferenceno("ionpaytest08202106091121206416") originalreferenceno("ncpy20221017161458") partnerrefundno("ncpy20221017161458") externalstoreid("nicepay") refundamount("10000 00", "idr") reason("refund trans") additionalinfo( mapof( "canceltype" to "1" ) ) build() // step 3 execute the refund val response nicepayresponse? = snapqrisservice refund(refundqris, access token, config) codeigniter $config = nicepay builder() >setisproduction(false) >setiscloudserver(iscloudserver true) >setprivatekey(" your private key ") >setclientsecret(" your client secret ") >setpartnerid("ionpaytest") >setexternalid("exid202402111402271707638098") >settimestamp("2024 12 31t10 11 40+07 00") >build(); $requestbody = refundqris builder() >setoriginalreferenceno("ncpy20221017161458") >setoriginalpartnerreferenceno("ionpaytest08202106091121206416") >setpartnerrefundno("ncpy20221017161458") >setmerchantid("ionpaytest") >setexternalstoreid("nicepay") >setrefundamount("10000 00", "idr") >setreason("refund trans") >setadditionalinfo(\["canceltype" => "1"]) >build(); $accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijjt05qqvlurvnuiiwiaxnzijoitkldrvbbwsisim5hbwuioijcukloiiwizxhwijoimjaync0wmi0xmvqwodowotoznvoifq== aiyblx36dywffvw7dcoenxkoe2eawiyq84ztpuif3k8="; $snapqrisservice = new snapqrisservice($config); try { $response = $snapqrisservice >refund($requestbody, $accesstoken, $config); } catch (\exception $e) { // handle exception } response parameter sample response { "responsecode" "2007800", "responsemessage" "successful", "originalreferenceno" "ncpy20221017161458", "originalpartnerreferenceno" "ionpaytest08202106091121206416", "referenceno" "ionpaytest08202106091121206416", "partnerrefundno" "ncpy20221017161458", "refundamount" { "value" "10000 00", "currency" "idr" }, "refundtime" "2022 07 20t07 15 00+07 00", "additionalinfo" { "canceltrxsn" "07202210051341224326" } }