| Previous Topic | Next Topic |
|---|---|
| Online Ordering Module 5: Redemptions Overview | Online Ordering Module 5b: Show Applicable Offers (Redemptions 1.0) |
Online Ordering API Certification Tutorial - Module 5a: Process/Create Redemption (Redemptions 1.0)
Goal
Redemptions 1.0 - Process redemptions with the appropriate reward type.
Prerequisites
You must have read the Online Ordering Module 3a: Show Offers in Guest Account and Online Ordering Module 3b: Show Account Balance tutorials.
Use Cases and Context
Redemption is a discount that can be applied to an order. While ordering via a website or mobile app, a user can use offers (e.g., rewards or redeemables) that are available in the user's account. These offers are configured by businesses. The loyalty user generates a redemption by selecting the offer to use.
Unlike the POS implementation, which uses two different API endpoints (one for determining possible redemptions and one for processing redemptions), the online ordering implementation uses a single Create Online Redemption API endpoint for both operations:
-
Possible Redemptions: A Possible Redemptions call is used to verify that a redemption can be applied to an order. To make the Possible Redemptions call, the query parameter must be included in the request of the Create Online Redemption API.
-
Process Redemption: To actually process a redemption on an order, when making the API call do NOT include the query parameter in the request of the Create Online Redemption API.
Applicable API Endpoints
| Endpoint Name/Path | Relevant Request Parameters | Relevant Response Parameters |
| Create Online Redemption POST {server-name}/api/auth/redemptions/online_order |
- client - access_token - query (Include this parameter in the request only when making a Possible Redemptions call.) - discount_type - reward_id - redeemable_id - subscription_id - subtotal_amount - receipt_amount - receipt_datetime - store_number The required parameters under the Menu Items object: - item_name - item_qty - item_amount - menu_item_type - menu_item_id - menu_family - menu_major_group - serial_number |
- category - status - redemption_id - redemption_amount - redemption_code These parameters under the Qualified Menu Items object show the menu items to which the offer can be applied: - item_name - item_qty - item_amount - menu_item_type - menu_item_id - menu_family - menu_major_group - serial_number |
Example Code
Note: We do not recommend sending the D (discount), T (tax), and P (payment) values in the
menu_item_typeparameter for Redemptions 1.0 API calls. Instead, send them in check-in API calls, such as Create Loyalty Check-in and Update Loyalty Check-in.For example, if a business offers a $2 discount on a $10 burger, send the burger as $8 ($10 - $2) in the API request. Send the discount as a line item in the Check-in API call.
If you must send D, T, and P menu item types, you must configure an exclusion qualification criterion (QC) for the offer in the Punchh platform. Create an exclusion filter using item types D, T, and P to ensure they are properly excluded. See the Qualification Criteria article on the Support Portal.
Note: To view the Punchh product documentation on the Punchh Support Portal, you must log in to a Punchh platform production environment. If you already have access to a production environment, follow the instructions here to access the Punchh Support Portal.
Reward - Possible Redemptions
The following code examples demonstrate how to send a reward Possible Redemptions call in order to verify whether a $5 discount can be applied to a transaction using a reward ID. By adding the query field to the request, the request is sent as a Possible Redemptions call.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "reward",
"reward_id": "1111111111",
"query": true,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def reward_possible_redemptions():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"query": True,
"discount_type": "reward",
"reward_id": "1111111111",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
reward_possible_redemptions()
class RewardPossibleRedemptions
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.possible_redemptions
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, query: true, discount_type: "reward", reward_id: "REWARD_ID_GOES_HERE", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
RewardPossibleRedemptions.possible_redemptions
Reward - Process Redemption
The following code examples demonstrate how to send a reward Process Redemption call in order to apply a $5 discount to a transaction using a reward ID. By removing the query field from the request, this processes the redemption.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "reward",
"reward_id": "1111111111",
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def reward_process_redemption():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"discount_type": "reward",
"reward_id": "1111111111",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
reward_process_redemption()
class RewardProcessRedemption
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.process_redemption
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, discount_type: "reward", reward_id: "REWARD_ID_GOES_HERE", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
RewardProcessRedemption.process_redemption
Redeemable - Possible Redemptions
The following code examples demonstrate how to send a redeemable Possible Redemptions call in order to verify whether a $5 discount can be applied to a transaction. By adding the query field to the request, the request is sent as a Possible Redemptions call.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "redeemable",
"redeemable_id": "111111",
"query": true,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.0,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def redeemable_possible_redemptions():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"query": True,
"discount_type": "redeemable",
"redeemable_id": "111111",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
redeemable_possible_redemptions()
class RedeemablePossibleRedemptions
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.possible_redemptions
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, query: true, discount_type: "redeemable", redeemable_id: "111111", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
RedeemablePossibleRedemptions.possible_redemptions
Redeemable - Process Redemption
The following code examples demonstrate how to send a redeemable Process Redemption call in order to apply a $5 discount to a transaction. By removing the query field from the request, this processes the redemption.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "redeemable",
"redeemable_id": "111111",
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.0,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def redeemable_process_redemption():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"discount_type": "redeemable",
"redeemable_id": "111111",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
redeemable_process_redemption()
class RedeemableProcessRedemption
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.process_redemption
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, discount_type: "redeemable", redeemable_id: "111111", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
RedeemableProcessRedemption.process_redemption
Banked Rewards - Possible Redemptions
The following code examples demonstrate how to send a banked rewards (discount amount) Possible Redemptions call in order to verify whether a $5 discount can be applied to a transaction. By adding the query field to the request, the request is sent as a Possible Redemptions call.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "discount_amount",
"redeemed_points": 5.0,
"query": true,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.0,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def banked_rewards_possible_redemptions():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"query": True,
"discount_type": "discount_amount",
"redeemed_points": 5.0,
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
banked_rewards_possible_redemptions()
class BankedRewardsPossibleRedemptions
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.possible_redemptions
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, query: true, discount_type: "discount_amount", redeemed_points: 5.0, receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
BankedRewardsPossibleRedemptions.possible_redemptions
Banked Rewards - Process Redemption
The following code examples demonstrate how to send a banked rewards (discount amount) Process Redemption call in order to apply a $5 discount to a transaction. By removing the query field from the request, this processes the redemption.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "discount_amount",
"redeemed_points": 5.0,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.0,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 1.98,
"receipt_amount": 1.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def banked_rewards_process_redemption():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"discount_type": "discount_amount",
"redeemed_points": 5.0,
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
banked_rewards_process_redemption()
class BankedRewardsProcessRedemption
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.process_redemption
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, discount_type: "discount_amount", redeemed_points: 5.0, receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
BankedRewardsProcessRedemption.process_redemption
Redemption Code - Possible Redemptions
The following code examples demonstrate how to send a redemption code Possible Redemptions call in order to verify whether a $5 discount can be applied to a transaction. This is how a coupon or promo code Possible Redemptions call should be sent. By adding the query field to the request, the request is sent as a Possible Redemptions call.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "redemption_code",
"redemption_code": "111111",
"query": true,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def redemption_code_possible_redemptions():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"query": True,
"discount_type": "redemption_code",
"redemption_code": "REDEMPTION_CODE_GOES_HERE",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
redemption_code_possible_redemptions()
class RedemptionCodePossibleRedemptions
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.possible_redemptions
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, query: true, discount_type: "redemption_code", redemption_code: "REDEMPTION_CODE_GOES_HERE", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-12T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
RedemptionCodePossibleRedemptions.possible_redemptions
Redemption Code - Process Redemption
The following code examples demonstrate how to send a redemption code Process Redemption call in order to apply a $5 discount to a transaction. This is how a coupon or promo code redemption should be sent. By removing the query field from the request, this processes the redemption.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "redemption_code",
"redemption_code": "111111",
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def redemption_code_process_redemption():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"discount_type": "redemption_code",
"redemption_code": "REDEMPTION_CODE_GOES_HERE",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
redemption_code_process_redemption()
class RedemptionCodeProcessRedemption
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.process_redemption
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, discount_type: "redemption_code", redemption_code: "REDEMPTION_CODE_GOES_HERE", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-12T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
RedemptionCodeProcessRedemption.process_redemption
Card Completion - Possible Redemptions
The following code examples demonstrate how to send a card completion Possible Redemptions call in order to verify whether a $5 discount can be applied to a transaction. By adding the query field to the request, the request is sent as a Possible Redemptions call.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "card_completion",
"query": true,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def card_completion_possible_redemptions():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"query": True,
"discount_type": "card_completion",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
card_completion_possible_redemptions()
class CardCompletionPossibleRedemptions
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.possible_redemptions
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, query: true, discount_type: "card_completion", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-12T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
CardCompletionPossibleRedemptions.possible_redemptions
Card Completion - Process Redemption
The following code examples demonstrate how to send a card completion Process Redemption call in order to apply a $5 discount to a transaction. By removing the query field from the request, this processes the redemption.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "card_completion",
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def card_completion_process_redemption():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"discount_type": "card_completion",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
card_completion_process_redemption()
class CardCompletionProcessRedemption
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.process_redemption
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, discount_type: "card_completion", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-12T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
CardCompletionProcessRedemption.process_redemption
Subscription - Possible Redemptions
The following code examples demonstrate how to send a subscription Possible Redemptions call in order to verify whether a $5 discount can be applied to a transaction using a subscription ID. By adding the query field to the request, the request is sent as a Possible Redemptions call.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "subscription",
"subscription_id": "1111111111",
"query": true,
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def subscription_possible_redemptions():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"query": True,
"discount_type": "subscription",
"subscription_id": "1111111111",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
subscription_possible_redemptions()
class SubscriptionPossibleRedemptions
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.possible_redemptions
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, query: true, discount_type: "subscription", subscription_id: "SUBSCRIPTION_ID_GOES_HERE", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
SubscriptionPossibleRedemptions.possible_redemptions
Subscription - Process Redemption
The following code examples demonstrate how to send a subscription Process Redemption call in order to apply a $5 discount to a transaction using a subscription ID. By removing the query field from the request, this processes the redemption.
curl --location --request POST 'https://server-name-goes-here.punchh.com/api/auth/redemptions/online_order' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-pch-digest: SIGNATURE_GOES_HERE' \
--header 'Authorization: Bearer ACCESS_TOKEN_GOES_HERE' \
--header 'User-Agent: Punchh/OnlineOrder/1.0/Web/BrowserVersion/OS_Type' \
--data-raw '{
"client": "CLIENT_GOES_HERE",
"discount_type": "subscription",
"subscription_id": "1111111111",
"menu_items": [
{
"item_name": "Pizza with Pepperoni Topping",
"item_qty": 1,
"item_amount": 10.99,
"menu_item_type": "M",
"menu_item_id": "3001",
"menu_family": "Pizza",
"menu_major_group": "Pizza",
"serial_number": "1.0"
},
{
"item_name": "Pepperoni Topping",
"item_qty": 1,
"item_amount": 0.99,
"menu_item_type": "M",
"menu_item_id": "3002",
"menu_family": "Pizza Topping",
"menu_major_group": "Pizza",
"serial_number": "1.1"
},
{
"item_name": "Discount",
"item_qty": 1,
"item_amount": 5.00,
"menu_item_type": "D",
"menu_item_id": "4001",
"menu_family": "Discount",
"menu_major_group": "Discount",
"serial_number": "2.0"
}
],
"subtotal_amount": 6.98,
"receipt_amount": 6.98,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"store_number": "001"
}'
import json
from http_client import send_request
def subscription_process_redemption():
path = "/api/auth/redemptions/online_order"
http_verb = "POST"
menu_items = [{"item_name": "Pizza with Pepperoni Topping", "item_qty": 1, "item_amount": 10.99, "menu_item_type": "M", "menu_item_id": "3001", "menu_family": "Pizza", "menu_major_group": "Pizza", "serial_number": "1.0"}, {
"item_name": "Pepperoni Topping", "item_qty": 1, "item_amount": 0.99, "menu_item_type": "M", "menu_item_id": "3002", "menu_family": "Pizza Topping", "menu_major_group": "Pizza", "serial_number": "1.1"}, {
"item_name": "Discount", "item_qty": 1, "item_amount": 5.00, "menu_item_type": "D", "menu_item_id": "4001", "menu_family": "Discount", "menu_major_group": "Discount", "serial_number": "2.0"}]
receipt_amount = 0
for item in menu_items:
if item["menu_item_type"] == "M":
receipt_amount += item["item_amount"]
if item["menu_item_type"] == "D":
receipt_amount -= item["item_amount"]
body = json.dumps({
"client": "CLIENT_GOES_HERE",
"discount_type": "subscription",
"subscription_id": "1111111111",
"receipt_amount": receipt_amount,
"subtotal_amount": receipt_amount,
"store_number": "001",
"menu_items": menu_items,
"receipt_datetime": "2022-09-012T07:42:03-00:00",
"external_uid": "1111-1111-1111-1111",
"transaction_no": "111111111"
})
response = send_request(path, http_verb, body)
print(f"Response: {response}")
subscription_process_redemption()
class SubscriptionProcessRedemption
require_relative 'generate_signature.rb'
require_relative 'http_client.rb'
require 'json'
# Client for the environment that you are pointing the request to
CLIENT = "CLIENT_GOES_HERE"
PATH = "/api/auth/redemptions/online_order"
HTTP_VERB = "POST"
MENU_ITEMS = [{ item_name: "Pizza with Pepperoni Topping", item_qty: 1, item_amount: 10.99, menu_item_type: "M", menu_item_id: "3001", menu_family: "Pizza", menu_major_group: "Pizza", serial_number: "1.0" }, { item_name: "Pepperoni Topping", item_qty: 1, item_amount: 0.99, menu_item_type: "M", menu_item_id: "3002", menu_family: "Pizza Topping", menu_major_group: "Pizza", serial_number: "1.1" }, {item_name: "Discount", item_qty: 1, item_amount: 5.00, menu_item_type: "D", menu_item_id: "4001", menu_family: "Discount", menu_major_group: "Discount", serial_number: "2.0"}]
def self.process_redemption
receipt_amount = 0
MENU_ITEMS.each do |item|
if item[:menu_item_type] == "M"
receipt_amount += item[:item_amount]
end
if item[:menu_item_type] == "D"
receipt_amount -= item[:item_amount]
end
end
body = {client: CLIENT, discount_type: "subscription", subscription_id: "SUBSCRIPTION_ID_GOES_HERE", receipt_amount: receipt_amount, subtotal_amount: receipt_amount, store_number: "001", menu_items: MENU_ITEMS, receipt_datetime: "2022-09-07T07:42:03-00:00", external_uid: "1111-1111-1111-1111", transaction_no: "111111111"}.to_json
response = HttpClient::send_request(PATH, HTTP_VERB, body)
end
end
SubscriptionProcessRedemption.process_redemption
Workflow
The Create Online Redemption API endpoint enables you to 1) apply an offer on the order as a Possible Redemptions call and determine whether the offer can be applied to a menu item in the check, and 2) process a redemption to get a discount. Both the Possible Redemptions call and the Process Redemption call are nearly the same in terms of the request and response parameters. The difference between the two calls is that the Possible Redemptions call only verifies if an offer in the guest account (sent in the API request) can be applied to the menu items (sent in the API request) on a current check and returns in the API response the qualified menu item(s) for the offer.
To make a Possible Redemptions call, the query parameter must be included in the request with a value of “true”. The value of the query parameter (i.e., true or false) is irrelevant; if this parameter is included in the request, it will be treated as a Possible Redemptions call regardless of the parameter value. If the Possible Redemptions call shows that the offer is valid, you can then make the Process Redemption call (i.e., by removing the query parameter from the request) and submit the offer to process the actual redemption. If the Process Redemption call is successful, the offer is marked as used in the user’s account. The message in the status parameter in the API response shows that the offer is redeemed if the redemption is successful.
The status parameter in the Create Online Redemption API response shows a message that explains if the customer's redemption was successfully completed or not, and the category parameter indicates whether the offer the guest is trying to redeem is redeemable, expired, invalid, processed, or unassigned. If the message in the status parameter indicates that the offer passed in the API request cannot be redeemed, then check the category of the offer. If the category of the offer is expired, invalid, processed, or unassigned, the offer cannot be redeemed. A unique ID associated with the redemption is generated for each redemption. The ID is stored in the redemption_id parameter in the API response. Save this in your system for future reference. You need the redemption_id or the redemption_code to void a redemption. Note: In the case of coupons/promos, the redemption_id returned would be the same as the redemption_code.
Example response for Possible Redemptions call
When making a Possible Redemptions call, the value of the status parameter in the response includes “It can be honored.” This indicates that the offer has not actually been redeemed yet.
{
"status": "Redeemed at <redemption-time> by <user-name> at <location>. It can be honored.",
"redemption_amount": 2.86,
"category": "redeemable",
"qualified_menu_items":[
{
"item_name":"White rice",
"item_qty":1,
"item_amount":2.86,
"menu_item_type":"M",
"menu_item_id":3419,
"menu_family":"800",
"menu_major_group":"152",
"serial_number":"1.0"
}
],
"redemption_id": 111111111,
"redemption_code": "1111111"
}
Example response for Process Redemption call
For a Process Redemption call, the value of the status parameter in the response includes “Please HONOR it.” This indicates that the offer will be redeemed.
{
"status": "Redeemed at <redemption-time> by <user-name> at <location>. Please HONOR it.",
"redemption_amount": 2.86,
"category": "redeemable",
"qualified_menu_items": [],
"qualified_menu_items":[
{
"item_name":"White rice",
"item_qty":1,
"item_amount":2.86,
"menu_item_type":"M",
"menu_item_id":3419,
"menu_family":"800",
"menu_major_group":"152",
"serial_number":"1.0"
}
],
"redemption_id": 111111111,
"redemption_code": "1111111"
}
The Create Online Redemption API endpoint requires you to identify the offer type you want to redeem when validating an offer. In Punchh, using a reward is different from using a redeemable. You have to send slightly different requests when making a call, depending on the offer type. Following are the rules to decide which “discount type” to use depending on redemption types in the Create Online Redemption API request.
Punchh supports the following redemption types based on the configuration chosen by the business.
| Redemption Types | Request Parameters and Values for Redemption Types |
| Reward | Rewards are offers that are tied to an individual user’s account. A reward may be awarded to the user due to some campaign or may be explicitly gifted by a business admin. No points will be deducted for the redemption of this offer. This is applicable when a user performs a particular action mentioned in a campaign. For example, if the user places an order under Facebook login or on a special day/event like Thanksgiving, Christmas, etc., the user gets rewards in the account. In the Fetch Account Balance of User API response, if any offer in the Rewards array either has type as “reward” or does not have a type parameter, use its id to pass in the reward_id parameter and use discount type = reward in the Create Online Redemption API request."discount_type": "reward" "reward_id": "REWARD_ID_GOES_HERE" |
| Redeemable | Redeemables are offers that are configured at the business level for the "points unlock redeemable” program type. Each redeemable object in the Redeemables array in the Fetch Account Balance of User API response shows the available redeemables in the user’s account, including the number of points required for redemption. A user must have the required points in the user’s account in order to redeem a specific redeemable. The response of the Fetch Account Balance of User API also shows the user’s points balance, which must exceed the number of points required to redeem the specific redeemable. In the Fetch Account Balance of User API response, if any item in the Redeemables array has type as “redeemable”, use its id to pass in the redeemable_id parameter and use discount_type = redeemable in the Create Online Redemption API request."discount_type": "redeemable" "redeemable_id": "REDEEMABLE_ID_GOES_HERE" |
| Banked rewards | Banked rewards can be used for the redemption of banked currency. This will be available if the program structure configured is "points convert to currency". This is applicable after a certain number of points are gained by order purchases, gifts, campaigns, referrals, etc. For example, after a total of 100 points are gathered by purchases made by orders, the user gets $10 redeemable (rewards banked) into the account. This type of discount is allowed in points-based businesses. In the Fetch Account Balance of User API response, if the value of banked_rewards is greater than 0, then use a dollar amount in the redeemed_points parameter not exceeding the value of banked_rewards and use discount_type = discount_amount in the Create Online Redemption API request."discount_type": "discount_amount" "redeemed_points": 5.0 |
| Redemption code | This redemption type also applies to coupons and promos. Punchh coupons apply a discount on the receipt. To use coupon codes, a guest need not be a Punchh user. Promo codes are similar to coupon codes, but are separately termed due to the fact that they can be configured by the business admin in the Punchh dashboard as required with a minimum length of 4 characters with at least one letter. To use promo codes, a guest need not be a Punchh loyalty user. When using a redemption code, coupon code, or promo code, pass the code in the redemption_code parameter and use discount_type = redemption_code in the Create Online Redemption API request."discount_type": "redemption_code" "redemption_code": "REDEMPTION_CODE_GOES_HERE" Coupon and promo codes are typically sent directly to a user via email/SMS campaigns but can be provided via direct marketing mailers to users as well. |
| Card completion | This type of discount is allowed in visit-based businesses. This is applicable after a certain number of visits by a user, as configured by a business. A user can hold multiple cards. For example, if the user has had 7 check-ins at the POS, then on the 8th check-in one card will be completed and the user will be offered rewards. In the Fetch Account Balance of User API response, if the value of unredeemed_cards is greater than 0, then use discount_type = card_completion in the Create Online Redemption API request.“discount_type": "card_completion" |
| Subscription | It allows a user to redeem subscription-related benefits. Fetch the subscriptions of the user and pass the ID of the subscription that you want to redeem in the subscription_id parameter using discount_type = subscription in the Create Online Redemption API request."discount_type": "subscription" "subscription_id": "SUBSCRIPTION_ID_GOES_HERE" |
Best Practices
- Submit your redemption as a Possible Redemptions call by passing the
queryparameter with a value of “true” with the Create Online Redemption API request. - Process the redemption using the appropriate discount type (e.g., reward, redeemable, etc.) in the Create Online Redemption API request.
- Submit another redemption only now with the applied discount reflected in the menu items with type “D” for discount (see How To Send Menu Items to Punchh.
- Create the second redemption and repeat this process as needed.
- In case of multiple redemptions, submit any previously applied Punchh discounts along with internal discounts in the check details for each subsequent Possible Redemptions call.
- You can make Possible Redemptions calls throughout the ordering process, but there is a risk that if you wait until payment to process the redemption, there will be a discrepancy between the discount shown to the guest and the actual discount.
Related Topics
Fetch Account Balance of User API
How To Send Menu Items to Punchh