{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "data/receipt", "title": "Receipt", "description": "A Versa itemized receipt", "type": "object", "additionalProperties": false, "required": ["version", "header", "itemization", "actions", "payments"], "properties": { "version": { "type": "string", "minLength": 5, "maxLength": 14, "pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$" }, "header": { "type": "object", "additionalProperties": false, "required": [ "receipt_id", "currency", "total", "subtotal", "paid", "invoiced_at", "mcc", "third_party", "customer", "location" ], "properties": { "receipt_id": { "type": "string" }, "currency": { "description": "ISO 4217 currency code", "type": "string", "enum": ["usd", "eur", "jpy", "gbp", "aud", "cad", "chf", "cnh"] }, "total": { "type": "integer" }, "subtotal": { "type": "integer" }, "paid": { "type": "integer" }, "invoiced_at": { "type": "integer" }, "mcc": { "type": ["string", "null"] }, "third_party": { "type": ["object", "null"], "additionalProperties": false, "required": ["first_party_relation", "make_primary", "merchant"], "properties": { "first_party_relation": { "type": "string", "enum": [ "bnpl", "delivery_service", "marketplace", "payment_processor", "platform", "point_of_sale" ] }, "make_primary": { "description": "Determines whether the merchant or third party gets top billing on the receipt", "type": "boolean" }, "merchant": { "$ref": "#/$defs/merchant" } } }, "customer": { "type": ["object", "null"], "required": ["name", "email", "address", "phone"], "properties": { "name": { "type": "string" }, "email": { "type": ["string", "null"], "format": "email", "minLength": 6, "maxLength": 127 }, "address": { "oneOf": [ { "type": "null" }, { "$ref": "#/$defs/address" } ] }, "phone": { "type": ["string", "null"] } } }, "location": { "oneOf": [ { "$ref": "#/$defs/place" }, { "type": "null" } ] } } }, "itemization": { "$ref": "#/$defs/itemization" }, "actions": { "oneOf": [ { "type": "null" }, { "type": "array", "items": { "type": "object", "required": ["name", "url"], "properties": { "name": { "type": "string" }, "url": { "type": "string", "format": "uri" } } } } ] }, "payments": { "oneOf": [ { "type": "null" }, { "type": "array", "items": { "type": "object", "required": [ "amount", "paid_at", "payment_type", "card_payment", "ach_payment" ], "properties": { "amount": { "type": "integer" }, "paid_at": { "type": "integer" }, "payment_type": { "type": "string", "enum": ["card", "ach"] } }, "allOf": [ { "if": { "properties": { "payment_type": { "const": "card" } } }, "then": { "properties": { "card_payment": { "type": "object", "required": ["last_four", "network"], "properties": { "last_four": { "type": "string" }, "network": { "type": "string", "enum": [ "amex", "diners", "discover", "eftpos_au", "jcb", "mastercard", "unionpay", "visa" ] } } }, "ach_payment": { "type": "null" } } } }, { "if": { "properties": { "payment_type": { "const": "ach" } } }, "then": { "properties": { "card_payment": { "type": "null" }, "ach_payment": { "type": "object", "required": ["routing_number"], "properties": { "routing_number": { "type": "string" } } } } } } ] } } ] } }, "$defs": { "car_rental": { "type": "object", "required": [ "rental_at", "return_at", "rental_location", "return_location", "vehicle", "driver_name", "odometer_reading_in", "odometer_reading_out", "items", "invoice_level_adjustments" ], "properties": { "rental_at": { "type": "integer" }, "return_at": { "type": "integer" }, "rental_location": { "$ref": "#/$defs/place" }, "return_location": { "$ref": "#/$defs/place" }, "vehicle": { "type": ["object", "null"], "required": ["description", "image"], "properties": { "description": { "type": "string" }, "image": { "type": ["string", "null"], "format": "uri" } } }, "driver_name": { "type": "string" }, "odometer_reading_in": { "type": "integer" }, "odometer_reading_out": { "type": "integer" }, "items": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item" } }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "flight": { "type": "object", "required": ["tickets", "itinerary_locator", "invoice_level_adjustments"], "properties": { "tickets": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/flight_ticket" } }, "itinerary_locator": { "type": ["null", "string"] }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "flight_segment": { "type": "object", "required": [ "fare", "departure_airport_code", "arrival_airport_code", "departure_at", "arrival_at", "flight_number", "class_of_service", "taxes", "adjustments" ], "properties": { "fare": { "type": "integer" }, "departure_airport_code": { "type": "string" }, "arrival_airport_code": { "type": "string" }, "departure_at": { "type": ["null", "integer"] }, "arrival_at": { "type": ["null", "integer"] }, "flight_number": { "type": ["null", "string"] }, "class_of_service": { "type": ["null", "string"] }, "taxes": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/tax" } } ] }, "adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "flight_ticket": { "type": "object", "required": ["segments", "number", "record_locator", "passenger"], "properties": { "segments": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/flight_segment" } }, "number": { "type": ["null", "string"] }, "record_locator": { "type": ["null", "string"] }, "passenger": { "type": ["null", "string"] } } }, "itemization": { "type": "object", "required": [ "general", "lodging", "ecommerce", "car_rental", "transit_route", "subscription", "flight" ], "properties": { "general": { "oneOf": [ { "$ref": "#/$defs/general_itemization" }, { "type": "null" } ] }, "lodging": { "oneOf": [ { "$ref": "#/$defs/lodging" }, { "type": "null" } ] }, "ecommerce": { "oneOf": [ { "$ref": "#/$defs/ecommerce" }, { "type": "null" } ] }, "car_rental": { "oneOf": [ { "$ref": "#/$defs/car_rental" }, { "type": "null" } ] }, "transit_route": { "oneOf": [ { "$ref": "#/$defs/transit_route" }, { "type": "null" } ] }, "subscription": { "oneOf": [ { "$ref": "#/$defs/subscription" }, { "type": "null" } ] }, "flight": { "oneOf": [ { "$ref": "#/$defs/flight" }, { "type": "null" } ] } } }, "ecommerce": { "type": "object", "required": [ "shipments", "invoice_level_line_items", "invoice_level_adjustments" ], "properties": { "shipments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "type": "object", "required": [ "items", "tracking_number", "expected_delivery_at", "shipment_status", "destination_address" ], "properties": { "items": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item" } }, "tracking_number": { "type": ["string", "null"] }, "expected_delivery_at": { "type": ["integer", "null"] }, "shipment_status": { "type": ["string", "null"], "enum": ["prep", "in_transit", "delivered"] }, "destination_address": { "oneOf": [ { "type": "null" }, { "$ref": "#/$defs/address" } ] } } } } ] }, "invoice_level_line_items": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item" } } ] }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "general_itemization": { "type": "object", "required": ["line_items", "invoice_level_adjustments"], "properties": { "line_items": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item" } }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "lodging": { "type": "object", "required": ["lodging_items", "invoice_level_adjustments"], "properties": { "lodging_items": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/lodging_item" } }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "lodging_item": { "type": "object", "required": ["check_in", "check_out", "location", "items"], "properties": { "check_in": { "type": "integer" }, "check_out": { "type": "integer" }, "location": { "$ref": "#/$defs/place" }, "items": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item" } }, "room": { "type": ["null", "string"] }, "guests": { "type": ["null", "string"] }, "metadata": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item_metadata" } } ] } } }, "merchant": { "type": "object", "required": ["id", "name", "brand_color", "logo", "website"], "properties": { "name": { "type": "string" }, "brand_color": { "oneOf": [ { "description": "Hex color", "type": "string", "pattern": "^#?([a-f0-9]{6}|[a-f0-9]{3})$" }, { "type": "null" } ] }, "logo": { "type": ["string", "null"], "format": "uri" }, "website": { "type": ["string", "null"], "format": "hostname" } } }, "address": { "type": "object", "required": [ "street_address", "city", "region", "country", "postal_code", "lat", "lon" ], "properties": { "street_address": { "type": ["string", "null"] }, "city": { "type": ["string", "null"] }, "region": { "oneOf": [ { "type": "null" }, { "type": "string", "minLength": 2, "maxLength": 2 } ] }, "country": { "oneOf": [ { "type": "null" }, { "type": "string", "minLength": 2, "maxLength": 2 } ] }, "postal_code": { "type": ["string", "null"] }, "lat": { "oneOf": [ { "type": "number", "minimum": -90, "maximum": 90 }, { "type": "null" } ] }, "lon": { "oneOf": [ { "type": "number", "minimum": -180, "maximum": 180 }, { "type": "null" } ] } } }, "place": { "type": "object", "required": [ "name", "address", "phone", "url", "google_place_id", "image" ], "properties": { "name": { "type": ["string", "null"] }, "address": { "oneOf": [ { "type": "null" }, { "$ref": "#/$defs/address" } ] }, "phone": { "type": ["string", "null"] }, "url": { "oneOf": [ { "type": "null" }, { "type": "string", "format": "uri" } ] }, "google_place_id": { "type": ["string", "null"] }, "image": { "oneOf": [ { "type": "null" }, { "type": "string", "format": "uri" } ] } } }, "item_metadata": { "type": "object", "required": ["key", "value"], "properties": { "key": { "type": "string" }, "value": { "type": "string" } } }, "adjustment": { "type": "object", "required": ["amount", "name", "adjustment_type", "rate"], "properties": { "amount": { "type": "integer" }, "name": { "type": ["null", "string"] }, "adjustment_type": { "type": "string", "enum": ["discount", "tip", "fee", "other"] }, "rate": { "type": ["null", "number"] } } }, "subscription": { "type": "object", "required": ["subscription_items", "invoice_level_adjustments"], "properties": { "subscription_items": { "type": "array", "minItems": 1, "items": { "type": "object", "required": [ "subscription_type", "description", "interval", "interval_count", "current_period_start", "current_period_end", "quantity", "unit_cost", "taxes", "metadata", "adjustments", "total" ], "properties": { "total": { "type": "integer" }, "subscription_type": { "type": "string", "enum": ["one_time", "recurring"] }, "description": { "type": "string" }, "interval": { "oneOf": [ { "type": "null" }, { "type": "string", "enum": ["day", "week", "month", "year"] } ] }, "interval_count": { "type": ["integer", "null"] }, "current_period_start": { "type": ["integer", "null"] }, "current_period_end": { "type": ["integer", "null"] }, "quantity": { "type": ["number", "null"] }, "unit_cost": { "type": ["number", "null"] }, "taxes": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/tax" } } ] }, "metadata": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item_metadata" } } ] }, "adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } } }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "tax": { "type": "object", "required": ["amount", "rate", "name"], "properties": { "amount": { "type": "integer" }, "rate": { "type": ["number", "null"] }, "name": { "type": "string" } } }, "transit_route": { "type": "object", "required": ["transit_route_items", "invoice_level_adjustments"], "properties": { "transit_route_items": { "type": "array", "minItems": 1, "items": { "type": "object", "required": [ "departure_location", "arrival_location", "departure_at", "arrival_at", "fare", "passenger", "polyline", "taxes", "metadata", "adjustments" ], "properties": { "departure_location": { "oneOf": [ { "type": "null" }, { "$ref": "#/$defs/place" } ] }, "arrival_location": { "oneOf": [ { "type": "null" }, { "$ref": "#/$defs/place" } ] }, "departure_at": { "type": ["integer", "null"] }, "arrival_at": { "type": ["integer", "null"] }, "polyline": { "oneOf": [ { "type": "null" }, { "type": "string" } ] }, "taxes": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/tax" } } ] }, "metadata": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item_metadata" } } ] }, "fare": { "type": ["integer"] }, "passenger": { "type": ["string", "null"] }, "mode": { "type": ["string", "null"], "enum": ["car", "taxi", "rail", "bus", "ferry", "other"] } } } }, "invoice_level_adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } }, "item": { "type": "object", "required": ["description", "total"], "properties": { "description": { "type": "string" }, "total": { "type": "integer" }, "quantity": { "type": ["null", "number"] }, "unit_cost": { "type": ["null", "integer"] }, "unit": { "type": ["null", "string"] }, "taxes": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/tax" } } ] }, "metadata": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/item_metadata" } } ] }, "product_image": { "oneOf": [ { "type": "null" }, { "type": "string", "format": "uri" } ] }, "group": { "type": ["null", "string"] }, "url": { "oneOf": [ { "type": "null" }, { "type": "string", "format": "uri" } ] }, "adjustments": { "oneOf": [ { "type": "null" }, { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/adjustment" } } ] } } } } }