import { ModuleRef } from '@nestjs/core'; import { Order, Payment, PaymentMethodService, RequestContext, TransactionalConnection } from '@vendure/core'; import Stripe from 'stripe'; import { VendureStripeClient } from './stripe-client'; import { StripePluginOptions } from './types'; export declare class StripeService { private options; private connection; private paymentMethodService; private moduleRef; constructor(options: StripePluginOptions, connection: TransactionalConnection, paymentMethodService: PaymentMethodService, moduleRef: ModuleRef); createPaymentIntent(ctx: RequestContext, order: Order): Promise; /** * Whether the plugin is configured to authorize first and capture separately * (`captureMethod: 'manual'`). */ isManualCapture(): boolean; /** * Retrieves the live state of a PaymentIntent. Webhook payloads are a snapshot taken when the * event was created, so a redelivered event can describe an intent that has since been captured * or cancelled. */ retrievePaymentIntent(ctx: RequestContext, order: Order, paymentIntentId: string): Promise; /** * Captures a previously authorized PaymentIntent, charging the held funds. Called by the * webhook controller once the authorized payment has been committed, and by the payment * handler's `settlePayment` for captures started from the Admin UI. * * No idempotency key of our own is sent. Stripe returns the first response for a key for 24 * hours, errors included, so a fixed key would hand a failed capture back to every retry. The * SDK still adds its own key to its internal network retries. * * Safe to call again: a repeated capture is refused with `payment_intent_unexpected_state` * (typically because an earlier attempt already captured it and only the response was lost), and * the intent's live state is then returned so the caller can decide from the status. */ capturePaymentIntent(ctx: RequestContext, order: Order, paymentIntentId: string): Promise; /** * Voids (cancels) a PaymentIntent, releasing any authorized hold without charging the customer. * Used to release the hold when an order cannot be arranged after authorization, and by the * handler's `cancelPayment`. * * Safe to call again: if the intent can no longer be cancelled (typically because an earlier * attempt already cancelled it), its live state is returned so the caller can decide from the * status. */ cancelPaymentIntent(ctx: RequestContext, order: Order, paymentIntentId: string): Promise; /** * Returns the order's current PaymentIntent if it can still be confirmed. Used only in * manual-capture mode, where an intent can be cancelled server-side after authorization. * * The first intent for an order and amount is created under `${order.code}_${amount}`. When that * intent is cancelled, its replacement is created under a key derived from the cancelled intent's * ID, so every retry, sequential or concurrent, is handed the same replacement by Stripe instead * of creating another one. Stripe's idempotency store is the record of these attempts, so nothing * has to be stored on the order. * * An intent that is already authorized, processing or captured is never replaced, since that * would let the customer place a second hold for the same order. */ private resolveConfirmableIntent; private isConfirmableStatus; constructEventFromPayload(ctx: RequestContext, order: Order, payload: Buffer, signature: string): Promise; constructEventForChannel(ctx: RequestContext, payload: Buffer, signature: string): Promise; createRefund(ctx: RequestContext, order: Order, payment: Payment, amount: number): Promise>; /** * Get Stripe client for a channel, without requiring an order. * * Used to resolve the webhook secret before the payload is trusted: * the credentials come from the channel's enabled Stripe payment * method. Order eligibility is checked separately via * {@link getStripeClient} once the event is verified. */ getStripeClientForChannel(ctx: RequestContext): Promise; /** * Get Stripe client based on eligible payment methods for order */ getStripeClient(ctx: RequestContext, order: Order): Promise; private findEnabledStripePaymentMethod; private findOrThrowArgValue; /** * Resolves the optional per-request options (e.g. a `stripeAccount` targeting a * connected account). Returns `undefined` when no callback is configured or it * yields an empty object, because the Stripe SDK rejects an empty options hash. */ private resolveRequestOptions; /** * Returns the stripeCustomerId if the Customer has one. If that's not the case, queries Stripe to check * if the customer is already registered, in which case it saves the id as stripeCustomerId and returns it. * Otherwise, creates a new Customer record in Stripe and returns the generated id. */ private getStripeCustomerId; }