API Reference

LoyaPro Partners are able to provide multiple loyalty programs such as:

  • Stamps
  • Cashback
  • Points
  • Subscriptions

In order for a customer to be able to earn their points; the POS system needs to send all the order details to LoyaPro API

The cashier is requested to attach the customer to the order before the order is paid and confirmed.

earning flow

earning flow

LoyaPro will provide a Webhook for you to send your order details. The Webhook should be a POST and will look like this:

WebhookMethod
https://loyapro.com/pos/1.0.0/{pos_name}/orderPOST

Example:

https://loyapro.com/pos/1.0.0/foodics/order

The payload for the API should include to the following:

  1. POS Business Reference or Identifier
  2. Date & Time of event
  3. Branch Details
  4. Products details
    1. Id
    2. Price (After tax )
    3. Quantity
    4. Status (Added, Paid, Voided or Refunded)
  5. Total details
    1. Subtotal
    2. Discounts Details
      1. Discounted amount
      2. Reason for the discount (Coupon, Loyalty Redemption)
    3. Total (Including tax)
  6. Order Status (Initiated, Paid, Void, Refunded)
{
	"timestamp": 1672585625,
	"event": "customer.order.created",
	"business": {
		"name": "LoyaPro Coffee",
		"reference": 440810
	},
	"order": {
		"branch": {
			"id": "97be5de5-ae01-4efe-8355-7c6aaf077be7",
			"name": "north coffee esplanade",
			"name_localized": "u0646u0648u0631u062b u0643u0648u0641u064a u0627u0633u0628u0644u0627u0646u0627u062fu0627",
			"reference": "b06",
			"type": 1,
			"latitude": null,
			"longitude": null,
			"phone": null,
			"opening_from": "04:00",
			"opening_to": "04:00",
			"inventory_end_of_day_time": "05:00",
			"receipt_header": null,
			"receipt_footer": null,
			"settings": {
				"display_background_image": null
			},
			"created_at": "2022-11-14 15:12:29",
			"updated_at": "2022-11-14 15:12:29",
			"deleted_at": null,
			"receives_online_orders": true,
			"accepts_reservations": false,
			"reservation_duration": 30,
			"reservation_times": null,
			"address": null
		},
		"promotion": null,
		"original_order": null,
		"table": null,
		"creator": {
			"pin": "*****",
			"is_owner": false,
			"id": "97c817bd-ff52-4aa9-ad52-f12d14d2996d",
			"name": "c2-esplanade",
			"number": null,
			"email": null,
			"phone": null,
			"lang": "ar",
			"display_localized_names": false,
			"email_verified": false,
			"must_use_fingerprint": false,
			"last_console_login_at": null,
			"last_cashier_login_at": null,
			"associate_to_all_branches": false,
			"created_at": "2022-11-19 11:14:35",
			"updated_at": "2022-12-12 16:51:18",
			"deleted_at": null
		},
		"closer": {
			"pin": "*****",
			"is_owner": false,
			"id": "97c817bd-ff52-4aa9-ad52-f12d14d2996d",
			"name": "c2-esplanade",
			"number": null,
			"email": null,
			"phone": null,
			"lang": "ar",
			"display_localized_names": false,
			"email_verified": false,
			"must_use_fingerprint": false,
			"last_console_login_at": null,
			"last_cashier_login_at": null,
			"associate_to_all_branches": false,
			"created_at": "2022-11-19 11:14:35",
			"updated_at": "2022-12-12 16:51:18",
			"deleted_at": null
		},
		"driver": null,
		"customer": {
			"id": "981ee9ec-384f-49f2-891b-d6a374190412",
			"name": "faisal alsalamah - 612344",
			"dial_code": 966,
			"phone": "557937530",
			"email": "[email protected]",
			"gender": 1,
			"birth_date": null,
			"is_blacklisted": false,
			"is_house_account_enabled": false,
			"house_account_limit": null,
			"is_loyalty_enabled": false,
			"order_count": 1,
			"last_order_at": "2023-01-01 14:53:57",
			"created_at": "2023-01-01 15:03:30",
			"updated_at": "2023-01-01 15:07:05",
			"deleted_at": null
		},
		"customer_address": null,
		"discount": null,
		"tags": [],
		"coupon": null,
		"gift_card": null,
		"charges": [],
		"payments": [
			{
				"user": {
					"pin": "*****",
					"is_owner": false,
					"id": "97c817bd-ff52-4aa9-ad52-f12d14d2996d",
					"name": "c2-esplanade",
					"number": null,
					"email": null,
					"phone": null,
					"lang": "ar",
					"display_localized_names": false,
					"email_verified": false,
					"must_use_fingerprint": false,
					"last_console_login_at": null,
					"last_cashier_login_at": null,
					"associate_to_all_branches": false,
					"created_at": "2022-11-19 11:14:35",
					"updated_at": "2022-12-12 16:51:18",
					"deleted_at": null
				},
				"payment_method": {
					"id": "_37583g17",
					"name": "cash",
					"name_localized": "cash",
					"type": 1,
					"code": null,
					"auto_open_drawer": true,
					"is_active": true,
					"created_at": "2018-07-19 11:47:33",
					"updated_at": "2018-07-19 11:47:33",
					"deleted_at": null,
					"index": 0
				},
				"meta": [],
				"id": "c2857d2f-12a3-42c3-a108-6fa1bc0df265",
				"amount": 24,
				"tendered": 24,
				"tips": 0,
				"business_date": "2023-01-01",
				"added_at": "2023-01-01 15:06:16"
			}
		],
		"products": [
			{
				"product": {
					"category": {
						"id": "_7ad32937",
						"name": "hot drinks",
						"name_localized": "u0645u0634u0631u0648u0628u0627u062a u0633u0627u062eu0646u0629",
						"reference": null,
						"image": null,
						"created_at": "2018-12-10 14:39:27",
						"updated_at": "2021-02-06 11:33:57",
						"deleted_at": null
					},
					"ingredients": [],
					"id": "_7g3g8555",
					"sku": "prd_7g3g8555",
					"barcode": null,
					"name": "blue north",
					"name_localized": "u0628u0644u0648 u0646u0648u0631u062b",
					"description": null,
					"description_localized": null,
					"image": "https://foodics.s3.eu-west-1.amazonaws.com/menu/1614502473.jpg",
					"is_active": true,
					"is_stock_product": false,
					"is_ready": true,
					"pricing_method": 1,
					"selling_method": 1,
					"costing_method": 2,
					"preparation_time": null,
					"price": 0,
					"cost": null,
					"calories": 0,
					"created_at": "2019-04-13 14:17:56",
					"updated_at": "2022-09-23 01:15:01",
					"deleted_at": null,
					"meta": null
				},
				"promotion": null,
				"discount": null,
				"options": [
					{
						"modifier_option": {
							"ingredients": [],
							"id": "93254047-41f5-461b-846f-204c47789537",
							"name": "blue north l",
							"name_localized": "u0628u0644u0648 u0646u0648u0631u062b u0643",
							"sku": "sk-0221",
							"is_active": true,
							"costing_method": 2,
							"price": 24,
							"cost": null,
							"calories": null,
							"created_at": "2021-04-08 11:40:14",
							"updated_at": "2022-09-23 22:24:55",
							"deleted_at": null,
							"index": 0
						},
						"taxes": [
							{
								"pivot": {
									"amount": 3.13043,
									"rate": 15,
									"tax_exclusive_discount_amount": null
								},
								"id": "_279594g7",
								"name": "vat",
								"name_localized": "u0636u0631u064au0628u0647 u0627u0644u0642u064au0645u0647 u0627u0644u0645u0636u0627u0641u0629",
								"rate": 15,
								"created_at": "2019-07-27 19:10:10",
								"updated_at": "2020-06-30 23:00:59",
								"deleted_at": null,
								"inactive_in_order_types": null
							}
						],
						"id": "981eeb34-50da-41b8-9e84-232d0f2254b2",
						"quantity": 1,
						"partition": 1,
						"unit_price": 24,
						"total_price": 24,
						"total_cost": 0,
						"tax_exclusive_unit_price": 20.86957,
						"tax_exclusive_total_price": 20.86957,
						"tax_exclusive_discount_amount": 0,
						"added_at": "2023-01-01 14:53:58"
					}
				],
				"taxes": [],
				"timed_events": [],
				"void_reason": null,
				"creator": {
					"pin": "*****",
					"is_owner": false,
					"id": "97c817bd-ff52-4aa9-ad52-f12d14d2996d",
					"name": "c2-esplanade",
					"number": null,
					"email": null,
					"phone": null,
					"lang": "ar",
					"display_localized_names": false,
					"email_verified": false,
					"must_use_fingerprint": false,
					"last_console_login_at": null,
					"last_cashier_login_at": null,
					"associate_to_all_branches": false,
					"created_at": "2022-11-19 11:14:35",
					"updated_at": "2022-12-12 16:51:18",
					"deleted_at": null
				},
				"voider": null,
				"id": "981eeb34-4e97-4d68-bf52-74c658f805ee",
				"discount_type": null,
				"quantity": 1,
				"returned_quantity": 0,
				"unit_price": 0,
				"discount_amount": 0,
				"total_price": 24,
				"total_cost": 0,
				"tax_exclusive_discount_amount": 0,
				"tax_exclusive_unit_price": 0,
				"tax_exclusive_total_price": 20.86957,
				"status": 3,
				"is_ingredients_wasted": 0,
				"delay_in_seconds": null,
				"kitchen_notes": null,
				"meta": {
					"foodics": {
						"uuid": "2f49fd87-9627-4a08-89e5-5cd367ba7bf5"
					}
				},
				"added_at": "2023-01-01 14:53:57",
				"closed_at": "2023-01-01 15:06:16"
			}
		],
		"combos": [],
		"device": {
			"id": "97c24668-341f-4c3a-aa0a-eccd5e7060a2",
			"name": "c2-esplanade",
			"code": "42545",
			"reference": "c12",
			"type": 1
		},
		"id": "9edb65d0-ee21-4e32-a99d-85bf2f454e73",
		"app_id": "8f7884c0-9e14-4833-ba96-3221471e8709",
		"promotion_id": null,
		"discount_type": null,
		"reference_x": null,
		"number": 1,
		"type": 1,
		"source": 1,
		"status": 4,
		"delivery_status": null,
		"guests": 1,
		"kitchen_notes": null,
		"customer_notes": null,
		"business_date": "2023-01-01",
		"subtotal_price": 20.86957,
		"discount_amount": 0,
		"rounding_amount": 0,
		"total_price": 24,
		"tax_exclusive_discount_amount": 0,
		"delay_in_seconds": null,
		"meta": {
			"foodics": {
				"device_id": "97c24668-341f-4c3a-aa0a-eccd5e7060a2",
				"receipt_qr": "aq8zmtazmjc4mdy0mdawmdmcdzmxmdmynzgwnjqwmdawmwmtmjaymy0wms0wmsaxodownjoxnguemy4xmwqfmjqumda=",
				"auto_closed": false,
				"products_kitchen": []
			}
		},
		"opened_at": "2023-01-01 14:53:57",
		"accepted_at": null,
		"due_at": null,
		"driver_assigned_at": null,
		"dispatched_at": null,
		"driver_collected_at": null,
		"delivered_at": null,
		"closed_at": "2023-01-01 15:06:16",
		"created_at": "2023-01-01 15:07:05",
		"updated_at": "2023-01-01 15:07:05",
		"reference": 382546,
		"check_number": 100011
	}
}
const http = require("https");

