Branch8

香港跨境電商支付寶 HK 整合 Shopify 教學:三條實作路線

Matt Li
November 28, 2026
12 mins read
香港跨境電商支付寶 HK 整合 Shopify 教學:三條實作路線

Key Takeaways

  • 三條整合路線:現成閘道 App、Antom 直連 API、自建 Payments App Extension。
  • AlipayHK 只收 HKD,金額須以最小貨幣單位傳送(HK$499 = 49900)。
  • 訂單狀態必須由伺服器 webhook 驅動,不可依賴瀏覽器 redirect。
  • 所有 webhook 與退款都要有冪等鍵,避免重複入帳。
  • 接好 Alipay+ 後,擴至東南亞錢包多數只需改支付方式參數。

想在 Shopify 收 AlipayHK?你有三條路:安裝已支援 Alipay+ 的第三方支付閘道 App(最快,1–2 天)、直接申請 Antom(Ant International)商戶帳號並接 API(最彈性)、或用 Shopify Payments Apps API 自建 offsite payments extension(跨店、跨市場最可控)。以下是三者的前置條件、設定步驟與排錯方法。

為什麼香港商戶要認真看待 AlipayHK?

AlipayHK 是香港金融管理局(HKMA)發牌的儲值支付工具(SVF)之一,與 Octopus、PayMe、WeChat Pay HK 同屬一個監管框架。HKMA 的儲值支付工具季度統計長期顯示,本地 SVF 戶口數目以千萬計、季度交易宗數同樣以億計,代表香港消費者早已習慣用手機錢包完成零售與線上付款。

對跨境賣家而言,真正的槓桿不是「多一個付款按鈕」,而是 Alipay+。Ant International 的 Alipay+ 網絡把 AlipayHK、Alipay(內地)、Touch 'n Go eWallet(馬來西亞)、GCash(菲律賓)、TrueMoney(泰國)、Kakao Pay(韓國)等數十個錢包收攏在同一組 API 之下——根據 Alipay+ 官方說明,該網絡連接的錢包與銀行應用數量已超過 30 個、覆蓋消費者帳戶逾十億。換句話說,你為香港做一次整合,就等於為東南亞多個市場預先鋪好收款管道。這正是把香港當成亞太營運樞紐的典型做法:一套合規與對帳流程,服務多個市場。

誰適合哪條路線

路線 A — 第三方閘道 App(PayDollar / AsiaPay、Oceanpayment、Global Payments、PingPong 等):單一 Shopify 店、月交易量未到需要自議費率的規模、團隊沒有後端資源。

路線 B — Antom 直連:你已有自己的中台或 headless 前端,需要控制付款流程、分期結算、或同時服務多個站點與 App。

路線 C — 自建 Shopify Payments App Extension:你是品牌集團或代營運商,要把同一個收款能力裝進 5 個以上 Shopify / Shopify Plus 店,或要支援 Shopify Checkout Extensibility 下的自訂流程。

開始前要備齊什麼?

不論走哪條路,以下前置條件都省不掉:

  1. 香港公司主體與商業登記證(BR)。跨境主體(例如 BVI 或新加坡公司)通常也可以申請,但結算幣別與 KYC 要求會不同,先問清楚。
  2. 商戶銀行戶口,幣別需與你打算的結算幣別一致(HKD 最直接;若主要賣美金商品,確認閘道是否支援 USD 結算,否則每筆都會吃匯兌差)。
  3. 網站合規頁面:Shopify 店必須有清楚的退款政策、送貨政策、服務條款、聯絡方式與營業地址。審批被退回最常見的原因就是這幾頁缺失或內容空泛。
  4. Shopify 方案等級。第三方閘道在所有付費方案都能用,但會收 Shopify 的額外交易費(除非你用 Shopify Payments);Payments Apps API 自建應用需要 Shopify Partner 帳號,並通過 Shopify 的 payments app 審核。
  5. 開發環境(路線 B / C):Node.js 18+、Shopify CLI 3.x、ngrok 或 Cloudflare Tunnel 做本地 webhook 測試。
1npm install -g @shopify/cli@latest
2shopify version
3# 預期輸出:3.x.x

