Stripe payments for AntelopeJS: create payment intents tied to your own records, and react when Stripe reports that they succeed or fail.
GetClient()resolves to the project's configured Stripe SDK client.InitializePaymentcreates a payment intent and stores your own identifier, such as an order ID, in its metadata.WaitForPaymentresolves when a payment intent succeeds and rejects when it is canceled.WatchPaymentandWatchAllPaymentscall you on every status change, with a flag that tells whether this instance received the event.
| Module | Notes |
|---|---|
@antelopejs/stripe |
Configures the client and receives Stripe webhooks |
Add the interface to the module that takes payments:
pnpm add @antelopejs/interface-stripeThen add the implementation to the project:
ajs project modules add @antelopejs/stripeimport {
InitializePayment,
WatchAllPayments,
} from "@antelopejs/interface-stripe";
export async function startCheckout(orderId: string, amountInCents: number) {
const intent = await InitializePayment(orderId, {
amount: amountInCents,
currency: "eur",
payment_method_types: ["card"],
});
return intent.client_secret;
}
WatchAllPayments((orderId, intent, context) => {
if (orderId && context.local && intent.status === "succeeded") {
markOrderPaid(orderId);
}
});orderId is the identifier passed to InitializePayment. Return the client secret
to the authenticated payer before waiting for completion, so Stripe.js can confirm
the payment. markOrderPaid stands for your own idempotent order update; handle
webhook redelivery even when context.local is true. Configure the implementation's
Stripe credentials and webhook endpoint before using these functions.
Peer requirement:
| Package | Supported | Tested with |
|---|---|---|
@antelopejs/interface-core |
>=0.2.4 <1.0.0 |
0.2.4 |
Runtime dependency:
These are the runtime ranges in package.json. This package does not declare an
@antelopejs/core peer range; check the implementing module's requirements too.
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm lint
pnpm build