Overview
What Happened
ShurjoPay’s BRAC Bank integration depended on a bank-provided library (from BRAC Bank’s IT team) that generated an encrypted
token required for transaction requests. The library was authored for PHP 7, while ShurjoPay’s main system
ran on PHP 8. When we require-ed the library directly in the PHP 8 runtime, the encrypted token
was produced incorrectly, and BRAC Bank transactions failed.
A prior team mitigated the incident by creating a small PHP 7 REST endpoint (hosted on a subdomain) that
wrapped the bank library and returned the encrypted token to the main app. This restored payment success — but introduced a
domain boundary that blocked the Card-on-File (CoF) confirmation workflow. As a result, CoF remained disabled
for a long time.
Context
Why This Was High-Stakes
- Reliability: issuer-specific failures erode trust quickly (users perceive the gateway as unstable).
- Security & compliance: token/encryption steps must remain correct, deterministic, and auditable.
- Product growth: Card-on-File is a conversion and convenience driver for repeat payments.
- Operational burden: a “side-service” adds extra deployment, monitoring, and incident surface area.
In payments, the integration layer is part of the product. If token-generation is brittle, both revenue and reputation suffer.
Investigation
Root Cause
After taking charge, I reproduced the token-generation flow in controlled environments and compared outputs across runtimes.
The core issue was not only “PHP 7 vs PHP 8” — the failure came from a salt mechanism mismatch that changed the
derived/encrypted output when executed in our PHP 8 environment.
- Validated token parity (same inputs must yield bank-accepted outputs).
- Isolated where the encrypted output diverged.
- Confirmed the divergence originated in the salt-handling step affecting the final encrypted token.