Ready to Transform Your Ecommerce Operations?

Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.

路線 A:用現成閘道 App 在 48 小時內上線

這是九成香港中小商戶該走的路。流程如下:

  1. 在 Shopify App Store 或閘道官網申請商戶帳號,提交 BR、銀行證明、網站 URL、負責人身分證明。
  2. 審批通過後,你會收到一組 Merchant ID、Secure Hash Secret(或 API Key / Secret)。
  3. Shopify 後台 → Settings → Payments → Add payment methods → Search by provider,選取該閘道並安裝。
  4. 在設定頁填入 Merchant ID 與 Secret,勾選要啟用的付款方式(AlipayHK、Alipay CN、WeChat Pay HK、UnionPay 等)。
  5. 開啟 Test mode,下一張 HK$1 的測試單。

必須手動確認的三個設定

回調網址(Return / Notify URL):多數閘道需要你在它們的後台白名單中加入 Shopify 的回調網域。若漏了這步,顧客付完款會卡在錢包 App,訂單永遠停在 pending。

幣別對應:AlipayHK 以 HKD 計價。如果你的 Shopify 店以 USD 為主幣別,又啟用了 Markets 多幣別,請確認閘道是否會收到 HKD 的 presentment currency。常見錯誤碼 CURRENCY_NOT_SUPPORT 幾乎都是這裡出問題。

Payment capture 模式:Shopify 的 Settings → Payments → Payment capture 設成 Automatic 還是 Manual,會直接影響退款與取消流程。錢包類付款多數不支援「授權後延遲請款」,建議設 Automatic,否則 offsite 閘道可能回傳 CAPTURE_NOT_SUPPORTED。

路線 B:直連 Antom(Alipay+)API

如果你要自建 headless 結帳、或同時服務 Shopify 以外的渠道,直連 Antom 的 /ams/api/v1/payments/pay 是最直接的做法。Antom 的沙盒與生產環境共用同一組 API 規格,只差 client-id 與端點。

步驟 1:產生 RSA2 金鑰對

1openssl genrsa -out merchant_private_key.pem 2048
2openssl rsa -in merchant_private_key.pem -pubout -out merchant_public_key.pem
3# 把 merchant_public_key.pem 內容(去掉頭尾行)貼到 Antom Dashboard → Developer → Integration

步驟 2:建立付款請求

1curl -X POST https://open-sea-global.alipay.com/ams/api/v1/payments/pay \
2 -H "Content-Type: application/json" \
3 -H "client-id: SANDBOX_5X00000000000000" \
4 -H "Request-Time: 2026-01-15T10:00:00+08:00" \
5 -H "Signature: algorithm=RSA256,keyVersion=1,signature=<URL_ENCODED_SIGNATURE>" \
6 -d '{
7 "productCode": "CASHIER_PAYMENT",
8 "paymentRequestId": "SHOP-1001-20260115",
9 "paymentAmount": { "currency": "HKD", "value": "49900" },
10 "paymentMethod": { "paymentMethodType": "ALIPAY_HK" },
11 "order": {
12 "referenceOrderId": "1001",
13 "orderDescription": "Order #1001",
14 "orderAmount": { "currency": "HKD", "value": "49900" }
15 },
16 "paymentRedirectUrl": "https://shop.example.com/thank-you?order=1001",
17 "paymentNotifyUrl": "https://pay.example.com/antom/notify",
18 "settlementStrategy": { "settlementCurrency": "HKD" }
19 }'

注意 value 是最小貨幣單位(HK$499.00 = 49900)。這是最常見的低級錯誤:把 499 傳上去,顧客只被扣 HK$4.99。

預期回應:

1{
2 "result": { "resultCode": "PAYMENT_IN_PROCESS", "resultStatus": "U" },
3 "paymentId": "202601151940108001...",
4 "normalUrl": "https://globalsandbox.alipay.com/cashier/..."
5}

把顧客導向 normalUrl;在手機瀏覽器上,Antom 會自動嘗試 deep link 喚起 AlipayHK App。

步驟 3:簽章(Node.js)

