Skip to main content

1. Obtain Merchant Self-Service Platform Account

After the partnership is confirmed, HaiPay will create an administrator account for the merchant to log into the Merchant Management Self-Service Platform, based on the “Administrator Account Information” filled out in the “Merchant Access Application Form.” Please pay attention to the activation email sent by HaiPay. The merchant can activate the administrator account according to the instructions in the email. The first login will require a password change, so please ensure the password is secure to prevent leakage.

2. Obtain appId and Secret Key

The merchant’s appId required for integration testing can be obtained from the Merchant Management Platform. The signature uses the SHA256WithRSA signing algorithm, and the merchant needs to generate the public and private key pair themselves. The public key must be uploaded to the Merchant Management Platform, and HaiPay’s public key should also be downloaded. Please securely store the key information. If the key is leaked, it should be updated immediately. Configuration entry: “Business Management” - “Payment Product Configuration”
The merchant’s appId and secret key are paired, distinguished by currency, and differentiated between the test environment and the production environment.

3. Public Key and Private Key Configuration

3.1 Role of Public and Private Keys

3.2 Generating Public and Private Keys

The private key should be securely stored, and the public key should be added to the HaiPay backend. Remove the -----BEGIN XXX KEY----- and -----END XXX KEY----- parts, along with any newlines and spaces.

Method 1: Use OpenSSL to Generate Keys

Refer to online examples; OpenSSL needs to be installed, and the key length should be 2048 bits.

Method 2: Generate Keys Online

You can generate key pairs using the HaiPay Developer Tools, which are implemented purely in JavaScript and will not interact with the HaiPay server, ensuring that merchant key information is not leaked. Generates addresses can be found in here.

Method 3: Generate Keys via Code

Merchants can generate public and private keys using the following SDK. The merchant’s private key should be securely stored and used for signing requests to HaiPay. The merchant’s public key should be uploaded to the platform for HaiPay to verify the merchant’s signature to prevent tampering during transmission. Additionally, the HaiPay public key should be obtained from the platform and integrated into the merchant’s system for verifying the HaiPay-signed messages.

4. Signature

Unified signature generation rule: For RSA signing and verification, include every parameter whose value is neither null nor "". Exclude the sign and sign_type fields, sort the remaining field names in ASCII ascending order, and concatenate each key and value in the format k1=v1&k2=v2&.... Append &key=merchantSecretKey (the merchant secret key configured in the Merchant Management Platform) to form the string to be signed. The merchant signs the string to be signed with its RSA private key using SHA256WithRSA to produce the signature string.
The string "null", strings containing only whitespace, 0, and false all participate in signing.
Only null and the empty string "" are excluded from signing.
When verifying a signature, use the business object that contains sign and include every valid field in that object, including fields added in later API versions; do not verify against a fixed field list. For synchronous responses with a wrapper, verify the documented data or business object only, rather than wrapper fields such as status, error, or msg.
Encode the string to be signed as UTF-8 bytes before performing SHA256WithRSA signing or verification.
merchantSecretKey and the merchant RSA private key are sensitive information. Do not place them in frontend code, client applications, logs, or public repositories.

5. Example Message

Request

Response

Last modified on July 17, 2026