@hyperse-hub/hps-plugin-payment-core
Shared payment infrastructure for Vendure: shop GraphQL extensions, reusable services, and conventions that provider-specific plugins (PayPal, Stripe, and others) build on.
1. Role in the stack
- Foundation layer — Provider plugins import
HpsPluginPaymentCore and extend the same patterns (payment handlers, webhooks, storefront config).
- Cross-cutting Shop API — Adds fields and mutations that are not tied to a single PSP, so the storefront can poll settlement and read normalized client configuration.
- Optional integrations — Exports hooks such as reward-points payment integration for other hub-pay packages.
2. Requirements
- Vendure
>= 3.0.0
- Node.js
>= 20
3. Install
yarn add @hyperse-hub/hps-plugin-payment-core
4. Vendure registration
Register the plugin like any other Vendure plugin. Provider packages already import it; you only add this explicitly if you consume the API or services without a provider plugin, or when building a custom payment plugin.
import { HpsPluginPaymentCore } from '@hyperse-hub/hps-plugin-payment-core';
5. Key concepts
5.1 Shop GraphQL extensions
PaymentMethodQuote.clientConfig — Resolved from PaymentMethod.customFields.clientConfig (JSON). Lets the Admin UI store a structured blob (for example publishable keys or SDK options) and exposes it to the storefront as parsed JSON. Keys depend on each provider.
refreshPaymentStatus — Mutation for post-checkout polling. After redirect or hosted UI, the client sends the active order id and the transactionId from addPaymentToOrder. The server finds that payment by both orderId and transactionId, then runs settlePayment so multiple pending payments on one order stay unambiguous. Returns true if the payment is already or becomes Settled.
5.2 Custom fields
PaymentMethod.clientConfig — Text field (JSON in Admin) used to pass storefront-safe configuration; often combined with PaymentMethodQuote.clientConfig resolution.
- Order — Additional custom fields used by the payment stack (see package source for the exact list).
5.3 Built-in payment handler (development)
The plugin registers a dummy payment method handler and an admin-only eligibility checker so local development and tests can exercise the payment pipeline without a real PSP.
5.4 Exported utilities
PaymentHelperService — Resolves PaymentMethod by handler code, builds channel/order metadata for webhooks, loads orders. Used by provider controllers (PayPal, Stripe).
orderPaidStates — Order states treated as “paid” for webhook/settlement logic (e.g. PaymentSettled, shipped states, cancelled as appropriate for your flows).
5.5 Subscription helpers
The package exports subscription-related types and strategies (for example DefaultCommerceRecurringStrategy) consumed by the Stripe subscription integration.
6. Typical usage
- As a dependency of a provider plugin — You normally do not install this package alone; install
@hyperse-hub/hps-plugin-payment-paypal or @hyperse-hub/hps-plugin-payment-stripe, which already import the core.
- Storefront — After
addPaymentToOrder, call refreshPaymentStatus when the customer returns from a redirect or when the SDK completes, until the payment settles or you handle failure in UI.
- Custom provider plugins — Import
HpsPluginPaymentCore, reuse PaymentHelperService, extend PaymentMethodQuote / refreshPaymentStatus patterns, and store public config in PaymentMethod.customFields.clientConfig where it fits your design.
7. License
MIT