1import crypto from 'node:crypto';
2import fs from 'node:fs';
3
4const privateKey = fs.readFileSync('merchant_private_key.pem', 'utf8');
5
6export function sign({ method, path, clientId, requestTime, body }) {
7 const content = `${method} ${path}\n${clientId}.${requestTime}.${body}`;
8 const signature = crypto
9 .createSign('RSA-SHA256')
10 .update(content, 'utf8')
11 .sign(privateKey, 'base64');
12 return encodeURIComponent(signature);
13}

簽章字串的換行符號必須是 \n、client-id 與 Request-Time 必須與 header 完全一致(含時區偏移),否則你會一直看到 SIGNATURE_INVALID。

步驟 4:驗證 webhook 並更新 Shopify 訂單

Antom 的通知會帶 Signature header,用 Antom 公鑰驗證:

1export function verifyAntomNotify(req) {
2 const sig = decodeURIComponent(
3 req.headers['signature'].split('signature=')[1]
4 );
5 const content = `POST /antom/notify\n${req.headers['client-id']}.${req.headers['request-time']}.${req.rawBody}`;
6 return crypto
7 .createVerify('RSA-SHA256')
8 .update(content, 'utf8')
9 .verify(ANTOM_PUBLIC_KEY, sig, 'base64');
10}

驗證通過後,用 Shopify Admin GraphQL API 將訂單標記為已付款(若你是用 draft order / headless 流程):

1mutation MarkPaid($input: OrderMarkAsPaidInput!) {
2 orderMarkAsPaid(input: $input) {
3 order { id displayFinancialStatus }
4 userErrors { field message }
5 }
6}

切記回應 Antom {"result":{"resultCode":"SUCCESS","resultStatus":"S"}},否則它會在之後數小時內重試,造成重複入帳。所有 webhook handler 都要以 paymentRequestId 做冪等(idempotency)檢查。

Ready to Transform Your Ecommerce Operations?

Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.

路線 C:自建 Shopify Payments App Extension

當你要把同一套 AlipayHK 收款能力裝進多間店(例如集團旗下 7 個品牌站、分屬香港與台灣市場),就值得做一個 offsite payments app。Shopify 的 Payments Apps API 讓你的 app 直接出現在 Shopify Checkout 的付款選項中,不用走 additional scripts 或 hack。

擴充設定檔

1# extensions/alipayhk-offsite/shopify.extension.toml
2api_version = "2025-07"
3
4[[extensions]]
5type = "payments_extension"
6name = "AlipayHK"
7handle = "alipayhk-offsite"
8payment_session_url = "https://pay.example.com/shopify/payment_sessions"
9refund_session_url = "https://pay.example.com/shopify/refund_sessions"
10void_session_url = "https://pay.example.com/shopify/void_sessions"
11merchant_label = "AlipayHK"
12supported_countries = ["HK"]
13supported_payment_currencies = ["HKD"]
14test_mode_available = true
15multiple_capture = false
16target = "payments.offsite.render"

部署:

1shopify app deploy
2# 預期輸出:Extension alipayhk-offsite deployed to version 2026.01.15

處理 payment session

Shopify 會 POST 一個 payment session 到你的 payment_session_url,先驗 HMAC:

1import crypto from 'node:crypto';
2
3export function verifyShopifyHmac(rawBody, headerHmac, secret) {
4 const digest = crypto
5 .createHmac('sha256', secret)
6 .update(rawBody, 'utf8')
7 .digest('base64');
8 const a = Buffer.from(digest);
9 const b = Buffer.from(headerHmac || '');
10 return a.length === b.length && crypto.timingSafeEqual(a, b);
11}

接著回傳 redirect_url(你剛從 Antom 拿到的 normalUrl):

1{ "redirect_url": "https://globalsandbox.alipay.com/cashier/..." }

顧客付款完成、你收到 Antom 通知後,呼叫 Payments Apps GraphQL API 結算這個 session:

1mutation ResolveSession($id: ID!) {
2 paymentSessionResolve(id: $id) {
3 paymentSession { id status { code } }
4 userErrors { field message }
5 }
6}

