Payment Metadata
Klevr Portal – Dynamics 365 Customer Engagement
💳 Payment Metadata Feature
Klevr Portal – Dynamics 365 Customer Engagement
📌 Overview
The Payment Metadata Feature allows administrators to configure how data from Dynamics 365 CE is mapped into metadata sent to external payment gateways such as Stripe and Payfurl.
This is achieved through a configurable Environment Variable, enabling:
- Dynamic metadata enrichment without code changes
- Flexible fallback logic
- Support for lookup traversal
- Hard-coded metadata values
⚙️ Configuration
Environment Variable
| Solution | Klevr Portal |
|---|---|
| Name | klevr_PaymentToGatewayMetadataMap |
| Type | JSON KVP (e.g. {"x":"y", "z":"a"} ) |
📍 Location
Navigate to Solutions → Klevr Portal
Open Environment Variables
Locate klevr_PaymentToGatewayMetadataMap
Set the Current Value
🧱 JSON Structure
The configuration must be a JSON Dictionary:
Definitions
metadataKey : Name of the metadata field sent to the payment gateway
valueSource: Dynamics field path OR hard-coded value
🔁 Mapping Behaviour
✅ 1. Direct Field Mapping
Fields are sourced from the payment record
- Retrieves value from the
namefield - Assigns it to metadata key
m1
🔗 2. Lookup Traversal (Dot Notation)
Starting point is the payment record
Process:
klevr_contactid→ lookup field- Retrieve related record
emailaddress1→ field on that record
🔄 3. Recursive Lookup Traversal
Supports multi-level lookups:
Each segment is processed sequentially.
⚠️ 4. Null Handling
A mapping is ignored if any of the following occurs:
- Field is not a lookup where expected
- Lookup field has no value
- Related record cannot be retrieved
- Final field value is null or empty
🔄 Fallback Logic (Multiple Mappings)
You can define multiple mappings for the same metadata key.
📘 Example
Evaluation Order
- Try
name - If null → try
amount - If null → use
'blank'
🧩 Hard-Coded Values
If the value is wrapped in single quotes, it is treated as a constant.
Behaviour
- No field lookup is performed
- Value is inserted directly
- Quotes are not included in final output
📘 Full Example
Field names below are mostly ficticious and you should verify the correct schema names for your fields
✅ Result
CustomerEmail:
- Contact email
- Account email
- Fallback to
"unknown"
Reference:
- Invoice number from associated gif (if it is associated to a gift)
- Fallback to
"no-ref"
🚫 Reserved Metadata Fields
The following keys are system-controlled and cannot be overridden:
TransactionIdCustomerId
⚠️ Any mappings configured for these keys will be ignored
🔁 Processing Logic Summary
For each metadata key:
- Iterate mappings in order
- Evaluate value (field or literal)
- If valid → assign and stop
- If invalid → continue
- If none valid → key not included
✅ Best Practices
✔️ Prioritise Likely Fields First
Improves performance and clarity
✔️ Always Include a Fallback
✔️ Keep Mappings Readable
Avoid overly deep lookup chains where possible
You could use powerfx columns to surface lower level data upwards too
✔️ Validate Schema Names
Ensure:
- Correct logical names
- Relationships exist
- Fields are accessible
✔️ Test End-to-End
Confirm metadata is correctly sent to:
- Stripe
- Payfurl
🛠 Troubleshooting
| Issue | Cause |
|---|---|
| Metadata missing | All mappings returned null |
| Incorrect value | Invalid field name |
| Lookup failed | Empty or invalid lookup |
| JSON error | Invalid syntax |
🧾 Summary
The Payment Metadata Feature provides a flexible, configuration-driven approach to enriching payment transactions with contextual Dynamics 365 data.
Key Capabilities
- JSON-based configuration
- Lookup traversal with dot notation
- Fallback prioritisation
- Hard-coded values
- No-code extensibility
Last updated on