import { Logger } from '../..'; import { AuthorizationService } from '../types/authorization.type'; import { RecurringPaymentJob, RecurringPaymentJobDraft, RecurringPaymentJobService } from '../types/recurring-payment-job.type'; import { DefaultCartService } from './ct-cart.service'; /** * Default implementation of the RecurringPaymentJobService interface. */ export declare class DefaultRecurringPaymentJobService implements RecurringPaymentJobService { private authorizationService; private ctCartService; private checkoutUrl; private projectKey; private logger; private token; constructor(opts: { authorizationService: AuthorizationService; ctCartService: DefaultCartService; checkoutUrl: string; projectKey: string; logger: Logger; }); /** * Creates a recurring payment job only if applicable (i.e., when the cart is configured for recurring payments). * * This method abstracts the business logic of determining whether a recurring payment job should be created. * The caller doesn't need to validate the cart - the method handles it internally. * * The method performs the following operations: * 1. Retrieves the cart associated with the origin payment * 2. Checks if the cart is configured for recurring payments * 3. If yes, creates the recurring payment job via the checkout API * 4. If no, returns null without creating anything * * @param draft - The draft object containing the origin payment and payment method references * @returns The created recurring payment job if the cart supports recurring payments, * or null if it doesn't or if an error occurs * * @example * ```typescript * // Caller doesn't need to check if cart is recurring - method handles it * const job = await service.createRecurringPaymentJobIfApplicable({ * originPayment: { id: 'payment-123', typeId: 'payment' }, * paymentMethod: { id: 'method-456', typeId: 'payment-method' } * }); * * if (job) { * // Job was created because cart is recurring * } else { * // Cart is not recurring or an error occurred * } * ``` */ createRecurringPaymentJobIfApplicable(draft: RecurringPaymentJobDraft): Promise; /** * Internal method that performs the HTTP request to create a recurring payment job. */ private internalCreateRecurringPaymentJob; /** * Performs a fetch request with automatic token refresh on 401/403 errors. */ private fetchWithTokenRetry; private safeParseErrorResponse; }