跳到正文
DEV Community· Samy·· 1 小時前AI 評分35

以程式讀取阿聯酋信用卡月結單:把交易描述轉換成商戶資料

Reading UAE card statements in code: turning "POS 4521 CAREEM*RIDE DXB AE" into a merchant

AI 導讀

DescriptorAPI 可把阿聯酋信用卡月結單中的交易描述轉換成商戶資料,並回傳商戶名稱、類別、網站、標誌、地點、處理商、交易類型及 0 至 1 的信心分數。無法辨識時商戶欄位會是 null;若來源標示為「ai」且 verified 為 false,應以建議結果呈現,直至核實。API 提供免費方案。

正文

Samy

If you build anything that shows a user their card transactions, you meet the descriptor problem fast. The bank does not write "Careem". It writes POS 4521 CAREEM*RIDE DXB AE.

What is in the line

A statement line is a fixed-width field written by the merchant's acquirer, not by your bank. A typical Emirates line carries a channel (POS), a terminal number, a payment processor or aggregator prefix, a truncated merchant name, a city code (DXB) and a country code (AE). Mall names, utilities and toll lines follow their own abbreviations. I wrote a longer guide here: https://descriptorapi.com/learn/reading-uae-card-statements

Why regex stops working

  • Aggregator prefixes (SQ *, PAYPAL *, AMZN Mktp) hide the real merchant.
  • Not every line is a purchase: transfers, refunds, fees and declines look similar.
  • In the Gulf and North Africa you also see Arabic script, mada, SADAD, Fawry, InstaPay, and pay-later instalments from Tabby and Tamara.

One call

curl https://api.descriptorapi.com/v1/enrich \
  -H "Authorization: Bearer $DESCRIPTORAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"descriptor": "POS 4521 CAREEM*RIDE DXB AE", "country": "AE"}'

The response has merchant (name, category, website, logo), location, processor, kind and a confidence from 0 to 1.

Handling the awkward cases

  1. merchant: null means we could not tell. These calls are free. Show the raw line.
  2. source: "ai" with verified: false means the merchant was read from the text itself. Show these differently, for example with a "suggested" label, until verified.
  3. Check kind before charting spend. A salary or a refund is not a merchant.

Try it

Playground (decode a line in the browser): https://descriptorapi.com/playground
Docs: https://descriptorapi.com/docs
There is a free plan, so you can test with your own statements.

I built DescriptorAPI. Tell me which statement lines it gets wrong and I will fix them.

Drafted with AI help, edited and checked by me.

來源:DEV Community · dev.to