Best Practices
1. Maintain Detailed Logs
1. Maintain Detailed Logs
Comprehensive logging is your first line of defense when investigating a failed transaction or resolving a customer dispute. You should log:
- All request parameters before they are assigned or sent, so you can catch data-formatting bugs early.
- Every request your server sends to Payzah, including headers, payload, and timestamp.
- Every response received from Payzah, including HTTP status codes and full response bodies.
2. Complete UAT (User Acceptance Testing)
2. Complete UAT (User Acceptance Testing)
Never skip User Acceptance Testing before moving to production. Your UAT suite should exercise every integration point, including:
- Successful payment flows for each supported payment method (K-Net, Visa, MasterCard).
- Declined and expired card scenarios.
- Cancelled or abandoned sessions.
- Payment status-check polling, including edge cases where a status is not immediately available.
3. Secure Transaction Logs
3. Secure Transaction Logs
Transaction logs contain sensitive financial data and must be protected accordingly. Store logs in an access-controlled system with encryption at rest. Retain them for a period that satisfies your local regulatory requirements and internal audit policies. Secure logs are invaluable during chargeback disputes — they provide a timestamped, tamper-evident record of exactly what was sent and received.
4. Include the Customer IP Address
4. Include the Customer IP Address
Always pass the customer’s IP address in your payment requests. Payzah uses this information for fraud detection and provides richer tracking data in your transaction reports. Capturing the IP at the point of checkout (rather than using your server’s IP) ensures the data is meaningful and accurate.
5. Use Unique Track IDs
5. Use Unique Track IDs
Every transaction you initiate must have a unique
trackid. Reusing a track ID across multiple transactions can cause look-up collisions and make it impossible to reliably map a Payzah response back to the correct order in your system. Generate track IDs using a UUID or a similarly collision-resistant method, and store the mapping between your internal order ID and the trackid in your database.6. No Special Characters in trackid or UDF Fields
6. No Special Characters in trackid or UDF Fields
The
trackid and all User-Defined Fields (UDFs) must contain only alphanumeric characters. Special characters (e.g., &, =, #, spaces) can break URL encoding or cause request parsing failures on the Payzah gateway. Validate and sanitize these fields before every request, and enforce the constraint at the input layer so invalid values never reach your payment code.7. Key Rotation Procedure
7. Key Rotation Procedure
If your private key is ever exposed — whether through a repository leak, an accidental log entry, or a security incident — treat it as compromised immediately. Do not wait to confirm misuse before acting. Contact Payzah at [email protected] or call +965 22410760 to request an immediate key rotation. Update all environments with the new key and audit your logs for any unauthorized activity during the window of exposure.
8. Keep Test and Production Keys Separate
8. Keep Test and Production Keys Separate
Your test and production API keys must never be mixed. Using a test key in production will cause all live transactions to fail; using a production key in your test environment risks accidental real charges. Store each key in environment-specific configuration (e.g.,
.env.test and .env.production) and use your deployment pipeline to inject the correct value per environment automatically. Periodically audit your configuration to confirm no cross-environment key usage exists.