import { Address, Cart, ShippingInfo } from '@commercetools/platform-sdk'; import { Logger } from '../../logger'; import { AddPayment, CommercetoolsAPI } from './api.type'; import { PaymentAmount } from './payment.type'; import { ContextProvider, RequestContextData } from '../../api'; export type GetCart = { id: string; version?: number; }; export type GetPaymentAmount = { cart: Cart; }; export type GetOneShippingAddress = { cart: Pick; }; export type GetNormalizedShipping = { cart: Pick; }; export type NormalizedShipping = { shippingAddress: Address; shippingInfo: ShippingInfo; }; export type ShippingAmounts = { priceCentAmount: number; taxRateAmount: number; totalNetCentAmount: number; totalGrossCentAmount: number; totalTaxCentAmount: number; }; export type CartServiceOptions = { ctAPI: CommercetoolsAPI; logger: Logger; contextProvider: ContextProvider; }; export type GetCartByPaymentIdRequest = { paymentId: string; }; /** * Cart service interface exposes methods to interact with the commercetools platform API. */ export interface CartService { getCartByPaymentId(opts: GetCartByPaymentIdRequest): Promise; getCart(opts: GetCart): Promise; /** * Get payment amount for a cart. This method is used to calculate the payment amount for a cart. * It takes into account existing successful payments. * @param opts */ getPaymentAmount(opts: GetPaymentAmount): Promise; /** * Get payment amount for a cart. This method is used to calculate the payment amount for a cart. * It takes into account existing successful payments and giftcards connectors. * This method is specifically used for calculating the payment amount for a cart when a giftcard is applied and the payment session is created upfront. * @param opts */ getPlannedPaymentAmount(opts: GetPaymentAmount): Promise; addPayment(opts: AddPayment): Promise; /** * Checks if the given cart contains items configured for recurring orders. * * @param cart - The cart to check * @returns true if the cart contains recurring items, false otherwise */ isRecurringCart(cart: Cart): boolean; }