{
	"info": {
		"_postman_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
		"name": "PollenPay API",
		"description": "Complete API collection for PollenPay financing services. Pre-configured with demo merchant credentials for testing.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"variable": [
		{
			"key": "baseUrl",
			"value": "https://bnpl-merchant-sepia.vercel.app/api",
			"type": "string"
		},
		{
			"key": "secretKey",
			"value": "sk_test_Xo4DQ3y4N22xtUBB4WgEZeDl",
			"type": "string"
		},
		{
			"key": "publishableKey",
			"value": "pk_test_n5PMhFJdZmK6nMWsqKdNB486",
			"type": "string"
		},
		{
			"key": "merchantId",
			"value": "mer_40dc2def-8f45-47c8-8771-7bdba2a2ab06",
			"type": "string"
		},
		{
			"key": "sessionId",
			"value": "",
			"type": "string"
		},
		{
			"key": "orderId",
			"value": "",
			"type": "string"
		}
	],
	"item": [
		{
			"name": "Sessions",
			"item": [
				{
					"name": "Initiate Financing Session",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"body": {
							"mode": "raw",
							"raw": "{\n  \"basket\": [\n    {\n      \"referenceId\": \"a1b2c3d4-e5f6-7890-1234-567890abcdef\",\n      \"name\": \"Fancy Shoes\",\n      \"price\": 7500,\n      \"currency\": \"GBP\",\n      \"qty\": 1,\n      \"vat\": 20\n    }\n  ],\n  \"otherBilledItems\": [\n    {\n      \"type\": \"fee\",\n      \"name\": \"Shipping\",\n      \"price\": 999,\n      \"currency\": \"GBP\"\n    }\n  ],\n  \"customerInfo\": {\n    \"email\": \"customer@example.com\",\n    \"phone\": \"+447123456789\"\n  },\n  \"redirectSuccessUrl\": \"https://merchant.com/order-success\",\n  \"redirectFailureUrl\": \"https://merchant.com/order-fail\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/v1/sessions",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "sessions"]
						},
						"description": "Creates a new financing session for a customer. This endpoint is called by the merchant's backend to initiate the financing flow. Returns a sessionId that should be used to redirect the customer to PollenPay."
					},
					"response": []
				},
				{
					"name": "Check Session Status",
					"request": {
						"method": "GET",
						"header": [],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{publishableKey}}",
									"type": "string"
								}
							]
						},
						"url": {
							"raw": "{{baseUrl}}/v1/sessions/:sessionId/status",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "sessions", ":sessionId", "status"],
							"variable": [
								{
									"key": "sessionId",
									"value": "{{sessionId}}",
									"description": "The ID of the financing session"
								}
							]
						},
						"description": "Retrieves the current status of a financing session. Can be called from frontend using publishable key. Returns status such as 'customer_actions_pending', 'pending_settlement', 'approved', 'rejected', or 'abandoned'."
					},
					"response": []
				},
				{
					"name": "Settle Session (Approve)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"body": {
							"mode": "raw",
							"raw": "{\n  \"status\": \"approved\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/v1/sessions/:sessionId/settle",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "sessions", ":sessionId", "settle"],
							"variable": [
								{
									"key": "sessionId",
									"value": "{{sessionId}}",
									"description": "The ID of the financing session to settle"
								}
							]
						},
						"description": "Finalizes a financing session after customer authorization. This endpoint allows merchants to perform final checks (stock, fraud) before confirming the order. Approving will create the order."
					},
					"response": []
				},
				{
					"name": "Settle Session (Reject)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"body": {
							"mode": "raw",
							"raw": "{\n  \"status\": \"rejected\",\n  \"reason\": \"Stock unavailable\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/v1/sessions/:sessionId/settle",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "sessions", ":sessionId", "settle"],
							"variable": [
								{
									"key": "sessionId",
									"value": "{{sessionId}}",
									"description": "The ID of the financing session to settle"
								}
							]
						},
						"description": "Finalizes a financing session by rejecting it. Use this when final checks (stock, fraud) fail. Requires a reason for rejection."
					},
					"response": []
				}
			],
			"description": "Endpoints for managing financing sessions. Sessions represent the financing application flow from initiation through customer authorization to final settlement."
		},
		{
			"name": "Orders",
			"item": [
				{
					"name": "Get Order Events",
					"request": {
						"method": "GET",
						"header": [],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"url": {
							"raw": "{{baseUrl}}/v1/events?order={{orderId}}",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "events"],
							"query": [
								{
									"key": "order",
									"value": "{{orderId}}",
									"description": "Optional order ID to filter events. Leave empty to get latest events across all orders."
								}
							]
						},
						"description": "Query the latest order events for the merchant. Returns up to 3 most recent events. Optionally filter by a specific orderId. Events include order lifecycle changes, payments, refunds, and other significant updates."
					},
					"response": []
				},
				{
					"name": "Get All Orders",
					"request": {
						"method": "GET",
						"header": [],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"url": {
							"raw": "{{baseUrl}}/v1/orders",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "orders"]
						},
						"description": "Retrieves a list of all finalized orders for the merchant."
					},
					"response": []
				},
				{
					"name": "Get Order by ID",
					"request": {
						"method": "GET",
						"header": [],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"url": {
							"raw": "{{baseUrl}}/v1/orders/:orderId",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "orders", ":orderId"],
							"variable": [
								{
									"key": "orderId",
									"value": "{{orderId}}",
									"description": "ID of the order to retrieve"
								}
							]
						},
						"description": "Retrieves a single order by its unique identifier. Returns full order details including basket, payment information, and status."
					},
					"response": []
				},
				{
					"name": "Initiate Refund",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"auth": {
							"type": "bearer",
							"bearer": [
								{
									"key": "token",
									"value": "{{secretKey}}",
									"type": "string"
								}
							]
						},
						"body": {
							"mode": "raw",
							"raw": "{\n  \"refundItems\": [\n    {\n      \"name\": \"Fancy Shoes\",\n      \"qty\": 1,\n      \"amount\": 7500\n    }\n  ],\n  \"totalRefundAmount\": 7500,\n  \"reason\": \"Customer returned one item.\"\n}"
						},
						"url": {
							"raw": "{{baseUrl}}/v1/orders/:orderId/refund",
							"host": ["{{baseUrl}}"],
							"path": ["v1", "orders", ":orderId", "refund"],
							"variable": [
								{
									"key": "orderId",
									"value": "{{orderId}}",
									"description": "The ID of the order to refund"
								}
							]
						},
						"description": "Initiates a full or partial refund for an order. Provide the items being refunded, total refund amount (in pence), and a reason. This will trigger a refund order event and adjust the outstanding balance."
					},
					"response": []
				}
			],
			"description": "Endpoints for managing orders. Orders are created after successful session settlement and represent the finalized financing agreement."
		}
	]
}

