{
	"info": {
		"_postman_id": "e6268840-6ee3-4c23-9de5-7814d98a4a97",
		"name": "Order Management API",
		"description": "API to add and read additional info for Vipps MobilePay orders. See the [API Guide](https://developer.vippsmobilepay.com/docs/APIs/order-management-api) for more information.\n\nContact Support:\n Name: Vipps MobilePay",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "31688623"
	},
	"item": [
		{
			"name": "Get Access Token",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.environment.set(\"access_token\", pm.response.json().access_token);"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "client_id",
						"value": "{{client_id}}"
					},
					{
						"key": "client_secret",
						"value": "{{client_secret}}"
					},
					{
						"key": "Ocp-Apim-Subscription-Key",
						"value": "{{Ocp-Apim-Subscription-Key}}"
					},
					{
						"key": "Merchant-Serial-Number",
						"value": "{{merchantSerialNumber}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Name",
						"value": "{{vipps_system_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Version",
						"value": "{{vipps_system_version}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Name",
						"value": "{{vipps_system_plugin_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Version",
						"value": "{{vipps_system_plugin_version}}",
						"type": "default"
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "{{base_url}}/accessToken/get",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"accessToken",
						"get"
					]
				}
			},
			"response": []
		},
		{
			"name": "Initiate Payment",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							"pm.environment.set('orderId',pm.environment.get('merchantSerialNumber') + (new Date()).getTime());"
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"if(pm.response.code === 200) { ",
							"    var jsonData = pm.response.json();",
							"    pm.environment.set('LandingPageURL', jsonData.url);",
							"    var str = jsonData.url",
							"    var str2 = str.split('=', 3)[2]",
							"    pm.environment.set('payment_token', str2);",
							"}"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "Ocp-Apim-Subscription-Key",
						"value": "{{Ocp-Apim-Subscription-Key}}"
					},
					{
						"key": "Authorization",
						"value": "Bearer {{access_token}}"
					},
					{
						"key": "Merchant-Serial-Number",
						"value": "{{merchantSerialNumber}}",
						"type": "text"
					},
					{
						"key": "Vipps-System-Name",
						"value": "{{vipps_system_name}}",
						"type": "text"
					},
					{
						"key": "Vipps-System-Version",
						"value": "{{vipps_system_version}}",
						"type": "text"
					},
					{
						"key": "Vipps-System-Plugin-Name",
						"value": "{{vipps_system_plugin_name}}",
						"type": "text"
					},
					{
						"key": "Vipps-System-Plugin-Version",
						"value": "{{vipps_system_plugin_version}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"merchantInfo\": {\n    \"authToken\": \"{{$guid}}\",\n    \"callbackPrefix\":\"{{callbackPrefix}}\",\n    \"fallBack\": \"{{fallBack}}\",\n    \"merchantSerialNumber\": \"{{merchantSerialNumber}}\"\n  },\n  \"customerInfo\": {\n    \"mobileNumber\": \"{{mobileNumber}}\"\n  },\n  \"transaction\": {\n    \"amount\": {{amount}},\n    \"orderId\": \"{{orderId}}\",\n    \"transactionText\": \"{{transactionTextInitiate}}\",\n    \"skipLandingPage\": false\n}\n}"
				},
				"url": {
					"raw": "{{base_url}}/ecomm/v2/payments/",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"ecomm",
						"v2",
						"payments",
						""
					]
				},
				"description": "This is the default, simple initiate request."
			},
			"response": []
		},
		{
			"name": "Add order details to an order",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Merchant-Serial-Number",
						"value": "{{merchantSerialNumber}}",
						"description": "(Required) The merchant serial number for this sales unit."
					},
					{
						"key": "Ocp-Apim-Subscription-Key",
						"value": "{{Ocp-Apim-Subscription-Key}}",
						"description": "(Required) The API subscription key."
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Authorization",
						"value": "Bearer {{access_token}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Name",
						"value": "{{vipps_system_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Version",
						"value": "{{vipps_system_version}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Name",
						"value": "{{vipps_system_plugin_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Version",
						"value": "{{vipps_system_plugin_version}}",
						"type": "default"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"orderLines\": [\n    {\n      \"name\": \"Socks\",\n      \"id\": \"line_item_1\",\n      \"totalAmount\": 1000,\n      \"totalAmountExcludingTax\": 800,\n      \"totalTaxAmount\": 200,\n      \"taxRate\": 2500,\n      \"unitInfo\": {\n        \"unitPrice\": 400,\n        \"quantity\": \"2.5\",\n        \"quantityUnit\": \"KG\"\n      },\n      \"discount\": 0,\n      \"productUrl\": \"https://example.com/store/socks\",\n      \"isReturn\": false,\n      \"isShipping\": false\n    },\n    {\n      \"name\": \"Flip-flops\",\n      \"id\": \"line_item_2\",\n      \"totalAmount\": 5000,\n      \"totalAmountExcludingTax\": 4000,\n      \"totalTaxAmount\": 1000,\n      \"taxRate\": 2550,\n      \"unitInfo\": {\n        \"unitPrice\": 2500,\n        \"quantity\": \"3\",\n        \"quantityUnit\": \"PCS\"\n      },\n      \"discount\": 2500,\n      \"productUrl\": \"https://example.com/store/flipflops\",\n      \"isReturn\": false,\n      \"isShipping\": false\n    },\n    {\n      \"name\": \"Home delivery\",\n      \"id\": \"shipping_1\",\n      \"totalAmount\": 1000,\n      \"totalAmountExcludingTax\": 1000,\n      \"totalTaxAmount\": 0,\n      \"taxRate\": 0,\n      \"discount\": 0,\n      \"isReturn\": false,\n      \"isShipping\": true\n    }\n  ],\n  \"bottomLine\": {\n    \"currency\": \"NOK\",\n    \"posId\": \"vipps_pos_122\",\n    \"receiptNumber\": \"123456789\"\n  }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{base_url}}/order-management/v2/eCom/receipts/{{orderId}}",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"order-management",
						"v2",
						"eCom",
						"receipts",
						"{{orderId}}"
					]
				},
				"description": "Add receipt to an order."
			},
			"response": []
		},
		{
			"name": "Get order with order details",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Merchant-Serial-Number",
						"value": "{{merchantSerialNumber}}",
						"description": "(Required) The merchant serial number for this sales unit."
					},
					{
						"key": "Ocp-Apim-Subscription-Key",
						"value": "{{Ocp-Apim-Subscription-Key}}",
						"description": "(Required) The API subscription key."
					},
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Authorization",
						"value": "Bearer {{access_token}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Name",
						"value": "{{vipps_system_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Version",
						"value": "{{vipps_system_version}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Name",
						"value": "{{vipps_system_plugin_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Version",
						"value": "{{vipps_system_plugin_version}}",
						"type": "default"
					}
				],
				"url": {
					"raw": "{{base_url}}/order-management/v2/ecom/{{orderId}}",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"order-management",
						"v2",
						"ecom",
						"{{orderId}}"
					]
				},
				"description": "Get order with category and receipt"
			},
			"response": []
		},
		{
			"name": "Upload an image",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							"var uuid = require('uuid')\r",
							"var unique_image_id = 'imageid_' + uuid.v4()\r",
							"pm.environment.set(\"imageId\", unique_image_id)"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Merchant-Serial-Number",
						"value": "{{merchantSerialNumber}}",
						"description": "(Required) The merchant serial number for this sales unit."
					},
					{
						"key": "Ocp-Apim-Subscription-Key",
						"value": "{{Ocp-Apim-Subscription-Key}}",
						"description": "(Required) The API subscription key."
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Authorization",
						"value": "Bearer {{access_token}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Name",
						"value": "{{vipps_system_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Version",
						"value": "{{vipps_system_version}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Name",
						"value": "{{vipps_system_plugin_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Version",
						"value": "{{vipps_system_plugin_version}}",
						"type": "default"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"imageId\": \"{{imageId}}\",\n  \"src\": \"iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAABo0lEQVR42u3SQQ0AMAgAMfyLmDx0YIFksH1aCZeLAwtCAoyFsTAWGAtjYSx4NFZCg7EwFsbCWMbCWBgLYxkLY2EsjGUsjIWxMJaxMBbGwljGwlgYC2MZC2NhLIxlLIyFsTCWsTAWxsJYxsJYGAtjGQtjYSyMZSyMhbEwlrEwFsbCWMbCWBgLYxkLY2EsjGUsjIWxMJaxMBbGwlhgLIyFscBYGAtjgbEwFsYCY2EsjAXGwlgYC4yFsTAWGAtjYSwwFsbCWGAsjIWxwFgYC2OBsTAWxgJjYSyMhbGMhbEwFsYyFsbCWBjLWBgLY2EsY2EsjIWxjIWxMBbGMhbGwlgYy1gYC2NhLGNhLIyFsYyFsTAWxjIWxsJYGMtYGAtjYSxjYSyMhbGMhbEwFsYyFsbCWBjLWBgLY2EsY2EsjIWxwFgYC2OBsTAWxgJjYSyMBcbCWBgLjIWxMBYYC2NhLDAWxsJYYCyMhbHAWBgLY4GxMBbGAmNhLIwFxsJYGAtjGQtjYSyMZSyMhbEwlrEwFsbCWMbi51hww1gYC2NhLDAWxsJYMKwAo7/78eLTClwAAAAASUVORK5CYII=\",\n  \"type\": \"base64\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{base_url}}/order-management/v1/images",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"order-management",
						"v1",
						"images"
					]
				},
				"description": "Endpoint for uploading images. A imageId will be returned that can be used when adding metadata to orders."
			},
			"response": []
		},
		{
			"name": "Add category to an order",
			"request": {
				"method": "PUT",
				"header": [
					{
						"key": "Merchant-Serial-Number",
						"value": "{{merchantSerialNumber}}",
						"description": "(Required) The merchant serial number for this sales unit."
					},
					{
						"key": "Ocp-Apim-Subscription-Key",
						"value": "{{Ocp-Apim-Subscription-Key}}",
						"description": "(Required) The API subscription key."
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					},
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Authorization",
						"value": "Bearer {{access_token}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Name",
						"value": "{{vipps_system_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Version",
						"value": "{{vipps_system_version}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Name",
						"value": "{{vipps_system_plugin_name}}",
						"type": "default"
					},
					{
						"key": "Vipps-System-Plugin-Version",
						"value": "{{vipps_system_plugin_version}}",
						"type": "default"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"category\": \"GENERAL\",\n  \"orderDetailsUrl\": \"https://example.com/{{orderId}}\",\n  \"imageId\": \"{{imageId}}\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{base_url}}/order-management/v2/eCom/categories/{{orderId}}",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"order-management",
						"v2",
						"eCom",
						"categories",
						"{{orderId}}"
					]
				},
				"description": "The category adds a link, specified by you, to the Transaction page on the Vipps MobilePay app. Only one (the latest) category is shown in the app."
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "baseUrl",
			"value": "https://api.vipps.no/order-management",
			"type": "string"
		}
	]
}