[{"data":1,"prerenderedAt":858},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fauthentication":3,"docs-nav":822,"docs-order":848},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"body":10,"_type":816,"_id":817,"_source":818,"_file":819,"_stem":820,"_extension":821},"\u002Fdocs\u002Fauthentication","docs",false,"","Authentication","Every request must include four headers:",{"type":11,"children":12,"toc":811},"root",[13,21,26,139,146,166,198,217,223,551,557,792,805],{"type":14,"tag":15,"props":16,"children":18},"element","h1",{"id":17},"authentication",[19],{"type":20,"value":8},"text",{"type":14,"tag":22,"props":23,"children":24},"p",{},[25],{"type":20,"value":9},{"type":14,"tag":27,"props":28,"children":29},"table",{},[30,49],{"type":14,"tag":31,"props":32,"children":33},"thead",{},[34],{"type":14,"tag":35,"props":36,"children":37},"tr",{},[38,44],{"type":14,"tag":39,"props":40,"children":41},"th",{},[42],{"type":20,"value":43},"Header",{"type":14,"tag":39,"props":45,"children":46},{},[47],{"type":20,"value":48},"Value",{"type":14,"tag":50,"props":51,"children":52},"tbody",{},[53,78,101,118],{"type":14,"tag":35,"props":54,"children":55},{},[56,67],{"type":14,"tag":57,"props":58,"children":59},"td",{},[60],{"type":14,"tag":61,"props":62,"children":64},"code",{"className":63},[],[65],{"type":20,"value":66},"Authorization",{"type":14,"tag":57,"props":68,"children":69},{},[70,76],{"type":14,"tag":61,"props":71,"children":73},{"className":72},[],[74],{"type":20,"value":75},"Bearer pk_…",{"type":20,"value":77}," (your publishable key)",{"type":14,"tag":35,"props":79,"children":80},{},[81,90],{"type":14,"tag":57,"props":82,"children":83},{},[84],{"type":14,"tag":61,"props":85,"children":87},{"className":86},[],[88],{"type":20,"value":89},"X-Timestamp",{"type":14,"tag":57,"props":91,"children":92},{},[93,95],{"type":20,"value":94},"Current Unix time in ",{"type":14,"tag":96,"props":97,"children":98},"strong",{},[99],{"type":20,"value":100},"seconds",{"type":14,"tag":35,"props":102,"children":103},{},[104,113],{"type":14,"tag":57,"props":105,"children":106},{},[107],{"type":14,"tag":61,"props":108,"children":110},{"className":109},[],[111],{"type":20,"value":112},"X-Signature",{"type":14,"tag":57,"props":114,"children":115},{},[116],{"type":20,"value":117},"HMAC-SHA256 of the signing string (hex)",{"type":14,"tag":35,"props":119,"children":120},{},[121,130],{"type":14,"tag":57,"props":122,"children":123},{},[124],{"type":14,"tag":61,"props":125,"children":127},{"className":126},[],[128],{"type":20,"value":129},"Content-Type",{"type":14,"tag":57,"props":131,"children":132},{},[133],{"type":14,"tag":61,"props":134,"children":136},{"className":135},[],[137],{"type":20,"value":138},"application\u002Fjson",{"type":14,"tag":140,"props":141,"children":143},"h2",{"id":142},"signing-string",[144],{"type":20,"value":145},"Signing string",{"type":14,"tag":22,"props":147,"children":148},{},[149,151,156,158,164],{"type":20,"value":150},"Build the string, then HMAC-SHA256 it with your ",{"type":14,"tag":96,"props":152,"children":153},{},[154],{"type":20,"value":155},"secret key",{"type":20,"value":157}," (",{"type":14,"tag":61,"props":159,"children":161},{"className":160},[],[162],{"type":20,"value":163},"sk_…",{"type":20,"value":165},"):",{"type":14,"tag":167,"props":168,"children":169},"ul",{},[170,185],{"type":14,"tag":171,"props":172,"children":173},"li",{},[174,176],{"type":20,"value":175},"When the request has a reference, amount and currency:\n",{"type":14,"tag":177,"props":178,"children":180},"pre",{"code":179},"merchant_code|reference_no|amount|currency|timestamp\n",[181],{"type":14,"tag":61,"props":182,"children":183},{"__ignoreMap":7},[184],{"type":20,"value":179},{"type":14,"tag":171,"props":186,"children":187},{},[188,190],{"type":20,"value":189},"Otherwise (e.g. Get Session):\n",{"type":14,"tag":177,"props":191,"children":193},{"code":192},"merchant_code|timestamp\n",[194],{"type":14,"tag":61,"props":195,"children":196},{"__ignoreMap":7},[197],{"type":20,"value":192},{"type":14,"tag":22,"props":199,"children":200},{},[201,207,209,215],{"type":14,"tag":61,"props":202,"children":204},{"className":203},[],[205],{"type":20,"value":206},"amount",{"type":20,"value":208}," is formatted to two decimals (e.g. ",{"type":14,"tag":61,"props":210,"children":212},{"className":211},[],[213],{"type":20,"value":214},"3.00",{"type":20,"value":216},").",{"type":14,"tag":140,"props":218,"children":220},{"id":219},"nodejs",[221],{"type":20,"value":222},"Node.js",{"type":14,"tag":177,"props":224,"children":228},{"code":225,"language":226,"meta":7,"className":227,"style":7},"import crypto from 'node:crypto'\n\nconst secret = process.env.SYOK2PAY_SECRET \u002F\u002F sk_...\nconst timestamp = Math.floor(Date.now() \u002F 1000).toString()\nconst amount = (3).toFixed(2)\nconst signingString = `M00001|ORD-20260428-001|${amount}|MYR|${timestamp}`\nconst signature = crypto.createHmac('sha256', secret).update(signingString).digest('hex')\n\n\u002F\u002F headers: Authorization: `Bearer ${pk}`, 'X-Timestamp': timestamp, 'X-Signature': signature\n","js","language-js shiki shiki-themes github-dark",[229],{"type":14,"tag":61,"props":230,"children":231},{"__ignoreMap":7},[232,261,271,307,374,424,465,534,542],{"type":14,"tag":233,"props":234,"children":237},"span",{"class":235,"line":236},"line",1,[238,244,250,255],{"type":14,"tag":233,"props":239,"children":241},{"style":240},"--shiki-default:#F97583",[242],{"type":20,"value":243},"import",{"type":14,"tag":233,"props":245,"children":247},{"style":246},"--shiki-default:#E1E4E8",[248],{"type":20,"value":249}," crypto ",{"type":14,"tag":233,"props":251,"children":252},{"style":240},[253],{"type":20,"value":254},"from",{"type":14,"tag":233,"props":256,"children":258},{"style":257},"--shiki-default:#9ECBFF",[259],{"type":20,"value":260}," 'node:crypto'\n",{"type":14,"tag":233,"props":262,"children":264},{"class":235,"line":263},2,[265],{"type":14,"tag":233,"props":266,"children":268},{"emptyLinePlaceholder":267},true,[269],{"type":20,"value":270},"\n",{"type":14,"tag":233,"props":272,"children":274},{"class":235,"line":273},3,[275,280,286,291,296,301],{"type":14,"tag":233,"props":276,"children":277},{"style":240},[278],{"type":20,"value":279},"const",{"type":14,"tag":233,"props":281,"children":283},{"style":282},"--shiki-default:#79B8FF",[284],{"type":20,"value":285}," secret",{"type":14,"tag":233,"props":287,"children":288},{"style":240},[289],{"type":20,"value":290}," =",{"type":14,"tag":233,"props":292,"children":293},{"style":246},[294],{"type":20,"value":295}," process.env.",{"type":14,"tag":233,"props":297,"children":298},{"style":282},[299],{"type":20,"value":300},"SYOK2PAY_SECRET",{"type":14,"tag":233,"props":302,"children":304},{"style":303},"--shiki-default:#6A737D",[305],{"type":20,"value":306}," \u002F\u002F sk_...\n",{"type":14,"tag":233,"props":308,"children":310},{"class":235,"line":309},4,[311,315,320,324,329,335,340,345,350,355,360,364,369],{"type":14,"tag":233,"props":312,"children":313},{"style":240},[314],{"type":20,"value":279},{"type":14,"tag":233,"props":316,"children":317},{"style":282},[318],{"type":20,"value":319}," timestamp",{"type":14,"tag":233,"props":321,"children":322},{"style":240},[323],{"type":20,"value":290},{"type":14,"tag":233,"props":325,"children":326},{"style":246},[327],{"type":20,"value":328}," Math.",{"type":14,"tag":233,"props":330,"children":332},{"style":331},"--shiki-default:#B392F0",[333],{"type":20,"value":334},"floor",{"type":14,"tag":233,"props":336,"children":337},{"style":246},[338],{"type":20,"value":339},"(Date.",{"type":14,"tag":233,"props":341,"children":342},{"style":331},[343],{"type":20,"value":344},"now",{"type":14,"tag":233,"props":346,"children":347},{"style":246},[348],{"type":20,"value":349},"() ",{"type":14,"tag":233,"props":351,"children":352},{"style":240},[353],{"type":20,"value":354},"\u002F",{"type":14,"tag":233,"props":356,"children":357},{"style":282},[358],{"type":20,"value":359}," 1000",{"type":14,"tag":233,"props":361,"children":362},{"style":246},[363],{"type":20,"value":216},{"type":14,"tag":233,"props":365,"children":366},{"style":331},[367],{"type":20,"value":368},"toString",{"type":14,"tag":233,"props":370,"children":371},{"style":246},[372],{"type":20,"value":373},"()\n",{"type":14,"tag":233,"props":375,"children":377},{"class":235,"line":376},5,[378,382,387,391,395,400,404,409,414,419],{"type":14,"tag":233,"props":379,"children":380},{"style":240},[381],{"type":20,"value":279},{"type":14,"tag":233,"props":383,"children":384},{"style":282},[385],{"type":20,"value":386}," amount",{"type":14,"tag":233,"props":388,"children":389},{"style":240},[390],{"type":20,"value":290},{"type":14,"tag":233,"props":392,"children":393},{"style":246},[394],{"type":20,"value":157},{"type":14,"tag":233,"props":396,"children":397},{"style":282},[398],{"type":20,"value":399},"3",{"type":14,"tag":233,"props":401,"children":402},{"style":246},[403],{"type":20,"value":216},{"type":14,"tag":233,"props":405,"children":406},{"style":331},[407],{"type":20,"value":408},"toFixed",{"type":14,"tag":233,"props":410,"children":411},{"style":246},[412],{"type":20,"value":413},"(",{"type":14,"tag":233,"props":415,"children":416},{"style":282},[417],{"type":20,"value":418},"2",{"type":14,"tag":233,"props":420,"children":421},{"style":246},[422],{"type":20,"value":423},")\n",{"type":14,"tag":233,"props":425,"children":427},{"class":235,"line":426},6,[428,432,437,441,446,450,455,460],{"type":14,"tag":233,"props":429,"children":430},{"style":240},[431],{"type":20,"value":279},{"type":14,"tag":233,"props":433,"children":434},{"style":282},[435],{"type":20,"value":436}," signingString",{"type":14,"tag":233,"props":438,"children":439},{"style":240},[440],{"type":20,"value":290},{"type":14,"tag":233,"props":442,"children":443},{"style":257},[444],{"type":20,"value":445}," `M00001|ORD-20260428-001|${",{"type":14,"tag":233,"props":447,"children":448},{"style":246},[449],{"type":20,"value":206},{"type":14,"tag":233,"props":451,"children":452},{"style":257},[453],{"type":20,"value":454},"}|MYR|${",{"type":14,"tag":233,"props":456,"children":457},{"style":246},[458],{"type":20,"value":459},"timestamp",{"type":14,"tag":233,"props":461,"children":462},{"style":257},[463],{"type":20,"value":464},"}`\n",{"type":14,"tag":233,"props":466,"children":468},{"class":235,"line":467},7,[469,473,478,482,487,492,496,501,506,511,516,521,525,530],{"type":14,"tag":233,"props":470,"children":471},{"style":240},[472],{"type":20,"value":279},{"type":14,"tag":233,"props":474,"children":475},{"style":282},[476],{"type":20,"value":477}," signature",{"type":14,"tag":233,"props":479,"children":480},{"style":240},[481],{"type":20,"value":290},{"type":14,"tag":233,"props":483,"children":484},{"style":246},[485],{"type":20,"value":486}," crypto.",{"type":14,"tag":233,"props":488,"children":489},{"style":331},[490],{"type":20,"value":491},"createHmac",{"type":14,"tag":233,"props":493,"children":494},{"style":246},[495],{"type":20,"value":413},{"type":14,"tag":233,"props":497,"children":498},{"style":257},[499],{"type":20,"value":500},"'sha256'",{"type":14,"tag":233,"props":502,"children":503},{"style":246},[504],{"type":20,"value":505},", secret).",{"type":14,"tag":233,"props":507,"children":508},{"style":331},[509],{"type":20,"value":510},"update",{"type":14,"tag":233,"props":512,"children":513},{"style":246},[514],{"type":20,"value":515},"(signingString).",{"type":14,"tag":233,"props":517,"children":518},{"style":331},[519],{"type":20,"value":520},"digest",{"type":14,"tag":233,"props":522,"children":523},{"style":246},[524],{"type":20,"value":413},{"type":14,"tag":233,"props":526,"children":527},{"style":257},[528],{"type":20,"value":529},"'hex'",{"type":14,"tag":233,"props":531,"children":532},{"style":246},[533],{"type":20,"value":423},{"type":14,"tag":233,"props":535,"children":537},{"class":235,"line":536},8,[538],{"type":14,"tag":233,"props":539,"children":540},{"emptyLinePlaceholder":267},[541],{"type":20,"value":270},{"type":14,"tag":233,"props":543,"children":545},{"class":235,"line":544},9,[546],{"type":14,"tag":233,"props":547,"children":548},{"style":303},[549],{"type":20,"value":550},"\u002F\u002F headers: Authorization: `Bearer ${pk}`, 'X-Timestamp': timestamp, 'X-Signature': signature\n",{"type":14,"tag":140,"props":552,"children":554},{"id":553},"php",[555],{"type":20,"value":556},"PHP",{"type":14,"tag":177,"props":558,"children":561},{"code":559,"language":553,"meta":7,"className":560,"style":7},"\u003C?php\n$secret = getenv('SYOK2PAY_SECRET'); \u002F\u002F sk_...\n$timestamp = (string) time();\n$amount = number_format(3, 2, '.', ''); \u002F\u002F \"3.00\"\n$signingString = \"M00001|ORD-20260428-001|{$amount}|MYR|{$timestamp}\";\n$signature = hash_hmac('sha256', $signingString, $secret);\n\u002F\u002F Send Authorization: Bearer pk_..., X-Timestamp, X-Signature\n","language-php shiki shiki-themes github-dark",[562],{"type":14,"tag":61,"props":563,"children":564},{"__ignoreMap":7},[565,578,615,651,712,754,784],{"type":14,"tag":233,"props":566,"children":567},{"class":235,"line":236},[568,573],{"type":14,"tag":233,"props":569,"children":570},{"style":240},[571],{"type":20,"value":572},"\u003C?",{"type":14,"tag":233,"props":574,"children":575},{"style":282},[576],{"type":20,"value":577},"php\n",{"type":14,"tag":233,"props":579,"children":580},{"class":235,"line":263},[581,586,591,596,600,605,610],{"type":14,"tag":233,"props":582,"children":583},{"style":246},[584],{"type":20,"value":585},"$secret ",{"type":14,"tag":233,"props":587,"children":588},{"style":240},[589],{"type":20,"value":590},"=",{"type":14,"tag":233,"props":592,"children":593},{"style":282},[594],{"type":20,"value":595}," getenv",{"type":14,"tag":233,"props":597,"children":598},{"style":246},[599],{"type":20,"value":413},{"type":14,"tag":233,"props":601,"children":602},{"style":257},[603],{"type":20,"value":604},"'SYOK2PAY_SECRET'",{"type":14,"tag":233,"props":606,"children":607},{"style":246},[608],{"type":20,"value":609},"); ",{"type":14,"tag":233,"props":611,"children":612},{"style":303},[613],{"type":20,"value":614},"\u002F\u002F sk_...\n",{"type":14,"tag":233,"props":616,"children":617},{"class":235,"line":273},[618,623,627,631,636,641,646],{"type":14,"tag":233,"props":619,"children":620},{"style":246},[621],{"type":20,"value":622},"$timestamp ",{"type":14,"tag":233,"props":624,"children":625},{"style":240},[626],{"type":20,"value":590},{"type":14,"tag":233,"props":628,"children":629},{"style":246},[630],{"type":20,"value":157},{"type":14,"tag":233,"props":632,"children":633},{"style":240},[634],{"type":20,"value":635},"string",{"type":14,"tag":233,"props":637,"children":638},{"style":246},[639],{"type":20,"value":640},") ",{"type":14,"tag":233,"props":642,"children":643},{"style":282},[644],{"type":20,"value":645},"time",{"type":14,"tag":233,"props":647,"children":648},{"style":246},[649],{"type":20,"value":650},"();\n",{"type":14,"tag":233,"props":652,"children":653},{"class":235,"line":309},[654,659,663,668,672,676,681,685,689,694,698,703,707],{"type":14,"tag":233,"props":655,"children":656},{"style":246},[657],{"type":20,"value":658},"$amount ",{"type":14,"tag":233,"props":660,"children":661},{"style":240},[662],{"type":20,"value":590},{"type":14,"tag":233,"props":664,"children":665},{"style":282},[666],{"type":20,"value":667}," number_format",{"type":14,"tag":233,"props":669,"children":670},{"style":246},[671],{"type":20,"value":413},{"type":14,"tag":233,"props":673,"children":674},{"style":282},[675],{"type":20,"value":399},{"type":14,"tag":233,"props":677,"children":678},{"style":246},[679],{"type":20,"value":680},", ",{"type":14,"tag":233,"props":682,"children":683},{"style":282},[684],{"type":20,"value":418},{"type":14,"tag":233,"props":686,"children":687},{"style":246},[688],{"type":20,"value":680},{"type":14,"tag":233,"props":690,"children":691},{"style":257},[692],{"type":20,"value":693},"'.'",{"type":14,"tag":233,"props":695,"children":696},{"style":246},[697],{"type":20,"value":680},{"type":14,"tag":233,"props":699,"children":700},{"style":257},[701],{"type":20,"value":702},"''",{"type":14,"tag":233,"props":704,"children":705},{"style":246},[706],{"type":20,"value":609},{"type":14,"tag":233,"props":708,"children":709},{"style":303},[710],{"type":20,"value":711},"\u002F\u002F \"3.00\"\n",{"type":14,"tag":233,"props":713,"children":714},{"class":235,"line":376},[715,720,724,729,734,739,744,749],{"type":14,"tag":233,"props":716,"children":717},{"style":246},[718],{"type":20,"value":719},"$signingString ",{"type":14,"tag":233,"props":721,"children":722},{"style":240},[723],{"type":20,"value":590},{"type":14,"tag":233,"props":725,"children":726},{"style":257},[727],{"type":20,"value":728}," \"M00001|ORD-20260428-001|{",{"type":14,"tag":233,"props":730,"children":731},{"style":246},[732],{"type":20,"value":733},"$amount",{"type":14,"tag":233,"props":735,"children":736},{"style":257},[737],{"type":20,"value":738},"}|MYR|{",{"type":14,"tag":233,"props":740,"children":741},{"style":246},[742],{"type":20,"value":743},"$timestamp",{"type":14,"tag":233,"props":745,"children":746},{"style":257},[747],{"type":20,"value":748},"}\"",{"type":14,"tag":233,"props":750,"children":751},{"style":246},[752],{"type":20,"value":753},";\n",{"type":14,"tag":233,"props":755,"children":756},{"class":235,"line":426},[757,762,766,771,775,779],{"type":14,"tag":233,"props":758,"children":759},{"style":246},[760],{"type":20,"value":761},"$signature ",{"type":14,"tag":233,"props":763,"children":764},{"style":240},[765],{"type":20,"value":590},{"type":14,"tag":233,"props":767,"children":768},{"style":282},[769],{"type":20,"value":770}," hash_hmac",{"type":14,"tag":233,"props":772,"children":773},{"style":246},[774],{"type":20,"value":413},{"type":14,"tag":233,"props":776,"children":777},{"style":257},[778],{"type":20,"value":500},{"type":14,"tag":233,"props":780,"children":781},{"style":246},[782],{"type":20,"value":783},", $signingString, $secret);\n",{"type":14,"tag":233,"props":785,"children":786},{"class":235,"line":467},[787],{"type":14,"tag":233,"props":788,"children":789},{"style":303},[790],{"type":20,"value":791},"\u002F\u002F Send Authorization: Bearer pk_..., X-Timestamp, X-Signature\n",{"type":14,"tag":22,"props":793,"children":794},{},[795,797,803],{"type":20,"value":796},"Requests with an invalid signature return ",{"type":14,"tag":61,"props":798,"children":800},{"className":799},[],[801],{"type":20,"value":802},"401 Invalid signature",{"type":20,"value":804},".",{"type":14,"tag":806,"props":807,"children":808},"style",{},[809],{"type":20,"value":810},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":263,"depth":263,"links":812},[813,814,815],{"id":142,"depth":263,"text":145},{"id":219,"depth":263,"text":222},{"id":553,"depth":263,"text":556},"markdown","content:docs:2.authentication.md","content","docs\u002F2.authentication.md","docs\u002F2.authentication","md",[823,824,827,830,833,836,839,842,845],{"_path":4,"title":8},{"_path":825,"title":826},"\u002Fdocs\u002Fcallbacks","Callbacks",{"_path":828,"title":829},"\u002Fdocs\u002Fgetting-started","Getting started",{"_path":831,"title":832},"\u002Fdocs\u002Finitiate","Initiate",{"_path":834,"title":835},"\u002Fdocs\u002Finquiry","Inquiry",{"_path":837,"title":838},"\u002Fdocs\u002Frefund","Refund",{"_path":840,"title":841},"\u002Fdocs\u002Fstatus-codes","Status codes",{"_path":843,"title":844},"\u002Fdocs\u002Fvoid","Void",{"_path":846,"title":847},"\u002Fdocs\u002Fwoocommerce","WooCommerce",[849,850,851,852,853,854,855,856,857],{"_path":828,"title":829},{"_path":4,"title":8},{"_path":831,"title":832},{"_path":834,"title":835},{"_path":837,"title":838},{"_path":843,"title":844},{"_path":840,"title":841},{"_path":825,"title":826},{"_path":846,"title":847},1780230577965]