Receive Result Notification
The integrated system needs to provide a separate REST API to receive payment result notifications from the Payment server.
URL:
POST notifyUrl - notifyUrl parameter
Header:
Content-Type: application/json
Body(json format)
id
String
Yes
Unique identifier for the payment order
oid
String
Yes
Order ID
uid
String
Yes
User ID
timestamp
Long
Yes
Current timestamp
nonce
String
Yes
Random string for replay attack prevention
status
Enum
Yes
Transaction status, fixed as PAID
statusCode
Int
Yes
Enum value of the order status
sign
String
Yes
Request signature for verifying request validity
Signature
The signature is generated by sorting the request parameters by key name, concatenating them into a string, and appending the environment variable PAYMENT_NOTIFY_SECRET at the end. Then, the SHA-256 algorithm is used to generate the signature.
Example
id=123&nonce=abc&oid=456&status=PAID&statusCode=1×tamp=1617181723{PAYMENT_NOTIFY_SECRET}
Response
- Success: Returns the string "success"
- Failure: Returns an error message
Error Handling
If the notification fails, the system will log the error and increment the retry count.
The retry interval is dynamically adjusted based on the number of retries. If the retry count exceeds 29 attempts, the task status will be marked as FINAL_FAIL.
Code Example
public function notify($params)
{
$payload = trim(get_request_content());
if (empty($payload)) {
throw new ApiException('request error');
}
$json_params = json_decode($payload, true);
$data = [
'id' => $json_params['id'], //
'oid' => $json_params['oid'], //
'uid' => $json_params['uid'], // userid
'timestamp' => $json_params['timestamp'], // timestamp
'nonce' => $json_params['nonce'], // one-time code
'status' => $json_params['status'], // PAID
'statusCode' => $json_params['statusCode']
];
$sign = $this->sign($data);
if ($sign != $json_params['sign']) {
throw new ApiException('sign error');
}
if ($json_params['status'] == 'PAID') {
return [
'trade_no' => $data['oid'],
'callback_no' => $data['id'],
];
} else {
return false;
}
}
Last updated