Skip to content

CGB (China Guangfa Bank)

About This Page

What: CGB's FPS API batch withdrawal channel, FPS message types, and batch processing mechanism Audience: PMs needing to understand CGB integration details Prerequisites: Bank Capability MatrixReading time: 2 minutes Owner: Withdrawal Product Manager

Key takeaway: CGB FPS withdrawal uses a batch submission model — multiple withdrawals are packaged into one batch, the system polls for each result, up to 1500 times (spanning several hours).


Capability Overview

CapabilitySupportedProtocol/ChannelCore Service
Deposit Statements
FPS Withdrawal APIForm-URLEncoded HTTP POST (XML payload)cgb_fps_service (Go)
FPS DepositFPS collection
eDDA/eDDI
BST

CGB is the only bank supporting FPS API batch withdrawal — multiple withdrawals can be submitted at once for bank batch processing.


Withdrawal: FPS API

Withdrawal Method

DimensionDescription
Method CodeTRANSFER_METHOD_CGB_FPS_API = 'cgb_fps_api'
ClassificationElectronic bank method (allEBankMethod)
NameFPS API (CGB)

FPS Message Types

CGB FPS completes the withdrawal lifecycle through 4 message types:

Message TypePurposeDirection
2063Single withdrawal requestmoomoo → CGB
2064Batch withdrawal requestmoomoo → CGB
2065Single withdrawal querymoomoo → CGB
2066Batch withdrawal querymoomoo → CGB

Single Withdrawal (2063)

ParameterDescriptionExample
Remote TypeRegion01=Hong Kong, 02=Macau
Remit CurrencyRemittance currencyHKD/CNY/MOP
Payee Account TypePayee account typeBBAN/SVID/MOBN/AIIN/EMAL
Transaction StatusTransaction status0=Success, 1=Failed, 2=Processing

Batch Withdrawal (2064)

CGB's unique batch capability, submitting up to 2000 withdrawals at once:

ParameterDescription
Customer Batch NoBatch number (20 digits)
All CountTotal count (max 2000)
RecordsMultiple Fps2064Record entries
Batch Status1=Failed, 2=Processing

Batch Withdrawal Data Flow

Status Code Mapping

Status codes have different meanings across message types — pay attention to the distinction:

Status Code2063 (Single Request)2065 (Single Query)2066 (Batch Query)
0SuccessProcessingFailed
1FailedSuccessSuccess
2ProcessingFailedProcessing

Note

2063 and 2065/2066 status codes have reversed meanings — in 2063, 0=Success, but in 2065, 0=Processing. Always distinguish the request type during development.

Error Handling

Batch query (2066) returns detailed information for each item:

  • Success Count: Number of successful items
  • Fail Count: Number of failed items
  • Each failure includes an error reason code and error description
  • Distinguishes payer errors (Error Type=0) from payee errors (Error Type=1)

Channel Interface Details

Channel Interface Overview

DimensionDescription
Protocol TypeForm-URLEncoded HTTP POST (XML payload)
AuthenticationSM2 National Crypto signing
Data FormatXML (UTF-8)
Port9091 (HTTPS)
Timeout30 seconds
Core Servicecgb_fps_service (Go)

SM2 Signing Configuration

CGB uses the SM2 national crypto algorithm for request signing, involving the following keys:

KeyPathFormat
Futu private keyconf/keys/futu.pvkPKCS#8
Futu public keyconf/keys/futu.puk
Bank public keyconf/keys/gfs.tst.puk
User ID16-byte string"1234567812345678"

Signing flow: Use Futu's private key to SM2-sign the request XML, Base64-encode the signature result and place it in the SIGN block; bank responses are verified using the bank's public key.


Interface 1: 2063 Single Withdrawal (FPS Single Payment)

Request COMMHEAD (Common Message Header):

FieldDescriptionExample
TRANCODETransaction code"2063"
CIFMASTERCustomer master number"1000001287"
ENTSEQNOSequence number (≤20 digits)Financial unique sequence
ENTUSERIDUser ID"100001"
TRANDATETransaction date"YYYYMMDD"
TRANTIMETransaction time"HHMMSS"

Request BODY:

FieldTypeRequiredDescription
REMITTYPEstringRemittance type. Values "01"=Hong Kong, "02"=Macau
PAYACCstringPayer account. e.g. "3597601080012948"
REMITCURstringCurrency. Values Hong Kong: "HKD" / "CNY", Macau: "HKD" / "MOP"
REMITAMOUNTdecimal(16,2)Amount. e.g. "1000.00"
PAYEEACTYPEstringPayee account type. Values "BBAN" / "SVID" / "MOBN" / "AIIN" / "EMAL"
BENEFCORPACCTstringPayee account/ID. Format depends on PAYEEACTYPE
PAYEEBANKstringPayee bank code. Values "359"=internal HK, or FPS bank code
BENEFCORPNAMEstring(≤140)Payee name
PAYPURSstringPayment purpose. Values "CXBSNS"=Business, "CXSALA"=Salary, "CXMRCH"=Merchant, "CXPSNL"=Personal
REMITMEMOstringMemo. ≤34 Chinese characters / 102 English characters
MEMOstringNote. ≤50 Chinese characters / 150 English characters

SIGN Block:

FieldDescription
CSTIDCustomer ID (16 bytes)
SIGNVALUEBase64-encoded SM2 signature

Response:

FieldDescription
RETCODECommunication code: "000"=Success
ERRORCODEBusiness code: "0000"=Success
ERRORMESSAGEError description
TRACENOBank tracking number
TRANSTATUS"0"=Success, "1"=Failed, "2"=Processing

