Skip to content

Webhooks ​

When an order reaches SUCCESS, FAILED or RETURNED, EasyPay sends a POST to the notify_url given at creation. A cancellation you requested is not notified, nor is PENDING → PROCESSING.

Request ​

Headers are exactly those of request signing; verify with your app_secret:

HeaderValue
X-App-IdThe App id used for the order
X-TimestampUnix seconds at send time
X-Nonce32 hex chars, random
X-Signaturehex(HMAC-SHA256(app_secret, "POST\n<path>\n<timestamp>\n<nonce>\n<hex(sha256(body))>"))
Content-Typeapplication/json
User-AgentEasyPay-Webhook/1.0

path is the path part of notify_url (https://merchant.example.com/webhooks/easypay?x=1 → /webhooks/easypay, no query). The body is hashed as raw bytes: verify before you parse.

Body:

json
{
  "event": "payout.succeeded",
  "event_id": "PO2026101408050047391520BRPX:SUCCESS",
  "occurred_at": "2026-10-14T08:05:00Z",
  "attempt": 1,
  "data": { "trade_no": "PO2026101408050047391520BRPX", "status": "SUCCESS", "...": "same structure as /payout/query" }
}
FieldDescription
eventpayout.succeeded / payout.failed / payout.returned
event_id<trade_no>:<status>; identical on every retry of the same event — deduplicate on it
occurred_atWhen the channel reported the change (UTC)
attemptDelivery attempt, 1–7
dataThe order, same structure as /payout/query. data.status is the state at send time; update your records from it. event is only the trigger

An order produces at most two events: SUCCESS may be followed by RETURNED.

Response and retries ​

Any 2xx acknowledges; the response body is ignored. A timeout (10 s), connection error or non-2xx is retried after 1 m / 5 m / 30 m / 2 h / 6 h / 24 h — seven attempts in total. After that no more deliveries are made; /payout/query always has the final state.

Recommended: verify, enqueue, answer 200 immediately, and process asynchronously, so slow processing never triggers retries.

Security requirements ​

  • notify_url must be a publicly reachable https:// URL. Private / loopback addresses and localhost-style names are rejected at creation, and hostnames resolving to private IPs are refused at send time.
  • Redirects are not followed; notify_url must answer 2xx directly.
  • Drop and alert on requests that fail verification. The signature proves the request came from EasyPay and the body is untouched.

Verification examples ​

js
const crypto = require('crypto');
// rawBody must be the raw bytes (express: express.raw({ type: 'application/json' }))
function verify(req, rawBody, appSecret) {
  const h = (k) => String(req.headers[k.toLowerCase()] ?? '');
  const bodyHash = crypto.createHash('sha256').update(rawBody).digest('hex');
  const sts = ['POST', new URL(req.url, 'https://x').pathname, h('X-Timestamp'), h('X-Nonce'), bodyHash].join('\n');
  const want = crypto.createHmac('sha256', appSecret).update(sts).digest('hex');
  const got = h('X-Signature').toLowerCase();
  return got.length === want.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(got));
}
python
import hashlib, hmac
from flask import request

def verify(app_secret: str) -> bool:
    raw = request.get_data()  # raw bytes
    body_hash = hashlib.sha256(raw).hexdigest()
    sts = "\n".join(["POST", request.path, request.headers["X-Timestamp"], request.headers["X-Nonce"], body_hash])
    want = hmac.new(app_secret.encode(), sts.encode(), hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, request.headers.get("X-Signature", "").lower())
go
func verify(r *http.Request, raw []byte, appSecret string) bool {
	sum := sha256.Sum256(raw)
	sts := strings.Join([]string{"POST", r.URL.Path, r.Header.Get("X-Timestamp"), r.Header.Get("X-Nonce"), hex.EncodeToString(sum[:])}, "\n")
	mac := hmac.New(sha256.New, []byte(appSecret))
	mac.Write([]byte(sts))
	want := hex.EncodeToString(mac.Sum(nil))
	return hmac.Equal([]byte(want), []byte(strings.ToLower(r.Header.Get("X-Signature"))))
}

Suggested handling ​

  1. Verification fails → answer 401, alert.
  2. Look up event_id; already processed → answer 200.
  3. Update the local order from data.status (it only moves forward: SUCCESS may become RETURNED, never back).
  4. Answer 200.

EasyPay merchant API · v1