Skip to main content

Creating an Authorization Policy

Start by visiting the Charge Authentication Page.

Charge Authentication page

Click on the "+ Add Authentication Policy" to open the "Add Authentication Policy" modal. Here is where you can fill out any complex pricing policies.

Add Authentcation Policy modal

Pricing Policy Examples

Employee / Guest Pricing Policies

import future.keywords.if

# Default to deny unless explicitly allowed
default allow = false

# Allow employees - they get free charging
allow if {
input.user.type == "employee"
}

# Allow guests - they will be charged
allow if {
input.user.type == "guest"
}

# Billing strategy: free for employees, standard for guests
billing_strategy := "free" if {
input.user.type == "employee"
}

billing_strategy := "guest_billing" if {
input.user.type == "guest"
}

# Contextual metadata about the decision
context := {
"policy": "employee_guest",
"user_type": input.user.type,
"payment_method": input.user.payment_method,
"timestamp": input.timestamp
}

# Denial reason for registered customers or other user types
denial_reason := "Access denied: Only employees and guests are permitted" if {
not allow
}

Enforce Preauthorization Limits for Different Users

package authorization.spending_limits

import future.keywords.if

default allow = false

# Guests have a lower pre-auth limit ($50)
allow if {
input.user.type == "guest"
input.pre_auth_amount <= 5000 # Assuming cents
}

# Registered customers have medium limit ($200)
allow if {
input.user.type == "registered_customer"
input.pre_auth_amount <= 20000
}

# Employees have no limit
allow if {
input.user.type == "employee"
}

billing_strategy := "guest_billing" if {
allow
input.user.type == "guest"
}

billing_strategy := "customer_billing" if {
allow
input.user.type == "registered_customer"
}

billing_strategy := "free" if {
allow
input.user.type == "employee"
}

denial_reason := sprintf("Pre-authorization amount $%.2f exceeds limit for %s users",
[input.pre_auth_amount / 100, input.user.type]) if {
not allow
}

Charger Specific VIP Access

package authorization.vip_chargers

import future.keywords.if

default allow = false

vip_chargers := {
"charger-vip-001",
"charger-vip-002",
"charger-executive-parking"
}

is_vip_charger if {
vip_chargers[input.charger.charge_box_id]
}

# Only employees can use VIP chargers
allow if {
is_vip_charger
input.user.type == "employee"
}

# Everyone can use regular chargers
allow if {
not is_vip_charger
}

billing_strategy := "free" if {
allow
is_vip_charger
input.user.type == "employee"
}

billing_strategy := "standard" if {
allow
not is_vip_charger
}

context := {
"policy": "vip_chargers",
"is_vip_charger": is_vip_charger,
"charger_id": input.charger.charge_box_id
}

denial_reason := "Access denied: VIP chargers are reserved for employees only" if {
not allow
is_vip_charger
}

Need Support?

Let us help you. Send enquiries to hello@voltra.com