{
	"info": {
		"_postman_id": "78874a4c-d1f8-440e-996f-be17eedbbf80",
		"name": "Spreedly -> Airwallex",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "13361263"
	},
	"item": [
		{
			"name": "Spreedly 3DS2 Global",
			"item": [
				{
					"name": "Create Merchant Profile",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var merchant_profile=JSON.parse(responseBody);",
									"pm.environment.set(\"sandbox_merchant_profile\", merchant_profile.merchant_profile.token);",
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"merchant_profile\": {\n    \"visa\": {\n      \"acquirer_merchant_id\": \"spreedlys_mid\",\n      \"merchant_name\": \"Spreedly\",\n      \"country_code\": \"840\",\n      \"mcc\": \"5978\"\n    },\n    \"mastercard\": {\n      \"acquirer_merchant_id\": \"spreedlys_mid\",\n      \"merchant_name\": \"Spreedly\",\n      \"country_code\": \"840\",\n      \"mcc\": \"5978\"\n    },\n    \"amex\": {\n      \"acquirer_merchant_id\": \"spreedlys_mid\",\n      \"merchant_name\": \"Spreedly\",\n      \"country_code\": \"840\",\n      \"mcc\": \"5978\"\n    }\n  }\n}\n",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base}}/v1/merchant_profiles.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"merchant_profiles.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Create Sandbox Spreedly SCA Provider",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var sca_provider=JSON.parse(responseBody);",
									"pm.environment.set(\"sandbox_sca_provider\", sca_provider.sca_provider.token);",
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"sca_provider\": {\n    \"merchant_profile_key\": \"{{sandbox_merchant_profile}}\",\n    \"type\": \"test\",\n    \"sandbox\": true,\n    \"mastercard\": {\n        \"acquirer_bin\": \"4444444444\",\n        \"merchant_url\": \"https://spreedly.com\",\n        \"merchant_password\": \"password\",\n        \"three_ds_requestor_name\": \"Spreedly\"\n    },\n    \"visa\": {\n        \"acquirer_bin\": \"4444444444\",\n        \"merchant_url\": \"https://spreedly.com\",\n        \"merchant_password\": \"password\",\n        \"three_ds_requestor_name\": \"Spreedly\"\n    },\n    \"amex\": {\n        \"acquirer_bin\": \"4444444444\",\n        \"merchant_url\": \"https://spreedly.com\",\n        \"merchant_password\": \"password\",\n        \"three_ds_requestor_name\": \"Spreedly\"\n    }\n  }\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base}}/v1/sca/providers.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"sca",
								"providers.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Create Payment Method - Spreedly SCA Provider",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var paymentMethod=JSON.parse(responseBody);",
									"pm.environment.set(\"spreedly_sca_pm\", paymentMethod.transaction.payment_method.token);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"payment_method\": {\n\t\"credit_card\": {\n    \t\"address1\": \"33 Lane Road\",\n      \"address2\": \"Apartment 4\",\n      \"city\": \"Wanaque\",\n      \"state\": \"NJ\",\n      \"zip\": \"31331\",\n      \"country\": \"UK\",\n      \"first_name\": \"Joe\",\n      \"last_name\": \"Smith\",\n      \"number\": \"5555555555554444\",\n      \"verification_value\": \"123\",\n      \"month\": \"10\",\n      \"year\": \"2029\"\n    },\n    \"retained\": true\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/payment_methods.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"payment_methods.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Purchase - 3DS Frictionless",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"// ***************** Post Stack ***************************",
									"// See https://github.com/spreedly/post-stack",
									"",
									"",
									"// if not set, point to Heroku-based instsance. ",
									"poststack_base_url = pm.environment.get(\"poststack_base_url\")",
									"",
									"if (poststack_base_url == '' || poststack_base_url.match('https://post-stack') != null || poststack_base_url == null) {",
									"  poststack_base_url = \"https://spreedly-post-stack.herokuapp.com\"",
									"  pm.environment.set(\"poststack_base_url\", poststack_base_url)",
									"}",
									"",
									"pm.environment.set(\"poststack_redirect_url\", \"{{poststack_base_url}}/index.html?fin=true&thisisfun=true\")",
									"",
									"// ***************** Browser Info utils ***************************",
									"",
									"browserInfo = {",
									"  \"width\": 2133,",
									"  \"height\": 1200,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"05\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"",
									"browserInfoWorldPay = {",
									"  \"width\": 390,",
									"  \"height\": 400,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"01\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browserInfoFallbackBrowser = {",
									"  \"width\": 0,",
									"  \"height\": 0,",
									"  \"depth\": -1,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly 3DS Debugging\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"04\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browser_info = btoa(JSON.stringify(browserInfo))",
									"pm.environment.set(\"browser_info\", browser_info)",
									"",
									"browser_info_wp = btoa(JSON.stringify(browserInfoWorldPay))",
									"pm.environment.set(\"browser_info_wp\", browser_info)",
									"",
									"browser_info_fallback = btoa(JSON.stringify(browserInfoFallbackBrowser))",
									"pm.environment.set(\"browser_info_fallback\", browser_info_fallback)",
									"",
									"",
									"console.log(`browser_info = ${browser_info}`)",
									"console.log(`browser_info_fallback = ${browser_info_fallback}`)",
									"",
									"console.log(`poststack_base_url = ${poststack_base_url}`)",
									"",
									"// ***************** Post Stack ***************************"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Provides general info about this script. Useful for various loading tricks...",
									"",
									"const RELEASE_VERSION=\"v2022.04.28.1539\"",
									"",
									"const postStackInfo = {",
									"  \"app\": \"post-stack\",",
									"  \"version\": RELEASE_VERSION",
									"}",
									"",
									"// See https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-visualizations",
									"const template = `",
									"      <base href=\"{{poststack_base_url}}/\"/>",
									"<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css\">",
									"<script src=\"https://cdn.tailwindcss.com\"></script>",
									"<script src=\"https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js\"></script>",
									"<!-- Pass todays unix date to ensure we do not cache tests.js -->",
									"<script src=\"postman-templates/tests.js?d={{unixDate}}\"></script>",
									"<script src=\"versioning.js?d={{unixDate}}\"></script>",
									"<div class=\"md:container md:mx-auto\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"<div>",
									"    <div id=\"versionWarning\" style=\"display:none\">",
									"        <i class=\"bi bi-exclamation-triangle\"></i>WARNING<i class=\"bi bi-exclamation-triangle\"></i>",
									"        Your PostStack version {{poststack_version}} is outdated <strong>pre-request</strong> and <strong>tests</strong> scripts are outdated.<br/><br/>",
									"        Update to latest PostStack in <strong>main</strong> branch .",
									"        <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"        <br/><br/>",
									"        <br/><br/>",
									"    </div>",
									"    <div>",
									"      <span class=\"btn-clipboard\" data-clipboard-target=\"#poststackUrlInput\" type=\"button\" title=\"Copy to clipboard\">",
									"        <button",
									"          class=\"inline-flex items-center h-15 px-25 text-sky-100 transition-colors duration-150 bg-sky-500 rounded-lg focus:shadow-outline hover:bg-sky-600\">Click",
									"          to Copy Challenge URL into Clipboard",
									"          <i id=\"clipboard_copy_btn\" class=\"bi bi-clipboard\"></i>",
									"        </button>",
									"      </span>",
									"    </div>",
									"    ",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      Challenge URL: <code id=\"poststackUrlInput\">",
									"          {{poststackUrl}}",
									"      </code>",
									"    </div>",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      <i class=\"bi bi-broadcast\"></i>&nbsp;",
									"      <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"      |",
									"      envKey: {{envKey}}",
									"      | ",
									"       poststack_version: {{poststack_version}}",
									"    </div>",
									"</div>",
									"<script type=\"text/javascript\">",
									"  /*",
									"   * Does the version of PostStack in {poststack_base_url}} match the script in PostMan calling it?",
									"   */",
									"  checkVersion(postStackInfo, \"{{poststack_version}}\")",
									"  clipboard = new ClipboardJS('.btn-clipboard');",
									"  clipboard.on('success', function (e) {",
									"    document.getElementById(\"clipboard_copy_btn\").className = \"bi bi-clipboard-check\"",
									"    e.clearSelection();",
									"  });",
									"</script>",
									"      `;",
									"",
									"/**",
									" * Renders the PostStack Helper UI if we detect the script us running inside Postman.",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" *",
									" */",
									"function detectPostman(pm) {",
									"  // don't run if postman's pm is not available",
									"  if (pm == null || pm.response == null) {",
									"    return;",
									"  }",
									"",
									"  console.log(\"Postman detected. Running Post-Stack\")",
									"  const isJson = pm.response.headers.get('Content-Type') != null && pm.response.headers.get('Content-Type').includes('application/json')",
									"  const envKey = pm.environment.get('environment');",
									"",
									"",
									"  if (isJson) {",
									"    console.log(\"Parsing JSON Response...\")",
									"    const jsonResponse = pm.response.json()",
									"",
									"    if (jsonResponse.transaction) {",
									"      pm.environment.set(\"transaction_token\", jsonResponse.transaction.token)",
									"    }",
									"",
									"    // ********************* LifecycleJS Launcher **********************",
									"",
									"",
									"    if (jsonResponse.transaction) {",
									"      token = jsonResponse.transaction.token",
									"      transaction_type = jsonResponse.transaction.transaction_type",
									"",
									"      switch (transaction_type) {",
									"        case \"Authorization\":",
									"        case \"Sca::Authentication\":",
									"        case \"Purchase\":",
									"          displayPostStack(pm, jsonResponse, envKey);",
									"          break;",
									"        default:",
									"          pm.visualizer.set(`PostStack 3DS Flow not available for '{{transaction_type}}' Transactions `, { transaction_type: transaction_type });",
									"      }",
									"    }",
									"  }",
									"}",
									"",
									"",
									"/**",
									" * Renders the PostStack Helper UI, passing in all parameters expected by the mustache template",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" * @param {Object} jsonResponse - the response returned by Core",
									" * @param {String} envKey - the environment key configured in PostMan via pm.environment.get('environment');",
									" *",
									" * @returns {string} a base64 encoded JSON string of the output from `detect`",
									" * @memberOf module:ThreeDS",
									" */",
									"function displayPostStack(pm, jsonResponse, envKey) {",
									"  checkout_form_param = \"\"",
									"  challenge_form_param = \"\"",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.checkout_form) {",
									"    form = jsonResponse.transaction.sca_authentication.checkout_form.cdata",
									"    checkout_form_param = `&checkout_form=${escape(form)}`",
									"    console.table(jsonResponse.transaction.sca_authentication)",
									"    console.log(`${form}, checkout_form '${checkout_form_param}'`)",
									"  }",
									"",
									"  // TODO: figure out the real usage behind challenge_form and checkout_form ",
									"  // this is a quick and dirty hack to allow the flow to complete with current PostStack logic",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.challenge_form) {",
									"    form = jsonResponse.transaction.sca_authentication.challenge_form",
									"    challenge_form_param = `&challenge_form=${escape(form)}`",
									"    console.log(`${form}, challenge_form '${challenge_form_param}'`)",
									"  }",
									"",
									"  if (jsonResponse.transaction.state !== 'pending') {",
									"    template = `Transaction NOT in Pending state. Review and try again.`",
									"  }",
									"",
									"  // left side is the postman-specific JS variable, right side is the environment injected value",
									"  poststack_base_url = pm.environment.get('poststack_base_url');",
									"  core_url = pm.environment.get('base_url') || pm.environment.get('base');",
									"  iframe_url = \"http://localhost:8000\"",
									"  iframe_version = \"1.74.min.js\"",
									"",
									"  if (/.*\\.spreedly\\.com/.test(core_url)) {",
									"    iframe_url = core_url",
									"  }",
									"",
									"  console.log(core_url)",
									"",
									"  // pass the variables required by the `template`",
									"  pm.visualizer.set(template, {",
									"    poststack_base_url: `${poststack_base_url}`,",
									"    poststackUrl: `${poststack_base_url}/index.html?transaction_token=${token}&environment_key=${envKey}&core_url=${core_url}&iframe_url=${iframe_url}&iframe_version=${iframe_version}${checkout_form_param}${challenge_form_param}`,",
									"    envKey: envKey,",
									"    // the version when this script was last updated",
									"    // when the template is evaluated, it will pull the latest version of this script and ensure they match at runtime",
									"    poststack_version: postStackInfo.version,",
									"    unixDate: new Date().getTime()",
									"  });",
									"}",
									"",
									"console.log(`PostStack Version: ${postStackInfo.version}`)",
									"",
									"try {",
									"  detectPostman(pm)",
									"}",
									"catch (e) {",
									"  // it's ok, we're not running inside Postman",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"payment_method_token\": \"{{spreedly_sca_pm}}\",\n    \"amount\": 100,\n    \"currency_code\": \"EUR\",\n    \"sca_provider_key\": \"{{sandbox_sca_provider}}\",\n    \"browser_info\": \"{{browser_info}}\",\n    \"callback_url\": \"http://core.spreedly.com/\",\n    \"redirect_url\": \"{{poststack_redirect_url}}\",\n    \"sca_authentication_parameters\": {\n            \"test_scenario\": {\n              \"scenario\": \"authenticated\"\n            }\n          },\n    \"ip\": \"127.0.0.1\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/gateways/{{airwallex_gateway}}/purchase.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"gateways",
								"{{airwallex_gateway}}",
								"purchase.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Purchase - 3DS Failure",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"// ***************** Post Stack ***************************",
									"// See https://github.com/spreedly/post-stack",
									"",
									"",
									"// if not set, point to Heroku-based instsance. ",
									"poststack_base_url = pm.environment.get(\"poststack_base_url\")",
									"",
									"if (poststack_base_url == '' || poststack_base_url.match('https://post-stack') != null || poststack_base_url == null) {",
									"  poststack_base_url = \"https://spreedly-post-stack.herokuapp.com\"",
									"  pm.environment.set(\"poststack_base_url\", poststack_base_url)",
									"}",
									"",
									"pm.environment.set(\"poststack_redirect_url\", \"{{poststack_base_url}}/index.html?fin=true&thisisfun=true\")",
									"",
									"// ***************** Browser Info utils ***************************",
									"",
									"browserInfo = {",
									"  \"width\": 2133,",
									"  \"height\": 1200,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"05\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"",
									"browserInfoWorldPay = {",
									"  \"width\": 390,",
									"  \"height\": 400,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"01\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browserInfoFallbackBrowser = {",
									"  \"width\": 0,",
									"  \"height\": 0,",
									"  \"depth\": -1,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly 3DS Debugging\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"04\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browser_info = btoa(JSON.stringify(browserInfo))",
									"pm.environment.set(\"browser_info\", browser_info)",
									"",
									"browser_info_wp = btoa(JSON.stringify(browserInfoWorldPay))",
									"pm.environment.set(\"browser_info_wp\", browser_info)",
									"",
									"browser_info_fallback = btoa(JSON.stringify(browserInfoFallbackBrowser))",
									"pm.environment.set(\"browser_info_fallback\", browser_info_fallback)",
									"",
									"",
									"console.log(`browser_info = ${browser_info}`)",
									"console.log(`browser_info_fallback = ${browser_info_fallback}`)",
									"",
									"console.log(`poststack_base_url = ${poststack_base_url}`)",
									"",
									"// ***************** Post Stack ***************************"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Provides general info about this script. Useful for various loading tricks...",
									"",
									"const RELEASE_VERSION=\"v2022.04.28.1539\"",
									"",
									"const postStackInfo = {",
									"  \"app\": \"post-stack\",",
									"  \"version\": RELEASE_VERSION",
									"}",
									"",
									"// See https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-visualizations",
									"const template = `",
									"      <base href=\"{{poststack_base_url}}/\"/>",
									"<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css\">",
									"<script src=\"https://cdn.tailwindcss.com\"></script>",
									"<script src=\"https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js\"></script>",
									"<!-- Pass todays unix date to ensure we do not cache tests.js -->",
									"<script src=\"postman-templates/tests.js?d={{unixDate}}\"></script>",
									"<script src=\"versioning.js?d={{unixDate}}\"></script>",
									"<div class=\"md:container md:mx-auto\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"<div>",
									"    <div id=\"versionWarning\" style=\"display:none\">",
									"        <i class=\"bi bi-exclamation-triangle\"></i>WARNING<i class=\"bi bi-exclamation-triangle\"></i>",
									"        Your PostStack version {{poststack_version}} is outdated <strong>pre-request</strong> and <strong>tests</strong> scripts are outdated.<br/><br/>",
									"        Update to latest PostStack in <strong>main</strong> branch .",
									"        <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"        <br/><br/>",
									"        <br/><br/>",
									"    </div>",
									"    <div>",
									"      <span class=\"btn-clipboard\" data-clipboard-target=\"#poststackUrlInput\" type=\"button\" title=\"Copy to clipboard\">",
									"        <button",
									"          class=\"inline-flex items-center h-15 px-25 text-sky-100 transition-colors duration-150 bg-sky-500 rounded-lg focus:shadow-outline hover:bg-sky-600\">Click",
									"          to Copy Challenge URL into Clipboard",
									"          <i id=\"clipboard_copy_btn\" class=\"bi bi-clipboard\"></i>",
									"        </button>",
									"      </span>",
									"    </div>",
									"    ",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      Challenge URL: <code id=\"poststackUrlInput\">",
									"          {{poststackUrl}}",
									"      </code>",
									"    </div>",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      <i class=\"bi bi-broadcast\"></i>&nbsp;",
									"      <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"      |",
									"      envKey: {{envKey}}",
									"      | ",
									"       poststack_version: {{poststack_version}}",
									"    </div>",
									"</div>",
									"<script type=\"text/javascript\">",
									"  /*",
									"   * Does the version of PostStack in {poststack_base_url}} match the script in PostMan calling it?",
									"   */",
									"  checkVersion(postStackInfo, \"{{poststack_version}}\")",
									"  clipboard = new ClipboardJS('.btn-clipboard');",
									"  clipboard.on('success', function (e) {",
									"    document.getElementById(\"clipboard_copy_btn\").className = \"bi bi-clipboard-check\"",
									"    e.clearSelection();",
									"  });",
									"</script>",
									"      `;",
									"",
									"/**",
									" * Renders the PostStack Helper UI if we detect the script us running inside Postman.",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" *",
									" */",
									"function detectPostman(pm) {",
									"  // don't run if postman's pm is not available",
									"  if (pm == null || pm.response == null) {",
									"    return;",
									"  }",
									"",
									"  console.log(\"Postman detected. Running Post-Stack\")",
									"  const isJson = pm.response.headers.get('Content-Type') != null && pm.response.headers.get('Content-Type').includes('application/json')",
									"  const envKey = pm.environment.get('environment');",
									"",
									"",
									"  if (isJson) {",
									"    console.log(\"Parsing JSON Response...\")",
									"    const jsonResponse = pm.response.json()",
									"",
									"    if (jsonResponse.transaction) {",
									"      pm.environment.set(\"transaction_token\", jsonResponse.transaction.token)",
									"    }",
									"",
									"    // ********************* LifecycleJS Launcher **********************",
									"",
									"",
									"    if (jsonResponse.transaction) {",
									"      token = jsonResponse.transaction.token",
									"      transaction_type = jsonResponse.transaction.transaction_type",
									"",
									"      switch (transaction_type) {",
									"        case \"Authorization\":",
									"        case \"Sca::Authentication\":",
									"        case \"Purchase\":",
									"          displayPostStack(pm, jsonResponse, envKey);",
									"          break;",
									"        default:",
									"          pm.visualizer.set(`PostStack 3DS Flow not available for '{{transaction_type}}' Transactions `, { transaction_type: transaction_type });",
									"      }",
									"    }",
									"  }",
									"}",
									"",
									"",
									"/**",
									" * Renders the PostStack Helper UI, passing in all parameters expected by the mustache template",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" * @param {Object} jsonResponse - the response returned by Core",
									" * @param {String} envKey - the environment key configured in PostMan via pm.environment.get('environment');",
									" *",
									" * @returns {string} a base64 encoded JSON string of the output from `detect`",
									" * @memberOf module:ThreeDS",
									" */",
									"function displayPostStack(pm, jsonResponse, envKey) {",
									"  checkout_form_param = \"\"",
									"  challenge_form_param = \"\"",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.checkout_form) {",
									"    form = jsonResponse.transaction.sca_authentication.checkout_form.cdata",
									"    checkout_form_param = `&checkout_form=${escape(form)}`",
									"    console.table(jsonResponse.transaction.sca_authentication)",
									"    console.log(`${form}, checkout_form '${checkout_form_param}'`)",
									"  }",
									"",
									"  // TODO: figure out the real usage behind challenge_form and checkout_form ",
									"  // this is a quick and dirty hack to allow the flow to complete with current PostStack logic",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.challenge_form) {",
									"    form = jsonResponse.transaction.sca_authentication.challenge_form",
									"    challenge_form_param = `&challenge_form=${escape(form)}`",
									"    console.log(`${form}, challenge_form '${challenge_form_param}'`)",
									"  }",
									"",
									"  if (jsonResponse.transaction.state !== 'pending') {",
									"    template = `Transaction NOT in Pending state. Review and try again.`",
									"  }",
									"",
									"  // left side is the postman-specific JS variable, right side is the environment injected value",
									"  poststack_base_url = pm.environment.get('poststack_base_url');",
									"  core_url = pm.environment.get('base_url') || pm.environment.get('base');",
									"  iframe_url = \"http://localhost:8000\"",
									"  iframe_version = \"1.74.min.js\"",
									"",
									"  if (/.*\\.spreedly\\.com/.test(core_url)) {",
									"    iframe_url = core_url",
									"  }",
									"",
									"  console.log(core_url)",
									"",
									"  // pass the variables required by the `template`",
									"  pm.visualizer.set(template, {",
									"    poststack_base_url: `${poststack_base_url}`,",
									"    poststackUrl: `${poststack_base_url}/index.html?transaction_token=${token}&environment_key=${envKey}&core_url=${core_url}&iframe_url=${iframe_url}&iframe_version=${iframe_version}${checkout_form_param}${challenge_form_param}`,",
									"    envKey: envKey,",
									"    // the version when this script was last updated",
									"    // when the template is evaluated, it will pull the latest version of this script and ensure they match at runtime",
									"    poststack_version: postStackInfo.version,",
									"    unixDate: new Date().getTime()",
									"  });",
									"}",
									"",
									"console.log(`PostStack Version: ${postStackInfo.version}`)",
									"",
									"try {",
									"  detectPostman(pm)",
									"}",
									"catch (e) {",
									"  // it's ok, we're not running inside Postman",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"payment_method_token\": \"{{spreedly_sca_pm}}\",\n    \"amount\": 100,\n    \"currency_code\": \"EUR\",\n    \"sca_provider_key\": \"{{sandbox_sca_provider}}\",\n    \"browser_info\": \"{{browser_info}}\",\n    \"callback_url\": \"http://core.spreedly.com/\",\n    \"redirect_url\": \"{{poststack_redirect_url}}\",\n    \"sca_authentication_parameters\": {\n            \"test_scenario\": {\n              \"scenario\": \"not_authenticated\"\n            }\n          },\n    \"ip\": \"127.0.0.1\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/gateways/{{airwallex_gateway}}/purchase.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"gateways",
								"{{airwallex_gateway}}",
								"purchase.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Purchase - 3DS Challenge",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"// ***************** Post Stack ***************************",
									"// See https://github.com/spreedly/post-stack",
									"",
									"",
									"// if not set, point to Heroku-based instsance. ",
									"poststack_base_url = pm.environment.get(\"poststack_base_url\")",
									"",
									"if (poststack_base_url == '' || poststack_base_url.match('https://post-stack') != null || poststack_base_url == null) {",
									"  poststack_base_url = \"https://spreedly-post-stack.herokuapp.com\"",
									"  pm.environment.set(\"poststack_base_url\", poststack_base_url)",
									"}",
									"",
									"pm.environment.set(\"poststack_redirect_url\", \"{{poststack_base_url}}/index.html?fin=true&thisisfun=true\")",
									"",
									"// ***************** Browser Info utils ***************************",
									"",
									"browserInfo = {",
									"  \"width\": 2133,",
									"  \"height\": 1200,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"05\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"",
									"browserInfoWorldPay = {",
									"  \"width\": 390,",
									"  \"height\": 400,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"01\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browserInfoFallbackBrowser = {",
									"  \"width\": 0,",
									"  \"height\": 0,",
									"  \"depth\": -1,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly 3DS Debugging\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"04\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browser_info = btoa(JSON.stringify(browserInfo))",
									"pm.environment.set(\"browser_info\", browser_info)",
									"",
									"browser_info_wp = btoa(JSON.stringify(browserInfoWorldPay))",
									"pm.environment.set(\"browser_info_wp\", browser_info)",
									"",
									"browser_info_fallback = btoa(JSON.stringify(browserInfoFallbackBrowser))",
									"pm.environment.set(\"browser_info_fallback\", browser_info_fallback)",
									"",
									"",
									"console.log(`browser_info = ${browser_info}`)",
									"console.log(`browser_info_fallback = ${browser_info_fallback}`)",
									"",
									"console.log(`poststack_base_url = ${poststack_base_url}`)",
									"",
									"// ***************** Post Stack ***************************"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Provides general info about this script. Useful for various loading tricks...",
									"",
									"const RELEASE_VERSION=\"v2022.04.28.1539\"",
									"",
									"const postStackInfo = {",
									"  \"app\": \"post-stack\",",
									"  \"version\": RELEASE_VERSION",
									"}",
									"",
									"// See https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-visualizations",
									"const template = `",
									"      <base href=\"{{poststack_base_url}}/\"/>",
									"<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css\">",
									"<script src=\"https://cdn.tailwindcss.com\"></script>",
									"<script src=\"https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js\"></script>",
									"<!-- Pass todays unix date to ensure we do not cache tests.js -->",
									"<script src=\"postman-templates/tests.js?d={{unixDate}}\"></script>",
									"<script src=\"versioning.js?d={{unixDate}}\"></script>",
									"<div class=\"md:container md:mx-auto\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"<div>",
									"    <div id=\"versionWarning\" style=\"display:none\">",
									"        <i class=\"bi bi-exclamation-triangle\"></i>WARNING<i class=\"bi bi-exclamation-triangle\"></i>",
									"        Your PostStack version {{poststack_version}} is outdated <strong>pre-request</strong> and <strong>tests</strong> scripts are outdated.<br/><br/>",
									"        Update to latest PostStack in <strong>main</strong> branch .",
									"        <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"        <br/><br/>",
									"        <br/><br/>",
									"    </div>",
									"    <div>",
									"      <span class=\"btn-clipboard\" data-clipboard-target=\"#poststackUrlInput\" type=\"button\" title=\"Copy to clipboard\">",
									"        <button",
									"          class=\"inline-flex items-center h-15 px-25 text-sky-100 transition-colors duration-150 bg-sky-500 rounded-lg focus:shadow-outline hover:bg-sky-600\">Click",
									"          to Copy Challenge URL into Clipboard",
									"          <i id=\"clipboard_copy_btn\" class=\"bi bi-clipboard\"></i>",
									"        </button>",
									"      </span>",
									"    </div>",
									"    ",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      Challenge URL: <code id=\"poststackUrlInput\">",
									"          {{poststackUrl}}",
									"      </code>",
									"    </div>",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      <i class=\"bi bi-broadcast\"></i>&nbsp;",
									"      <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"      |",
									"      envKey: {{envKey}}",
									"      | ",
									"       poststack_version: {{poststack_version}}",
									"    </div>",
									"</div>",
									"<script type=\"text/javascript\">",
									"  /*",
									"   * Does the version of PostStack in {poststack_base_url}} match the script in PostMan calling it?",
									"   */",
									"  checkVersion(postStackInfo, \"{{poststack_version}}\")",
									"  clipboard = new ClipboardJS('.btn-clipboard');",
									"  clipboard.on('success', function (e) {",
									"    document.getElementById(\"clipboard_copy_btn\").className = \"bi bi-clipboard-check\"",
									"    e.clearSelection();",
									"  });",
									"</script>",
									"      `;",
									"",
									"/**",
									" * Renders the PostStack Helper UI if we detect the script us running inside Postman.",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" *",
									" */",
									"function detectPostman(pm) {",
									"  // don't run if postman's pm is not available",
									"  if (pm == null || pm.response == null) {",
									"    return;",
									"  }",
									"",
									"  console.log(\"Postman detected. Running Post-Stack\")",
									"  const isJson = pm.response.headers.get('Content-Type') != null && pm.response.headers.get('Content-Type').includes('application/json')",
									"  const envKey = pm.environment.get('environment');",
									"",
									"",
									"  if (isJson) {",
									"    console.log(\"Parsing JSON Response...\")",
									"    const jsonResponse = pm.response.json()",
									"",
									"    if (jsonResponse.transaction) {",
									"      pm.environment.set(\"transaction_token\", jsonResponse.transaction.token)",
									"    }",
									"",
									"    // ********************* LifecycleJS Launcher **********************",
									"",
									"",
									"    if (jsonResponse.transaction) {",
									"      token = jsonResponse.transaction.token",
									"      transaction_type = jsonResponse.transaction.transaction_type",
									"",
									"      switch (transaction_type) {",
									"        case \"Authorization\":",
									"        case \"Sca::Authentication\":",
									"        case \"Purchase\":",
									"          displayPostStack(pm, jsonResponse, envKey);",
									"          break;",
									"        default:",
									"          pm.visualizer.set(`PostStack 3DS Flow not available for '{{transaction_type}}' Transactions `, { transaction_type: transaction_type });",
									"      }",
									"    }",
									"  }",
									"}",
									"",
									"",
									"/**",
									" * Renders the PostStack Helper UI, passing in all parameters expected by the mustache template",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" * @param {Object} jsonResponse - the response returned by Core",
									" * @param {String} envKey - the environment key configured in PostMan via pm.environment.get('environment');",
									" *",
									" * @returns {string} a base64 encoded JSON string of the output from `detect`",
									" * @memberOf module:ThreeDS",
									" */",
									"function displayPostStack(pm, jsonResponse, envKey) {",
									"  checkout_form_param = \"\"",
									"  challenge_form_param = \"\"",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.checkout_form) {",
									"    form = jsonResponse.transaction.sca_authentication.checkout_form.cdata",
									"    checkout_form_param = `&checkout_form=${escape(form)}`",
									"    console.table(jsonResponse.transaction.sca_authentication)",
									"    console.log(`${form}, checkout_form '${checkout_form_param}'`)",
									"  }",
									"",
									"  // TODO: figure out the real usage behind challenge_form and checkout_form ",
									"  // this is a quick and dirty hack to allow the flow to complete with current PostStack logic",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.challenge_form) {",
									"    form = jsonResponse.transaction.sca_authentication.challenge_form",
									"    challenge_form_param = `&challenge_form=${escape(form)}`",
									"    console.log(`${form}, challenge_form '${challenge_form_param}'`)",
									"  }",
									"",
									"  if (jsonResponse.transaction.state !== 'pending') {",
									"    template = `Transaction NOT in Pending state. Review and try again.`",
									"  }",
									"",
									"  // left side is the postman-specific JS variable, right side is the environment injected value",
									"  poststack_base_url = pm.environment.get('poststack_base_url');",
									"  core_url = pm.environment.get('base_url') || pm.environment.get('base');",
									"  iframe_url = \"http://localhost:8000\"",
									"  iframe_version = \"1.74.min.js\"",
									"",
									"  if (/.*\\.spreedly\\.com/.test(core_url)) {",
									"    iframe_url = core_url",
									"  }",
									"",
									"  console.log(core_url)",
									"",
									"  // pass the variables required by the `template`",
									"  pm.visualizer.set(template, {",
									"    poststack_base_url: `${poststack_base_url}`,",
									"    poststackUrl: `${poststack_base_url}/index.html?transaction_token=${token}&environment_key=${envKey}&core_url=${core_url}&iframe_url=${iframe_url}&iframe_version=${iframe_version}${checkout_form_param}${challenge_form_param}`,",
									"    envKey: envKey,",
									"    // the version when this script was last updated",
									"    // when the template is evaluated, it will pull the latest version of this script and ensure they match at runtime",
									"    poststack_version: postStackInfo.version,",
									"    unixDate: new Date().getTime()",
									"  });",
									"}",
									"",
									"console.log(`PostStack Version: ${postStackInfo.version}`)",
									"",
									"try {",
									"  detectPostman(pm)",
									"}",
									"catch (e) {",
									"  // it's ok, we're not running inside Postman",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"payment_method_token\": \"{{spreedly_sca_pm}}\",\n    \"amount\": 100,\n    \"currency_code\": \"EUR\",\n    \"sca_provider_key\": \"{{sandbox_sca_provider}}\",\n    \"browser_info\": \"{{browser_info}}\",\n    \"callback_url\": \"http://core.spreedly.com/\",\n    \"redirect_url\": \"{{poststack_redirect_url}}\",\n    \"sca_authentication_parameters\": {\n            \"test_scenario\": {\n              \"scenario\": \"challenge\"\n            }\n          },\n    \"ip\": \"127.0.0.1\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/gateways/{{airwallex_gateway}}/purchase.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"gateways",
								"{{airwallex_gateway}}",
								"purchase.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Show",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"protocolProfileBehavior": {
						"disableBodyPruning": true
					},
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": ""
						},
						"url": {
							"raw": "{{base}}/v1/transactions/{{transaction_token}}.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"transactions",
								"{{transaction_token}}.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Authorize - 3DS Frictionless",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"// ***************** Post Stack ***************************",
									"// See https://github.com/spreedly/post-stack",
									"",
									"",
									"// if not set, point to Heroku-based instsance. ",
									"poststack_base_url = pm.environment.get(\"poststack_base_url\")",
									"",
									"if (poststack_base_url == '' || poststack_base_url.match('https://post-stack') != null || poststack_base_url == null) {",
									"  poststack_base_url = \"https://spreedly-post-stack.herokuapp.com\"",
									"  pm.environment.set(\"poststack_base_url\", poststack_base_url)",
									"}",
									"",
									"pm.environment.set(\"poststack_redirect_url\", \"{{poststack_base_url}}/index.html?fin=true&thisisfun=true\")",
									"",
									"// ***************** Browser Info utils ***************************",
									"",
									"browserInfo = {",
									"  \"width\": 2133,",
									"  \"height\": 1200,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"05\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"",
									"browserInfoWorldPay = {",
									"  \"width\": 390,",
									"  \"height\": 400,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"01\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browserInfoFallbackBrowser = {",
									"  \"width\": 0,",
									"  \"height\": 0,",
									"  \"depth\": -1,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly 3DS Debugging\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"04\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browser_info = btoa(JSON.stringify(browserInfo))",
									"pm.environment.set(\"browser_info\", browser_info)",
									"",
									"browser_info_wp = btoa(JSON.stringify(browserInfoWorldPay))",
									"pm.environment.set(\"browser_info_wp\", browser_info)",
									"",
									"browser_info_fallback = btoa(JSON.stringify(browserInfoFallbackBrowser))",
									"pm.environment.set(\"browser_info_fallback\", browser_info_fallback)",
									"",
									"",
									"console.log(`browser_info = ${browser_info}`)",
									"console.log(`browser_info_fallback = ${browser_info_fallback}`)",
									"",
									"console.log(`poststack_base_url = ${poststack_base_url}`)",
									"",
									"// ***************** Post Stack ***************************"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Provides general info about this script. Useful for various loading tricks...",
									"",
									"const RELEASE_VERSION=\"v2022.04.28.1539\"",
									"",
									"const postStackInfo = {",
									"  \"app\": \"post-stack\",",
									"  \"version\": RELEASE_VERSION",
									"}",
									"",
									"// See https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-visualizations",
									"const template = `",
									"      <base href=\"{{poststack_base_url}}/\"/>",
									"<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css\">",
									"<script src=\"https://cdn.tailwindcss.com\"></script>",
									"<script src=\"https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js\"></script>",
									"<!-- Pass todays unix date to ensure we do not cache tests.js -->",
									"<script src=\"postman-templates/tests.js?d={{unixDate}}\"></script>",
									"<script src=\"versioning.js?d={{unixDate}}\"></script>",
									"<div class=\"md:container md:mx-auto\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"<div>",
									"    <div id=\"versionWarning\" style=\"display:none\">",
									"        <i class=\"bi bi-exclamation-triangle\"></i>WARNING<i class=\"bi bi-exclamation-triangle\"></i>",
									"        Your PostStack version {{poststack_version}} is outdated <strong>pre-request</strong> and <strong>tests</strong> scripts are outdated.<br/><br/>",
									"        Update to latest PostStack in <strong>main</strong> branch .",
									"        <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"        <br/><br/>",
									"        <br/><br/>",
									"    </div>",
									"    <div>",
									"      <span class=\"btn-clipboard\" data-clipboard-target=\"#poststackUrlInput\" type=\"button\" title=\"Copy to clipboard\">",
									"        <button",
									"          class=\"inline-flex items-center h-15 px-25 text-sky-100 transition-colors duration-150 bg-sky-500 rounded-lg focus:shadow-outline hover:bg-sky-600\">Click",
									"          to Copy Challenge URL into Clipboard",
									"          <i id=\"clipboard_copy_btn\" class=\"bi bi-clipboard\"></i>",
									"        </button>",
									"      </span>",
									"    </div>",
									"    ",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      Challenge URL: <code id=\"poststackUrlInput\">",
									"          {{poststackUrl}}",
									"      </code>",
									"    </div>",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      <i class=\"bi bi-broadcast\"></i>&nbsp;",
									"      <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"      |",
									"      envKey: {{envKey}}",
									"      | ",
									"       poststack_version: {{poststack_version}}",
									"    </div>",
									"</div>",
									"<script type=\"text/javascript\">",
									"  /*",
									"   * Does the version of PostStack in {poststack_base_url}} match the script in PostMan calling it?",
									"   */",
									"  checkVersion(postStackInfo, \"{{poststack_version}}\")",
									"  clipboard = new ClipboardJS('.btn-clipboard');",
									"  clipboard.on('success', function (e) {",
									"    document.getElementById(\"clipboard_copy_btn\").className = \"bi bi-clipboard-check\"",
									"    e.clearSelection();",
									"  });",
									"</script>",
									"      `;",
									"",
									"/**",
									" * Renders the PostStack Helper UI if we detect the script us running inside Postman.",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" *",
									" */",
									"function detectPostman(pm) {",
									"  // don't run if postman's pm is not available",
									"  if (pm == null || pm.response == null) {",
									"    return;",
									"  }",
									"",
									"  console.log(\"Postman detected. Running Post-Stack\")",
									"  const isJson = pm.response.headers.get('Content-Type') != null && pm.response.headers.get('Content-Type').includes('application/json')",
									"  const envKey = pm.environment.get('environment');",
									"",
									"",
									"  if (isJson) {",
									"    console.log(\"Parsing JSON Response...\")",
									"    const jsonResponse = pm.response.json()",
									"",
									"    if (jsonResponse.transaction) {",
									"      pm.environment.set(\"transaction_token\", jsonResponse.transaction.token)",
									"    }",
									"",
									"    // ********************* LifecycleJS Launcher **********************",
									"",
									"",
									"    if (jsonResponse.transaction) {",
									"      token = jsonResponse.transaction.token",
									"      transaction_type = jsonResponse.transaction.transaction_type",
									"",
									"      switch (transaction_type) {",
									"        case \"Authorization\":",
									"        case \"Sca::Authentication\":",
									"        case \"Purchase\":",
									"          displayPostStack(pm, jsonResponse, envKey);",
									"          break;",
									"        default:",
									"          pm.visualizer.set(`PostStack 3DS Flow not available for '{{transaction_type}}' Transactions `, { transaction_type: transaction_type });",
									"      }",
									"    }",
									"  }",
									"}",
									"",
									"",
									"/**",
									" * Renders the PostStack Helper UI, passing in all parameters expected by the mustache template",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" * @param {Object} jsonResponse - the response returned by Core",
									" * @param {String} envKey - the environment key configured in PostMan via pm.environment.get('environment');",
									" *",
									" * @returns {string} a base64 encoded JSON string of the output from `detect`",
									" * @memberOf module:ThreeDS",
									" */",
									"function displayPostStack(pm, jsonResponse, envKey) {",
									"  checkout_form_param = \"\"",
									"  challenge_form_param = \"\"",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.checkout_form) {",
									"    form = jsonResponse.transaction.sca_authentication.checkout_form.cdata",
									"    checkout_form_param = `&checkout_form=${escape(form)}`",
									"    console.table(jsonResponse.transaction.sca_authentication)",
									"    console.log(`${form}, checkout_form '${checkout_form_param}'`)",
									"  }",
									"",
									"  // TODO: figure out the real usage behind challenge_form and checkout_form ",
									"  // this is a quick and dirty hack to allow the flow to complete with current PostStack logic",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.challenge_form) {",
									"    form = jsonResponse.transaction.sca_authentication.challenge_form",
									"    challenge_form_param = `&challenge_form=${escape(form)}`",
									"    console.log(`${form}, challenge_form '${challenge_form_param}'`)",
									"  }",
									"",
									"  if (jsonResponse.transaction.state !== 'pending') {",
									"    template = `Transaction NOT in Pending state. Review and try again.`",
									"  }",
									"",
									"  // left side is the postman-specific JS variable, right side is the environment injected value",
									"  poststack_base_url = pm.environment.get('poststack_base_url');",
									"  core_url = pm.environment.get('base_url') || pm.environment.get('base');",
									"  iframe_url = \"http://localhost:8000\"",
									"  iframe_version = \"1.74.min.js\"",
									"",
									"  if (/.*\\.spreedly\\.com/.test(core_url)) {",
									"    iframe_url = core_url",
									"  }",
									"",
									"  console.log(core_url)",
									"",
									"  // pass the variables required by the `template`",
									"  pm.visualizer.set(template, {",
									"    poststack_base_url: `${poststack_base_url}`,",
									"    poststackUrl: `${poststack_base_url}/index.html?transaction_token=${token}&environment_key=${envKey}&core_url=${core_url}&iframe_url=${iframe_url}&iframe_version=${iframe_version}${checkout_form_param}${challenge_form_param}`,",
									"    envKey: envKey,",
									"    // the version when this script was last updated",
									"    // when the template is evaluated, it will pull the latest version of this script and ensure they match at runtime",
									"    poststack_version: postStackInfo.version,",
									"    unixDate: new Date().getTime()",
									"  });",
									"}",
									"",
									"console.log(`PostStack Version: ${postStackInfo.version}`)",
									"",
									"try {",
									"  detectPostman(pm)",
									"}",
									"catch (e) {",
									"  // it's ok, we're not running inside Postman",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"payment_method_token\": \"{{spreedly_sca_pm}}\",\n    \"amount\": 100,\n    \"currency_code\": \"EUR\",\n    \"sca_provider_key\": \"{{sandbox_sca_provider}}\",\n    \"browser_info\": \"{{browser_info}}\",\n    \"callback_url\": \"http://core.spreedly.com/\",\n    \"redirect_url\": \"{{poststack_redirect_url}}\",\n    \"sca_authentication_parameters\": {\n            \"test_scenario\": {\n              \"scenario\": \"authenticated\"\n            }\n          },\n    \"ip\": \"127.0.0.1\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/gateways/{{airwallex_gateway}}/authorize.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"gateways",
								"{{airwallex_gateway}}",
								"authorize.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Authenticate - Frictionless",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									"// ***************** Post Stack ***************************",
									"// See https://github.com/spreedly/post-stack",
									"",
									"",
									"// if not set, point to Heroku-based instsance. ",
									"poststack_base_url = pm.environment.get(\"poststack_base_url\")",
									"",
									"if (poststack_base_url == '' || poststack_base_url.match('https://post-stack') != null || poststack_base_url == null) {",
									"  poststack_base_url = \"https://spreedly-post-stack.herokuapp.com\"",
									"  pm.environment.set(\"poststack_base_url\", poststack_base_url)",
									"}",
									"",
									"pm.environment.set(\"poststack_redirect_url\", \"{{poststack_base_url}}/index.html?fin=true&thisisfun=true\")",
									"",
									"// ***************** Browser Info utils ***************************",
									"",
									"browserInfo = {",
									"  \"width\": 2133,",
									"  \"height\": 1200,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"05\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"",
									"browserInfoWorldPay = {",
									"  \"width\": 390,",
									"  \"height\": 400,",
									"  \"depth\": 24,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly Agent\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"01\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browserInfoFallbackBrowser = {",
									"  \"width\": 0,",
									"  \"height\": 0,",
									"  \"depth\": -1,",
									"  \"timezone\": 300,",
									"  \"user_agent\": \"Spreedly 3DS Debugging\",",
									"  \"java\": false,",
									"  \"language\": \"en-US\",",
									"",
									"  // EMVCO spec",
									"  \"browser_size\": \"04\",",
									"  \"accept_header\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"",
									"}",
									"",
									"browser_info = btoa(JSON.stringify(browserInfo))",
									"pm.environment.set(\"browser_info\", browser_info)",
									"",
									"browser_info_wp = btoa(JSON.stringify(browserInfoWorldPay))",
									"pm.environment.set(\"browser_info_wp\", browser_info)",
									"",
									"browser_info_fallback = btoa(JSON.stringify(browserInfoFallbackBrowser))",
									"pm.environment.set(\"browser_info_fallback\", browser_info_fallback)",
									"",
									"",
									"console.log(`browser_info = ${browser_info}`)",
									"console.log(`browser_info_fallback = ${browser_info_fallback}`)",
									"",
									"console.log(`poststack_base_url = ${poststack_base_url}`)",
									"",
									"// ***************** Post Stack ***************************"
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Provides general info about this script. Useful for various loading tricks...",
									"",
									"const RELEASE_VERSION=\"v2022.04.28.1539\"",
									"",
									"const postStackInfo = {",
									"  \"app\": \"post-stack\",",
									"  \"version\": RELEASE_VERSION",
									"}",
									"",
									"// See https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-visualizations",
									"const template = `",
									"      <base href=\"{{poststack_base_url}}/\"/>",
									"<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css\">",
									"<script src=\"https://cdn.tailwindcss.com\"></script>",
									"<script src=\"https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js\"></script>",
									"<!-- Pass todays unix date to ensure we do not cache tests.js -->",
									"<script src=\"postman-templates/tests.js?d={{unixDate}}\"></script>",
									"<script src=\"versioning.js?d={{unixDate}}\"></script>",
									"<div class=\"md:container md:mx-auto\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"  <img src=\"1x1.png\" alt=\"WARNING: your post-stack is not running\">",
									"<div>",
									"    <div id=\"versionWarning\" style=\"display:none\">",
									"        <i class=\"bi bi-exclamation-triangle\"></i>WARNING<i class=\"bi bi-exclamation-triangle\"></i>",
									"        Your PostStack version {{poststack_version}} is outdated <strong>pre-request</strong> and <strong>tests</strong> scripts are outdated.<br/><br/>",
									"        Update to latest PostStack in <strong>main</strong> branch .",
									"        <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"        <br/><br/>",
									"        <br/><br/>",
									"    </div>",
									"    <div>",
									"      <span class=\"btn-clipboard\" data-clipboard-target=\"#poststackUrlInput\" type=\"button\" title=\"Copy to clipboard\">",
									"        <button",
									"          class=\"inline-flex items-center h-15 px-25 text-sky-100 transition-colors duration-150 bg-sky-500 rounded-lg focus:shadow-outline hover:bg-sky-600\">Click",
									"          to Copy Challenge URL into Clipboard",
									"          <i id=\"clipboard_copy_btn\" class=\"bi bi-clipboard\"></i>",
									"        </button>",
									"      </span>",
									"    </div>",
									"    ",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      Challenge URL: <code id=\"poststackUrlInput\">",
									"          {{poststackUrl}}",
									"      </code>",
									"    </div>",
									"    <br/>&nbsp;",
									"    <br/>&nbsp;",
									"    <hr/>",
									"    <div>",
									"      <i class=\"bi bi-broadcast\"></i>&nbsp;",
									"      <a href=\"https://github.com/spreedly/post-stack\" target=\"_blank\">GitHub Repo <i class=\"bi bi-github\"></i></a>",
									"      |",
									"      envKey: {{envKey}}",
									"      | ",
									"       poststack_version: {{poststack_version}}",
									"    </div>",
									"</div>",
									"<script type=\"text/javascript\">",
									"  /*",
									"   * Does the version of PostStack in {poststack_base_url}} match the script in PostMan calling it?",
									"   */",
									"  checkVersion(postStackInfo, \"{{poststack_version}}\")",
									"  clipboard = new ClipboardJS('.btn-clipboard');",
									"  clipboard.on('success', function (e) {",
									"    document.getElementById(\"clipboard_copy_btn\").className = \"bi bi-clipboard-check\"",
									"    e.clearSelection();",
									"  });",
									"</script>",
									"      `;",
									"",
									"/**",
									" * Renders the PostStack Helper UI if we detect the script us running inside Postman.",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" *",
									" */",
									"function detectPostman(pm) {",
									"  // don't run if postman's pm is not available",
									"  if (pm == null || pm.response == null) {",
									"    return;",
									"  }",
									"",
									"  console.log(\"Postman detected. Running Post-Stack\")",
									"  const isJson = pm.response.headers.get('Content-Type') != null && pm.response.headers.get('Content-Type').includes('application/json')",
									"  const envKey = pm.environment.get('environment');",
									"",
									"",
									"  if (isJson) {",
									"    console.log(\"Parsing JSON Response...\")",
									"    const jsonResponse = pm.response.json()",
									"",
									"    if (jsonResponse.transaction) {",
									"      pm.environment.set(\"transaction_token\", jsonResponse.transaction.token)",
									"    }",
									"",
									"    // ********************* LifecycleJS Launcher **********************",
									"",
									"",
									"    if (jsonResponse.transaction) {",
									"      token = jsonResponse.transaction.token",
									"      transaction_type = jsonResponse.transaction.transaction_type",
									"",
									"      switch (transaction_type) {",
									"        case \"Authorization\":",
									"        case \"Sca::Authentication\":",
									"        case \"Purchase\":",
									"          displayPostStack(pm, jsonResponse, envKey);",
									"          break;",
									"        default:",
									"          pm.visualizer.set(`PostStack 3DS Flow not available for '{{transaction_type}}' Transactions `, { transaction_type: transaction_type });",
									"      }",
									"    }",
									"  }",
									"}",
									"",
									"",
									"/**",
									" * Renders the PostStack Helper UI, passing in all parameters expected by the mustache template",
									" *",
									" * @param {Object} pm - the pm object from PostMan, https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#the-pm-object",
									" * @param {Object} jsonResponse - the response returned by Core",
									" * @param {String} envKey - the environment key configured in PostMan via pm.environment.get('environment');",
									" *",
									" * @returns {string} a base64 encoded JSON string of the output from `detect`",
									" * @memberOf module:ThreeDS",
									" */",
									"function displayPostStack(pm, jsonResponse, envKey) {",
									"  checkout_form_param = \"\"",
									"  challenge_form_param = \"\"",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.checkout_form) {",
									"    form = jsonResponse.transaction.sca_authentication.checkout_form.cdata",
									"    checkout_form_param = `&checkout_form=${escape(form)}`",
									"    console.table(jsonResponse.transaction.sca_authentication)",
									"    console.log(`${form}, checkout_form '${checkout_form_param}'`)",
									"  }",
									"",
									"  // TODO: figure out the real usage behind challenge_form and checkout_form ",
									"  // this is a quick and dirty hack to allow the flow to complete with current PostStack logic",
									"  if (jsonResponse.transaction.sca_authentication && jsonResponse.transaction.sca_authentication.challenge_form) {",
									"    form = jsonResponse.transaction.sca_authentication.challenge_form",
									"    challenge_form_param = `&challenge_form=${escape(form)}`",
									"    console.log(`${form}, challenge_form '${challenge_form_param}'`)",
									"  }",
									"",
									"  if (jsonResponse.transaction.state !== 'pending') {",
									"    template = `Transaction NOT in Pending state. Review and try again.`",
									"  }",
									"",
									"  // left side is the postman-specific JS variable, right side is the environment injected value",
									"  poststack_base_url = pm.environment.get('poststack_base_url');",
									"  core_url = pm.environment.get('base_url') || pm.environment.get('base');",
									"  iframe_url = \"http://localhost:8000\"",
									"  iframe_version = \"1.74.min.js\"",
									"",
									"  if (/.*\\.spreedly\\.com/.test(core_url)) {",
									"    iframe_url = core_url",
									"  }",
									"",
									"  console.log(core_url)",
									"",
									"  // pass the variables required by the `template`",
									"  pm.visualizer.set(template, {",
									"    poststack_base_url: `${poststack_base_url}`,",
									"    poststackUrl: `${poststack_base_url}/index.html?transaction_token=${token}&environment_key=${envKey}&core_url=${core_url}&iframe_url=${iframe_url}&iframe_version=${iframe_version}${checkout_form_param}${challenge_form_param}`,",
									"    envKey: envKey,",
									"    // the version when this script was last updated",
									"    // when the template is evaluated, it will pull the latest version of this script and ensure they match at runtime",
									"    poststack_version: postStackInfo.version,",
									"    unixDate: new Date().getTime()",
									"  });",
									"}",
									"",
									"console.log(`PostStack Version: ${postStackInfo.version}`)",
									"",
									"try {",
									"  detectPostman(pm)",
									"}",
									"catch (e) {",
									"  // it's ok, we're not running inside Postman",
									"}",
									"var authentication=JSON.parse(responseBody);",
									"pm.environment.set(\"authentication_token\", authentication.transaction.token);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"payment_method_token\": \"{{spreedly_sca_pm}}\",\n    \"currency_code\": \"EUR\",\n    \"amount\": 100,\n    \"test_scenario\": {\n      \"scenario\": \"authenticated\"\n    },\n    \"browser_info\": \"{{browser_info}}\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/sca/providers/{{sandbox_sca_provider}}/authenticate.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"sca",
								"providers",
								"{{sandbox_sca_provider}}",
								"authenticate.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Authorize - Authenticated",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"sca_authentication_token\": \"{{authentication_token}}\",\n    \"amount\": 100,\n    \"currency_code\": \"EUR\",\n    \"ip\": \"127.0.0.1\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/gateways/{{airwallex_gateway}}/authorize.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"gateways",
								"{{airwallex_gateway}}",
								"authorize.json"
							]
						}
					},
					"response": []
				},
				{
					"name": "Purchase - Authenticated",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						},
						{
							"listen": "test",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Host",
								"value": "core.spreedly.com"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"transaction\": {\n    \"sca_authentication_token\": \"{{authentication_token}}\",\n    \"amount\": 100,\n    \"currency_code\": \"EUR\",\n    \"ip\": \"127.0.0.1\"\n  }\n}"
						},
						"url": {
							"raw": "{{base}}/v1/gateways/{{airwallex_gateway}}/purchase.json",
							"host": [
								"{{base}}"
							],
							"path": [
								"v1",
								"gateways",
								"{{airwallex_gateway}}",
								"purchase.json"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Create Gateway",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var gateway=JSON.parse(responseBody);",
							"var gateway_type=gateway.gateway.gateway_type",
							"pm.environment.set(gateway_type+\"_gateway\", gateway.gateway.token);",
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"gateway\": {\n        \"gateway_type\": \"airwallex\",\n        \"client_id\": \"{{client_id}}\",\n        \"client_api_key\": \"{{client_api_key}}\",\n        \"sandbox\": \"true\"\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Add Credit Card Payment Method",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var paymentMethod=JSON.parse(responseBody);",
							"pm.environment.set(\"payment_method\", paymentMethod.transaction.payment_method.token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"payment_method\": {\n        \"first_name\": \"John\",\n        \"last_name\": \"Doe Visa\",\n        \"country\": \"USA\",\n        \"number\": \"4704550000000005\",\n        \"verification_value\": \"123\",\n        \"month\": 12,\n        \"year\": 2022\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/payment_methods.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"payment_methods.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Store (TPV)",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var paymentMethod=JSON.parse(responseBody);",
							"pm.environment.set(\"third_party_token\", paymentMethod.transaction.payment_method.token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"payment_method_token\": \"{{payment_method}}\"\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/store.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"store.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Verify",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"protocolProfileBehavior": {
				"disabledSystemHeaders": {
					"content-type": true
				}
			},
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"retain_on_success\": true,\n        \"gateway_specific_fields\":{\n            \"airwallex\":{\n                \"return_url\":\"https://google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/verify.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"verify.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Purchase",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"var txn=JSON.parse(responseBody);",
							"pm.environment.set(\"transaction_token\", txn.transaction.token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"11000\",\n        \"currency_code\": \"GBP\",\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"gateway_specific_fields\":{\n            \"airwallex\":{\n                \"return_url\":\"https://google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/purchase.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"purchase.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Purchase SCs First",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"var txn=JSON.parse(responseBody);",
							"pm.environment.set(\"transaction_token\", txn.transaction.token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"11000\",\n        \"currency_code\": \"GBP\",\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"retain_on_success\":true,\n        \"stored_credential_initiator\":\"cardholder\",\n        \"stored_credential_reason_type\":\"unscheduled\",\n        \"gateway_specific_fields\":{\n            \"airwallex\":{\n                \"return_url\":\"https://google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/purchase.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"purchase.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Purchase SCs Recurring",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"var txn=JSON.parse(responseBody);",
							"pm.environment.set(\"transaction_token\", txn.transaction.token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"11000\",\n        \"currency_code\": \"GBP\",\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"retain_on_success\":true,\n        \"stored_credential_initiator\":\"merchant\",\n        \"stored_credential_reason_type\":\"recurring\",\n        \"gateway_specific_fields\":{\n            \"airwallex\":{\n                \"return_url\":\"https://google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/purchase.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"purchase.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Purchase + GSFs",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"1050\",\n        \"currency_code\": \"GBP\",\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"gateway_specific_fields\": {\n            \"airwallex\": {\n                \"request_id\": \"5\",\n                \"merchant_order_id\":\"abc\",\n                \"return_url\":\"https://www.google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/purchase.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"purchase.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Authorize",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"var token=JSON.parse(responseBody);",
							"pm.environment.set(\"auth_token\", token.transaction.token)"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"1000\",\n        \"currency_code\": \"USD\",\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"gateway_specific_fields\":{\n            \"airwallex\":{\n                \"return_url\":\"https://google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/authorize.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"authorize.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Authorize + GSFs",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"var token=JSON.parse(responseBody);",
							"pm.environment.set(\"auth_token\", token.transaction.token)"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"1700\",\n        \"currency_code\": \"ARS\",\n        \"payment_method_token\": \"{{payment_method}}\",\n        \"gateway_specific_fields\": {\n            \"airwallex\": {\n                \"request_id\": \"5\",\n                \"merchant_order_id\":\"abc\",\n                \"return_url\":\"https://www.google.com\"\n            }\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/gateways/{{airwallex_gateway}}/authorize.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"gateways",
						"{{airwallex_gateway}}",
						"authorize.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Capture",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/transactions/{{auth_token}}/capture.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"transactions",
						"{{auth_token}}",
						"capture.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Void",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/transactions/{{auth_token}}/void.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"transactions",
						"{{auth_token}}",
						"void.json"
					]
				}
			},
			"response": []
		},
		{
			"name": "Refund (Full) an Authorized Transaction",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"url": {
					"raw": "https://core.spreedly.com/v1/transactions/{{transaction_token}}/credit.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"transactions",
						"{{transaction_token}}",
						"credit.json"
					]
				},
				"description": "Fully refund a Spreedly transaction"
			},
			"response": []
		},
		{
			"name": "Refund (Partial) an Authorized Transaction",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"type": "text",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"transaction\": {\n        \"amount\": \"400\",\n        \"currency_code\": \"ARS\"\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://core.spreedly.com/v1/transactions/{{transaction_token}}/credit.json",
					"protocol": "https",
					"host": [
						"core",
						"spreedly",
						"com"
					],
					"path": [
						"v1",
						"transactions",
						"{{transaction_token}}",
						"credit.json"
					]
				},
				"description": "Partially refund a Spreedly transaction"
			},
			"response": []
		}
	],
	"auth": {
		"type": "basic",
		"basic": [
			{
				"key": "password",
				"value": "{{access_secret_value}}",
				"type": "string"
			},
			{
				"key": "username",
				"value": "{{environment_key}}",
				"type": "string"
			}
		]
	},
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	]
}