File Upload Signing
Overview
PayLoco’s open platform uses a public/private key mechanism. Merchants can configure their application’s public key or public key certificate in the open platform under Key Management to prevent data tampering and ensure secure communication between the merchant application and PayLoco.Terminology
- Public Key — The application public key (
public_key), generated by the developer using a key generation tool. - Private Key — The application private key (
private_key), generated by the developer using a key generation tool. - PayLoco Platform Public Key — Generated by PayLoco after the developer uploads their application public key. Developers use this key to verify the signatures on asynchronous messages received from PayLoco.
Signing Algorithm
| Signing Method | Standard Algorithm | Description |
|---|---|---|
| RSA | SHA256WithRSA | RSA key length must be at least 2048 bits. |
Functional Overview
- If you are unfamiliar with the API calling conventions, please review the interface documentation first.
-
Every API request must include a valid signature. The server validates the signature against the request parameters and rejects any request with an invalid signature. The purpose of signing is to:
- Verify the integrity of request parameters on both the merchant and platform sides.
- Verify the identity of the requester on both the merchant and platform sides.
Signature Calculation
Signature calculation can be implemented using the code in the Request Example below. PayLoco currently provides a Java reference implementation. If you are using a different language, implement the same logic accordingly.Signing Rules
- Fields included in the signature: All parameters with non-empty values (value is not
nulland is not an empty string after trimming) are included. Thesignfield itself is excluded. - Signature string assembly: Sort parameter names alphabetically (dictionary order). Concatenate each key-value pair as
key=value(using the trimmed value), and join multiple pairs with&. Example:key1=val1&key2=val2&key3=val3. The signature value is case-sensitive; MD5 produces a 32-character lowercase hex string. - Signing algorithm: MD5 or SHA256WithRSA.
- Signature placement: The signature value must be placed in the request
Header.
Notes
- If request parameters contain non-ASCII characters (e.g., Chinese), the characters must be URL-encoded in the request, but should not be URL-encoded when computing the signature.
- When computing the SHA256WithRSA signature, the byte stream must be encoded in UTF-8. Failure to do so may result in incorrect signatures for parameters containing non-ASCII characters.