Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

alipay-webhooks

БесплатноЗапускает вложенные скриптыНе проверен

Receive and verify Alipay (Antom / Alipay+) webhook notifications. Use when setting up Alipay webhook handlers, debugging RSA256 Signature header…

hookdeckот hookdeck★ 104 звезды на GitHub

Об этом скилле

Alipay Webhooks

Alipay's global / cross-border products — Antom (Cashier Payment / AMS) and Alipay+ — deliver asynchronous webhook notifications (notifyPayment, notifyRefund, notifyCapture, notifyAuthorization, notifyDispute) signed with an asymmetric RSA256 (SHA256withRSA) scheme carried in a Signature header. This skill targets that header-based scheme.

Scope note: The domestic Alipay open platform sends form-encoded notifications with a different signing scheme. If your integration receives application/x-www-form-urlencoded bodies, this skill does not cover it. Everything below is the Antom header RSA256 scheme (global.alipay.com/docs now redirects to docs.antom.com).

When to Use This Skill

  • How do I receive Alipay / Antom / Alipay+ webhooks?
  • How do I verify the Alipay Signature header (RSA256 / SHA256withRSA)?
  • How do I handle notifyPayment, notifyRefund, or notifyDispute events?
  • Why is my Alipay webhook signature verification failing (URL-encoded base64)?
  • What acknowledgement body does Antom expect?

Verification (core)

Alipay/Antom signs each request with SHA256withRSA using its private key and carries the result in a Signature header. You verify it with Antom's public key (from the Dashboard). Three details trip people up:

  1. The signed content is exactly two lines: <METHOD> <URI> then <Client-Id>.<Request-Time>.<RawBody> joined by single periods.
  2. The signature is base64, then URL-encoded (%2F, %3D) on the wire. URL-decode it, then base64-decode it.
  3. Use the raw request body — never re-serialize parsed JSON first.
const { createVerify } = require('crypto');

// Header: "algorithm=RSA256,keyVersion=1,signature=<URL-encoded base64 signature>"
function parseSignatureHeader(header) {
  return Object.fromEntries(
    header.split(',').map((p) => {
      const i = p.indexOf('=');
      return [p.slice(0, i).trim(), p.slice(i + 1).trim()];
    })
  );
}

function verifyAlipay({ method, uri, clientId, requestTime, rawBody, signatureHeader, publicKey }) {
  const { signature } = parseSignatureHeader(signatureHeader);
  if (!signature) return false;
  const content = `${method} ${uri}\n${clientId}.${requestTime}.${rawBody}`;
  // Percent-decode, accept a URL-safe alphabet too, then base64-decode.
  const sig = Buffer.from(decodeURIComponent(signature).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
  const v = createVerify('RSA-SHA256');
  v.update(content, 'utf8');
  v.end();
  try {
    return v.verify(publicKey, sig); // publicKey = Antom/Alipay+ PEM public key
  } catch {
    return false;
  }
}

For complete handlers (header parsing, acknowledgement, event dispatch, tests), see:

The Acknowledgement Response

Respond HTTP 200 with this body, with fixed values, so Antom stops resending:

{ "result": { "resultCode": "SUCCESS", "resultStatus": "S", "resultMessage": "success" } }

Antom's docs say no digital signature is required on the acknowledgement. Their example response headers are Content-Type: application/json, client-id and response-time.

Until Antom receives this body it resends the notification up to eight times within 24 hours, at 0s, 2m, 10m, 10m, 1h, 2h, 6h and 15h (one Antom page says seven). In the sandbox a wrong acknowledgement isn't resent. Make your handler idempotent: there's no notification ID, so key on the type field plus the resource ID (paymentId, refundId, captureId, disputeId).

Common Event Types

The event type sits in a different body field per notification API (there is no single type field), and most bodies also carry result.resultStatus (S success, F failure).

Type field Values Notification API
notifyType PAYMENT_RESULT, PAYMENT_PENDING, UPDATE_AMOUNT_RESULT notifyPayment
notifyType CAPTURE_RESULT notifyCapture
notifyType REFUND_RESULT notifyRefund
notifyType PAYMENT_REVERSAL notifyReversal
authorizationNotifyType AUTHCODE_CREATED, TOKEN_CREATED, TOKEN_CANCELED notifyAuthorization
disputeNotificationType DISPUTE_CREATED, DISPUTE_JUDGED, DEFENSE_DUE_ALERT, ... notifyDispute
subscriptionNotificationType CREATE, CHANGE, CANCEL, TERMINATE, UPDATE notifySubscription

notifyVaulting and the Subscription Payment notifyPayment carry no type field. PAYMENT_PENDING only means the buyer has paid: never let it overwrite a stored PAYMENT_RESULT.

For the full notification reference, see Antom notifications.

Environment Variables

ALIPAY_CLIENT_ID=SANDBOX_5YC47N2ZQHJ004124        # Your Client ID (from the Dashboard)
ALIPAY_
Полный SKILL.md на GitHub

Установить alipay-webhooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/express/src/verify.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/alipay/route.tsexamples/nextjs/lib/verify.tsexamples/nextjs/package.jsonexamples/nextjs/tsconfig.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл alipay-webhooks?

Receive and verify Alipay (Antom / Alipay+) webhook notifications. Use when setting up Alipay webhook handlers, debugging RSA256 Signature header verification, or handling payment events like notifyPayment, notifyCapture, notifyRefund, notifyAuthorization, and notifyDispute.

Как установить скилл alipay-webhooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл alipay-webhooks запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить alipay-webhooks с