失敗則用 paymentSessionReject,並帶上 reason(PROCESSING_ERROR、RISKY 等)。退款走 refundSessionResolve。整個狀態機的原則只有一條:Shopify 的訂單狀態永遠由你的伺服器在收到支付方通知後驅動,不要由前端 redirect 驅動。顧客關掉瀏覽器、網絡中斷,redirect 就不會發生,但錢已經收了。

怎樣讓結帳體驗在手機上不斷線?

香港錢包付款有八成以上發生在手機,而 offsite 流程最脆弱的一環就是 App 切換。幾個實務做法:

  • 不要在 iOS in-app browser(Instagram、Facebook)內硬塞 deep link。偵測 User-Agent,提示顧客「用 Safari 開啟」,或提供 QR code 備援。
  • 桌面版顯示 QR code,由顧客用 AlipayHK App 掃碼;Antom 的 cashier 頁已內建這個切換,但若你自建收銀頁就要自己做。
  • 保留訂單 15 分鐘庫存鎖。錢包付款的平均完成時間比信用卡長,Shopify 結帳本身有保留機制,但 headless 流程要自己處理。
  • 多幣別要明確。用 Shopify Markets 做 HK/TW/SG 分站時,AlipayHK 只應在 HKD 的 market 顯示;台灣站應改掛 Alipay+ 中的在地錢包或本地信用卡收單。

Ready to Transform Your Ecommerce Operations?

Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.

對帳與退款:用自動化取代人手比對

真正吃掉營運時間的不是上線,是每月對帳。錢包付款的結算通常 T+1 至 T+3、批次入帳、且扣掉手續費後只有淨額,跟 Shopify 的訂單金額對不上。

可行的自動化流程:

  1. 每日定時從 Antom(或閘道)後台下載結算檔(CSV / SFTP)。
  2. 用 paymentRequestId 對回 Shopify 訂單,透過 Admin GraphQL 查詢:
1query FindOrder($q: String!) {
2 orders(first: 50, query: $q) {
3 edges { node { id name totalPriceSet { shopMoney { amount currencyCode } } } }
4 }
5}
6# variables: { "q": "gateway:alipayhk AND created_at:>2026-01-01" }
  1. 差異(金額不符、重複、找不到對應訂單)寫入 Google Sheet 或 Slack 頻道,由人處理。

這類「規則明確、例外才需要人判斷」的流程,正是 LLM 輔助營運的合理落點:規則比對交給腳本,例外的文字說明(例如把支付方的錯誤碼翻成財務同事看得懂的中文、草擬給顧客的退款解釋)交給模型生成,人只做最後核准。Branch8 在為一家香港多品牌餐飲集團整合線上收款時,就是用 Shopify Flow 觸發 webhook、再由一個小型 Node 服務比對閘道結算檔,把需要人手介入的個案推到 Slack;重點不是省掉財務同事,而是讓他們只看例外。

上線前測試清單

  • [ ] 沙盒成功付款 → Shopify 訂單 Paid,且 Payment ID 可在閘道後台搜到
  • [ ] 顧客中途取消 → 訂單維持 Pending,庫存正確釋放
  • [ ] 付款後關掉瀏覽器(不觸發 redirect)→ webhook 仍把訂單標為已付款
  • [ ] 重複送出同一個 webhook → 不產生第二筆付款紀錄(冪等)
  • [ ] 全額退款 / 部分退款 → 閘道後台與 Shopify 兩邊金額一致
  • [ ] 多幣別:在 TW / SG market 下 AlipayHK 不顯示
  • [ ] 手機 Safari、Chrome、以及 WhatsApp in-app browser 各測一次
  • [ ] 正式環境換上 production client-id 與金鑰,並關閉 test mode

Ready to Transform Your Ecommerce Operations?

Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.

常見錯誤與排解

SIGNATURE_INVALID

簽章字串組裝錯誤。檢查三件事:HTTP method 與 path 大小寫(POST /ams/api/v1/payments/pay)、Request-Time 必須是帶時區的 ISO 8601(2026-01-15T10:00:00+08:00,不是 UTC Z 格式混用)、request body 必須是「送出去的那串原始字串」而非重新序列化的物件。

CURRENCY_NOT_SUPPORT

