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

VariablePurpose
NUXT_ZPAY_URLZPay API endpoint.
NUXT_ZPAY_MERCH_IDMerchant ID.
NUXT_ZPAY_MERCH_KEYMerchant key used for MD5 signing.
NUXT_ZPAY_NOTIFY_URLPublic callback URL ZPay calls after payment.

See Environment Variables.

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 sign parameter.
  • Handled result: trade_status === "TRADE_SUCCESS" marks the order success and creates a one-time subscription; 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 payment row is created.
  • A callback with a valid MD5 sign and TRADE_SUCCESS flips the order to success; an invalid sign is rejected.
  • The charged amount matches the selected plan (after replacing the sample amountCNY).

On this page