{
	"info": {
		"name": "Ecom365 - Bhojana Basket API",
		"description": "Customer-facing flow for the Bhojana Basket shop: login, browse, cart, address, checkout, orders. Mirrors the Vevvion e-shop flow and uses the same shared commission engine.\n\nSection 7 covers the ID-activation flow shared by every store: /products lists the activation packs (availability 1) and \"Both\" products (availability 3) of Vevvion, Bhojana Basket and the eShop vendors on one list; they are all added to the one activation cart (/cart) and paid through the one activation payment (/orders/store, Razorpay / Bank Account). Store carts never accept activation packs, and the activation cart never accepts store catalogue items.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"auth": {
		"type": "bearer",
		"bearer": [
			{ "key": "token", "value": "{{token}}", "type": "string" }
		]
	},
	"variable": [
		{ "key": "base_url", "value": "http://127.0.0.1:8000/api" },
		{ "key": "token", "value": "" },
		{ "key": "product_id", "value": "null" },
		{ "key": "product_pricing_id", "value": "null" },
		{ "key": "cart_id", "value": "null" },
		{ "key": "address_id", "value": "null" },
		{ "key": "order_id", "value": "null" },
		{ "key": "activation_product_id", "value": "null" },
		{ "key": "activation_cart_id", "value": "null" }
	],
	"item": [
		{
			"name": "1. Auth",
			"item": [
				{
					"name": "Login",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"if (res && res.data && res.data.token) {",
									"    pm.collectionVariables.set('token', res.data.token);",
									"}"
								]
							}
						}
					],
					"request": {
						"auth": { "type": "noauth" },
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"username\": \"9876543210\",\n  \"password\": \"yourpassword\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/login",
							"host": ["{{base_url}}"],
							"path": ["login"]
						},
						"description": "username accepts email, mobile, or access_code. Response data.token is saved to {{token}} automatically."
					}
				}
			]
		},
		{
			"name": "2. Browse - Bhojana Basket",
			"item": [
				{
					"name": "List Bhojana Basket Products",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"const products = (res && res.data) ? res.data : [];",
									"if (products.length > 0) {",
									"    const first = products[0];",
									"    pm.collectionVariables.set('product_id', first.id);",
									"    if (first.pricings && first.pricings.length > 0) {",
									"        const defaultPricing = first.pricings.find(p => p.is_default == 1) || first.pricings[0];",
									"        pm.collectionVariables.set('product_pricing_id', defaultPricing.id);",
									"    } else {",
									"        pm.collectionVariables.set('product_pricing_id', 'null');",
									"    }",
									"    console.log('Captured product_id=' + first.id);",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/vendors/bhojana-basket/products?per_page=16&search=&filter_by[is_in_stock]=1",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "vendors", "bhojana-basket", "products"],
							"query": [
								{ "key": "per_page", "value": "16" },
								{ "key": "search", "value": "", "disabled": true },
								{ "key": "filter_by[is_in_stock]", "value": "1", "disabled": true }
							]
						},
						"description": "Run this first — it automatically captures product_id and product_pricing_id (the default variant) from the first product returned, so downstream requests work without manual edits."
					}
				},
				{
					"name": "Bhojana Basket Product Detail",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"const product = res ? res.data : null;",
									"if (product && product.id) {",
									"    pm.collectionVariables.set('product_id', product.id);",
									"    if (product.pricings && product.pricings.length > 0) {",
									"        const defaultPricing = product.pricings.find(p => p.is_default == 1) || product.pricings[0];",
									"        pm.collectionVariables.set('product_pricing_id', defaultPricing.id);",
									"    } else {",
									"        pm.collectionVariables.set('product_pricing_id', 'null');",
									"    }",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/vendors/bhojana-basket/products/{{product_id}}",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "vendors", "bhojana-basket", "products", "{{product_id}}"]
						}
					}
				}
			]
		},
		{
			"name": "3. Cart",
			"item": [
				{
					"name": "View Cart",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"const items = (res && res.data && res.data.cart_products) ? res.data.cart_products : [];",
									"if (items.length > 0) {",
									"    pm.collectionVariables.set('cart_id', items[0].id);",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/cart",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "cart"]
						},
						"description": "Auto-captures cart_id from the first cart line item for the Update/Remove Cart Item requests."
					}
				},
				{
					"name": "Add to Cart",
					"request": {
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"product_id\": {{product_id}},\n  \"product_pricing_id\": {{product_pricing_id}},\n  \"quantity\": 2\n}"
						},
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/cart/store",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "cart", "store"]
						},
						"description": "product_pricing_id is the selected pricing/variant row (e.g. \"1kg\", \"2kg\") from the product list/detail response. Omit or set null for products without variants. Add \"type\": \"buynow\" to clear the existing cart first."
					}
				},
				{
					"name": "Decrease Cart Item Quantity",
					"request": {
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"product_id\": {{product_id}},\n  \"product_pricing_id\": {{product_pricing_id}},\n  \"quantity\": 1,\n  \"action\": \"sub\"\n}"
						},
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/cart/store",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "cart", "store"]
						}
					}
				},
				{
					"name": "Remove Cart Item",
					"request": {
						"method": "DELETE",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/cart/delete/{{cart_id}}",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "cart", "delete", "{{cart_id}}"]
						}
					}
				},
				{
					"name": "Empty Cart",
					"request": {
						"method": "DELETE",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/cart/empty",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "cart", "empty"]
						}
					}
				},
				{
					"name": "Related Products (Cart-based)",
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/cart/related-product?limit=5",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "cart", "related-product"],
							"query": [{ "key": "limit", "value": "5" }]
						}
					}
				}
			]
		},
		{
			"name": "4. Address",
			"item": [
				{
					"name": "List Addresses",
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/address",
							"host": ["{{base_url}}"],
							"path": ["address"]
						}
					}
				},
				{
					"name": "Add Address",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"if (res && res.data && res.data.id) {",
									"    pm.collectionVariables.set('address_id', res.data.id);",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"Ramesh Kumar\",\n  \"mobile\": \"9876543210\",\n  \"email\": \"ramesh@example.com\",\n  \"flat_no\": \"12A\",\n  \"area_street\": \"Gandhi Street\",\n  \"landmark\": \"Near Bus Stand\",\n  \"pincode\": \"600001\",\n  \"district\": \"Chennai\",\n  \"city\": \"Chennai\",\n  \"state\": \"Tamil Nadu\",\n  \"country\": \"India\",\n  \"address_type\": 1,\n  \"is_default_address\": 1\n}"
						},
						"url": {
							"raw": "{{base_url}}/address/store",
							"host": ["{{base_url}}"],
							"path": ["address", "store"]
						},
						"description": "Note: if any product in the cart has is_delivery_within_tamilnadu=1, checkout will reject any address where state != \"Tamil Nadu\"."
					}
				}
			]
		},
		{
			"name": "5. Checkout",
			"item": [
				{
					"name": "Place Order",
					"request": {
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"sub_total\": 240,\n  \"shipping_cost\": 20,\n  \"net_total\": 260,\n  \"delivery_method\": \"Courier Mode\",\n  \"order_address_id\": {{address_id}},\n  \"is_wallet_pin_required\": 1,\n  \"wpin\": \"123456\",\n  \"ecoins_value\": 0,\n  \"epass_value\": 0,\n  \"order_products\": [\n    {\n      \"product_id\": {{product_id}},\n      \"quantity\": 2,\n      \"unit_price\": 120,\n      \"total\": 240,\n      \"shipping_cost\": 20\n    }\n  ]\n}"
						},
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/users/orders/store",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "users", "orders", "store"]
						},
						"description": "Pays from wallet cash balance. wpin only required/validated when is_wallet_pin_required=1. On success: deducts wallet, creates the order, computes vendor CRC commission, fires the 20-level MLM bonus, and clears the cart."
					}
				}
			]
		},
		{
			"name": "6. Orders",
			"item": [
				{
					"name": "Order History",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"const orders = (res && res.data) ? res.data : [];",
									"if (orders.length > 0) {",
									"    pm.collectionVariables.set('order_id', orders[0].id);",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/bhojana-basket/users/orders/lists",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "bhojana-basket", "users", "orders", "lists"]
						},
						"description": "Auto-captures order_id (the OnlineStoreVendorOrder id) from the most recent order for the Order Detail/Invoice requests."
					}
				},
				{
					"name": "Order Detail",
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/users/orders/show/{{order_id}}",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "users", "orders", "show", "{{order_id}}"]
						}
					}
				},
				{
					"name": "Order Invoice",
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/online-stores/users/orders/invoice/{{order_id}}",
							"host": ["{{base_url}}"],
							"path": ["online-stores", "users", "orders", "invoice", "{{order_id}}"]
						}
					}
				}
			]
		},
		{
			"name": "7. Activation (All Stores)",
			"description": "One activation list, one activation cart and one activation payment for the activation packs of every store (Vevvion, Bhojana Basket, eShop vendors). Each product carries shop, availability (1 = activation pack, 3 = both) and is_activation_pack.",
			"item": [
				{
					"name": "List Activation Products (All Stores)",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"const items = (res && res.data) ? res.data : [];",
									"if (items.length > 0) {",
									"    pm.collectionVariables.set('activation_product_id', items[0].id);",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/products?include=paginate&per_page=15",
							"host": ["{{base_url}}"],
							"path": ["products"],
							"query": [
								{ "key": "include", "value": "paginate" },
								{ "key": "per_page", "value": "15" },
								{ "key": "shop", "value": "all", "disabled": true, "description": "Omit / all = every store on one list. vevvion or bhojana-basket narrows to that store." },
								{ "key": "name", "value": "", "disabled": true }
							]
						},
						"description": "Activation packs (availability 1) and \"Both\" products (availability 3) from every store on the same list. Auto-captures activation_product_id from the first row."
					}
				},
				{
					"name": "Activation Product Detail",
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/product/show/{{activation_product_id}}",
							"host": ["{{base_url}}"],
							"path": ["product", "show", "{{activation_product_id}}"]
						}
					}
				},
				{
					"name": "Add to Activation Cart",
					"request": {
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"product_id\": {{activation_product_id}},\n  \"quantity\": 1\n}"
						},
						"url": {
							"raw": "{{base_url}}/cart/store",
							"host": ["{{base_url}}"],
							"path": ["cart", "store"]
						},
						"description": "Accepts only activation packs / \"Both\" products (availability 1/3), from any store. Store catalogue items are rejected with 422 and must be added from their store cart. Variant products get their default pricing attached automatically."
					}
				},
				{
					"name": "View Activation Cart",
					"event": [
						{
							"listen": "test",
							"script": {
								"type": "text/javascript",
								"exec": [
									"const res = pm.response.json();",
									"const items = (res && res.data) ? res.data : [];",
									"if (items.length > 0) {",
									"    pm.collectionVariables.set('activation_cart_id', items[0].id);",
									"}"
								]
							}
						}
					],
					"request": {
						"method": "GET",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/cart",
							"host": ["{{base_url}}"],
							"path": ["cart"]
						},
						"description": "Only activation-flow rows (availability 1/3). Rows in the Vevvion / eShop / Bhojana Basket store carts never appear here."
					}
				},
				{
					"name": "Remove Activation Cart Item",
					"request": {
						"method": "DELETE",
						"header": [{ "key": "Accept", "value": "application/json" }],
						"url": {
							"raw": "{{base_url}}/cart/delete/{{activation_cart_id}}",
							"host": ["{{base_url}}"],
							"path": ["cart", "delete", "{{activation_cart_id}}"]
						}
					}
				},
				{
					"name": "Place Activation Order (Razorpay)",
					"request": {
						"method": "POST",
						"header": [
							{ "key": "Accept", "value": "application/json" },
							{ "key": "Content-Type", "value": "application/json" }
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"live_mode\": 1,\n  \"payment_method\": \"Razorpay\",\n  \"payment_date\": \"2026-08-25 10:00:00\",\n  \"payment_reference_no\": \"pay_XXXXXXXXXXXXXX\",\n  \"sub_total\": 3200,\n  \"tax_amount\": 0,\n  \"shipping_cost\": 0,\n  \"total\": 3200,\n  \"delivery_method\": \"Courier Mode\",\n  \"order_address_id\": {{address_id}},\n  \"order_products\": [\n    {\n      \"product_id\": {{activation_product_id}},\n      \"product_pricing_id\": null,\n      \"quantity\": 1,\n      \"unit_price\": 3200\n    }\n  ]\n}"
						},
						"url": {
							"raw": "{{base_url}}/orders/store",
							"host": ["{{base_url}}"],
							"path": ["orders", "store"]
						},
						"description": "The one activation payment for every store's packs. Rejects any product that is not availability 1/3. product_pricing_id is optional (variant products fall back to their default pricing for stock). On Razorpay capture the ID is activated (is_verified_access_code=1) via the queued UserBusinessValueAndLevelUpdateEvent; ordered rows are removed from the activation cart only — the store carts are untouched."
					}
				}
			]
		}
	]
}