AlipayHK 只收 HKD。若你的 Shopify Markets 把 presentment currency 設成 USD,閘道會收到 USD。解法是在該 market 強制 HKD,或在送出 API 前先換算並在收銀頁明示 HKD 金額。

訂單卡在 Pending

九成是 notify URL 不通:伺服器要求 IP 白名單、SSL 憑證鏈不完整、或你的 handler 回了 200 以外的狀態碼。用 openssl s_client -connect pay.example.com:443 檢查憑證鏈,並確認 webhook endpoint 不在任何認證 middleware 之後。

顧客被扣款但訂單顯示失敗

典型的 timeout 競態。永遠實作一個對帳 job:對所有 24 小時內 Pending 的訂單呼叫 /ams/api/v1/payments/inquiryPayment,以支付方的紀錄為準。

Shopify payment session 已過期

Shopify 的 payment session 有時效。若顧客在錢包中閒置太久才完成付款,paymentSessionResolve 會回 userErrors。此時不要硬改訂單,應觸發退款並以郵件通知顧客重下單——把這個情境寫進 runbook,不要靠臨場判斷。

重複退款

退款 API 同樣要帶唯一的 refundRequestId,並在自家資料庫記錄狀態。閘道後台手動退款 + 系統自動退款同時發生,是最容易出事的組合。

從香港一個站,擴到整個亞太

把 AlipayHK 接好之後,你的架構其實已經能支撐多市場。因為走的是同一組 Antom / Alipay+ API,要加 Touch 'n Go(馬來西亞)、GCash(菲律賓)、TrueMoney(泰國)或 Kakao Pay(韓國),多數情況只是改 paymentMethodType 與結算幣別設定,再申請對應市場的開通。

實務上要注意的是結算與稅務,不是技術:

  • 新加坡:GST 已上調至 9%(新加坡稅務局 IRAS 公布,自 2024 年 1 月 1 日起生效),低價值進口商品也納入課稅範圍。
  • 澳洲:GST 10%,海外賣家年營業額達 A$75,000 即須登記(澳洲稅務局 ATO 規定)。
  • 台灣:境外電商銷售電子勞務予境內個人,依財政部規定須辦理稅籍登記並繳納營業稅。

香港作為樞紐的價值在於:沒有銷售稅、外匯自由、而且 HKMA 的 SVF 制度讓本地錢包與跨境網絡的接軌相對成熟。把收款中台放在香港、再向外擴,比在每個市場各自重建一套流程省得多——前提是你的 webhook、對帳與退款流程從第一天就設計成多幣別、多支付方式。

如果你正在規劃把 Shopify 店延伸到多個亞太市場,或需要一支同時懂 Shopify Plus、支付整合與當地合規的團隊,Branch8 在香港、新加坡、台灣、越南、馬來西亞、印尼、菲律賓與澳洲都有交付人員,可以在同一時區內完成整合、測試與上線後的營運支援。歡迎聯絡我們討論你的架構。

Ready to Transform Your Ecommerce Operations?

Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.

Sources

FAQ

Shopify Payments 在香港不直接提供 AlipayHK,必須透過第三方支付閘道(如 AsiaPay/PayDollar、Oceanpayment、Global Payments)或直連 Antom(Alipay+)。使用第三方閘道時,Shopify 會額外收取交易費,費率視你的方案等級而定。

About the Author

Matt Li

Co-Founder & CEO, Branch8 & Second Talent

Matt Li is Co-Founder and CEO of Branch8, a Y Combinator-backed (S15) Adobe Solution Partner and e-commerce consultancy headquartered in Hong Kong, and Co-Founder of Second Talent, a global tech hiring platform ranked #1 in Global Hiring on G2. With 12 years of experience in e-commerce strategy, platform implementation, and digital operations, he has led delivery of Adobe Commerce Cloud projects for enterprise clients including Chow Sang Sang, HomePlus (HKBN), Maxim's, Hong Kong International Airport, Hotai/Toyota, and Evisu. Prior to founding Branch8, Matt served as Vice President of Mid-Market Enterprises at HSBC. He serves as Vice Chairman of the Hong Kong E-Commerce Business Association (HKEBA). A self-taught software engineer, Matt graduated from the University of Toronto with a Bachelor of Commerce in Finance and Economics.