respCode: S00001) and then completes the work in the background. When the operation finishes, Gcashier Pay pushes the result to a webhook endpoint on your server. You register this endpoint by including a callbackUrl in the relevant API request body. Understanding how to receive, decrypt, and verify these callbacks is essential for building a reliable integration.
How Webhooks Work
Gcashier Pay sends webhook notifications as HTTPS POST requests to yourcallbackUrl. The POST body uses exactly the same four-field encrypted envelope as a standard API response:
SK from keyEnc using your private key, decrypt jsonEnc with SK, then verify sign against the plaintext using Gcashier Pay’s public key.
Responding to a Webhook
Your endpoint must return an HTTP 200 status code to acknowledge successful receipt of the callback. If Gcashier Pay does not receive a 200 response — due to a network error, timeout, or any non-200 status code from your server — it will retry the notification. Implement your handler to be idempotent: processing the same callback more than once must not cause duplicate actions (for example, duplicate fund movements or double-confirmed orders).If you never receive a callback for an operation (for example, due to a prolonged outage), use the corresponding query API endpoint to check the operation’s status directly. Do not rely solely on callbacks for critical state transitions.
Webhook Event Codes
Each callback carries atradeCode in its decrypted head that identifies the type of event. The table below lists all supported notification codes:
| Trade Code | Event |
|---|---|
sp3101 | Merchant access (onboarding) result |
sp3102 | Virtual account (VA) opening result |
sp3103 | Trade receipt notification |
sp3104 | Trade order application result |
sp3105 | Flow-order association result |
sp3201 | FX trading result |
sp3301 | RMB payment result |
sp3302 | International remittance result |
sp3303 | Withdrawal result |
sp3304 | Internal transfer result |
sp3401 | Payee registration result |
Setting Your callbackUrl
You register a callback URL per-request, not as a global setting. Include acallbackUrl field in the body of any request that triggers an asynchronous operation. Gcashier Pay will POST the result notification to that URL when the operation completes.
Webhook Processing Checklist
Use the following checklist when implementing your webhook handler:Parse the outer envelope
Read the POST body as JSON and extract
merchantNo, jsonEnc, keyEnc, and sign.Decrypt the payload
HEX-decode
keyEnc, RSA-decrypt with your private key to recover the AES session key SK. Base64-decode jsonEnc and decrypt with SK (AES/ECB/PKCS7Padding) to obtain the inner JSON plaintext.Verify the signature
HEX-decode
sign and verify it against the inner JSON plaintext using Gcashier Pay’s public key (SHA1withRSA). Reject and log any message that fails verification.Inspect the tradeCode
Read
head.tradeCode from the decrypted JSON to determine which event type you received, then route the body to the appropriate handler.Process idempotently
Check whether you have already processed this event (for example, by recording the order or transaction number). If you have, skip reprocessing and return 200 immediately.
