Integrity and Source Verification
Every payload that you receive from a payment processor carries two inherent risks: (i) Data tampering risk (ii) Impersonation risk
Prism provides strong run-time checks to eliminate both risks. This section also includes some recommended best practices to developers using the library.
Integrity
Amount, currency, and transaction ID match your records
Data tampering
Source
Cryptographic signature using shared secrets
Impersonation, forged webhooks
What are the risks?
Interim of the implementation
Data Tampering (Integrity Risk)
An attacker intercepting a webhook can modify the payload before it reaches your server. The attacker will be able to exploit by:
Changing a failed payment status to "succeeded", which might deceive you to ship unpaid orders
Modifying the amount from $100 to $1, effectively making the customer pays less than expected.
Impersonation (Source Risk)
It is possible for attackers can forge webhooks that appear to come from payment processors. This can be exploited by:
Sending fake "payment succeeded" webhooks, which might deceive you to ship unpaid orders
Mimicking refund notifications, to manipulate your accounting systems
Prism provides built-in verification for both risks, and it is strongly recommended to enable them and test them before using on production.
How Prism helps with Integrity and Source Verification?
Request and Response Comparison
Prism uses a FlowIntegrity trait to compare request and response data in a strongly typed fashion. The core implementation is available in backend/interfaces/src/integrity.rs:
Amount and Currency Verification
During the payment authorization step, Prism extracts amount and currency from the request and compares with the response during run-time. The core implementation is available in backend/interfaces/src/integrity.rs:
Webhooks payloads also include amounts (might vary across payment processors). Prism verifies these match your records.
If amounts mismatch, Prism flags the discrepancy clearly. In such cases you should reject the webhook and use direct server-to-server APIs to cross validate the information.
Signature Verification
Typically Payment processors sign webhooks with a shared secret, to verify the payload against pre-configured secrets. An Authorize.net might use a SHA512, whereas a PPRO might use a SHA256.
Prism handles the signature verification across multiple processors.
And below are real examples from one of the connectors on how it is implemented backend/connector-integration/src/connectors/authorizedotnet.rs:
If verification fails, Prism flags the discrepancy very clearly.
Recommendations for Developers
Verify the Transaction ID and Amount in your system
It is strongly recommended to track transaction IDs across the lifecycle. When a webhook or API response arrives, check the following parameters in your application database, before updating them.
ID exists in system
Reject unknown transaction IDs
Status transition valid
Reject invalid state changes (e.g., SUCCEEDED → PENDING)
Amount match
Reject payload to prevent amount tampering
Currency match
Reject payload to prevent currency tampering
Always Configure the secrets while enabling a processor
Some payment processors may have the secrets as optional configuration/ implementation. Always, generate new secret in processor dashboard and update the Prism configuration accordingly.
An example configuration for Stripe as below.
Next Steps
Source Verification — Verify redirect responses and 3DS callbacks
Error Handling — Handle verification failures in your application
Last updated
Was this helpful?

