ZPay
The Alipay-style ZPay demo provider in the Nuxt template.
ZPay is a China-oriented (Alipay) demo provider. It
implements the PaymentProvider interface in
server/payment/providers/zpay-provider.ts and is registered by the factory
when NUXT_ZPAY_URL, NUXT_ZPAY_MERCH_ID, and NUXT_ZPAY_MERCH_KEY are all
set.
ZPay is included as a worked example of a non-Stripe, signature-based gateway.
It is not selectable through NUXT_PUBLIC_PAYMENT_PROVIDER (that switch
only chooses Creem or Stripe) and it has the amount caveat
below. Treat it as reference, not a production path.
Configuration
| Variable | Purpose |
|---|---|
NUXT_ZPAY_URL | ZPay API endpoint. |
NUXT_ZPAY_MERCH_ID | Merchant ID. |
NUXT_ZPAY_MERCH_KEY | Merchant key used for MD5 signing. |
NUXT_ZPAY_NOTIFY_URL | Public callback URL ZPay calls after payment. |
Checkout
createPayment builds an Alipay-type ZPay request (type: "alipay"), signs the
sorted params with MD5 + the merchant key, and returns the redirect
checkoutUrl. The user pays and is sent back via NUXT_ZPAY_NOTIFY_URL.
Webhook
- Path:
GET /api/payment/notify/zpay(notify/zpay.get.ts) — a GET callback, unlike the POST webhooks of Creem/Stripe. - Verification: recomputes the MD5 signature over the sorted query params and
the merchant key, compared to the
signparameter. - Handled result:
trade_status === "TRADE_SUCCESS"marks the ordersuccessand creates a one-timesubscription; otherwise the order is marked failed.
The ZPay amount caveat
create.post.ts records the amount/currency from app/config/payment-config.ts,
but the ZPay provider's createPayment currently charges
Math.round(paymentConfig.amountCNY * 100) from shared/config/payment.ts —
i.e. the hardcoded sample CNY amount for every order, regardless of the
selected plan.
Replace shared/config/payment.ts and map ZPay's charged amount to your real
per-plan pricing before going live.
Verify
- With ZPay env vars set, a logged-in user can start checkout and a
paymentrow is created. - A callback with a valid MD5 sign and
TRADE_SUCCESSflips the order tosuccess; an invalid sign is rejected. - The charged amount matches the selected plan (after replacing the sample
amountCNY).
