Skip to content

RemotePaymentAdapter

Adapter in @evolve-framework/commercetools

A PaymentAdapter that forwards every call over HTTP to a remote payment service (one hosting the real adapter behind a RemotePaymentPublisher).

import { RemotePaymentAdapter } from "@evolve-framework/commercetools/payments";
new RemotePaymentAdapter(identifier: string, endpoint: string, options?: RemotePaymentAdapterOptions)
OptionTypeDescription
timeoutMs?number

Per-request timeout in ms (defaults to DEFAULT_REMOTE_TIMEOUT_MS).

secret?string

Shared secret sent as authorization: Bearer <secret> on every request. Must match the secret configured on the remote RemotePaymentPublisher.

inFlightWindowMs?((payment: Payment) => number | undefined)

How long a transaction the remote adapter started may stay open, as that adapter's inFlightWindowMs would answer. Given here because the answer is read on every payability check, which is no place for a round trip.

MethodDescription
inFlightWindowMs(payment: Payment): number | undefinedHow long, in milliseconds, a transaction this adapter started may stay open before it counts as abandoned rather than in flight.
init(): Promise<void>One-shot, idempotent initialization (build SDK clients, etc.).
getRoutes(): undefinedProvider-specific external routes to publish when this adapter is hosted as a service — principally the webhook endpoint the PSP calls with async payment updates, plus any redirect-return routes.
getPaymentMethods( args: { targetId?: string | undefined; locale: string; targetType: "cart" | "order" | "invoice"; currency: string; country: string; device: "WEB" | "IOS" | "ANDROID"; }, ): Promise<PaymentMethod[]>Resolve the available payment methods for a cart/order.
createTransaction( req: { collected?: { currency: string; centAmount: number; } | undefined; customer: { ipAddress: string; }; locale: string; targetId: string; targetType: "cart" | "order" | "invoice"; amount: { currency: string; centAmount: number; }; paymentId: string; paymentMethod: string; paymentMethodArgs: { [x: string]: any; }; successUrl: string; failureUrl: string; }, ): Promise<TransactionResponse>Create (start) a transaction for a payment.
validateApplePaySession( args: { cartId: string; displayName: string; domainName: string; merchantIdentifier: string; }, ): Promise<{ data: string; }>Validate an Apple Pay session.
updateExpressCheckout( args: { amount: { currency: string; centAmount: number; }; paymentId: string; paymentData: string; deliveryMethods: { reference: string; amount: { currency: string; centAmount: number; }; description: string; selected: boolean; }[]; }, ): Promise<{ paymentData: string; }>Bring a wallet payment in progress up to date with the cart, for a wallet whose own sheet changes the address or shipping, such as PayPal Express.
submitPaymentDetails( args: { targetId: string; targetType: "cart" | "order" | "invoice"; paymentId: string; details: { [x: string]: any; }; }, ): Promise<TransactionResponse>Continue a transaction whose start answered with an action for the provider's component, with what that component reported.
cancelPayment( args: { targetId: string; targetType: "cart" | "order" | "invoice"; paymentId: string; }, ): Promise<{ cancelled: boolean; }>Withdraw a payment the shopper abandoned in the provider's component, and release its target.