Open API
首页
首页
  1. Asynchronous notification description v2
  • Document Revision History
  • Overview of Study Abroad Payment API Access
  • API Call Address
  • Request for serial number generation instructions
  • API Request Parameter Description
  • API Response Parameter Description
  • Interface encryption and signing steps
  • Interface decryption and verification process
  • Constant Description
    • pay_type description
    • order_status description
    • status_code description
    • fee_type description
    • attachment_type description
    • country_code description
    • currency_code description
    • Gender Description
    • ID type Description
  • API
    • Order interface
      POST
    • Attachment upload interface
      POST
    • Interface for obtaining payment address
      POST
    • Order batch query interface
      POST
  • Asynchronous notification description v1
    • [Successful Payment] Asynchronous notification parameter description for successful payment
    • Explanation of Asynchronous Notification Signature Generation Process
  • Asynchronous notification description v2
    • Asynchronous Notification Description
    • Asynchronous Notification Signature Generation Process
    • [Order Status Change] Asynchronous notification parameter description for order status change
  1. Asynchronous notification description v2

Asynchronous Notification Signature Generation Process

Asynchronous Notification Parameters Example#

FieldTypeDescriptionDetails
order_idStringOrder IDThe order ID assigned by YiSiHui.
pay_resultIntPayment Result1 for success, 0 for failure.
pay_amountFloatPayment AmountA floating-point value, e.g., 10000.00.
pay_datetimeStringPayment TimeA string, e.g., 2017-10-12 10:00:00.
extend_infoStringExtended InfoReserved for future use.
signStringSignatureGenerated using MD5. See the detailed process below.

Signature Generation Process for Asynchronous Notifications#

Follow the steps below to generate the signature based on the asynchronous notification parameters:
1.
Parameter Sorting
Exclude the sign field from the parameters. Sort the remaining parameters alphabetically by their key names. If the first letters are the same, compare the second letters, and so on.
2.
String Concatenation
Concatenate the sorted parameters into a single string. Use the & symbol to separate each key-value pair in the format key=value.
3.
Salt Addition (optional)
Add a specified salt value to the beginning of the concatenated string.
4.
MD5 Hashing
Apply the MD5 algorithm to compute the hash of the resulting string from the previous step.
5.
Assign the Signature
Use the computed MD5 hash as the value for the sign field in the notification.

Example for Signature Generation#

Suppose the parameters are:
{
    "order_id": "ETxxxxxxxxxxxx01",
    "pay_result": 1,
    "pay_amount": 10000.00,
    "pay_datetime": "2024-12-01 10:00:00",
    "extend_info": ""
}
1.
Sorting & Concatenation:
extend_info=&order_id=ETxxxxxxxxxxxx01&pay_amount=10000.00&pay_datetime=2024-12-01 10:00:00&pay_result=1
2.
Salt Addition (e.g., salt is abc123) (optional):
abc123extend_info=&order_id=ETxxxxxxxxxxxx01&pay_amount=10000.00&pay_datetime=2024-12-01 10:00:00&pay_result=1
3.
MD5 Hashing:
Generate the MD5 hash of the string:
MD5("abc123extend_info=&order_id=ETxxxxxxxxxxxx01&pay_amount=10000.00&pay_datetime=2024-12-01 10:00:00&pay_result=1")
4.
Result
The resulting MD5 hash becomes the value of the sign field.
{
    "order_id": "ETxxxxxxxxxxxx01",
    "pay_result": 1,
    "pay_amount": 10000.00,
    "pay_datetime": "2024-12-01 10:00:00",
    "extend_info": "",
    "sign": "652614570bcc49940d7dcc7a3c3dc7e5"
}

Example: Signature Generation#

Python3:
# Python3
import hashlib


def generate_sign(sign_params: dict, salt=None) -> str:
    if not salt:
        salt = ""

    md5_text = str(salt) + "&".join(
        [f"{k}={v}" for k, v in sorted(sign_params.items())]
    )
    return hashlib.md5(bytes(md5_text, encoding="utf-8")).hexdigest()
Previous
Asynchronous Notification Description
Next
[Order Status Change] Asynchronous notification parameter description for order status change
Built with