NICEPAY API
...
API QRIS SNAP
Registration - API QRIS SNAP
12 min
about registration api qris snap this api with snap standards uses to request order registration before proceeding with payment using the qris payment method registration api qris snap please request the access token firsthand before doing the authentication through the docid 92feymrqs iebhxrfgxuq section service code 47 api endpoint /api/v1 0/qr/qr mpm generate http method post description merchant request registration api qris content type application/json request header parameter for registration api qris snap parameter type required description example 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 (5) mandatory unique channel merchant credential id number client id + "01" = channel id "ionpaytest" + "01" = "ionpaytest01" ionpaytest01 request body parameter for registration api qris snap parameter parameter type required nicepay parameter description example partnerreferenceno string (40) mandatory referenceno unique transaction id from merchant ordno20230303001 amount object mandatory "amount" { "value" "100", "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 merchantid string (10) mandatory imid merchant identifier storeid string (32) mandatory storecd / shopid merchant id from acquirer pay side validityperiod string (25) mandatory paymentexpdt paymentexptm set default 5 minutes maximum 20 minutes using iso 8601 timestamp format additionalinfo object mandatory "additionalinfo" { , "cartdata" "{ }", "mitracd" "qshp" } goodsnm string (200) mandatory goods name billingnm string (100) mandatory buyer name billingphone string (20) mandatory buyer phone number billingemail string (100) mandatory buyer email billingcity string (50) mandatory buyer city billingstate string (50) mandatory buyer state billingpostcd string (10) mandatory buyer post number billingcountry string (10) mandatory buyer country callbackurl string (500) conditional dbprocessurl string (500) mandatory payment notification url (async notification) userip string (64) mandatory user ip (customer) cartdata string (4000) mandatory json string mitracd string (4) mandatory docid 6go07owr b22bafuetehl 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 request cart data parameter for registration api qris snap parameter description example count total cart data count 1 item img url goods image url (image size 50px 50px) https //merchant com/goodsimg png goods name goods name merchant goods goods detail goods detail description goods type 001 goods amt goods payment amount 100 goods quantity goods quantity 1 response parameter for registration api qris snap parameter parameter type required nicepay parameter description example responsecode string (7) mandatory responsecode error code to specify the error returned docid\ bjr4kjamzcknln 5zrnvw 2004700 responsemessage string (150) mandatory responsemsg debug message to provide more information successful referenceno string (40) mandatory txid nicepay transaction id or identifier ionpaytest08202106091121206416 partnerreferenceno string (40) mandatory referenceno transaction identifier on merchant side ncpy20221017161458 qrcontent string (360) mandatory qrcontent qr string in plain text "000201010212265400161d co shopee wwwo11893600918002024585002082024585052041234530 336054041 0058021d5911test6007bandung61054016362200516 1 july 20 126304d0a9 qrurl string (360) mandatory qrurl url to download qr image, url is valid for 5 minutes https //xxx co id/v3/merchant host/qr/download? 4arlcjaqjxyxifavfxz0eprx5c£g4nnzgeauyn1rl" additionalinfo object mandatory "additionalinfo" { } goodsnm string (200) mandatory goods name merchant goods 1 billingnm string (100) mandatory buyer name john doe validityperiod string (25) mandatory paymentexpdt , paymentexptm transaction date iso 8601 2023 03 08t07 15 00+07 00 mitracd string (4) mandatory docid 6go07owr b22bafuetehl qshp msid string (20) optional merchant seller id 123 msfee string (7) optional merchant seller fee 2000 msfeetype string (2) optional merchant seller fee type 2 mbfee string (7) optional merchant balance fee 2000 mbfeetype string (2) optional merchant balance fee type 2 sample parameter for registration api qris snap request parameter curl curl x post \\ 'https //dev nicepay co id/nicepay/api/v1 0/qr/qr mpm generate' \\ h 'content type application/json' \\ h 'authorization bearer eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss=' \\ h 'x timestamp 2022 04 18t09 00 40+07 00' \\ h 'x signature sbvrkrqxrzvjtr/7rwtherteyyds5nguotyfdcegt1novzuhf/uy25rvggvzmzqdkx6tivn9cmytrvxhwlgfzq==' \\ h 'x partner id tniceqr081' \\ h 'x external id 09041220240418' \\ h 'channel id tniceqr08101' \\ d '{"partnerreferenceno" "ordno2022120215134035","amount" {"value" "100 00","currency" "idr"},"merchantid" "tniceqr081","storeid" "nicepaystoreid1","validityperiod" "2024 04 18t10 31 33+07 00","additionalinfo" {"goodsnm" "test snap transaction nicepay","billingnm" "john doe","billingphone" "082213561712","billingemail" "email\@merchant com","billingcity" "jakarta","billingaddr" "jalan bukit berbunga 22","billingstate" "dki jakarta","billingpostcd" "12345","billingcountry" "indonesia","callbackurl" "https //ptsv2 com/t/jhon/post","dbprocessurl" "https //ptsv2 com/t/jhon/post","userip" "127 0 0 1","cartdata" "{\\"count\\" 1,\\"item\\" \[{\\"img url\\" \\"https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium\\",\\"goods name\\" \\"nokia 3360\\",\\"goods detail\\" \\"old nokia 3360\\",\\"goods amt\\" \\"100\\",\\"goods quantity\\" \\"1\\"}]}","mitracd" "qshp","msid" "","msfee" "","msfeetype" "","mbfee" "","mbfeetype" ""}}' node js const config = { isproduction false, // set true if using prod privatekey cons privatekey, clientsecret cons clientsecret, clientid "tniceqr081", iscloudserver false, }; const accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss="; const parameter = { body { partnerreferenceno "ordno2022120215134035", amount { value "100 00", currency "idr" }, merchantid "tniceqr081", storeid "nicepaystoreid1", validityperiod "2024 04 18t10 31 33+07 00", additionalinfo { goodsnm "test snap transaction nicepay", billingnm "john doe", billingphone "082213561712", billingemail "email\@merchant com", billingcity "jakarta", billingaddr "jalan bukit berbunga 22", billingstate "dki jakarta", billingpostcd "12345", billingcountry "indonesia", callbackurl "https //ptsv2 com/t/jhon/post", dbprocessurl "https //ptsv2 com/t/jhon/post", userip "127 0 0 1", cartdata "{\\"count\\" 1,\\"item\\" \[{\\"img url\\" \\"https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium\\",\\"goods name\\" \\"nokia 3360\\",\\"goods detail\\" \\"old nokia 3360\\",\\"goods amt\\" \\"100\\",\\"goods quantity\\" \\"1\\"}]}", mitracd "qshp", msid "", msfee "", msfeetype "", mbfee "", mbfeetype "" } }, headers { x external id "09041220240418", channel id "tniceqr08101", }, }; // initialize snap and make the request let snap = new snap(config); let endpoint = `/api/v1 0/qr/qr mpm generate`; let response = snap requestsnaptransaction(parameter, endpoint, accesstoken, "post"); // 1 configure the nicepay client nicepay config = nicepay builder() isproduction(false) clientsecret("your client secret") partnerid("tniceqr081") externalid("09041220240418") timestamp("2022 04 18t09 00 40+07 00") privatekey("your private key") build(); // 2 set the access token string accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss="; // 3 build the qris request body string cartdatajson = "{\\"count\\" 1,\\"item\\" \[{\\"img url\\" \\"https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium\\",\\"goods name\\" \\"nokia 3360\\",\\"goods detail\\" \\"old nokia 3360\\",\\"goods amt\\" \\"100\\",\\"goods quantity\\" \\"1\\"}]}"; qris qris = qris builder() merchantid("tniceqr081") storeid("nicepaystoreid1") amount("100 00", "idr") partnerreferenceno("ordno2022120215134035") validityperiod("2024 04 18t10 31 33+07 00") additionalinfo( "test snap transaction nicepay", "john doe", "082213561712", "email\@merchant com", "jakarta", "jalan bukit berbunga 22", "dki jakarta", "12345", "indonesia", "https //ptsv2 com/t/jhon/post", "https //ptsv2 com/t/jhon/post", "127 0 0 1", cartdatajson, "qshp", "", // msid "", // msfee "", // msfeetype "", // mbfee "" // mbfeetype ) build(); // 4 make the api call nicepayresponse response = snapqrisservice callserviceqrisregist(qris, accesstoken, config); \# 1 define the token request body bodycreatetoken = ( builderaccesstoken buildaccesstoken() setgranttype("client credentials") setadditionalinfo("") build() ) \# 2 define the qris request body components amount = { "value" "100 00", "currency" "idr" } cart data string = '{"count" 1,"item" \[{"img url" "https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium","goods name" "nokia 3360","goods detail" "old nokia 3360","goods amt" "100","goods quantity" "1"}]}' additionalinfo = { "goodsnm" "test snap transaction nicepay", "billingnm" "john doe", "billingphone" "082213561712", "billingemail" "email\@merchant com", "billingaddr" "jalan bukit berbunga 22", "billingcity" "jakarta", "billingstate" "dki jakarta", "billingcountry" "indonesia", "billingpostcd" "12345", "callbackurl" "https //ptsv2 com/t/jhon/post", "dbprocessurl" "https //ptsv2 com/t/jhon/post", "userip" "127 0 0 1", "msid" "", "msfee" "", "msfeetype" "", "mbfee" "", "mbfeetype" "", "cartdata" cart data string, "mitracd" "qshp" } \# 3 build the main qris request body bodyqris = ( builderqris buildqris() setmerchantid("tniceqr081") setpartnerreferenceno("ordno2022120215134035") setstoreid("nicepaystoreid1") setvalidityperiod("2024 04 18t10 31 33+07 00") setamount(amount) setadditionalinfo(additionalinfo) build() ) \# 4 set the environment environment = (builderenvironment buildenvironment() iscloud(false) isproduction(false) build()) \# 5 make the api call result = snapservice servicetransaction( bodycreatetoken jsonaccesstoken(), bodyqris jsonqris(), constantsendpoints qris(), environment ) c# string clientid = "tniceqr081"; string privatekey = config privatekey; string clientsecret = config clientsecret; string timestampstring = "2022 04 18t09 00 40+07 00"; datetimeoffset timestamp = datetimeoffset parse(timestampstring); string formattedtimestamp = timestamp tostring("yyyy mm ddthh\ mm\ sszzz"); string channelid = "tniceqr08101"; string accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss="; string externalid = "09041220240418"; apiendpoints apiendpoints = new apiendpoints(); apiservice qrisservice = new apiservice(apiendpoints, clientsecret, clientid, channelid, isproduction, iscloudserver); var bodybuilder = new qrisbuilder() setqrissnap( partnerreferenceno "ordno2022120215134035", merchantid "tniceqr081", storeid "nicepaystoreid1", validityperiod "2024 04 18t10 31 33+07 00", value "100 00", currency "idr", goodsnm "test snap transaction nicepay", billingnm "john doe", billingphone "082213561712", billingemail "email\@merchant com", billingcity "jakarta", billingstate "dki jakarta", billingpostcd "12345", billingcountry "indonesia", callbackurl "https //ptsv2 com/t/jhon/post", dbprocessurl "https //ptsv2 com/t/jhon/post", mitracd "qshp", userip "127 0 0 1", cartdata "{\\"count\\" 1,\\"item\\" \[{\\"img url\\" \\"https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium\\",\\"goods name\\" \\"nokia 3360\\",\\"goods detail\\" \\"old nokia 3360\\",\\"goods amt\\" \\"100\\",\\"goods quantity\\" \\"1\\"}]}" ) build(); string jsonpayload = newtonsoft json jsonconvert serializeobject(bodybuilder, newtonsoft json formatting indented); string createresponse = await qrisservice sendpostrequest( apiendpoints generateqris, accesstoken, formattedtimestamp, bodybuilder, externalid ); console writeline("generate qris response " + createresponse); laravel \<?php use carbon\carbon; use illuminate\support\str; $this >create qris endpoint = '/api/v1 0/qr/qr mpm generate'; $this >client id = 'tniceqr081'; $this >client secret = 'your client secret'; // replace with your actual client secret $this >access token = 'eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss='; $this >store id = 'nicepaystoreid1'; $this >amt = '100 00'; // 1 setup request parameters $url = httputil getnicepaydomain($this >useprod, $this >usecloud) $this >create qris endpoint; $helper = new helpers(); $http method = "post"; $x time stamp = "2022 04 18t09 00 40+07 00"; $validity period = "2024 04 18t10 31 33+07 00"; $partner id = $this >client id; $client secret = $this >client secret; $access token = $this >access token; $channel id = "tniceqr08101"; $store id = $this >store id; $result = array(); $external id = "09041220240418"; // from x external id $reference no = "ordno2022120215134035"; // from partnerreferenceno $totalamount = \[ "value" => $this >amt, "currency" => "idr" ]; $cartdata = \[ "count" => 1, "item" => \[ \[ "img url" => "https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium", "goods name" => "nokia 3360", "goods detail" => "old nokia 3360", "goods amt" => "100 00", "goods quantity" => "1" ] ] ]; $additionalinfo = \[ "goodsnm" => "test snap transaction nicepay", "billingnm" => "john doe", "billingphone" => "082213561712", "billingemail" => "email\@merchant com", "billingcity" => "jakarta", "billingaddr" => "jalan bukit berbunga 22", "billingstate" => "dki jakarta", "billingpostcd" => "12345", "billingcountry" => "indonesia", "dbprocessurl" => "https //ptsv2 com/t/jhon/post", "callbackurl"=> "https //ptsv2 com/t/jhon/post", "userip" => "127 0 0 1", "cartdata" => json encode($cartdata), "mitracd" => "qshp" ]; $body = \[ "partnerreferenceno" => $reference no, "amount" => $totalamount, "merchantid" => $partner id, "storeid" => $store id, "validityperiod" => $validity period, "additionalinfo" => $additionalinfo ]; // 2 generate signature $string to sign = $helper >generatestringtosign( $http method, $this >create qris endpoint, $access token, $body, $x time stamp ); $signature = $helper >hmacsha512encoded( $string to sign, $client secret, openssl algo sha512 ); // 3 generate header $header = $helper >generateheader( $access token, $x time stamp, $signature, $partner id, $external id, $channel id ); // 4 send request try { $response = httputil postjsonrequestwithheader($url, $body, $header); // handle response } catch (exception $e) { // handle exception } php native \<?php // 1 configure the nicepay client $config = nicepay builder() >setisproduction(false) >setclientsecret('your client secret') // replace with your actual client secret >setpartnerid('tniceqr081') >setexternalid('09041220240418') >settimestamp('2022 04 18t09 00 40+07 00') >setprivatekey('your private key') // replace with your actual private key >build(); // 2 set the access token $accesstoken = 'eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss='; // 3 build the qris request body $cartdatajson = '{"count" 1,"item" \[{"img url" "https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium","goods name" "nokia 3360","goods detail" "old nokia 3360","goods amt" "100","goods quantity" "1"}]}'; $requestbody = qris builder() >partnerreferenceno('ordno2022120215134035') >amount('100 00', 'idr') >merchantid('tniceqr081') >storeid('nicepaystoreid1') >validityperiod('2024 04 18t10 31 33+07 00') >additionalinfo( "test snap transaction nicepay", "john doe", "082213561712", "email\@merchant com", "jakarta", "jalan bukit berbunga 22", "dki jakarta", "12345", "indonesia", "https //ptsv2 com/t/jhon/post", "https //ptsv2 com/t/jhon/post", "127 0 0 1", $cartdatajson, "qshp" ) >build(); // 4 make the api call $qrisservice = new snapqrisservice($config); try { $response = $qrisservice >generateqris($requestbody, $accesstoken); } catch (exception $e) { // handle exception } // 1 configure the nicepay client val config nicepay = nicepay builder() isproduction(false) clientsecret("your client secret") // replace with your actual client secret partnerid("tniceqr081") externalid("09041220240418") timestamp("2022 04 18t09 00 40+07 00") privatekey("your private key") // replace with your actual private key build() // 2 set the access token val accesstoken = "eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss=" // 3 build the qris request body val cartdatajson = "{\\"count\\" 1,\\"item\\" \[{\\"img url\\" \\"https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium\\",\\"goods name\\" \\"nokia 3360\\",\\"goods detail\\" \\"old nokia 3360\\",\\"goods amt\\" \\"100\\",\\"goods quantity\\" \\"1\\"}]}" val qris = snapqris builder() merchantid("tniceqr081") storeid("nicepaystoreid1") amount("100 00", "idr") partnerreferenceno("ordno2022120215134035") validityperiod("2024 04 18t10 31 33+07 00") additionalinfo(mapof( "goodsnm" to "test snap transaction nicepay", "billingnm" to "john doe", "billingphone" to "082213561712", "billingemail" to "email\@merchant com", "billingcity" to "jakarta", "billingaddr" to "jalan bukit berbunga 22", "billingstate" to "dki jakarta", "billingpostcd" to "12345", "billingcountry" to "indonesia", "callbackurl" to "https //ptsv2 com/t/jhon/post", "dbprocessurl" to "https //ptsv2 com/t/jhon/post", "userip" to "127 0 0 1", "cartdata" to cartdatajson, "mitracd" to "qshp", "msid" to "", "msfee" to "", "msfeetype" to "", "mbfee" to "", "mbfeetype" to "" )) build() // 4 make the api call val response = snapqrisservice qrmpmgenerate(qris, accesstoken, config) codeigniter \<?php // 1 configure the nicepay client $config = nicepay builder() >setisproduction(false) // dev >setiscloudserver(iscloudserver false) >setprivatekey('your private key') // replace with your actual private key >setclientsecret('your client secret') // replace with your actual client secret >setpartnerid('tniceqr081') >setexternalid('09041220240418') >settimestamp('2022 04 18t09 00 40+07 00') >build(); // 2 build the qris request body $cartdatajson = '{"count" 1,"item" \[{"img url" "https //d3nevzfk7ii3be cloudfront net/igi/vorghxlovuka566a medium","goods name" "nokia 3360","goods detail" "old nokia 3360","goods amt" "100","goods quantity" "1"}]}'; $qrisbuilder = qris builder(); $requestbody = $qrisbuilder >setpartnerreferenceno('ordno2022120215134035') >setamount('100 00', 'idr') >setmerchantid('tniceqr081') >setstoreid('nicepaystoreid1') >setvalidityperiod('2024 04 18t10 31 33+07 00') >setadditionalinfo( "test snap transaction nicepay", "john doe", "082213561712", "email\@merchant com", "jakarta", "jalan bukit berbunga 22", "dki jakarta", "12345", "indonesia", "https //ptsv2 com/t/jhon/post", "https //ptsv2 com/t/jhon/post", "127 0 0 1", $cartdatajson, "qshp" ) >build(); // 3 set the access token and make the api call $accesstoken = 'eyj0exaioijkv1qilcjhbgcioijiuzi1nij9 eyjzdwiioijutkldrvfsmdgxiiwiaxnzijoitkldrvbbwsisim5hbwuioijosunfuefziiwizxhwijoimjaync0wnc0xofqwmjozmtoyovoifq== 5f1rppweobc eqjyw64w87f3m1 tls5dzfzfhjxpzss='; $snapqrisservice = new snapqrisservice(); try { $response = $snapqrisservice >generateqris($requestbody, $accesstoken, $config); } catch (exception $e) { // handle exception } response parameter sample response { "responsecode" "2004700", "responsemessage" "successful", "referenceno" "tniceqr08108202404181012168473", "partnerreferenceno" "ordno2022120215134035", "qrcontent" "00020101021226610016id co shopee www01189360091800202508660208202508660303umi5204123453033605406100 005802id5913nicepaystore16015kab aceh barat61052365962360520082024041810121600660708t00000026304c6f6", "qrurl" "https //mapi gw\ uat airpay co id/v3/merchant host/qr/download?qr=ps03qyb4zmuqmpdhsil1jir2wmpx3ergj3vjbavfwc", "additionalinfo" { "goodsnm" "test snap transaction nicepay", "billingnm" "john doe", "mitracd" "qshp", "validityperiod" "2024 04 18t10 31 33+07 00" } }