{
	"info": {
		"_postman_id": "95beddd1-7fb1-473c-a178-c5be5f58d444",
		"name": "[SNAP] Open API V2 Update",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "5512202"
	},
	"item": [
		{
			"name": "User-Management",
			"item": [
				{
					"name": "Lookup",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"var clientId = pm.environment.get(\"clientID\");\r",
									"var clientSecret = pm.environment.get(\"_secret_key\");\r",
									"function encodeURL(str){\r",
									"  return str.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/\\=+$/, '');\r",
									"}\r",
									"\r",
									"function decodeUrl(str){\r",
									"  str = (str + '===').slice(0, str.length + (str.length % 4));\r",
									"  return str.replace(/-/g, '+').replace(/_/g, '/');\r",
									"}\r",
									"\r",
									"var key = CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(clientSecret));\r",
									"\r",
									"var sdk = require('postman-collection');\r",
									"random = Math.round(new Date().getTime());\r",
									"var method = request.method.toUpperCase();\r",
									"var url = new sdk.Url(request.url);\r",
									"var url_string = url.getPathWithQuery();\r",
									"var urlParam = method + \" \" + url_string;\r",
									"\r",
									"var temp = JSON.stringify(request.data);\r",
									"var requestBody = '';\r",
									"var datarequestString =  JSON.stringify(request.data);\r",
									"if (method != 'GET' && datarequestString != '{}'){\r",
									"//var obj = JSON.parse(request.data);\r",
									"    requestBody = request.data;\r",
									"}\r",
									"var base64url = encodeURL(btoa(requestBody));\r",
									"var seed = clientId+random+urlParam+base64url;\r",
									"var hashedHmac = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(seed, key));\r",
									"\r",
									"// Add hmac values to environment\r",
									"pm.environment.set(\"api\", url_string);\r",
									"pm.environment.set(\"time\", random);\r",
									"pm.environment.set(\"signature\", hashedHmac);\r",
									"\r",
									"\r",
									"\r",
									"console.log('appId', clientId);\r",
									"console.log('url_string', url_string);\r",
									"console.log('b64', base64url);\r",
									"console.log('seed', seed);\r",
									"console.log('hashedHmac', hashedHmac);\r",
									"console.log('requestBody', requestBody);\r",
									"console.log('clientSecret', key);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "signature",
								"value": "{{signature}}"
							},
							{
								"key": "time",
								"value": "{{time}}"
							},
							{
								"key": "client-id",
								"value": "{{clientID}}"
							},
							{
								"key": "Content-type",
								"value": "application/json"
							}
						],
						"url": {
							"raw": "https://app.byte-stack.net/user/v2/account/lookup?phone=081212345678",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"user",
								"v2",
								"account",
								"lookup"
							],
							"query": [
								{
									"key": "phone",
									"value": "081212345678"
								}
							]
						}
					},
					"response": []
				},
				{
					"name": "Registration Account Binding",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the private key via environment variable with key as {clientID}_private_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.environment.get('pmlib_code') )\r",
									"\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID');\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const body = pm.request.body.raw.replace('{{merchantId}}',pm.environment.get('merchantId'))\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"var privateKey = pm.environment.get(\"_private_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"privateKey: \" + privateKey)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"var sig = new pmlib.rs.KJUR.crypto.Signature({\"alg\": \"SHA256withRSA\"})\r",
									"privateKey = pmlib.rs.KEYUTIL.getKey(privateKey)\r",
									"sig.init(privateKey)\r",
									"const hash = sig.signString(msg)\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\", fullPath)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = JSON.parse(responseBody);\r",
									"if (responseCode.code === 200) \r",
									"{    \r",
									"if (pm.environment.get(\"api\") == \"/OVOSNAP/v2.0/oauth/account/registration-account-binding\"){\r",
									"pm.environment.set(\"activation_webview\", jsonData.redirectUrl+\"?\"+\"authType=\"+jsonData.additionalInfo.qParams.authType+\"&submissionType=redirect&destination=\"+pm.environment.get(\"url-callback\")+\"&action=\"+jsonData.additionalInfo.qParams.action+\"&phoneNumber=\"+ jsonData.additionalInfo.qParams.phoneNumber +\"&refId=\"+ jsonData.additionalInfo.qParams.refId+\"&client-id=\"+pm.environment.get(\"clientID\")+\"&skipTnc=\"+ jsonData.additionalInfo.qParams.skipTnc+\"&token=\"+jsonData.linkageToken);\r",
									"pm.environment.set(\"payment_webview\",\"\");\r",
									"pm.environment.set(\"unlink_webview\",\"\");\r",
									"pm.environment.set(\"linkageToken\",jsonData.linkageToken)\r",
									"}\r",
									"}"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-SIGNATURE",
								"value": "{{gen_signature}}"
							},
							{
								"key": "X-PARTNER-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							},
							{
								"key": "X-TIMESTAMP",
								"value": "{{gen_timestamp}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"phoneNo\": \"081212345678\", \n    \"merchantId\" : \"{{merchantId}}\"\n    }"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/oauth/account/registration-account-binding",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"oauth",
								"account",
								"registration-account-binding"
							]
						}
					},
					"response": []
				},
				{
					"name": "B2B2C(Binding)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();\r",
									"if (pm.response.code === 200) {\r",
									"    if (pm.environment.get(\"api\") == \"/OVOSNAP/v2.0/access-token/b2b2c\") {\r",
									"        pm.environment.set(\"accessToken\", jsonData.accessToken);\r",
									"        pm.environment.set(\"refreshToken\", jsonData.refreshToken);\r",
									"        pm.environment.set(\"singleUseToken\", \"\");\r",
									"        pm.environment.set(\"b2b_accessToken\", \"\");\r",
									"    }\r",
									"}\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-client-key.\r",
									"- Configure the private key via environment variable with key as {clientID}_private_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.environment.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"\r",
									"const clientID = pm.environment.get(\"clientID\")\r",
									"var privateKey = pm.environment.get(\"_private_key\")\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"privateKey: \" + privateKey)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"\r",
									"const msg = `${clientID}|${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"var sig = new pmlib.rs.KJUR.crypto.Signature({\"alg\": \"SHA256withRSA\"})\r",
									"privateKey = pmlib.rs.KEYUTIL.getKey(privateKey)\r",
									"sig.init(privateKey)\r",
									"const hash = sig.signString(msg)\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\", \"/OVOSNAP/v2.0/access-token/b2b2c\")\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-Signature",
								"value": "{{gen_signature}}"
							},
							{
								"key": "X-Timestamp",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-Client-Key",
								"value": "{{clientID}}"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{linkageToken}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"grantType\" : \"authorization_code\",\n    \"authCode\" : \"Lm_6OcQ2Rl29EL5RRxn4Ag\"\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/access-token/b2b2c",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"access-token",
								"b2b2c"
							]
						}
					},
					"response": []
				},
				{
					"name": "B2B2C(Refresh)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();\r",
									"if (pm.response.code === 200)\r",
									"{    \r",
									"if (pm.environment.get(\"api\") == \"/OVOSNAP/v1.0/access-token/b2b2c\"){\r",
									"        pm.environment.set(\"accessToken\",jsonData.accessToken);\r",
									"        \r",
									"}\r",
									"}\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-client-key.\r",
									"- Configure the private key via environment variable with key as {clientID}_private_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.environment.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"\r",
									"const clientID = pm.environment.get(\"clientID\")\r",
									"var privateKey = pm.environment.get(\"_private_key\")\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"privateKey: \" + privateKey)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"\r",
									"const msg = `${clientID}|${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"const hashedMsg = CryptoJS.SHA256(msg)\r",
									"console.log(\"hashedMsg: \" + hashedMsg)\r",
									"\r",
									"var sig = new pmlib.rs.KJUR.crypto.Signature({\"alg\": \"SHA256withRSA\"})\r",
									"privateKey = pmlib.rs.KEYUTIL.getKey(privateKey)\r",
									"sig.init(privateKey)\r",
									"const hash = sig.signString(msg)\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"pm.environment.set(\"api\",fullPath)\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"\r",
									"\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-Signature",
								"value": "{{gen_signature}}"
							},
							{
								"key": "X-Timestamp",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-Client-Key",
								"value": "{{clientID}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"grantType\" : \"refresh_token\",\n    \"refreshToken\" : \"{{refreshToken}}\"\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/access-token/b2b2c",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"access-token",
								"b2b2c"
							]
						}
					},
					"response": []
				},
				{
					"name": "Registration Account Unbinding",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the access token via request headers with key as Authorization and format of value as Bearer {access_token}.\r",
									"- Configure the secret key via environment variable with key as {clientID}_secret_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.environment.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID');\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const body = pm.request.body.raw.replace('{{merchantId}}',pm.environment.get('merchantId'))\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"pm.environment.set(\"Authorization\", pm.request.headers.get('Authorization'));\r",
									"const dataAccessToken = pm.environment.get('accessToken')\r",
									"const dataLinkageToken = pm.environment.get('linkageToken')\r",
									" var accessToken;\r",
									"if (pm.environment.get('Authorization') == \"Bearer {{accessToken}}\"){\r",
									"     accessToken = dataAccessToken;\r",
									"} else {\r",
									" accessToken = dataLinkageToken;\r",
									"}\r",
									"\r",
									"var secret_key = pm.environment.get(\"_secret_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"accessToken: \" + accessToken)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"secret_key: \" + secret_key)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${accessToken}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"const hash = CryptoJS.HmacSHA512(msg, secret_key).toString()\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\", fullPath)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-Signature",
								"value": "{{gen_signature}}"
							},
							{
								"key": "X-Timestamp",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-Partner-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{accessToken}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "test1111"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"partnerReferenceNo\" : \"081212345678\",\n    \"merchantId\" : \"{{merchantId}}\"\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/oauth/account/registration-account-unbinding",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"oauth",
								"account",
								"registration-account-unbinding"
							]
						}
					},
					"response": []
				},
				{
					"name": "Generate Token",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();\r",
									"if (pm.response.code === 200)\r",
									"{    \r",
									"if(pm.environment.get(\"api\") == \"/user/v1/oauth/token?grantType=authorization_code&code=\"+pm.request.url.query.get(\"code\")){\r",
									"         if(jsonData.tokens[0].nameToken == \"SingleUseToken\"){\r",
									"        pm.environment.set(\"singleUseToken\", jsonData.tokens[0].accessToken);\r",
									"         }\r",
									"        if(jsonData.tokens[0].nameToken == \"unbindToken\"){\r",
									"            pm.environment.set(\"unbindToken\", jsonData.tokens[0].accessToken);\r",
									"        }\r",
									"    \r",
									"}\r",
									"}\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"var clientId = pm.environment.get(\"clientID\");\r",
									"var clientSecret = pm.environment.get(\"_secret_key\");\r",
									"\r",
									"function encodeURL(str) {\r",
									"    return str.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/\\=+$/, '');\r",
									"}\r",
									"\r",
									"function decodeUrl(str) {\r",
									"    str = (str + '===').slice(0, str.length + (str.length % 4));\r",
									"    return str.replace(/-/g, '+').replace(/_/g, '/');\r",
									"}\r",
									"\r",
									"var key = CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(clientSecret));\r",
									"\r",
									"var sdk = require('postman-collection');\r",
									"var random = Math.round(new Date().getTime());\r",
									"var method = request.method.toUpperCase();\r",
									"var url = new sdk.Url(request.url);\r",
									"var url_string = url.getPathWithQuery();\r",
									"var urlParam = method + \" \" + url_string;\r",
									"\r",
									"var temp = JSON.stringify(request.data);\r",
									"var requestBody = '';\r",
									"var datarequestString = JSON.stringify(request.data);\r",
									"if (method != 'GET' && datarequestString != '{}') {\r",
									"    requestBody = request.data;\r",
									"}\r",
									"var base64url = encodeURL(btoa(requestBody));\r",
									"var seed = clientId + random + urlParam + base64url;\r",
									"var hashedHmac = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(seed, key));\r",
									"\r",
									"// Add hmac values to environment\r",
									"pm.environment.set(\"api\", url_string);\r",
									"pm.environment.set(\"client-id\", clientId);\r",
									"pm.environment.set(\"time\", random);\r",
									"pm.environment.set(\"signature\", hashedHmac);\r",
									"\r",
									"console.log('appId', clientId);\r",
									"console.log('url_string', url_string);\r",
									"console.log('b64', base64url);\r",
									"console.log('seed', seed);\r",
									"console.log('hashedHmac', hashedHmac);\r",
									"console.log('requestBody', requestBody);\r",
									"console.log('clientSecret', key);"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{accessToken}}"
							},
							{
								"key": "time",
								"value": "{{time}}"
							},
							{
								"key": "signature",
								"value": "{{signature}}"
							},
							{
								"key": "client-id",
								"value": "{{clientID}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": ""
						},
						"url": {
							"raw": "https://app.byte-stack.net/user/v1/oauth/token?grantType=authorization_code&code=go3KlA2HSGus6s-RxsbU_Q",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"user",
								"v1",
								"oauth",
								"token"
							],
							"query": [
								{
									"key": "grantType",
									"value": "authorization_code"
								},
								{
									"key": "code",
									"value": "go3KlA2HSGus6s-RxsbU_Q"
								}
							]
						}
					},
					"response": []
				},
				{
					"name": "Token Migration",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = JSON.parse(responseBody);\r",
									"if (responseCode.code === 200) \r",
									"{    \r",
									"if(pm.environment.get(\"api\") == \"/v1/oauth/token/linkageMigrate?grantType=authorization_code\"){\r",
									"        pm.environment.set(\"accessToken\", jsonData.tokens.access_token);\r",
									"         }\r",
									"       \r",
									"}"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"var clientId = pm.environment.get(\"clientID\");\r",
									"var clientSecret = pm.environment.get(\"_secret_key\");\r",
									"function encodeURL(str){\r",
									"  return str.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/\\=+$/, '');\r",
									"}\r",
									"\r",
									"function decodeUrl(str){\r",
									"  str = (str + '===').slice(0, str.length + (str.length % 4));\r",
									"  return str.replace(/-/g, '+').replace(/_/g, '/');\r",
									"}\r",
									"\r",
									"var key = CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(clientSecret));\r",
									"\r",
									"var sdk = require('postman-collection');\r",
									"random = Math.round(new Date().getTime());\r",
									"var method = request.method.toUpperCase();\r",
									"var url = new sdk.Url(request.url);\r",
									"var url_string = url.getPathWithQuery();\r",
									"var urlParam = method + \" \" + url_string;\r",
									"\r",
									"var temp = JSON.stringify(request.data);\r",
									"var requestBody = '';\r",
									"var datarequestString =  JSON.stringify(request.data);\r",
									"if (method != 'GET' && datarequestString != '{}'){\r",
									"//var obj = JSON.parse(request.data);\r",
									"    requestBody = request.data;\r",
									"}\r",
									"var base64url = encodeURL(btoa(requestBody));\r",
									"var seed = clientId+random+urlParam+base64url;\r",
									"var hashedHmac = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(seed, key));\r",
									"\r",
									"// Add hmac values to environment\r",
									"pm.environment.set(\"api\", url_string);\r",
									"pm.environment.set(\"time\", random);\r",
									"pm.environment.set(\"signature\", hashedHmac);\r",
									"\r",
									"\r",
									"\r",
									"console.log('appId', clientId);\r",
									"console.log('url_string', url_string);\r",
									"console.log('b64', base64url);\r",
									"console.log('seed', seed);\r",
									"console.log('hashedHmac', hashedHmac);\r",
									"console.log('requestBody', requestBody);\r",
									"console.log('clientSecret', key);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{paymentToken}}"
							},
							{
								"key": "time",
								"value": "{{time}}"
							},
							{
								"key": "signature",
								"value": "{{signature}}"
							},
							{
								"key": "client-id",
								"value": "{{clientID}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": ""
						},
						"url": {
							"raw": "https://app.byte-stack.net/v1/oauth/token/linkageMigrate?grantType=authorization_code",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"v1",
								"oauth",
								"token",
								"linkageMigrate"
							],
							"query": [
								{
									"key": "grantType",
									"value": "authorization_code"
								}
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Payment",
			"item": [
				{
					"name": "Balance Inquiry",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the access token via request headers with key as Authorization and format of value as Bearer {access_token}.\r",
									"- Configure the secret key via environment variable with key as {clientID}_secret_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.globals.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID');\r",
									"const accessToken = pm.environment.get(\"accessToken\");\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const body = pm.request.body.raw\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"var secret_key = pm.environment.get(\"_secret_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"accessToken: \" + accessToken)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"secret_key: \" + secret_key)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${accessToken}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"const hash = CryptoJS.HmacSHA512(msg, secret_key).toString()\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-Partner-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "X-TIMESTAMP",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-SIGNATURE",
								"value": "{{gen_signature}}"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{accessToken}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"accountNo\":\"081212345678\"\n    \n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/balance-inquiry",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"balance-inquiry"
							]
						}
					},
					"response": []
				},
				{
					"name": "Direct Debit Payment",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();\r",
									"if (pm.response.code === 200)\r",
									"{    \r",
									"if (pm.environment.get(\"api\") == \"/OVOSNAP/v2.0/debit/payment-host-to-host\"){\r",
									"\r",
									"pm.environment.set(\"payment_webview\", jsonData.webRedirectUrl+\"?\"+\"action=\"+jsonData.additionalInfo.action+\"&clientTxnId=\"+jsonData.additionalInfo.clientTxnId+\"&submissionType=redirect&destination=\"+pm.environment.get(\"url-callback\")+\"&client-id=\"+pm.environment.get(\"clientID\")+\"&token=\"+pm.environment.get(\"accessToken\"));\r",
									"\r",
									"}\r",
									"}"
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the access token via request headers with key as Authorization and format of value as Bearer {access_token}.\r",
									"- Configure the secret key via environment variable with key as {clientID}_secret_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.globals.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID')\r",
									"\r",
									"\r",
									"pm.environment.set(\"Authorization\", pm.request.headers.get('Authorization'));\r",
									"const dataAccessToken = pm.environment.get('accessToken')\r",
									"const dataSingleUseToken = pm.environment.get('singleUseToken')\r",
									" var accessToken;\r",
									"if (pm.environment.get('Authorization') == \"Bearer {{accessToken}}\"){\r",
									"     accessToken = dataAccessToken;\r",
									"} else {\r",
									" accessToken = dataSingleUseToken;\r",
									"}\r",
									"\r",
									"\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"let body\r",
									"body = pm.request.body.raw.replace('{{merchantId}}',pm.environment.get('merchantId'))\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"var secret_key = pm.environment.get(\"_secret_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"accessToken1 : \" + accessToken)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"secret_key: \" + secret_key)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${accessToken}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"const hash = CryptoJS.HmacSHA512(msg, secret_key).toString()\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"console.log(\"test 12: \" + pm.request.headers.get('Authorization'))\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\",fullPath)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-PARTNER-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "X-TIMESTAMP",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-SIGNATURE",
								"value": "{{gen_signature}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{accessToken}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"partnerReferenceNo\": \"PayTest47451233\",\n    \"chargeToken\": \"OVO\",\n    \"merchantId\": \"{{merchantId}}\",\n    \"amount\": {\n        \"value\": \"10000.00\",\n        \"currency\": \"IDR\"\n    },\n    \"payOptionDetails\":\n    [{\n            \"payMethod\": \"CASH\",\n            \"payOption\" : \"OVO\",\n            \"transAmount\": {\n                \"value\": \"10000.00\",\n                \"currency\": \"IDR\"\n            }\n        }\n    ]\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/debit/payment-host-to-host",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"debit",
								"payment-host-to-host"
							]
						}
					},
					"response": []
				},
				{
					"name": "Direct Debit Payment - AUTO",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the access token via request headers with key as Authorization and format of value as Bearer {access_token}.\r",
									"- Configure the secret key via environment variable with key as {clientID}_secret_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.globals.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID')\r",
									"\r",
									"\r",
									"pm.environment.set(\"Authorization\", pm.request.headers.get('Authorization'));\r",
									"const dataAccessToken = pm.environment.get('accessToken')\r",
									"const dataSingleUseToken = pm.environment.get('singleUseToken')\r",
									" var accessToken;\r",
									"if (pm.environment.get('Authorization') == \"Bearer {{accessToken}}\"){\r",
									"     accessToken = dataAccessToken;\r",
									"} else {\r",
									" accessToken = dataSingleUseToken;\r",
									"}\r",
									"\r",
									"\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"let body\r",
									"body = pm.request.body.raw.replace('{{merchantId}}',pm.environment.get('merchantId'))\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"var secret_key = pm.environment.get(\"_secret_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"accessToken1 : \" + accessToken)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"secret_key: \" + secret_key)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${accessToken}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"const hash = CryptoJS.HmacSHA512(msg, secret_key).toString()\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"console.log(\"test 12: \" + pm.request.headers.get('Authorization'))\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\",fullPath)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-PARTNER-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "X-TIMESTAMP",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-SIGNATURE",
								"value": "{{gen_signature}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "external-id11"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{accessToken}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"partnerReferenceNo\": \"PayTest4764512633\",\n    \"chargeToken\": \"OVO\",\n    \"merchantId\": \"{{merchantId}}\",\n    \"amount\": {\n        \"value\": \"10000.00\",\n        \"currency\": \"IDR\"\n    },\n    \"payOptionDetails\":\n    [{\n            \"payMethod\": \"CASH\",\n            \"payOption\" : \"OVO\",\n            \"transAmount\": {\n                \"value\": \"10000.00\",\n                \"currency\": \"IDR\"\n            }\n        }\n    ], \n    \"additionalInfo\": {\"subTransactionType\": \"AUTO\"}\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/debit/payment-host-to-host",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"debit",
								"payment-host-to-host"
							]
						}
					},
					"response": []
				},
				{
					"name": "Direct Debit - Check Status",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the access token via request headers with key as Authorization and format of value as Bearer {access_token}.\r",
									"- Configure the secret key via environment variable with key as {clientID}_secret_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.environment.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID');\r",
									"const accessToken = pm.environment.get('accessToken');\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const body = pm.request.body.raw\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"var secret_key = pm.environment.get(\"_secret_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"b2b_accessToken: \" + accessToken)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"secret_key: \" + secret_key)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${accessToken}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"const hash = CryptoJS.HmacSHA512(msg, secret_key).toString()\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-PARTNER-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "X-TIMESTAMP",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-SIGNATURE",
								"value": "{{gen_signature}}"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{accessToken}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"originalPartnerReferenceNo\": \"Paytest300\",\n    \"serviceCode\": \"55\"\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/debit/status",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"debit",
								"status"
							]
						}
					},
					"response": []
				},
				{
					"name": "Get Access Token B2B",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();\r",
									"if (pm.response.code === 200)\r",
									"{    \r",
									"if(pm.environment.get(\"api\") == \"/OVOSNAP/v1.0/access-token/b2b\"){\r",
									"        pm.environment.set(\"b2b_accessToken\", jsonData.accessToken);\r",
									"        \r",
									"}\r",
									"}\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						},
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-client-key.\r",
									"- Configure the private key via environment variable with key as {clientID}_private_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.environment.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"\r",
									"const clientID = pm.environment.get(\"clientID\")\r",
									"var privateKey = pm.environment.get(\"_private_key\")\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"privateKey: \" + privateKey)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"\r",
									"const msg = `${clientID}|${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"const hashedMsg = CryptoJS.SHA256(msg)\r",
									"console.log(\"hashedMsg: \" + hashedMsg)\r",
									"\r",
									"var sig = new pmlib.rs.KJUR.crypto.Signature({\"alg\": \"SHA256withRSA\"})\r",
									"privateKey = pmlib.rs.KEYUTIL.getKey(privateKey)\r",
									"sig.init(privateKey)\r",
									"const hash = sig.signString(msg)\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\",fullPath)\r",
									""
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "x-client-key",
								"value": "{{clientID}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-Signature",
								"value": "{{gen_signature}}"
							},
							{
								"key": "x-Timestamp",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"grantType\" : \"client_credentials\"\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v1.0/access-token/b2b",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v1.0",
								"access-token",
								"b2b"
							]
						}
					},
					"response": []
				},
				{
					"name": "Direct Debit - Refund",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"/*\r",
									"How to use:\r",
									"- Configure the client ID via request headers with key as x-partner-id.\r",
									"- Configure the access token via request headers with key as Authorization and format of value as Bearer {access_token}.\r",
									"- Configure the secret key via environment variable with key as {clientID}_secret_key.\r",
									"- Script will generate / replace environment variables listed in the Output section.\r",
									"\r",
									"Output (Environment variables):\r",
									"- gen_signature -> add to X-Signature headers\r",
									"- gen_timestamp -> add to X-Timestamp headers\r",
									"*/\r",
									"eval( pm.globals.get('pmlib_code') )\r",
									"\r",
									"var moment = require('moment')\r",
									"var CryptoJS = require(\"crypto-js\")\r",
									"\r",
									"const clientID = pm.environment.get('clientID')\r",
									"const accessToken = pm.environment.get('b2b_accessToken');\r",
									"const timestamp = moment().format(\"YYYY-MM-DDThh:mm:ss.SSSZ\")\r",
									"const body = pm.request.body.raw\r",
									"const fullPath = pm.request.url.getPathWithQuery()\r",
									"const method = pm.request.method\r",
									"\r",
									"var secret_key = pm.environment.get(\"_secret_key\")\r",
									"\r",
									"console.log(\"clientID: \" + clientID)\r",
									"console.log(\"accessToken: \" + accessToken)\r",
									"console.log(\"timestamp: \" + timestamp)\r",
									"console.log(\"body: \" + body)\r",
									"console.log(\"fullPath: \" + fullPath)\r",
									"console.log(\"method: \" + method)\r",
									"console.log(\"secret_key: \" + secret_key)\r",
									"\r",
									"const hashedBody = CryptoJS.SHA256(body).toString()\r",
									"const finalBody = hashedBody.toLowerCase()\r",
									"\r",
									"console.log(\"hashedBody: \" + hashedBody)\r",
									"console.log(\"finalBody: \" + finalBody)\r",
									"\r",
									"const msg = `${method}:${fullPath}:${accessToken}:${finalBody}:${timestamp}`\r",
									"\r",
									"console.log(\"msg: \" + msg)\r",
									"\r",
									"const hash = CryptoJS.HmacSHA512(msg, secret_key).toString()\r",
									"\r",
									"console.log(\"hash: \" + hash)\r",
									"\r",
									"function randomString(minValue, maxValue, dataSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ') {\r",
									"    if (!minValue) {\r",
									"        minValue = 20;\r",
									"        maxValue = 20;\r",
									"    }\r",
									"\r",
									"    if (!maxValue) {\r",
									"        maxValue = minValue;\r",
									"    }\r",
									"\r",
									"    let length = _.random(minValue, maxValue),\r",
									"        randomString = \"\";\r",
									"\r",
									"    for (let i = 0; i < length; i++)\r",
									"        randomString += dataSet.charAt(Math.floor(Math.random() * dataSet.length));\r",
									"    return randomString;\r",
									"}\r",
									"\r",
									"pm.environment.set('random_xternalid', randomString());\r",
									"pm.environment.set(\"gen_timestamp\", timestamp)\r",
									"pm.environment.set(\"gen_signature\", hash)\r",
									"pm.environment.set(\"api\",fullPath)"
								],
								"type": "text/javascript",
								"packages": {}
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "X-PARTNER-ID",
								"value": "{{clientID}}"
							},
							{
								"key": "X-TIMESTAMP",
								"value": "{{gen_timestamp}}"
							},
							{
								"key": "X-SIGNATURE",
								"value": "{{gen_signature}}"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{b2b_accessToken}}"
							},
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "X-EXTERNAL-ID",
								"value": "{{random_xternalid}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n    \"partnerRefundNo\": \"PayTest471233-R1\",\n    \"originalPartnerReferenceNo\": \"PayTest471233\",\n    \"refundAmount\": {\n        \"value\": \"2000.00\",\n        \"currency\": \"IDR\"\n    },\n    \"additionalInfo\":{\n        \"sof\" : [ \n         {\n              \"accType\": \"CASH\",\n              \"amt\": {\n                     \"value\": \"2000.00\",\n                      \"currency\": \"IDR\"\n              }\n          }\n   ]\n    }\n}"
						},
						"url": {
							"raw": "https://app.byte-stack.net/OVOSNAP/v2.0/debit/refund",
							"protocol": "https",
							"host": [
								"app",
								"byte-stack",
								"net"
							],
							"path": [
								"OVOSNAP",
								"v2.0",
								"debit",
								"refund"
							]
						}
					},
					"response": []
				}
			]
		}
	]
}