const options = {
  "method": "POST",
  "hostname": "loyapro.com",
  "port": null,
  "path": "/pos/1.0.0/foodics/order",
  "headers": {
    "cookie": "ARRAffinity=35fbc4bf1e1481cf080cbb56028396449132b7b3e0d1ed88b47e0f5a8250823d; ARRAffinitySameSite=35fbc4bf1e1481cf080cbb56028396449132b7b3e0d1ed88b47e0f5a8250823d",
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwbGF0Zm9ybSI6InBvcyIsIm5hbWUiOiJmb29kaWNzIiwiaWF0IjoxNTE2MjM5MDIyfQ.wnFaxNkObU9MLit64yLYdGc9lxtt66dLCovMRull28I",
    "Content-Type": "application/json",
    "Content-Length": "8856"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({
  timestamp: 1672585625,
  event: 'customer.order.created',
  business: {name: 'north coffee', reference: 440810},
  order: {
    branch: {
      id: '97be5de5-ae01-4efe-8355-7c6aaf077be7',
      name: 'north coffee esplanade',
      name_localized: 'u0646u0648u0631u062b u0643u0648u0641u064a u0627u0633u0628u0644u0627u0646u0627u062fu0627',
      reference: 'b06',
      type: 1,
      latitude: null,
      longitude: null,
      phone: null,
      opening_from: '04:00',
      opening_to: '04:00',
      inventory_end_of_day_time: '05:00',
      receipt_header: null,
      receipt_footer: null,
      settings: {display_background_image: null},
      created_at: '2022-11-14 15:12:29',
      updated_at: '2022-11-14 15:12:29',
      deleted_at: null,
      receives_online_orders: true,
      accepts_reservations: false,
      reservation_duration: 30,
      reservation_times: null,
      address: null
    },
    promotion: null,
    original_order: null,
    table: null,
    creator: {
      pin: '*****',
      is_owner: false,
      id: '97c817bd-ff52-4aa9-ad52-f12d14d2996d',
      name: 'c2-esplanade',
      number: null,
      email: null,
      phone: null,
      lang: 'ar',
      display_localized_names: false,
      email_verified: false,
      must_use_fingerprint: false,
      last_console_login_at: null,
      last_cashier_login_at: null,
      associate_to_all_branches: false,
      created_at: '2022-11-19 11:14:35',
      updated_at: '2022-12-12 16:51:18',
      deleted_at: null
    },
    closer: {
      pin: '*****',
      is_owner: false,
      id: '97c817bd-ff52-4aa9-ad52-f12d14d2996d',
      name: 'c2-esplanade',
      number: null,
      email: null,
      phone: null,
      lang: 'ar',
      display_localized_names: false,
      email_verified: false,
      must_use_fingerprint: false,
      last_console_login_at: null,
      last_cashier_login_at: null,
      associate_to_all_branches: false,
      created_at: '2022-11-19 11:14:35',
      updated_at: '2022-12-12 16:51:18',
      deleted_at: null
    },
    driver: null,
    customer: {
      id: '981ee9ec-384f-49f2-891b-d6a374190412',
      name: 'faisal alsalamah - 612344',
      dial_code: 966,
      phone: '557937530',
      email: '[email protected]',
      gender: 1,
      birth_date: null,
      is_blacklisted: false,
      is_house_account_enabled: false,
      house_account_limit: null,
      is_loyalty_enabled: false,
      order_count: 1,
      last_order_at: '2023-01-01 14:53:57',
      created_at: '2023-01-01 15:03:30',
      updated_at: '2023-01-01 15:07:05',
      deleted_at: null
    },
    customer_address: null,
    discount: null,
    tags: [],
    coupon: null,
    gift_card: null,
    charges: [],
    payments: [
      {
        user: {
          pin: '*****',
          is_owner: false,
          id: '97c817bd-ff52-4aa9-ad52-f12d14d2996d',
          name: 'c2-esplanade',
          number: null,
          email: null,
          phone: null,
          lang: 'ar',
          display_localized_names: false,
          email_verified: false,
          must_use_fingerprint: false,
          last_console_login_at: null,
          last_cashier_login_at: null,
          associate_to_all_branches: false,
          created_at: '2022-11-19 11:14:35',
          updated_at: '2022-12-12 16:51:18',
          deleted_at: null
        },
        payment_method: {
          id: '_37583g17',
          name: 'cash',
          name_localized: 'cash',
          type: 1,
          code: null,
          auto_open_drawer: true,
          is_active: true,
          created_at: '2018-07-19 11:47:33',
          updated_at: '2018-07-19 11:47:33',
          deleted_at: null,
          index: 0
        },
        meta: [],
        id: 'c2857d2f-12a3-42c3-a108-6fa1bc0df265',
        amount: 24,
        tendered: 24,
        tips: 0,
        business_date: '2023-01-01',
        added_at: '2023-01-01 15:06:16'
      }
    ],
    products: [
      {
        product: {
          category: {
            id: '_7ad32937',
            name: 'hot drinks',
            name_localized: 'u0645u0634u0631u0648u0628u0627u062a u0633u0627u062eu0646u0629',
            reference: null,
            image: null,
            created_at: '2018-12-10 14:39:27',
            updated_at: '2021-02-06 11:33:57',
            deleted_at: null
          },
          ingredients: [],
          id: '_7g3g8555',
          sku: 'prd_7g3g8555',
          barcode: null,
          name: 'blue north',
          name_localized: 'u0628u0644u0648 u0646u0648u0631u062b',
          description: null,
          description_localized: null,
          image: 'https://foodics.s3.eu-west-1.amazonaws.com/menu/1614502473.jpg',
          is_active: true,
          is_stock_product: false,
          is_ready: true,
          pricing_method: 1,
          selling_method: 1,
          costing_method: 2,
          preparation_time: null,
          price: 0,
          cost: null,
          calories: 0,
          created_at: '2019-04-13 14:17:56',
          updated_at: '2022-09-23 01:15:01',
          deleted_at: null,
          meta: null
        },
        promotion: null,
        discount: null,
        options: [
          {
            modifier_option: {
              ingredients: [],
              id: '93254047-41f5-461b-846f-204c47789537',
              name: 'blue north l',
              name_localized: 'u0628u0644u0648 u0646u0648u0631u062b u0643',
              sku: 'sk-0221',
              is_active: true,
              costing_method: 2,
              price: 24,
              cost: null,
              calories: null,
              created_at: '2021-04-08 11:40:14',
              updated_at: '2022-09-23 22:24:55',
              deleted_at: null,
              index: 0
            },
            taxes: [
              {
                pivot: {amount: 3.13043, rate: 15, tax_exclusive_discount_amount: null},
                id: '_279594g7',
                name: 'vat',
                name_localized: 'u0636u0631u064au0628u0647 u0627u0644u0642u064au0645u0647 u0627u0644u0645u0636u0627u0641u0629',
                rate: 15,
                created_at: '2019-07-27 19:10:10',
                updated_at: '2020-06-30 23:00:59',
                deleted_at: null,
                inactive_in_order_types: null
              }
            ],
            id: '981eeb34-50da-41b8-9e84-232d0f2254b2',
            quantity: 1,
            partition: 1,
            unit_price: 24,
            total_price: 24,
            total_cost: 0,
            tax_exclusive_unit_price: 20.86957,
            tax_exclusive_total_price: 20.86957,
            tax_exclusive_discount_amount: 0,
            added_at: '2023-01-01 14:53:58'
          }
        ],
        taxes: [],
        timed_events: [],
        void_reason: null,
        creator: {
          pin: '*****',
          is_owner: false,
          id: '97c817bd-ff52-4aa9-ad52-f12d14d2996d',
          name: 'c2-esplanade',
          number: null,
          email: null,
          phone: null,
          lang: 'ar',
          display_localized_names: false,
          email_verified: false,
          must_use_fingerprint: false,
          last_console_login_at: null,
          last_cashier_login_at: null,
          associate_to_all_branches: false,
          created_at: '2022-11-19 11:14:35',
          updated_at: '2022-12-12 16:51:18',
          deleted_at: null
        },
        voider: null,
        id: '981eeb34-4e97-4d68-bf52-74c658f805ee',
        discount_type: null,
        quantity: 1,
        returned_quantity: 0,
        unit_price: 0,
        discount_amount: 0,
        total_price: 24,
        total_cost: 0,
        tax_exclusive_discount_amount: 0,
        tax_exclusive_unit_price: 0,
        tax_exclusive_total_price: 20.86957,
        status: 3,
        is_ingredients_wasted: 0,
        delay_in_seconds: null,
        kitchen_notes: null,
        meta: {foodics: {uuid: '2f49fd87-9627-4a08-89e5-5cd367ba7bf5'}},
        added_at: '2023-01-01 14:53:57',
        closed_at: '2023-01-01 15:06:16'
      }
    ],
    combos: [],
    device: {
      id: '97c24668-341f-4c3a-aa0a-eccd5e7060a2',
      name: 'c2-esplanade',
      code: '42545',
      reference: 'c12',
      type: 1
    },
    id: '9edb65d0-ee21-4e32-a99d-85bf2f454e73',
    app_id: '8f7884c0-9e14-4833-ba96-3221471e8709',
    promotion_id: null,
    discount_type: null,
    reference_x: null,
    number: 1,
    type: 1,
    source: 1,
    status: 4,
    delivery_status: null,
    guests: 1,
    kitchen_notes: null,
    customer_notes: null,
    business_date: '2023-01-01',
    subtotal_price: 20.86957,
    discount_amount: 0,
    rounding_amount: 0,
    total_price: 24,
    tax_exclusive_discount_amount: 0,
    delay_in_seconds: null,
    meta: {
      foodics: {
        device_id: '97c24668-341f-4c3a-aa0a-eccd5e7060a2',
        receipt_qr: 'aq8zmtazmjc4mdy0mdawmdmcdzmxmdmynzgwnjqwmdawmwmtmjaymy0wms0wmsaxodownjoxnguemy4xmwqfmjqumda=',
        auto_closed: false,
        products_kitchen: []
      }
    },
    opened_at: '2023-01-01 14:53:57',
    accepted_at: null,
    due_at: null,
    driver_assigned_at: null,
    dispatched_at: null,
    driver_collected_at: null,
    delivered_at: null,
    closed_at: '2023-01-01 15:06:16',
    created_at: '2023-01-01 15:07:05',
    updated_at: '2023-01-01 15:07:05',
    reference: 382546,
    check_number: 100011
  }
}));
req.end();