{
	"info": {
		"_postman_id": "11fe2131-7890-426a-85d2-e9218405e127",
		"name": "Fintecture API",
		"description": "## Introduction\n\nAt Fintecture we understand the importance of providing developers with the necessary tools to streamline their work. In this regard, we have created this Postman collection that aims to simplify the process of taking in charge our APIs.\n\nOur Postman collection includes a comprehensive set of API endpoints with sample requests. This allows developers to easily test and integrate our APIs into their applications without having to worry about the details of the implementation.\n\nFurthermore, our Postman collection is regularly updated to ensure that it reflects the latest changes and improvements to our APIs. This helps developers to stay up-to-date with the latest developments and ensures that their applications are always using the latest and most robust API endpoints.\n\n## 1\\. Variables\n\nAll of the variables are stored directly at root level (Fintecture API)\n\n## 2\\. Arborescence\n\nOur arboresence follows the one of our [documentation](https://doc.fintecture.com/docs/api-overview) and stronly relies upon it so please follow it in parallel.\n\n### 2.1. Authentication\n\nSimple requests to help you take over the auth.\n\n### 2.2. Integrate payments\n\nSamples for integrating our payment solutions.\n\n### 2.3. Integrate bank accounts\n\nSamples for integrating our bank account's integration solutions.\n\n## 3\\. Support\n\nWe are here to best serve your needs, so please [contact us](mailto:support-api@fintecture.com) to request a specific feature, to report a bug or just a general enquiry.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "513061"
	},
	"item": [
		{
			"name": "Authentication",
			"item": [
				{
					"name": "Request a PIS access token",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.environment.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-request-a-pis-access-token](https://doc.fintecture.com/docs/api-request-a-pis-access-token)"
				},
				{
					"name": "Request an AIS access token",
					"item": [
						{
							"name": "Request the AIS Connect URL",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"const scope = undefined;",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'state': state ?  state : undefined,  // mandatory",
											"    'scope': scope ?  scope : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"const res = pm.response.json();",
											"",
											"const connect_url = res.meta.url;",
											"",
											"pm.collectionVariables.set(\"connect_url\", connect_url);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "text"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v2",
										"connect"
									]
								},
								"description": "NOT DESCRIBED"
							},
							"response": []
						},
						{
							"name": "Redirect the user",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// On redirection extract the code received",
											"const fintecture_redirect_url = pm.response.headers.get('location');",
											"",
											"const query_params = fintecture_redirect_url?.split('?');",
											"const bank_code = query_params ? query_params[1].split('&').find(e => e.indexOf('code=') !== -1)?.replace('code=','') : undefined;",
											"const customer_id =  query_params ? query_params[1].split('&').find(e => e.indexOf('customer_id=') !== -1)?.replace('customer_id=','') : undefined;",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"bank_code\", bank_code);",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true
							},
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "referer",
										"value": "{{location}}",
										"type": "default",
										"disabled": true
									}
								],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Exchange the code for an access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"AIS\";",
											"",
											"// Retrieve app_id and app_secret from variables",
											"const app_id = pm.collectionVariables.get(\"app_id\");",
											"const app_secret = pm.collectionVariables.get(\"app_secret\");",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token, expires_in & refresh_token from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"const refresh_token = res.refresh_token;",
											"",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "code",
											"value": "{{bank_code}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-request-an-ais-token](https://doc.fintecture.com/docs/api-request-an-ais-token)",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"type": "text/javascript",
								"exec": [
									"",
									"/****************** ",
									" Signing algorithm",
									"*******************/",
									"// Load ForgeJS for signing",
									"eval(pm.globals.get(\"forgeJS\"));",
									"",
									"// Get information on the current request",
									"const host = pm.request.url.getHost().toLowerCase();",
									"const path = pm.request.getPath;",
									"const method = pm.request.method.toLowerCase();",
									"const contentType = pm.request.headers.get('Content-Type');",
									"",
									"// Build the message digest (in case of POST/PUT/PATCH) and create the signing parameters",
									"let digest;",
									"let sent_headers;",
									"let headers;",
									"",
									"if (method === \"post\" || method === \"put\" || method === \"patch\") {",
									"    digest = calculateDigest(contentType, pm.collectionVariables.get(\"payload\"));",
									"    sent_headers = 'date digest x-request-id' ;",
									"    headers = {",
									"    //  '(request-target)': method + ' ' + path,",
									"        'date': new Date().toGMTString(),",
									"        \"digest\": digest,",
									"        'x-request-id': require('uuid').v4()",
									"    }",
									"}",
									"else {",
									"    digest = undefined;",
									"    sent_headers = 'date x-request-id' ;",
									"    headers = {",
									"    //  '(request-target)': method + ' ' + path,",
									"        'date': new Date().toGMTString(),",
									"        'x-request-id': require('uuid').v4()",
									"    }",
									"}",
									"",
									"// Build the signing string",
									"let normalizedString = Object.entries(headers).map(([key, value]) => `${key}: ${value}`).join('\\n');",
									"",
									"// Encrypt the signing string",
									"const privateKey = pm.collectionVariables.get(\"private_key\"); // mandatory",
									"const encryptedSignature = encryptSignature(privateKey, normalizedString);",
									"",
									"// Create the signature string",
									"const keyId = pm.collectionVariables.get(\"key_id\"); ",
									"const signature = `keyId=\"${keyId}\",algorithm=\"rsa-sha256\",headers=\"${sent_headers}\",signature=\"${encryptedSignature}\"`;",
									"",
									"// Update current request's headers",
									"headers.signature = signature;",
									"Object.entries(headers).forEach(([key, value]) => {",
									"    if(!pm.request.headers.get(key)) ",
									"        pm.request.headers.add({key, value});",
									"});",
									"",
									"/****************** ",
									" Signing functions ",
									"*******************/",
									"// Digest Calculation",
									"function resolveRequestBody(contentType, body) {",
									"",
									"  if (contentType === \"application/x-www-form-urlencoded\") {",
									"  } else if(contentType === 'application/json') {",
									"",
									"        if (body)",
									"            return JSON.stringify(JSON.parse(body));",
									"        else",
									"            return JSON.stringify({});",
									"  }",
									"}",
									"",
									"function calculateDigest(contentType, body) {",
									"  const requestData = resolveRequestBody(contentType, body);",
									"",
									"  const calculatedDigest = 'SHA-256=' + CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(requestData));",
									"  return calculatedDigest;",
									"}",
									"",
									"function encryptSignature(privateKey, normalizedString) {",
									"  const messageDigest = forge.md.sha256.create();",
									"  messageDigest.update(normalizedString, \"utf8\");",
									"  return forge.util.encode64(formatPrivateKey(privateKey).sign(messageDigest));",
									"}",
									"",
									"function formatPrivateKey(privateKey) {",
									"  const formatedPrivKey = forge.pki.privateKeyFromPem(privateKey.replace(/\\\\n/g, '\\n'));",
									"  return formatedPrivKey;",
									"}",
									"",
									""
								]
							}
						},
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									""
								]
							}
						}
					]
				},
				{
					"name": "HTTP Signature",
					"item": [
						{
							"name": "Load ForgeJS library",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract lib and load it in a global variable",
											"const res = pm.response;",
											"pm.globals.set(\"forgeJS\", res.text());",
											"eval (res);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "https://raw.githubusercontent.com/loveiset/RSAForPostman/master/forge.js",
									"protocol": "https",
									"host": [
										"raw",
										"githubusercontent",
										"com"
									],
									"path": [
										"loveiset",
										"RSAForPostman",
										"master",
										"forge.js"
									]
								}
							},
							"response": []
						},
						{
							"name": "Every request to be signed",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"",
											"/****************** ",
											" Signing algorithm",
											"*******************/",
											"// Load ForgeJS for signing",
											"eval(pm.globals.get(\"forgeJS\"));",
											"",
											"// Get information on the current request",
											"const host = pm.request.url.getHost().toLowerCase();",
											"const path = pm.request.getPath;",
											"const method = pm.request.method.toLowerCase();",
											"const contentType = pm.request.headers.get('Content-Type');",
											"",
											"// Build the message digest (in case of POST/PUT/PATCH)",
											"let digest;",
											"let sent_headers;",
											"if (method === \"post\" || method === \"put\" || method === \"patch\") {",
											"    digest = calculateDigest(contentType, pm.collectionVariables.get(\"payload\"));",
											"    sent_headers = 'date digest x-request-id'  ",
											"}",
											"else",
											"    sent_headers = 'date x-request-id'  ",
											"",
											"// Create the signing parameters",
											"let headers = {",
											"  //  '(request-target)': method + ' ' + path,",
											"    'date': new Date().toGMTString(),",
											"    \"digest\": digest,",
											"    'x-request-id': require('uuid').v4()",
											"}",
											"",
											"// Build the signing string",
											"let normalizedString = Object.entries(headers).map(([key, value]) => `${key}: ${value}`).join('\\n');",
											"",
											"// Encrypt the signing string",
											"const privateKey = pm.collectionVariables.get(\"private_key\"); // mandatory",
											"const encryptedSignature = encryptSignature(privateKey, normalizedString);",
											"",
											"// Create the signature string",
											"const keyId = pm.collectionVariables.get(\"key_id\"); ",
											"const signature = `keyId=\"${keyId}\",algorithm=\"rsa-sha256\",headers=\"${sent_headers}\",signature=\"${encryptedSignature}\"`;",
											"",
											"// Update current request's headers",
											"headers.signature = signature;",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key)) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"/****************** ",
											" Signing functions ",
											"*******************/",
											"// Digest Calculation",
											"function resolveRequestBody(contentType, body) {",
											"",
											"  if (contentType === \"application/x-www-form-urlencoded\") {",
											"  } else if(contentType === 'application/json') {",
											"",
											"        if (body)",
											"            return JSON.stringify(JSON.parse(body));",
											"        else",
											"            return JSON.stringify({});",
											"  }",
											"}",
											"",
											"function calculateDigest(contentType, body) {",
											"  const requestData = resolveRequestBody(contentType, body);",
											"",
											"  const calculatedDigest = 'SHA-256=' + CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(requestData));",
											"  return calculatedDigest;",
											"}",
											"",
											"function encryptSignature(privateKey, normalizedString) {",
											"  const messageDigest = forge.md.sha256.create();",
											"  messageDigest.update(normalizedString, \"utf8\");",
											"  return forge.util.encode64(formatPrivateKey(privateKey).sign(messageDigest));",
											"}",
											"",
											"function formatPrivateKey(privateKey) {",
											"  const formatedPrivKey = forge.pki.privateKeyFromPem(privateKey.replace(/\\\\n/g, '\\n'));",
											"  return formatedPrivKey;",
											"}",
											"",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "OPTIONS",
								"header": []
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-http-signature](https://doc.fintecture.com/docs/api-http-signature)",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"type": "text/javascript",
								"exec": [
									""
								]
							}
						},
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									""
								]
							}
						}
					]
				}
			]
		},
		{
			"name": "Integrate payments",
			"item": [
				{
					"name": "Initiate an Immediate Payment",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Create the connect URL",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract session_id & url from provided response body",
											"const res = pm.response.json();",
											"",
											"const session_id = res.meta.session_id;",
											"const connect_url = res.meta.url;",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"session_id\", session_id);",
											"pm.collectionVariables.set(\"connect_url\", connect_url);"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const origin_uri = pm.collectionVariables.get(\"origin_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'origin_uri': origin_uri ?  origin_uri : undefined ,",
											"    'state': state ?  state : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});",
											"",
											"// Fill payload",
											"const b2c_mode = true;",
											"",
											"const b2c_body =  {",
											"    \"meta\": {",
											"        \"psu_name\": \"Julien Lefebre\",",
											"        \"psu_email\": \"julien.lefebre@gmail.com\",",
											"        \"psu_address\": {",
											"            \"number\": \"2\",",
											"            \"street\": \"rue Marie Stuart\",",
											"            \"zip\": \"75002\",",
											"            \"city\": \"PARIS\",",
											"            \"country\": \"FR\"",
											"        }",
											"    },",
											"    \"data\": {",
											"        \"type\": \"payments\",",
											"        \"attributes\": {",
											"            \"amount\": \"273\",",
											"            \"currency\": \"EUR\",",
											"            \"communication\": \"B34970692\"",
											"        }",
											"    }",
											"};",
											"",
											"const b2b_body = {",
											"     \"meta\": {",
											"          \"psu_name\": \"Julien Lefebre\",",
											"          \"psu_email\": \"julien.lefebre@my-business-sarl.com\",",
											"          \"psu_company\": \"My Business SARL\",",
											"          \"psu_incorporation\": \"123456789\",",
											"          \"psu_address\": {",
											"               \"number\": \"2\",",
											"               \"street\": \"rue Marie Stuart\",",
											"               \"zip\": \"75002\",",
											"               \"city\": \"PARIS\",",
											"               \"country\": \"FR\"",
											"          }",
											"     },",
											"     \"data\": {",
											"          \"type\": \"payments\",",
											"          \"attributes\": {",
											"               \"amount\": \"273\",",
											"               \"currency\": \"EUR\",",
											"               \"communication\": \"B34970692\"",
											"          }",
											"     }",
											"};",
											"",
											"const payload = b2c_mode ? JSON.stringify(b2c_body) : JSON.stringify(b2b_body);",
											"",
											"pm.collectionVariables.set(\"payload\", payload);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{{payload}}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"connect"
									]
								}
							},
							"response": []
						},
						{
							"name": "Redirect the payer",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true,
								"disableUrlEncoding": false
							},
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Verify the payment on callback",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}?with_beneficiary={{with_beneficiary}}&with_virtualbeneficiary={{with_virtualbeneficiary}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									],
									"query": [
										{
											"key": "with_beneficiary",
											"value": "{{with_beneficiary}}"
										},
										{
											"key": "with_virtualbeneficiary",
											"value": "{{with_virtualbeneficiary}}"
										}
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-initiate-an-immediate-payment](https://doc.fintecture.com/docs/api-initiate-an-immediate-payment)",
					"event": [
						{
							"listen": "prerequest",
							"script": {
								"type": "text/javascript",
								"exec": [
									"",
									"/****************** ",
									" Signing algorithm",
									"*******************/",
									"// Load ForgeJS for signing",
									"eval(pm.globals.get(\"forgeJS\"));",
									"",
									"// Get information on the current request",
									"const host = pm.request.url.getHost().toLowerCase();",
									"const path = pm.request.getPath;",
									"const method = pm.request.method.toLowerCase();",
									"const contentType = pm.request.headers.get('Content-Type');",
									"",
									"// Build the message digest (in case of POST/PUT/PATCH)",
									"let digest;",
									"let sent_headers;",
									"if (method === \"post\" || method === \"put\" || method === \"patch\") {",
									"    digest = calculateDigest(contentType, pm.collectionVariables.get(\"payload\"));",
									"    sent_headers = 'date digest x-request-id'  ",
									"}",
									"else",
									"    sent_headers = 'date x-request-id'  ",
									"",
									"// Create the signing parameters",
									"let headers = {",
									"  //  '(request-target)': method + ' ' + path,",
									"    'date': new Date().toGMTString(),",
									"    \"digest\": digest,",
									"    'x-request-id': require('uuid').v4()",
									"}",
									"",
									"// Build the signing string",
									"let normalizedString = Object.entries(headers).map(([key, value]) => `${key}: ${value}`).join('\\n');",
									"",
									"// Encrypt the signing string",
									"const privateKey = pm.collectionVariables.get(\"private_key\"); // mandatory",
									"const encryptedSignature = encryptSignature(privateKey, normalizedString);",
									"",
									"// Create the signature string",
									"const keyId = pm.collectionVariables.get(\"key_id\"); ",
									"const signature = `keyId=\"${keyId}\",algorithm=\"rsa-sha256\",headers=\"${sent_headers}\",signature=\"${encryptedSignature}\"`;",
									"",
									"// Update current request's headers",
									"headers.signature = signature;",
									"Object.entries(headers).forEach(([key, value]) => {",
									"    if(!pm.request.headers.get(key)) ",
									"        pm.request.headers.add({key, value});",
									"});",
									"",
									"/****************** ",
									" Signing functions ",
									"*******************/",
									"// Digest Calculation",
									"function resolveRequestBody(contentType, body) {",
									"",
									"  if (contentType === \"application/x-www-form-urlencoded\") {",
									"  } else if(contentType === 'application/json') {",
									"",
									"        if (body)",
									"            return JSON.stringify(JSON.parse(body));",
									"        else",
									"            return JSON.stringify({});",
									"  }",
									"}",
									"",
									"function calculateDigest(contentType, body) {",
									"  const requestData = resolveRequestBody(contentType, body);",
									"",
									"  const calculatedDigest = 'SHA-256=' + CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(requestData));",
									"  return calculatedDigest;",
									"}",
									"",
									"function encryptSignature(privateKey, normalizedString) {",
									"  const messageDigest = forge.md.sha256.create();",
									"  messageDigest.update(normalizedString, \"utf8\");",
									"  return forge.util.encode64(formatPrivateKey(privateKey).sign(messageDigest));",
									"}",
									"",
									"function formatPrivateKey(privateKey) {",
									"  const formatedPrivKey = forge.pki.privateKeyFromPem(privateKey.replace(/\\\\n/g, '\\n'));",
									"  return formatedPrivKey;",
									"}",
									"",
									""
								]
							}
						},
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									""
								]
							}
						}
					]
				},
				{
					"name": "Initiate a Request To Pay",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Initiate a Request To Pay",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const with_virtualbeneficiary = pm.collectionVariables.get(\"with_virtualbeneficiary\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined, // mandatory",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined ,",
											"    'with_virtualbeneficiary': with_virtualbeneficiary ?  with_virtualbeneficiary : undefined ,",
											"    'state': state ?  state : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});",
											"",
											"// Fill payload",
											"const b2c_mode = true;",
											"",
											"const b2c_body =  {",
											"     \"meta\": {",
											"          \"psu_name\": \"Julien Lefebre\",",
											"          \"psu_email\": \"julien.lefebre@gmail.com\",",
											"          \"psu_address\": {",
											"               \"number\": \"2\",",
											"               \"street\": \"rue Marie Stuart\",",
											"               \"zip\": \"75002\",",
											"               \"city\": \"PARIS\",",
											"               \"country\": \"FR\"",
											"          }",
											"     },",
											"     \"data\": {",
											"          \"type\": \"payments\",",
											"          \"attributes\": {",
											"               \"amount\": \"273\",",
											"               \"currency\": \"EUR\",",
											"               \"communication\": \"B34970692\"",
											"          }",
											"     }",
											"};",
											"",
											"const payload = JSON.stringify(b2c_body);",
											"",
											"pm.collectionVariables.set(\"payload\", payload);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{{payload}}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/request-to-pay",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"request-to-pay"
									]
								}
							},
							"response": []
						},
						{
							"name": "Check the payment's status",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}?with_beneficiary={{with_beneficiary}}&with_virtualbeneficiary={{with_virtualbeneficiary}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									],
									"query": [
										{
											"key": "with_beneficiary",
											"value": "{{with_beneficiary}}"
										},
										{
											"key": "with_virtualbeneficiary",
											"value": "{{with_virtualbeneficiary}}"
										}
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-initiate-a-request-to-pay](https://doc.fintecture.com/docs/api-initiate-a-request-to-pay)"
				},
				{
					"name": "Initiate a Buy Now Pay Later payment",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.environment.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Build the BNPL connect URL",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const origin_uri = pm.collectionVariables.get(\"origin_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined,",
											"    'origin_uri': origin_uri ?  origin_uri : undefined ,",
											"    'state': state ?  state : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});",
											"",
											"// Fill payload",
											"const b2b_body =  {",
											"     \"meta\": {",
											"          \"psu_name\": \"Julien Lefebre\",",
											"          \"psu_email\": \"julien.lefebre@my-business.com\",",
											"          \"psu_company\": \"My Business SARL\",",
											"          \"psu_incorporation\": \"524335262\",",
											"          \"type\": \"BuyNowPayLater\"",
											"     },",
											"     \"data\": {",
											"          \"type\": \"payments\",",
											"          \"attributes\": {",
											"               \"amount\": \"273\",",
											"               \"currency\": \"EUR\",",
											"               \"communication\": \"B34970692\"",
											"          }",
											"     }",
											"};",
											"",
											"const payload = JSON.stringify(b2b_body);",
											"",
											"pm.collectionVariables.set(\"payload\", payload);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{{payload}}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"connect"
									]
								}
							},
							"response": []
						},
						{
							"name": "Redirect the payer",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true,
								"disableUrlEncoding": false
							},
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Verify the payment on callback",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}?with_beneficiary={{with_beneficiary}}&with_virtualbeneficiary={{with_virtualbeneficiary}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									],
									"query": [
										{
											"key": "with_beneficiary",
											"value": "{{with_beneficiary}}"
										},
										{
											"key": "with_virtualbeneficiary",
											"value": "{{with_virtualbeneficiary}}"
										}
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/v2-b/docs/api-initiate-a-buy-now-pay-later](https://doc.fintecture.com/v2-b/docs/api-initiate-a-buy-now-pay-later)"
				},
				{
					"name": "Initiate a Smart transfer",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.environment.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Create the connect URL",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const origin_uri = pm.collectionVariables.get(\"origin_uri\");",
											"const with_virtualbeneficiary = pm.collectionVariables.get(\"with_virtualbeneficiary\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined,",
											"    'origin_uri': origin_uri ?  origin_uri : undefined ,",
											"    'with_virtualbeneficiary': with_virtualbeneficiary ?  with_virtualbeneficiary : undefined ,",
											"    'state': state ?  state : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});",
											"",
											"// Fill payload",
											"const b2c_mode = true;",
											"",
											"const b2c_body =  {",
											"    \"meta\": {",
											"        \"psu_name\": \"Julien Lefebre\",",
											"        \"psu_email\": \"julien.lefebre@gmail.com\",",
											"        \"psu_address\": {",
											"            \"number\": \"2\",",
											"            \"street\": \"rue Marie Stuart\",",
											"            \"zip\": \"75002\",",
											"            \"city\": \"PARIS\",",
											"            \"country\": \"FR\"",
											"        },",
											"        \"reconciliation\": {",
											"            \"level\": \"key\",",
											"            \"key\": \"my_key\"",
											"        }",
											"    },",
											"    \"data\": {",
											"        \"type\": \"payments\",",
											"        \"attributes\": {",
											"            \"amount\": \"273\",",
											"            \"currency\": \"EUR\",",
											"            \"communication\": \"B34970692\"",
											"        }",
											"    }",
											"};",
											"",
											"const b2b_body = {",
											"    \"meta\": {",
											"        \"psu_name\": \"Julien Lefebre\",",
											"        \"psu_email\": \"julien.lefebre@my-business-sarl.com\",",
											"        \"psu_company\": \"My Business SARL\",",
											"        \"psu_incorporation\": \"123456789\",",
											"        \"psu_address\": {",
											"            \"number\": \"2\",",
											"            \"street\": \"rue Marie Stuart\",",
											"            \"zip\": \"75002\",",
											"            \"city\": \"PARIS\",",
											"            \"country\": \"FR\"",
											"        },",
											"        \"reconciliation\": {",
											"            \"level\": \"key\",",
											"            \"key\": \"my_key\"",
											"        }",
											"    },",
											"    \"data\": {",
											"        \"type\": \"payments\",",
											"        \"attributes\": {",
											"            \"amount\": \"273\",",
											"            \"currency\": \"EUR\",",
											"            \"communication\": \"B34970692\"",
											"        }",
											"    }",
											"};",
											"",
											"const payload = b2c_mode ? JSON.stringify(b2c_body) : JSON.stringify(b2b_body);",
											"",
											"pm.collectionVariables.set(\"payload\", payload);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{{payload}}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"connect"
									]
								}
							},
							"response": []
						},
						{
							"name": "Redirect the payer",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true,
								"disableUrlEncoding": false
							},
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Verify the payment on callback",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}?with_beneficiary={{with_beneficiary}}&with_virtualbeneficiary={{with_virtualbeneficiary}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									],
									"query": [
										{
											"key": "with_beneficiary",
											"value": "{{with_beneficiary}}"
										},
										{
											"key": "with_virtualbeneficiary",
											"value": "{{with_virtualbeneficiary}}"
										}
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-initiate-a-smart-transfer](https://doc.fintecture.com/docs/api-initiate-a-smart-transfer)"
				},
				{
					"name": "Inititate an Immediate Refund",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Trigger the refund providing the session_id of the original payment",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const origin_uri = pm.collectionVariables.get(\"origin_uri\");",
											"const with_beneficiary = pm.collectionVariables.get(\"with_beneficiary\");",
											"const with_virtualbeneficiary = pm.collectionVariables.get(\"with_virtualbeneficiary\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'origin_uri': origin_uri ?  origin_uri : undefined ,",
											"    \"with_beneficiary\": with_beneficiary ?  with_beneficiary : undefined ,",
											"    'with_virtualbeneficiary': with_virtualbeneficiary ?  with_virtualbeneficiary : undefined ,",
											"    'state': state ?  state : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});",
											"",
											"// Fill payload",
											"const body =  {",
											"    \"meta\": {",
											"        \"session_id\": \"e968987c1d004c51a3457bd14b36d503\"",
											"    },",
											"    \"data\": {",
											"        \"type\": \"payments\",",
											"        \"attributes\": {",
											"            \"amount\": \"273\",",
											"            \"currency\": \"EUR\",",
											"            \"communication\": \"B34970692\"",
											"        }",
											"    }",
											"};",
											"",
											"const payload = JSON.stringify(body);",
											"",
											"pm.collectionVariables.set(\"payload\", payload);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{{payload}}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/refund",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"refund"
									]
								}
							},
							"response": []
						},
						{
							"name": "Verify the payment on callback",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}?with_beneficiary={{with_beneficiary}}&with_virtualbeneficiary={{with_virtualbeneficiary}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									],
									"query": [
										{
											"key": "with_beneficiary",
											"value": "{{with_beneficiary}}"
										},
										{
											"key": "with_virtualbeneficiary",
											"value": "{{with_virtualbeneficiary}}"
										}
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-initiate-an-immediate-refund](https://doc.fintecture.com/docs/api-initiate-an-immediate-refund)"
				},
				{
					"name": "Follow all payments",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Recover all payments",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-follow-all-payments](https://doc.fintecture.com/docs/api-follow-all-payments)"
				},
				{
					"name": "Follow a payment",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Follow the desired payment",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const with_beneficiary = pm.collectionVariables.get(\"with_beneficiary\");",
											"const with_virtualbeneficiary = pm.collectionVariables.get(\"with_virtualbeneficiary\");",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4()",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    \"with_beneficiary\": with_beneficiary ?  with_beneficiary : undefined ,",
											"    'with_virtualbeneficiary': with_virtualbeneficiary ?  with_virtualbeneficiary : undefined ",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});",
											"",
											"// Fill path parameter",
											"const session_id = \"\" // mandatory",
											"",
											"pm.collectionVariables.set(\"session_id\", session_id);",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Content-Type",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-follow-a-payment](https://doc.fintecture.com/docs/api-follow-a-payment)"
				},
				{
					"name": "Update a payment",
					"item": [
						{
							"name": "Request a PIS access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"client_credentials\";",
											"const scope = \"PIS\";",
											"",
											"// Register a client application and get its credentials",
											"const app_id = pm.collectionVariables.get(\"app_id\"); // mandatory",
											"const app_secret = pm.collectionVariables.get(\"app_secret\"); // mandatory",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											"",
											"",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token & expires_in from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										},
										{
											"key": "app_id",
											"value": "{{app_id}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Update the desired payment",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Fill path parameter",
											"const session_id = \"\" // mandatory",
											"",
											"pm.collectionVariables.set(\"session_id\", session_id);",
											"",
											"// Fill payload",
											"const body =  {",
											"     \"meta\": {",
											"          \"status\": \"payment_cancelled\"",
											"     }",
											"};",
											"",
											"const payload = JSON.stringify(body);",
											"",
											"pm.collectionVariables.set(\"payload\", payload);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "PATCH",
								"header": [
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									},
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "text"
									},
									{
										"key": "x-request-id",
										"value": "{{$guid}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{{payload}}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "{{API_BASE_URL}}/pis/v2/payments/{{session_id}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"pis",
										"v2",
										"payments",
										"{{session_id}}"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-update-a-payment](https://doc.fintecture.com/docs/api-update-a-payment)"
				}
			],
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"type": "text/javascript",
						"exec": [
							"",
							"// NOTE : BEFORE EVERY REQUEST PLEASE LOAD ForgeJS LIBRARY (Authentication -> HTTP Signature -> Load ForgeJS library)",
							"",
							"/****************** ",
							" Signing algorithm",
							"*******************/",
							"// Load ForgeJS for signing",
							"eval(pm.globals.get(\"forgeJS\"));",
							"",
							"// Get information on the current request",
							"const host = pm.request.url.getHost().toLowerCase();",
							"const path = pm.request.getPath;",
							"const method = pm.request.method.toLowerCase();",
							"const contentType = pm.request.headers.get('Content-Type');",
							"",
							"// Build the message digest (in case of POST/PUT/PATCH) and create the signing parameters",
							"let digest;",
							"let sent_headers;",
							"let headers;",
							"",
							"if (method === \"post\" || method === \"put\" || method === \"patch\") {",
							"    digest = calculateDigest(contentType, pm.collectionVariables.get(\"payload\"));",
							"    sent_headers = 'date digest x-request-id' ;",
							"    headers = {",
							"    //  '(request-target)': method + ' ' + path,",
							"        'date': new Date().toGMTString(),",
							"        \"digest\": digest,",
							"        'x-request-id': require('uuid').v4()",
							"    }",
							"}",
							"else {",
							"    digest = undefined;",
							"    sent_headers = 'date x-request-id' ;",
							"    headers = {",
							"    //  '(request-target)': method + ' ' + path,",
							"        'date': new Date().toGMTString(),",
							"        'x-request-id': require('uuid').v4()",
							"    }",
							"}",
							"",
							"// Build the signing string",
							"let normalizedString = Object.entries(headers).map(([key, value]) => `${key}: ${value}`).join('\\n');",
							"",
							"// Encrypt the signing string",
							"const privateKey = pm.collectionVariables.get(\"private_key\"); // mandatory",
							"const encryptedSignature = encryptSignature(privateKey, normalizedString);",
							"",
							"// Create the signature string",
							"const keyId = pm.collectionVariables.get(\"key_id\"); ",
							"const signature = `keyId=\"${keyId}\",algorithm=\"rsa-sha256\",headers=\"${sent_headers}\",signature=\"${encryptedSignature}\"`;",
							"",
							"// Update current request's headers",
							"headers.signature = signature;",
							"Object.entries(headers).forEach(([key, value]) => {",
							"    if(!pm.request.headers.get(key)) ",
							"        pm.request.headers.add({key, value});",
							"});",
							"",
							"/****************** ",
							" Signing functions ",
							"*******************/",
							"// Digest Calculation",
							"function resolveRequestBody(contentType, body) {",
							"",
							"  if (contentType === \"application/x-www-form-urlencoded\") {",
							"  } else if(contentType === 'application/json') {",
							"",
							"        if (body)",
							"            return JSON.stringify(JSON.parse(body));",
							"        else",
							"            return JSON.stringify({});",
							"  }",
							"}",
							"",
							"function calculateDigest(contentType, body) {",
							"  const requestData = resolveRequestBody(contentType, body);",
							"",
							"  const calculatedDigest = 'SHA-256=' + CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(requestData));",
							"  return calculatedDigest;",
							"}",
							"",
							"function encryptSignature(privateKey, normalizedString) {",
							"  const messageDigest = forge.md.sha256.create();",
							"  messageDigest.update(normalizedString, \"utf8\");",
							"  return forge.util.encode64(formatPrivateKey(privateKey).sign(messageDigest));",
							"}",
							"",
							"function formatPrivateKey(privateKey) {",
							"  const formatedPrivKey = forge.pki.privateKeyFromPem(privateKey.replace(/\\\\n/g, '\\n'));",
							"  return formatedPrivKey;",
							"}",
							"",
							""
						]
					}
				},
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							""
						]
					}
				}
			]
		},
		{
			"name": "Integrate bank accounts",
			"item": [
				{
					"name": "Recover all bank accounts",
					"item": [
						{
							"name": "Request the AIS Connect URL",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"const scope = undefined;",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'state': state ?  state : undefined,  // mandatory",
											"    'scope': scope ?  scope : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"const res = pm.response.json();",
											"",
											"const connect_url = res.meta.url;",
											"",
											"pm.collectionVariables.set(\"connect_url\", connect_url);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "text"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v2",
										"connect"
									]
								},
								"description": "NOT DESCRIBED"
							},
							"response": []
						},
						{
							"name": "Redirect the user",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// On redirection extract the code received",
											"const fintecture_redirect_url = pm.response.headers.get('location');",
											"",
											"const query_params = fintecture_redirect_url?.split('?');",
											"const bank_code = query_params ? query_params[1].split('&').find(e => e.indexOf('code=') !== -1)?.replace('code=','') : undefined;",
											"const customer_id =  query_params ? query_params[1].split('&').find(e => e.indexOf('customer_id=') !== -1)?.replace('customer_id=','') : undefined;",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"bank_code\", bank_code);",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true
							},
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "referer",
										"value": "{{location}}",
										"type": "default",
										"disabled": true
									}
								],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Exchange the code for an access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"authorization_code\";",
											"const scope = \"AIS\";",
											"",
											"// Retrieve app_id and app_secret from variables",
											"const app_id = pm.collectionVariables.get(\"app_id\");",
											"const app_secret = pm.collectionVariables.get(\"app_secret\");",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token, expires_in & refresh_token from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"const refresh_token = res.refresh_token;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "code",
											"value": "c33052fd5ac38df3f574ded926a51c4a",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Recover all accounts",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Fill path parameter",
											"const customer_id = \"\" // mandatory",
											"",
											"pm.collectionVariables.set(\"customer_id\", customer_id);"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"let res = pm.response.json();",
											"",
											"let account_id = res.data[0].id;",
											"",
											"pm.collectionVariables.set(\"account_id\", account_id);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "default"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v1/customer/{{customer_id}}/accounts",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v1",
										"customer",
										"{{customer_id}}",
										"accounts"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-recover-bank-accounts](https://doc.fintecture.com/docs/api-recover-bank-accounts)"
				},
				{
					"name": "Consult bank account's details",
					"item": [
						{
							"name": "Request the AIS Connect URL",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"const scope = undefined;",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'state': state ?  state : undefined,  // mandatory",
											"    'scope': scope ?  scope : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"const res = pm.response.json();",
											"",
											"const connect_url = res.meta.url;",
											"",
											"pm.collectionVariables.set(\"connect_url\", connect_url);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "text"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v2",
										"connect"
									]
								},
								"description": "NOT DESCRIBED"
							},
							"response": []
						},
						{
							"name": "Redirect the user",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// On redirection extract the code received",
											"const fintecture_redirect_url = pm.response.headers.get('location');",
											"",
											"const query_params = fintecture_redirect_url?.split('?');",
											"const bank_code = query_params ? query_params[1].split('&').find(e => e.indexOf('code=') !== -1)?.replace('code=','') : undefined;",
											"const customer_id =  query_params ? query_params[1].split('&').find(e => e.indexOf('customer_id=') !== -1)?.replace('customer_id=','') : undefined;",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"bank_code\", bank_code);",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true
							},
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "referer",
										"value": "{{location}}",
										"type": "default",
										"disabled": true
									}
								],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Exchange the code for an access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"authorization_code\";",
											"const scope = \"AIS\";",
											"",
											"// Retrieve app_id and app_secret from variables",
											"const app_id = pm.collectionVariables.get(\"app_id\");",
											"const app_secret = pm.collectionVariables.get(\"app_secret\");",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token, expires_in & refresh_token from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"const refresh_token = res.refresh_token;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "code",
											"value": "{{bank_code}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Consult account's details",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Fill path parameters",
											"const customer_id = \"\" // mandatory",
											"const account_id = \"\" // mandatory",
											"",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											"pm.collectionVariables.set(\"account_id\", account_id);"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "default"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v1/customer/{{customer_id}}/accounts/{{account_id}}",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v1",
										"customer",
										"{{customer_id}}",
										"accounts",
										"{{account_id}}"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-consult-bank-account](https://doc.fintecture.com/docs/api-consult-bank-account)"
				},
				{
					"name": "Recover bank account's holders",
					"item": [
						{
							"name": "Request the AIS Connect URL",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"const scope = undefined;",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'state': state ?  state : undefined,  // mandatory",
											"    'scope': scope ?  scope : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"const res = pm.response.json();",
											"",
											"const connect_url = res.meta.url;",
											"",
											"pm.collectionVariables.set(\"connect_url\", connect_url);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "text"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v2",
										"connect"
									]
								},
								"description": "NOT DESCRIBED"
							},
							"response": []
						},
						{
							"name": "Redirect the user",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// On redirection extract the code received",
											"const fintecture_redirect_url = pm.response.headers.get('location');",
											"",
											"const query_params = fintecture_redirect_url?.split('?');",
											"const bank_code = query_params ? query_params[1].split('&').find(e => e.indexOf('code=') !== -1)?.replace('code=','') : undefined;",
											"const customer_id =  query_params ? query_params[1].split('&').find(e => e.indexOf('customer_id=') !== -1)?.replace('customer_id=','') : undefined;",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"bank_code\", bank_code);",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true
							},
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "referer",
										"value": "{{location}}",
										"type": "default",
										"disabled": true
									}
								],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Exchange the code for an access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"authorization_code\";",
											"const scope = \"AIS\";",
											"",
											"// Retrieve app_id and app_secret from variables",
											"const app_id = pm.collectionVariables.get(\"app_id\");",
											"const app_secret = pm.collectionVariables.get(\"app_secret\");",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token, expires_in & refresh_token from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"const refresh_token = res.refresh_token;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "code",
											"value": "{{bank_code}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Recover account's holders",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Fill path parameter",
											"const customer_id = \"\" // mandatory",
											"",
											"pm.collectionVariables.set(\"customer_id\", customer_id);"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "default"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v1/customer/{{customer_id}}/accountholders",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v1",
										"customer",
										"{{customer_id}}",
										"accountholders"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-recover-bank-account-holders](https://doc.fintecture.com/docs/api-recover-bank-account-holders)"
				},
				{
					"name": "Recover bank account's transactions",
					"item": [
						{
							"name": "Request the AIS Connect URL",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Get collection variables",
											"const psu_type = pm.collectionVariables.get(\"psu_type\");",
											"const country_code = pm.collectionVariables.get(\"country_code\");",
											"const language = pm.collectionVariables.get(\"language\");",
											"const provider = pm.collectionVariables.get(\"provider\");",
											"",
											"const redirect_uri = pm.collectionVariables.get(\"redirect_uri\");",
											"const state = pm.collectionVariables.get(\"state\");",
											"const scope = undefined;",
											"",
											"// Fill headers",
											"const headers = {",
											"    'x-request_id': require('uuid').v4(),",
											"    'x-psu_type': psu_type ? psu_type : undefined,",
											"    \"x-country_code\": country_code ? country_code : undefined,",
											"    'x-language': language ? language : undefined,",
											"    'x-provider': provider ? provider : undefined",
											"}",
											"Object.entries(headers).forEach(([key, value]) => {",
											"    if(!pm.request.headers.get(key) && value) ",
											"        pm.request.headers.add({key, value});",
											"});",
											"",
											"// Fill query parameters",
											"const query_params = {",
											"    'redirect_uri': redirect_uri ?  redirect_uri : undefined, // mandatory",
											"    'state': state ?  state : undefined,  // mandatory",
											"    'scope': scope ?  scope : undefined  // mandatory",
											"}",
											"Object.entries(query_params).forEach(([key, value]) => {",
											"    if(value) ",
											"        pm.request.url.query.add(key + \"=\" + value);",
											"});"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"const res = pm.response.json();",
											"",
											"const connect_url = res.meta.url;",
											"",
											"pm.collectionVariables.set(\"connect_url\", connect_url);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "text"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "text"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v2/connect",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v2",
										"connect"
									]
								},
								"description": "NOT DESCRIBED"
							},
							"response": []
						},
						{
							"name": "Redirect the user",
							"event": [
								{
									"listen": "test",
									"script": {
										"exec": [
											"// On redirection extract the code received",
											"const fintecture_redirect_url = pm.response.headers.get('location');",
											"",
											"const query_params = fintecture_redirect_url?.split('?');",
											"const bank_code = query_params ? query_params[1].split('&').find(e => e.indexOf('code=') !== -1)?.replace('code=','') : undefined;",
											"const customer_id =  query_params ? query_params[1].split('&').find(e => e.indexOf('customer_id=') !== -1)?.replace('customer_id=','') : undefined;",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"bank_code\", bank_code);",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"protocolProfileBehavior": {
								"followRedirects": true
							},
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "referer",
										"value": "{{location}}",
										"type": "default",
										"disabled": true
									}
								],
								"url": {
									"raw": "{{connect_url}}",
									"host": [
										"{{connect_url}}"
									]
								}
							},
							"response": []
						},
						{
							"name": "Exchange the code for an access token",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Request a PIS access token",
											"const grant_type = \"authorization_code\";",
											"const scope = \"AIS\";",
											"",
											"// Retrieve app_id and app_secret from variables",
											"const app_id = pm.collectionVariables.get(\"app_id\");",
											"const app_secret = pm.collectionVariables.get(\"app_secret\");",
											"",
											"// Encode your credentials using Base64",
											"let keys = app_id + \":\" + app_secret;",
											"let encodedKeys = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(keys));",
											"",
											"// Set Postman variables",
											"pm.collectionVariables.set(\"base64_token\", encodedKeys);",
											"pm.collectionVariables.set(\"grant_type\", grant_type);",
											"pm.collectionVariables.set(\"scope\", scope);",
											""
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											"// Extract access_token, expires_in & refresh_token from provided response body",
											"const res = pm.response.json();",
											"",
											"const access_token = res.access_token;",
											"const expires_in = res.expires_in;",
											"const refresh_token = res.refresh_token;",
											"",
											"// Set Postman variable",
											"pm.collectionVariables.set(\"access_token\", access_token);"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "POST",
								"header": [
									{
										"key": "Authorization",
										"value": "Basic {{base64_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "Content-Type",
										"value": "application/x-www-form-urlencoded",
										"type": "default"
									}
								],
								"body": {
									"mode": "urlencoded",
									"urlencoded": [
										{
											"key": "grant_type",
											"value": "{{grant_type}}",
											"type": "default"
										},
										{
											"key": "code",
											"value": "{{bank_code}}",
											"type": "default"
										},
										{
											"key": "scope",
											"value": "{{scope}}",
											"type": "default"
										}
									]
								},
								"url": {
									"raw": "{{API_BASE_URL}}/oauth/accesstoken",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"oauth",
										"accesstoken"
									]
								}
							},
							"response": []
						},
						{
							"name": "Recover account's transactions",
							"event": [
								{
									"listen": "prerequest",
									"script": {
										"exec": [
											"// Fill path parameters",
											"const customer_id = \"\" // mandatory",
											"const account_id = \"\" // mandatory",
											"",
											"pm.collectionVariables.set(\"customer_id\", customer_id);",
											"pm.collectionVariables.set(\"account_id\", account_id);"
										],
										"type": "text/javascript"
									}
								},
								{
									"listen": "test",
									"script": {
										"exec": [
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"method": "GET",
								"header": [
									{
										"key": "Authorization",
										"value": "Bearer {{access_token}}",
										"type": "default"
									},
									{
										"key": "Accept",
										"value": "application/json",
										"type": "default"
									},
									{
										"key": "app_id",
										"value": "{{app_id}}",
										"type": "default"
									}
								],
								"url": {
									"raw": "{{API_BASE_URL}}/ais/v1/customer/{{customer_id}}/accounts/{{account_id}}/transactions",
									"host": [
										"{{API_BASE_URL}}"
									],
									"path": [
										"ais",
										"v1",
										"customer",
										"{{customer_id}}",
										"accounts",
										"{{account_id}}",
										"transactions"
									]
								}
							},
							"response": []
						}
					],
					"description": "[https://doc.fintecture.com/docs/api-recover-bank-account-transactions](https://doc.fintecture.com/docs/api-recover-bank-account-transactions)"
				}
			],
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"type": "text/javascript",
						"exec": [
							"",
							"// NOTE : BEFORE EVERY REQUEST PLEASE LOAD ForgeJS LIBRARY (Authentication -> HTTP Signature -> Load ForgeJS library)",
							"",
							"/****************** ",
							" Signing algorithm",
							"*******************/",
							"// Load ForgeJS for signing",
							"eval(pm.globals.get(\"forgeJS\"));",
							"",
							"// Get information on the current request",
							"const host = pm.request.url.getHost().toLowerCase();",
							"const path = pm.request.getPath;",
							"const method = pm.request.method.toLowerCase();",
							"const contentType = pm.request.headers.get('Content-Type');",
							"",
							"// Build the message digest (in case of POST/PUT/PATCH) and create the signing parameters",
							"let digest;",
							"let sent_headers;",
							"let headers;",
							"",
							"if (method === \"post\" || method === \"put\" || method === \"patch\") {",
							"    digest = calculateDigest(contentType, pm.collectionVariables.get(\"payload\"));",
							"    sent_headers = 'date digest x-request-id' ;",
							"    headers = {",
							"    //  '(request-target)': method + ' ' + path,",
							"        'date': new Date().toGMTString(),",
							"        \"digest\": digest,",
							"        'x-request-id': require('uuid').v4()",
							"    }",
							"}",
							"else {",
							"    digest = undefined;",
							"    sent_headers = 'date x-request-id' ;",
							"    headers = {",
							"    //  '(request-target)': method + ' ' + path,",
							"        'date': new Date().toGMTString(),",
							"        'x-request-id': require('uuid').v4()",
							"    }",
							"}",
							"",
							"// Build the signing string",
							"let normalizedString = Object.entries(headers).map(([key, value]) => `${key}: ${value}`).join('\\n');",
							"",
							"// Encrypt the signing string",
							"const privateKey = pm.collectionVariables.get(\"private_key\"); // mandatory",
							"const encryptedSignature = encryptSignature(privateKey, normalizedString);",
							"",
							"// Create the signature string",
							"const keyId = pm.collectionVariables.get(\"key_id\"); ",
							"const signature = `keyId=\"${keyId}\",algorithm=\"rsa-sha256\",headers=\"${sent_headers}\",signature=\"${encryptedSignature}\"`;",
							"",
							"// Update current request's headers",
							"headers.signature = signature;",
							"Object.entries(headers).forEach(([key, value]) => {",
							"    if(!pm.request.headers.get(key)) ",
							"        pm.request.headers.add({key, value});",
							"});",
							"",
							"/****************** ",
							" Signing functions ",
							"*******************/",
							"// Digest Calculation",
							"function resolveRequestBody(contentType, body) {",
							"",
							"  if (contentType === \"application/x-www-form-urlencoded\") {",
							"  } else if(contentType === 'application/json') {",
							"",
							"        if (body)",
							"            return JSON.stringify(JSON.parse(body));",
							"        else",
							"            return JSON.stringify({});",
							"  }",
							"}",
							"",
							"function calculateDigest(contentType, body) {",
							"  const requestData = resolveRequestBody(contentType, body);",
							"",
							"  const calculatedDigest = 'SHA-256=' + CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(requestData));",
							"  return calculatedDigest;",
							"}",
							"",
							"function encryptSignature(privateKey, normalizedString) {",
							"  const messageDigest = forge.md.sha256.create();",
							"  messageDigest.update(normalizedString, \"utf8\");",
							"  return forge.util.encode64(formatPrivateKey(privateKey).sign(messageDigest));",
							"}",
							"",
							"function formatPrivateKey(privateKey) {",
							"  const formatedPrivKey = forge.pki.privateKeyFromPem(privateKey.replace(/\\\\n/g, '\\n'));",
							"  return formatedPrivKey;",
							"}",
							"",
							""
						]
					}
				},
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							""
						]
					}
				}
			]
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "API_BASE_URL",
			"value": "https://api-sandbox-test.fintecture.com",
			"type": "string"
		},
		{
			"key": "app_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "app_secret",
			"value": "",
			"type": "string"
		},
		{
			"key": "private_key",
			"value": "",
			"type": "string"
		},
		{
			"key": "key_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "redirect_uri",
			"value": "https://redirect"
		},
		{
			"key": "origin_uri",
			"value": ""
		},
		{
			"key": "state",
			"value": "123"
		},
		{
			"key": "country_code",
			"value": ""
		},
		{
			"key": "language",
			"value": ""
		},
		{
			"key": "psu_type",
			"value": ""
		},
		{
			"key": "provider",
			"value": ""
		},
		{
			"key": "with_beneficiary",
			"value": ""
		},
		{
			"key": "with_virtualbeneficiary",
			"value": ""
		},
		{
			"key": "base64_token",
			"value": ""
		},
		{
			"key": "grant_type",
			"value": ""
		},
		{
			"key": "scope",
			"value": ""
		},
		{
			"key": "access_token",
			"value": ""
		},
		{
			"key": "request_id",
			"value": ""
		},
		{
			"key": "payload",
			"value": ""
		},
		{
			"key": "session_id",
			"value": ""
		},
		{
			"key": "connect_url",
			"value": ""
		},
		{
			"key": "customer_id",
			"value": ""
		},
		{
			"key": "account_id",
			"value": ""
		}
	]
}