Interface 2: 2064 Batch Withdrawal (FPS Batch Payment)

Building on the 2063 single payment, the following batch-specific fields are added:

FieldDescription
CUSTOMERBATCHNOBatch number (≤20 digits, globally unique)
ALLCOUNTTotal count (≤2000)
ALLAMOUNTTotal amount (decimal precise calculation, no floating point errors allowed)
RECORD.CUSTOMERSALARYSEQDetail sequence number (20 characters, unique within batch)

Each RECORD contains the same PAYEEACTYPE, BENEFCORPACCT, REMITAMOUNT fields as the 2063 single payment.

Batch Amount Validation

ALLAMOUNT must strictly equal the sum of all detail REMITAMOUNT values. The system uses decimal type for precise calculation, avoiding floating point errors that would cause the bank to reject the entire batch.


Interface 3: 2065 Single Query

FieldDescription
ORIGENTSEQNOOriginal sequence number (= ENTSEQNO from 2063 request)
STARTRANSDATEQuery start date
ENDTRANSDATEQuery end date

Response TRANSTATUS: "0"=Processing, "1"=Success, "2"=Failed

Different Status Code Meanings

Note that 2065 query status codes have completely opposite meanings from 2063 request status codes: in 2063, "0"=Success, but in 2065, "0"=Processing. Always distinguish the request type during development and troubleshooting.


Interface 4: 2066 Batch Query

FieldDescription
CUSTOMERBATCHNOBatch number (= batch number from 2064 request)
BATCHSTATUS"0"=Failed, "1"=Complete, "2"=Processing
SUCCESSCOUNTSuccess count
FAILCOUNTFailure count

Each detail's TRANSTATUS has the same meaning as 2065 ("0"=Processing, "1"=Success, "2"=Failed).

2066 Dual-Layer Status

The 2066 response contains two layers of status: BATCHSTATUS (batch level: 0=Failed, 1=Success, 2=Processing) and TRANSTATUS (detail level: 0=Processing, 1=Success, 2=Failed). The detail-level status has the same meaning as 2065, but is opposite to the batch-level meaning.


Idempotency Rules

CGB has strict idempotency checks for duplicate requests:

ScenarioBehaviorScope
Duplicate CUSTOMERBATCHNOEntire batch rejectedEntire batch
Duplicate CUSTOMERSALARYSEQ within batchOnly that item failsSingle detail
Historical duplicate CUSTOMERSALARYSEQThat item failsSingle detail

Idempotency Design Recommendations

  • CUSTOMERBATCHNO should use "date + business sequence" format to ensure global uniqueness
  • CUSTOMERSALARYSEQ should use the withdrawal order ID to ensure no duplicates across batches
  • When retrying, a new CUSTOMERBATCHNO must be used; the old batch number cannot be reused

Configuration

ParameterValueDescription
pay_acc_hkd"3597601080012948"HKD payment account
pay_acc_cny"3597601080012939"CNY payment account
batch_max_count3Max items per batch (bank limit 1999, conservative setting)

Why is batch_max_count set to 3?

Although the bank supports up to 2000 items per batch, the actual operation sets it to 3 because: withdrawals typically require per-item review and tracking, and overly large batches increase troubleshooting difficulty; if a batch fails and needs retry, smaller batches have a more controllable impact scope.


moomoo-Side Adaptation

DBQueue Asynchronous Submission: The withdrawal service doesn't call CGB API directly. Instead, it writes withdrawal instructions to DBQueue, which cgb_fps_service consumes asynchronously and submits to the bank.

Fallback Query: The system continuously polls via the DBQueue mechanism, checking incomplete transaction status every 15 seconds, with up to 1500 retries (covering approximately 6 hours).

Status Mapping (TRANSTATUS → Internal Status):

TRANSTATUS (2065/2066)MeaningInternal Status
0Processingpending
1Successsuccess
2Failedfailed

Change Guide

Change RequirementModification LocationDescription
Modify batch limitcgb_fps_service → batch construction logicAdjust 2000 item limit
Add payee account typecgb_fps_service → 2063 request parametersAdd Payee Account Type
Modify query frequencycgb_fps_service → polling configurationAdjust 2066 query interval
Add currency supportcgb_fps_service → request parametersAdd Remit Currency options
Modify withdrawal approval templateTask.php$stepTemplatesAdjust CGB withdrawal approval flow

Common Customer Complaints Top 3

#User FeedbackCauseCS Script
1"FPS withdrawal failed"Bank system busy (A014) or incorrect payee information"The transfer temporarily failed, the system is automatically retrying, please wait"
2"Withdrawal status shows unknown"Batch query returned UNKNOWN status"Your withdrawal is being confirmed, we will update the status as soon as possible"
3"Withdrawal amount doesn't match application"Batch amount aggregation calculation difference"Please verify your withdrawal records, contact customer service if there's a discrepancy"

Monitoring & Alerts

Alert ItemTrigger ConditionSeverityHandling Steps
Batch send timeout2064 batch request unresponsiveHighSystem auto-degrades to single (2063) resend, check degradation logs
Signature verification failureSIGN_ERRORHighCheck signing key configuration, confirm keys haven't been replaced
Status code misjudgment alert2063/2065 vs 2064/2066 status code meaning differencesMediumConfirm message type then re-evaluate, refer to status code reversal

After Reading

I want to...Go to
See CGB's position among all banksBank Capability Matrix
Understand CGB withdrawal's full approval flowWithdrawal Lifecycle
Compare with another FPS withdrawal bankSCB
Check FPS message type error codesUnified Error Code Center
Was this page helpful?

内部业务文档 · 仅限 moomoo 团队使用