npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gerbergpt/medusa-payment-alipay

v1.0.3

Published

Seamlessly connects the AliPay gateway to the Medusa Payment Module, enabling merchants to offer AliPay as a checkout option, authorize and capture payments, and process asynchronous status updates via webhooks.

Downloads

47

Readme

Medusa AliPay Payment Provider

@gerbergpt/medusa-alipay is a Medusa V2 payment provider modeled after the official Medusa Stripe integration. It wires the AliPay gateway into the Payment Module so the provider can be selected during checkout, orders can be authorized/captured, and asynchronous updates are delivered through webhooks.

Platforms

Features

  • 🔐 Implements the AbstractPaymentProvider contract with capture, refund, cancel, and status flows aligned with AliPay trade states.
  • 💳 Uses alipay.trade.page.pay via the OpenAPI curl interface to create redirect-based payments and stores the AliPay payload on the payment session for later reconciliation.
  • 🔁 Surfaces POST /hooks/alipay so AliPay can notify the Medusa backend. The hook feeds the same event-bus pipeline used by the Stripe provider (payment.webhook_received).
  • ⚙️ Ships with option validation, sandbox toggles, configurable subjects/notify URLs, and signature verification to guard webhook calls.

Installation

yarn add @gerbergpt/medusa-payment-alipay
# or
npm install @gerbergpt/medusa-payment-alipay

Configuration

Register the provider in medusa-config.ts (or the file where you bootstrap modules):

module.exports = defineConfig({
  modules: [
    {
      key: Modules.PAYMENT,
      resolve: "@medusajs/payment",
      options: {
        providers: [
          {
            resolve: "@gerbergpt/medusa-payment-alipay/providers",
            id: "alipay",
            options: {
              appId: process.env.ALIPAY_APP_ID!,
              privateKey: process.env.ALIPAY_PRIVATE_KEY!,
              alipayPublicKey: process.env.ALIPAY_PUBLIC_KEY!,
              notifyUrl: "https://your-domain/hooks/alipay",
              sandbox: process.env.ALIPAY_ENV !== "production",
            },
          },
        ],
      },
    },
  ],
})

Available options

| Option | Description | | --- | --- | | appId | AliPay App ID (required). | | privateKey | Merchant RSA private key (PKCS8) used to sign requests (required). | | alipayPublicKey | AliPay RSA public key for webhook verification (required). | | notifyUrl | Override for the async notification callback URL. Defaults to the plugin webhook route. | | sandbox | When true, directs traffic to the AliPay sandbox gateway. | | gateway | Custom gateway URL. Useful for regional AliPay entrants. | | timeoutExpress | AliPay trade timeout window (defaults to 30m). | | defaultSubject | Fallback order description sent to AliPay. | | storeId | Optional AliPay store identifier for reconciliation. | | webhookValidation | Set to false to skip signature verification (not recommended). | | debug | Enables extra SDK logging. Defaults to false. |

Webhook setup

The Medusa application has a /hooks/payment/[identifier]_[provider] API route out-of-the-box that allows you to listen to webhook events from third-party payment providers, where:

  • [identifier] is the identifier static property defined in the payment provider. For example, stripe.
  • [provider] is the ID of the provider. For example, stripe.

For example, when integrating basic Stripe payments with the Stripe Module Provider, the webhook listener route is {store_url}/hooks/payment/alipay_alipay.

You can use this webhook listener when configuring webhook events in your third-party payment provider.


Development

  1. Install Yarn
npm i -g yarn
  1. Publish Alipay payment locally via yalc:
cd medusa-payment-alipay
yarn install
npx medusa plugin:publish
  1. Navigate to your Medusa backend application and install the plugin:
npx medusa plugin:add @gerbergpt/medusa-payment-alipay

After installation, you should see an entry pointing to the local yalc package:

"dependencies": {
  ...,
  "@gerbergpt/medusa-payment-alipay": "file:.yalc/@gerbergpt/medusa-payment-alipay",
  ...
}
  1. Configure your Medusa application (backend)
module.exports = defineConfig({
  modules: [
    {
      key: Modules.PAYMENT,
      resolve: "@medusajs/payment",
      options: {
        providers: [
          {
            resolve: "@gerbergpt/medusa-payment-alipay/providers",
            id: "alipay",
            options: {
              appId: process.env.ALIPAY_APP_ID!,
              privateKey: process.env.ALIPAY_PRIVATE_KEY!,
              alipayPublicKey: process.env.ALIPAY_PUBLIC_KEY!,
              notifyUrl: "https://{server}/hooks/payment/alipay_alipay",
              sandbox: process.env.ALIPAY_ENV !== "production",
            },
          },
        ],
      },
    },
  ],
})
  1. If you need to move the local npm package bridged by yalc, just run:
npx yalc remove @gerbergpt/medusa-payment-alipay

Usage notes

  • AliPay currently expects amounts in CNY. The provider rounds to 2 decimals (0 for JPY) before calling the API.
  • The Initiate API stores the payment_url (and any additional payload) returned by alipay.trade.page.pay inside the payment session’s data field so storefronts can redirect customers to AliPay.
  • authorizePayment/capturePayment mirror getPaymentStatus. When a webhook reports TRADE_SUCCESS or TRADE_FINISHED, Medusa’s processPaymentWorkflow captures the payment automatically.
  • Return URLs are taken from the payment session payload so the storefront can point AliPay back to the active checkout page for the shopper’s current region rather than a static configuration value.
  • Payment subjects default to the cart’s product names (joined) to surface a meaningful order title in AliPay; they fall back to a provided subject value, then the configured defaultSubject.

Troubleshooting

  • yarn build compiles the plugin to .medusa/server.
  • If you see Invalid AliPay webhook signature, confirm that the public key in your configuration matches the one configured on AliPay.
  • Use the sandbox gateway (sandbox: true) together with the AliPay playground app to test QR flows locally.