Encrypt receipt
curl --request POST \
--url https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt \
--header 'Content-Type: application/json' \
--data '
{
"version": "1.0",
"receiptId": "rcpt_abc123def456",
"merchantId": "merch_kitchenmart_001",
"merchantName": "KitchenMart",
"merchantStreet": "456 Commerce Ave",
"merchantCity": "San Francisco",
"merchantState": "CA",
"merchantPostalCode": "94103",
"merchantCountry": "US",
"merchantTaxId": "98-7654321",
"merchantContactEmail": "[email protected]",
"transactionId": "txn_550e8400e29b41d4a716",
"transactionDate": "2025-12-18T10:30:00Z",
"transactionTimezone": "America/Los_Angeles",
"paymentMethod": "card",
"cardLast4": "4242",
"cardBrand": "visa",
"currency": "USD",
"subtotal": 10997,
"taxAmount": 962,
"totalAmount": 11959,
"items": [
{
"lineItemId": "item_001",
"name": "Stainless Steel Mixing Bowl Set",
"quantity": 1,
"unitPrice": 2999,
"totalPrice": 2999,
"category": "Kitchen Essentials",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 262
}
]
},
{
"lineItemId": "item_002",
"name": "Non-Stick Frying Pan",
"quantity": 2,
"unitPrice": 3999,
"totalPrice": 7998,
"category": "Cookware",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 700
}
]
}
],
"mockItems": false,
"recipientHashedPan": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
}
'import requests
url = "https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt"
payload = {
"version": "1.0",
"receiptId": "rcpt_abc123def456",
"merchantId": "merch_kitchenmart_001",
"merchantName": "KitchenMart",
"merchantStreet": "456 Commerce Ave",
"merchantCity": "San Francisco",
"merchantState": "CA",
"merchantPostalCode": "94103",
"merchantCountry": "US",
"merchantTaxId": "98-7654321",
"merchantContactEmail": "[email protected]",
"transactionId": "txn_550e8400e29b41d4a716",
"transactionDate": "2025-12-18T10:30:00Z",
"transactionTimezone": "America/Los_Angeles",
"paymentMethod": "card",
"cardLast4": "4242",
"cardBrand": "visa",
"currency": "USD",
"subtotal": 10997,
"taxAmount": 962,
"totalAmount": 11959,
"items": [
{
"lineItemId": "item_001",
"name": "Stainless Steel Mixing Bowl Set",
"quantity": 1,
"unitPrice": 2999,
"totalPrice": 2999,
"category": "Kitchen Essentials",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 262
}
]
},
{
"lineItemId": "item_002",
"name": "Non-Stick Frying Pan",
"quantity": 2,
"unitPrice": 3999,
"totalPrice": 7998,
"category": "Cookware",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 700
}
]
}
],
"mockItems": False,
"recipientHashedPan": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
version: '1.0',
receiptId: 'rcpt_abc123def456',
merchantId: 'merch_kitchenmart_001',
merchantName: 'KitchenMart',
merchantStreet: '456 Commerce Ave',
merchantCity: 'San Francisco',
merchantState: 'CA',
merchantPostalCode: '94103',
merchantCountry: 'US',
merchantTaxId: '98-7654321',
merchantContactEmail: '[email protected]',
transactionId: 'txn_550e8400e29b41d4a716',
transactionDate: '2025-12-18T10:30:00Z',
transactionTimezone: 'America/Los_Angeles',
paymentMethod: 'card',
cardLast4: '4242',
cardBrand: 'visa',
currency: 'USD',
subtotal: 10997,
taxAmount: 962,
totalAmount: 11959,
items: [
{
lineItemId: 'item_001',
name: 'Stainless Steel Mixing Bowl Set',
quantity: 1,
unitPrice: 2999,
totalPrice: 2999,
category: 'Kitchen Essentials',
taxes: [{name: 'Sales Tax', rate: 0.0875, amount: 262}]
},
{
lineItemId: 'item_002',
name: 'Non-Stick Frying Pan',
quantity: 2,
unitPrice: 3999,
totalPrice: 7998,
category: 'Cookware',
taxes: [{name: 'Sales Tax', rate: 0.0875, amount: 700}]
}
],
mockItems: false,
recipientHashedPan: '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'
})
};
fetch('https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => '1.0',
'receiptId' => 'rcpt_abc123def456',
'merchantId' => 'merch_kitchenmart_001',
'merchantName' => 'KitchenMart',
'merchantStreet' => '456 Commerce Ave',
'merchantCity' => 'San Francisco',
'merchantState' => 'CA',
'merchantPostalCode' => '94103',
'merchantCountry' => 'US',
'merchantTaxId' => '98-7654321',
'merchantContactEmail' => '[email protected]',
'transactionId' => 'txn_550e8400e29b41d4a716',
'transactionDate' => '2025-12-18T10:30:00Z',
'transactionTimezone' => 'America/Los_Angeles',
'paymentMethod' => 'card',
'cardLast4' => '4242',
'cardBrand' => 'visa',
'currency' => 'USD',
'subtotal' => 10997,
'taxAmount' => 962,
'totalAmount' => 11959,
'items' => [
[
'lineItemId' => 'item_001',
'name' => 'Stainless Steel Mixing Bowl Set',
'quantity' => 1,
'unitPrice' => 2999,
'totalPrice' => 2999,
'category' => 'Kitchen Essentials',
'taxes' => [
[
'name' => 'Sales Tax',
'rate' => 0.0875,
'amount' => 262
]
]
],
[
'lineItemId' => 'item_002',
'name' => 'Non-Stick Frying Pan',
'quantity' => 2,
'unitPrice' => 3999,
'totalPrice' => 7998,
'category' => 'Cookware',
'taxes' => [
[
'name' => 'Sales Tax',
'rate' => 0.0875,
'amount' => 700
]
]
]
],
'mockItems' => false,
'recipientHashedPan' => '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt"
payload := strings.NewReader("{\n \"version\": \"1.0\",\n \"receiptId\": \"rcpt_abc123def456\",\n \"merchantId\": \"merch_kitchenmart_001\",\n \"merchantName\": \"KitchenMart\",\n \"merchantStreet\": \"456 Commerce Ave\",\n \"merchantCity\": \"San Francisco\",\n \"merchantState\": \"CA\",\n \"merchantPostalCode\": \"94103\",\n \"merchantCountry\": \"US\",\n \"merchantTaxId\": \"98-7654321\",\n \"merchantContactEmail\": \"[email protected]\",\n \"transactionId\": \"txn_550e8400e29b41d4a716\",\n \"transactionDate\": \"2025-12-18T10:30:00Z\",\n \"transactionTimezone\": \"America/Los_Angeles\",\n \"paymentMethod\": \"card\",\n \"cardLast4\": \"4242\",\n \"cardBrand\": \"visa\",\n \"currency\": \"USD\",\n \"subtotal\": 10997,\n \"taxAmount\": 962,\n \"totalAmount\": 11959,\n \"items\": [\n {\n \"lineItemId\": \"item_001\",\n \"name\": \"Stainless Steel Mixing Bowl Set\",\n \"quantity\": 1,\n \"unitPrice\": 2999,\n \"totalPrice\": 2999,\n \"category\": \"Kitchen Essentials\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 262\n }\n ]\n },\n {\n \"lineItemId\": \"item_002\",\n \"name\": \"Non-Stick Frying Pan\",\n \"quantity\": 2,\n \"unitPrice\": 3999,\n \"totalPrice\": 7998,\n \"category\": \"Cookware\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 700\n }\n ]\n }\n ],\n \"mockItems\": false,\n \"recipientHashedPan\": \"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt")
.header("Content-Type", "application/json")
.body("{\n \"version\": \"1.0\",\n \"receiptId\": \"rcpt_abc123def456\",\n \"merchantId\": \"merch_kitchenmart_001\",\n \"merchantName\": \"KitchenMart\",\n \"merchantStreet\": \"456 Commerce Ave\",\n \"merchantCity\": \"San Francisco\",\n \"merchantState\": \"CA\",\n \"merchantPostalCode\": \"94103\",\n \"merchantCountry\": \"US\",\n \"merchantTaxId\": \"98-7654321\",\n \"merchantContactEmail\": \"[email protected]\",\n \"transactionId\": \"txn_550e8400e29b41d4a716\",\n \"transactionDate\": \"2025-12-18T10:30:00Z\",\n \"transactionTimezone\": \"America/Los_Angeles\",\n \"paymentMethod\": \"card\",\n \"cardLast4\": \"4242\",\n \"cardBrand\": \"visa\",\n \"currency\": \"USD\",\n \"subtotal\": 10997,\n \"taxAmount\": 962,\n \"totalAmount\": 11959,\n \"items\": [\n {\n \"lineItemId\": \"item_001\",\n \"name\": \"Stainless Steel Mixing Bowl Set\",\n \"quantity\": 1,\n \"unitPrice\": 2999,\n \"totalPrice\": 2999,\n \"category\": \"Kitchen Essentials\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 262\n }\n ]\n },\n {\n \"lineItemId\": \"item_002\",\n \"name\": \"Non-Stick Frying Pan\",\n \"quantity\": 2,\n \"unitPrice\": 3999,\n \"totalPrice\": 7998,\n \"category\": \"Cookware\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 700\n }\n ]\n }\n ],\n \"mockItems\": false,\n \"recipientHashedPan\": \"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": \"1.0\",\n \"receiptId\": \"rcpt_abc123def456\",\n \"merchantId\": \"merch_kitchenmart_001\",\n \"merchantName\": \"KitchenMart\",\n \"merchantStreet\": \"456 Commerce Ave\",\n \"merchantCity\": \"San Francisco\",\n \"merchantState\": \"CA\",\n \"merchantPostalCode\": \"94103\",\n \"merchantCountry\": \"US\",\n \"merchantTaxId\": \"98-7654321\",\n \"merchantContactEmail\": \"[email protected]\",\n \"transactionId\": \"txn_550e8400e29b41d4a716\",\n \"transactionDate\": \"2025-12-18T10:30:00Z\",\n \"transactionTimezone\": \"America/Los_Angeles\",\n \"paymentMethod\": \"card\",\n \"cardLast4\": \"4242\",\n \"cardBrand\": \"visa\",\n \"currency\": \"USD\",\n \"subtotal\": 10997,\n \"taxAmount\": 962,\n \"totalAmount\": 11959,\n \"items\": [\n {\n \"lineItemId\": \"item_001\",\n \"name\": \"Stainless Steel Mixing Bowl Set\",\n \"quantity\": 1,\n \"unitPrice\": 2999,\n \"totalPrice\": 2999,\n \"category\": \"Kitchen Essentials\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 262\n }\n ]\n },\n {\n \"lineItemId\": \"item_002\",\n \"name\": \"Non-Stick Frying Pan\",\n \"quantity\": 2,\n \"unitPrice\": 3999,\n \"totalPrice\": 7998,\n \"category\": \"Cookware\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 700\n }\n ]\n }\n ],\n \"mockItems\": false,\n \"recipientHashedPan\": \"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"version": "1.0",
"receiptId": "rcpt_abc123def456",
"keyId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"keyBundle": {
"encryptedAesKey": "base64_encrypted_aes_key_here...",
"keyId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"algorithm": "RSA-OAEP-256"
},
"ciphertext": "base64_encrypted_receipt_data_here...",
"iv": "base64_initialization_vector...",
"authTag": "base64_authentication_tag...",
"merchantId": "merch_kitchenmart_001",
"transactionId": "txn_550e8400e29b41d4a716",
"createdAt": "2025-12-18T10:30:00Z",
"isEscrowed": false
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "ENCRYPTION_ERROR",
"message": "Failed to encrypt receipt"
}
}Receipt Encryption (Merchant)
Encrypt Receipt
Encrypt a digital receipt for a specific recipient using hybrid encryption:
- AES-256-GCM for the receipt data (symmetric)
- RSA-OAEP-SHA256 for key wrapping (asymmetric)
If the recipient is not onboarded, the receipt will be encrypted with
the escrow key instead (indicated by isEscrowed: true in the response).
POST
/
api
/
v1
/
receipts
/
encrypt
Encrypt receipt
curl --request POST \
--url https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt \
--header 'Content-Type: application/json' \
--data '
{
"version": "1.0",
"receiptId": "rcpt_abc123def456",
"merchantId": "merch_kitchenmart_001",
"merchantName": "KitchenMart",
"merchantStreet": "456 Commerce Ave",
"merchantCity": "San Francisco",
"merchantState": "CA",
"merchantPostalCode": "94103",
"merchantCountry": "US",
"merchantTaxId": "98-7654321",
"merchantContactEmail": "[email protected]",
"transactionId": "txn_550e8400e29b41d4a716",
"transactionDate": "2025-12-18T10:30:00Z",
"transactionTimezone": "America/Los_Angeles",
"paymentMethod": "card",
"cardLast4": "4242",
"cardBrand": "visa",
"currency": "USD",
"subtotal": 10997,
"taxAmount": 962,
"totalAmount": 11959,
"items": [
{
"lineItemId": "item_001",
"name": "Stainless Steel Mixing Bowl Set",
"quantity": 1,
"unitPrice": 2999,
"totalPrice": 2999,
"category": "Kitchen Essentials",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 262
}
]
},
{
"lineItemId": "item_002",
"name": "Non-Stick Frying Pan",
"quantity": 2,
"unitPrice": 3999,
"totalPrice": 7998,
"category": "Cookware",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 700
}
]
}
],
"mockItems": false,
"recipientHashedPan": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
}
'import requests
url = "https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt"
payload = {
"version": "1.0",
"receiptId": "rcpt_abc123def456",
"merchantId": "merch_kitchenmart_001",
"merchantName": "KitchenMart",
"merchantStreet": "456 Commerce Ave",
"merchantCity": "San Francisco",
"merchantState": "CA",
"merchantPostalCode": "94103",
"merchantCountry": "US",
"merchantTaxId": "98-7654321",
"merchantContactEmail": "[email protected]",
"transactionId": "txn_550e8400e29b41d4a716",
"transactionDate": "2025-12-18T10:30:00Z",
"transactionTimezone": "America/Los_Angeles",
"paymentMethod": "card",
"cardLast4": "4242",
"cardBrand": "visa",
"currency": "USD",
"subtotal": 10997,
"taxAmount": 962,
"totalAmount": 11959,
"items": [
{
"lineItemId": "item_001",
"name": "Stainless Steel Mixing Bowl Set",
"quantity": 1,
"unitPrice": 2999,
"totalPrice": 2999,
"category": "Kitchen Essentials",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 262
}
]
},
{
"lineItemId": "item_002",
"name": "Non-Stick Frying Pan",
"quantity": 2,
"unitPrice": 3999,
"totalPrice": 7998,
"category": "Cookware",
"taxes": [
{
"name": "Sales Tax",
"rate": 0.0875,
"amount": 700
}
]
}
],
"mockItems": False,
"recipientHashedPan": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
version: '1.0',
receiptId: 'rcpt_abc123def456',
merchantId: 'merch_kitchenmart_001',
merchantName: 'KitchenMart',
merchantStreet: '456 Commerce Ave',
merchantCity: 'San Francisco',
merchantState: 'CA',
merchantPostalCode: '94103',
merchantCountry: 'US',
merchantTaxId: '98-7654321',
merchantContactEmail: '[email protected]',
transactionId: 'txn_550e8400e29b41d4a716',
transactionDate: '2025-12-18T10:30:00Z',
transactionTimezone: 'America/Los_Angeles',
paymentMethod: 'card',
cardLast4: '4242',
cardBrand: 'visa',
currency: 'USD',
subtotal: 10997,
taxAmount: 962,
totalAmount: 11959,
items: [
{
lineItemId: 'item_001',
name: 'Stainless Steel Mixing Bowl Set',
quantity: 1,
unitPrice: 2999,
totalPrice: 2999,
category: 'Kitchen Essentials',
taxes: [{name: 'Sales Tax', rate: 0.0875, amount: 262}]
},
{
lineItemId: 'item_002',
name: 'Non-Stick Frying Pan',
quantity: 2,
unitPrice: 3999,
totalPrice: 7998,
category: 'Cookware',
taxes: [{name: 'Sales Tax', rate: 0.0875, amount: 700}]
}
],
mockItems: false,
recipientHashedPan: '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'
})
};
fetch('https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'version' => '1.0',
'receiptId' => 'rcpt_abc123def456',
'merchantId' => 'merch_kitchenmart_001',
'merchantName' => 'KitchenMart',
'merchantStreet' => '456 Commerce Ave',
'merchantCity' => 'San Francisco',
'merchantState' => 'CA',
'merchantPostalCode' => '94103',
'merchantCountry' => 'US',
'merchantTaxId' => '98-7654321',
'merchantContactEmail' => '[email protected]',
'transactionId' => 'txn_550e8400e29b41d4a716',
'transactionDate' => '2025-12-18T10:30:00Z',
'transactionTimezone' => 'America/Los_Angeles',
'paymentMethod' => 'card',
'cardLast4' => '4242',
'cardBrand' => 'visa',
'currency' => 'USD',
'subtotal' => 10997,
'taxAmount' => 962,
'totalAmount' => 11959,
'items' => [
[
'lineItemId' => 'item_001',
'name' => 'Stainless Steel Mixing Bowl Set',
'quantity' => 1,
'unitPrice' => 2999,
'totalPrice' => 2999,
'category' => 'Kitchen Essentials',
'taxes' => [
[
'name' => 'Sales Tax',
'rate' => 0.0875,
'amount' => 262
]
]
],
[
'lineItemId' => 'item_002',
'name' => 'Non-Stick Frying Pan',
'quantity' => 2,
'unitPrice' => 3999,
'totalPrice' => 7998,
'category' => 'Cookware',
'taxes' => [
[
'name' => 'Sales Tax',
'rate' => 0.0875,
'amount' => 700
]
]
]
],
'mockItems' => false,
'recipientHashedPan' => '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt"
payload := strings.NewReader("{\n \"version\": \"1.0\",\n \"receiptId\": \"rcpt_abc123def456\",\n \"merchantId\": \"merch_kitchenmart_001\",\n \"merchantName\": \"KitchenMart\",\n \"merchantStreet\": \"456 Commerce Ave\",\n \"merchantCity\": \"San Francisco\",\n \"merchantState\": \"CA\",\n \"merchantPostalCode\": \"94103\",\n \"merchantCountry\": \"US\",\n \"merchantTaxId\": \"98-7654321\",\n \"merchantContactEmail\": \"[email protected]\",\n \"transactionId\": \"txn_550e8400e29b41d4a716\",\n \"transactionDate\": \"2025-12-18T10:30:00Z\",\n \"transactionTimezone\": \"America/Los_Angeles\",\n \"paymentMethod\": \"card\",\n \"cardLast4\": \"4242\",\n \"cardBrand\": \"visa\",\n \"currency\": \"USD\",\n \"subtotal\": 10997,\n \"taxAmount\": 962,\n \"totalAmount\": 11959,\n \"items\": [\n {\n \"lineItemId\": \"item_001\",\n \"name\": \"Stainless Steel Mixing Bowl Set\",\n \"quantity\": 1,\n \"unitPrice\": 2999,\n \"totalPrice\": 2999,\n \"category\": \"Kitchen Essentials\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 262\n }\n ]\n },\n {\n \"lineItemId\": \"item_002\",\n \"name\": \"Non-Stick Frying Pan\",\n \"quantity\": 2,\n \"unitPrice\": 3999,\n \"totalPrice\": 7998,\n \"category\": \"Cookware\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 700\n }\n ]\n }\n ],\n \"mockItems\": false,\n \"recipientHashedPan\": \"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt")
.header("Content-Type", "application/json")
.body("{\n \"version\": \"1.0\",\n \"receiptId\": \"rcpt_abc123def456\",\n \"merchantId\": \"merch_kitchenmart_001\",\n \"merchantName\": \"KitchenMart\",\n \"merchantStreet\": \"456 Commerce Ave\",\n \"merchantCity\": \"San Francisco\",\n \"merchantState\": \"CA\",\n \"merchantPostalCode\": \"94103\",\n \"merchantCountry\": \"US\",\n \"merchantTaxId\": \"98-7654321\",\n \"merchantContactEmail\": \"[email protected]\",\n \"transactionId\": \"txn_550e8400e29b41d4a716\",\n \"transactionDate\": \"2025-12-18T10:30:00Z\",\n \"transactionTimezone\": \"America/Los_Angeles\",\n \"paymentMethod\": \"card\",\n \"cardLast4\": \"4242\",\n \"cardBrand\": \"visa\",\n \"currency\": \"USD\",\n \"subtotal\": 10997,\n \"taxAmount\": 962,\n \"totalAmount\": 11959,\n \"items\": [\n {\n \"lineItemId\": \"item_001\",\n \"name\": \"Stainless Steel Mixing Bowl Set\",\n \"quantity\": 1,\n \"unitPrice\": 2999,\n \"totalPrice\": 2999,\n \"category\": \"Kitchen Essentials\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 262\n }\n ]\n },\n {\n \"lineItemId\": \"item_002\",\n \"name\": \"Non-Stick Frying Pan\",\n \"quantity\": 2,\n \"unitPrice\": 3999,\n \"totalPrice\": 7998,\n \"category\": \"Cookware\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 700\n }\n ]\n }\n ],\n \"mockItems\": false,\n \"recipientHashedPan\": \"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.digitalreceiptprotocol.org/api/v1/receipts/encrypt")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"version\": \"1.0\",\n \"receiptId\": \"rcpt_abc123def456\",\n \"merchantId\": \"merch_kitchenmart_001\",\n \"merchantName\": \"KitchenMart\",\n \"merchantStreet\": \"456 Commerce Ave\",\n \"merchantCity\": \"San Francisco\",\n \"merchantState\": \"CA\",\n \"merchantPostalCode\": \"94103\",\n \"merchantCountry\": \"US\",\n \"merchantTaxId\": \"98-7654321\",\n \"merchantContactEmail\": \"[email protected]\",\n \"transactionId\": \"txn_550e8400e29b41d4a716\",\n \"transactionDate\": \"2025-12-18T10:30:00Z\",\n \"transactionTimezone\": \"America/Los_Angeles\",\n \"paymentMethod\": \"card\",\n \"cardLast4\": \"4242\",\n \"cardBrand\": \"visa\",\n \"currency\": \"USD\",\n \"subtotal\": 10997,\n \"taxAmount\": 962,\n \"totalAmount\": 11959,\n \"items\": [\n {\n \"lineItemId\": \"item_001\",\n \"name\": \"Stainless Steel Mixing Bowl Set\",\n \"quantity\": 1,\n \"unitPrice\": 2999,\n \"totalPrice\": 2999,\n \"category\": \"Kitchen Essentials\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 262\n }\n ]\n },\n {\n \"lineItemId\": \"item_002\",\n \"name\": \"Non-Stick Frying Pan\",\n \"quantity\": 2,\n \"unitPrice\": 3999,\n \"totalPrice\": 7998,\n \"category\": \"Cookware\",\n \"taxes\": [\n {\n \"name\": \"Sales Tax\",\n \"rate\": 0.0875,\n \"amount\": 700\n }\n ]\n }\n ],\n \"mockItems\": false,\n \"recipientHashedPan\": \"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"version": "1.0",
"receiptId": "rcpt_abc123def456",
"keyId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"keyBundle": {
"encryptedAesKey": "base64_encrypted_aes_key_here...",
"keyId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"algorithm": "RSA-OAEP-256"
},
"ciphertext": "base64_encrypted_receipt_data_here...",
"iv": "base64_initialization_vector...",
"authTag": "base64_authentication_tag...",
"merchantId": "merch_kitchenmart_001",
"transactionId": "txn_550e8400e29b41d4a716",
"createdAt": "2025-12-18T10:30:00Z",
"isEscrowed": false
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": {}
}
}{
"success": false,
"error": {
"code": "ENCRYPTION_ERROR",
"message": "Failed to encrypt receipt"
}
}Body
application/json
Flattened receipt structure with recipient identifier
Hashed PAN of the recipient
Example:
"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
Show child attributes
Show child attributes
If true and items are empty, generates mock line items
⌘I