In many payment-related integrations, credit card numbers often arrive as plain numeric strings. For security and compliance—and to meet target schema requirements—we need to standardize their format (e.g., always output 16‑digit strings, padding with leading zeros when necessary). In this post, we’ll explore a simple XSLT/Expression Builder approach in Oracle Integration Cloud to achieve consistent credit card number formatting.
🎯 Use Case
- Source System: A front-end or legacy application that sends credit‑card numbers without leading zeros (e.g., “123456789012345”).
- Target System: A downstream ERP or card‑processing API requiring exactly 16 digits (e.g., “0123456789012345”).
- Challenge: Ensure every card number string is left‑padded with zeros up to 16 characters, without manually writing complex code.
🚀 Solution Steps
-
Locate the Target Element
In your OIC mapping or XSLT, identify the node where the formatted card number should go (e.g.,<ns24:ExternalCardNumber>
). -
Use the
fn:format-number()
Function
Leverage the built‑in XPath function in OIC’s Expression Builder to pad the numeric string. The format mask for 16 digits is simply 16 zeros:"0000000000000000"
. -
Write the Expression
In the Expression Builder forns24:ExternalCardNumber
, enter:fn:format-number(ns22:CreditcardNumber, "0000000000000000")
- Argument 1:
ns22:CreditcardNumber
– the incoming numeric string - Argument 2:
"0000000000000000"
– the format mask specifying 16-digit width, padded with leading zeros
- Argument 1:
-
Test with Sample Payloads
- Input:
<CreditcardNumber>123456789012345</CreditcardNumber>
→ Output:<ExternalCardNumber>0123456789012345</ExternalCardNumber>
- Input:
<CreditcardNumber>987654321</CreditcardNumber>
→ Output:<ExternalCardNumber>0000000987654321</ExternalCardNumber>
- Input:
-
Deploy and Validate
- Activate your integration and send real messages.
- Verify target payloads always carry exactly 16 digits, meeting downstream requirements.