commercetools-stripe
Stripe payments for the commercetools engine: a payment adapter that lists Stripe's payment methods, starts payments, and processes the shopper's return and Stripe's webhooks, recording each on the commercetools payment.
When to use
Use it when Stripe is a payment provider of a shop on
@evolve-framework/commercetools. There is one package per provider, and a
shop can register several. It only works behind the commercetools engine.
The adapter runs in one of two ways: as a payment service of its own, with
PaymentProviderModule mounting its routes, as in the example below; or inside
the commercetools service, registered in the PaymentRegistry that the cart,
checkout and payment modules are given.
- Payment methods: Those enabled in the first active Stripe payment method configuration, limited to card, iDEAL, Bancontact, PayPal and Klarna.
- Webhook route:
POST /push, Stripe's webhook, verified by its signing secret. Inside the commercetools service, registered in aPaymentRegistry, the routes are prefixed with/stripe, for example/stripe/push.
Get started
Install the package with the peer dependencies it needs. It comes from the Evolve registry, which needs a one-time sign-in.
pnpm add @evolve-framework/commercetools-stripe @evolve-framework/commercetools @evolve-framework/core fastifyRequirements5
@evolve-framework/commercetools>= 0.10.0 < 2.0.0@evolve-framework/core>= 1.0.0 < 2.0.0@types/node>=22optionalfastify>= 5.12.1 < 6.0.0msw^2.14.6 || ^3.0.1optional
For example:
import { ClientFactory, type CommercetoolsLoaderContext, PaymentProviderModule,} from "@evolve-framework/commercetools";import { StripePaymentAdapter } from "@evolve-framework/commercetools-stripe";import { CompositeModule, createApplication, HealthModule,} from "@evolve-framework/core";
const clientFactory = ClientFactory.create({ projectKey: process.env.CTP_PROJECT_KEY!, apiUrl: process.env.CTP_API_URL!, authUrl: process.env.CTP_AUTH_URL!, clientId: process.env.CTP_CLIENT_ID!, clientSecret: process.env.CTP_CLIENT_SECRET!, scopes: process.env.CTP_SCOPES?.split(",") ?? [],});
const app = await createApplication({ name: "payment-commercetools-stripe", module: new CompositeModule<CommercetoolsLoaderContext>([ new PaymentProviderModule({ adapter: new StripePaymentAdapter({ clientFactory, config: { apiKey: process.env.STRIPE_API_KEY!, account: process.env.STRIPE_ACCOUNT!, webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!, serverUrl: process.env.SERVER_URL!, }, }), internalRoutes: true, externalRoutes: true, }), // Serves /healthcheck for the liveness probe and /readiness for the // dependency check. `graphql: false` because this service has no schema. new HealthModule({ name: "commercetools-stripe", graphql: false }), ]), http: { address: { host: process.env.HTTP_HOST ?? "localhost", port: Number(process.env.HTTP_PORT ?? 4025), }, },});
await app.start();Adapters
StripePaymentAdapter
Stripe as a commercetools payment provider, offering card, iDEAL, Bancontact, PayPal and Klarna as the active payment method configuration enables them.
import { StripePaymentAdapter } from "@evolve-framework/commercetools-stripe";new StripePaymentAdapter(options: StripePaymentAdapterOptions)| Option | Type | Description |
|---|---|---|
clientFactory | ClientFactory | Pre-configured commercetools |
config | StripeConfig | Stripe credentials and runtime settings used by the SDK and routes. |
StripeConfig4The fields of config.
| Field | Type | Description |
|---|---|---|
apiKey | string | Stripe secret API key (sk_*). |
account | string | Stripe connected account id used when issuing API calls. |
webhookSecret | string | Endpoint signing secret (whsec_*) used to validate webhook signatures. |
serverUrl | string | Externally reachable base URL of this service; used to build redirect URLs. |
Extends BasePaymentAdapter.
Entry points
@evolve-framework/commercetools-stripe | StripePaymentAdapter and its options, configuration and client.3 exports |
@evolve-framework/commercetools-stripe/testing | An MSW server with the mocked commercetools project, for testing a service that uses the adapter.1 export |

