export interface Create3DSSessionPayload { /** * The card ID that's going to be submitted for payment. */ card_id: string; /** * The resource that is going to be submitted for payment after a 3DS session status is ready for payment. * This is used together with services to calculate the payment amount in the currency to be paid. */ resource_id: string; /** * The name of the exception to opt out of authenticating the payment with the card issuer. */ exception: 'secure_corporate_payment' | null; /** * The service IDs and quantities of the services that are being added to the order. */ services?: Array<{ id: string; quantity: number }>; } type ThreeDSSessionStatus = | 'client_action_required' | 'ready_for_payment' | 'expired' | 'failed'; export interface ThreeDSecureSession { /** * The ID of the ThreeDSecureSession. */ id: string; /** * Whether the 3DS session was created in live mode. This field will be set to `true` if the card was created in live mode, or `false` if it was created in test mode. */ live_mode: boolean; /** * The resource (offer, order, order change..) ID that the 3DS session is for. */ resource_id: string; /** * The status of the 3DS session. * - `client_action_required` - The 3DS session requires the UI Component to be initailised. This is the initial state when the payment is eligible for SCA and requires a 3DS challenge. * - `ready_for_payment` - The 3DS session is ready to be used on a payment object as part of a order creation/payment request. This is the initial state if the card or the supplier does not support 3DS. * - `failed` - The 3DS session was not authenticated to proceed with the payment. Payment should not be attempted. Cardholder should try again, possibly with a different card. Additionally, this is the initial state if the cardholder details are invalid. * - `expired` - The 3DS session has expired. A new session should be created if needed. */ status: ThreeDSSessionStatus; /** * Used to initiate the UI component when `status` is `challenge_required`. */ client_id: string; /** * The card ID used to initiate the 3DS session. */ card_id: string; } export interface Create3DSecureSessionCallbacks { /** * The 'success' event will be fired once the 3DS authentication process has been completed successfully. * You should use this event to trigger your backend to complete the order or booking creation. */ onSuccess: (threeDSecureSession: ThreeDSecureSession) => void; /** * The 'failure' event will be fired if the 3DS authentication process fails. You should use this event to handle the failure and inform the user and prompt them to try again. If the user cancels the 3DS authentication process this event will be fired. */ onFailure: (error: Error) => void; /** * The error event will be fired if the component fails to create the 3DS session or render the 3DS challenge. */ onError: (error: Error) => void; }