Payment code structure in SePay Test mode

Configure payment code structures in SePay Test mode: enable code recognition, define prefix and suffix-length templates so SePay extracts the code field from transaction content automatically.

||

The payment code structure in Test mode (chế độ thử nghiệm) controls how SePay extracts the code field from transfer content. Each template defines a prefix (e.g. DH) and a suffix length range (e.g. 3-10 chars). When you simulate a transaction, SePay scans the content against active templates and attaches the match to the webhook payload.

Summary
  • Toggle payment code recognition on/off globally
  • Each company account can define multiple templates; the first one is the default and cannot be deleted
  • Each template has: prefix, min/max suffix length, character type, status
  • Applies to Simulate transaction and webhook filters

Open the Test mode Configuration page

Go to Test modeCấu hình (Configuration).

Configuration page in SePay Test mode
Click to expand
Test mode Configuration page with payment code recognition toggle and template list

Enable payment code recognition

The Nhận diện mã thanh toán (Payment code recognition) section at the top has two states:

StateEffect
Bật (On, default)SePay scans the transfer content against active templates; the code field is filled when a match is found
Tắt (Off)SePay skips scanning; the code field is always empty even if the content contains a valid code

The webhook filter Chỉ gửi khi có mã thanh toán (Only send when code present) only takes effect when this toggle is On.

Fields in each template

Each template is a card with 4 fields plus a status switch:

FieldRequiredDescription
Prefix (Tiền tố)YesBeginning of the code (e.g. DH, HD, ORDER). Up to 10 characters. The system uppercases automatically on save.
Min suffix lengthYesMinimum characters after the prefix. Range 1-30. Default 3.
Max suffix lengthYesMaximum characters after the prefix. Range 1-30, must be ≥ min value. Default 10.
Character typeYesSố nguyên (digits only, 0-9) or Số và chữ (alphanumeric, digits and letters A-Z).
StatusNoSwitch Đang hoạt động (Active) / Ngưng hoạt động (Inactive). Only active templates participate in matching.

The Ví dụ (Example) line in each card auto-updates based on the current values (e.g. prefix DH + 3-char digit suffix shows DH111).

Test mode payment code template card with prefix DH
Click to expand
Template card with prefix, suffix length, character type, and status

Add, edit, remove templates

ActionHow
Add templateClick + Thêm cấu trúc (Add structure) at the end of the list. The new card opens expanded.
Edit templateExpand the card, change fields, click Lưu cấu hình (Save) at the bottom of the page.
Delete templateClick the trash icon on the card. The first template (Cấu trúc mặc định / Default structure badge) cannot be deleted, you can only deactivate it.
Pause templateTurn the Đang hoạt động switch off, then Lưu cấu hình. The template stays but is excluded from matching.

After editing, click Lưu cấu hình at the bottom. A "Lưu cấu hình thành công" (Saved successfully) toast appears on success.

How SePay extracts the code from content

When you simulate a transaction (or when a real transaction lands on Live), the system scans the transfer content against active templates in declaration order:

  1. Take the first active template.
  2. Search the content for a string matching <prefix><N characters of the chosen type> where N is between min and max suffix length. The prefix match is case-insensitive.
  3. On match, attach the matched string to the webhook payload's code field and stop.
  4. On no match, try the next template. If no template matches, code stays empty.
TemplateTransfer contentExtracted code
Prefix DH, suffix 3-10, Digits onlyDH123456 thanh toan don hangDH123456
Prefix DH, suffix 3-10, Digits onlydh999 thanh toanDH999
Prefix DH, suffix 3-10, Digits onlyChuyen tien sinh hoat(empty)
Prefix HD, suffix 4-6, AlphanumericHD12AB chuyen khoanHD12AB

Differences vs Live

AspectLiveTest mode
LocationCấu hình Công tyCấu hình chungCấu trúc mã thanh toánTest modeCấu hình
Max prefix length5 characters10 characters
Matching behaviorApplied to real bank transactionsApplied to simulated transactions in Test mode
Template countUnlimitedUnlimited

Live and Test mode configurations are isolated: changes in Test mode never affect Live and vice versa.

Next