interface ShippingAddress { city: string; address: string; zip: string; } export type Lang = 'en' | 'ar'; interface OrderHistoryItem { amount: string; // "0.00"; status: | 'new' | 'processing' | 'complete' | 'refunded' | 'canceled' | 'unknown'; purchased_at: string; // "2019-08-24T14:15:22Z"; payment_method?: 'card' | 'cod'; buyer?: Buyer; shipping_address?: ShippingAddress; items?: OrderItem[]; } interface BuyerHistory { registered_since: string; // "2019-08-24T14:15:22Z"; loyalty_level: number; // 0; wishlist_count?: number; //0; is_social_networks_connected?: boolean; // true; is_phone_number_verified?: boolean; // true; is_email_verified?: boolean; // true; } interface OrderItem { title: string; // 'Sample Item #1' quantity: number; // 1 unit_price: string; // '300.00' category: string; // jeans / dress / shorts / etc description?: string; // 'To be displayed in tabby order information' product_url?: string; // https://tabby.store/p/SKU123 reference_id?: string; // 'SKU123' brand?: string; color?: string; gender?: 'Male' | 'Female' | 'Kids' | 'Other'; image_url?: string; discount_amount?: string; // "2.00" } interface Order { reference_id: string; // #xxxx-xxxxxx-xxxx items: OrderItem[]; shipping_amount?: string; // '50' tax_amount?: string; // '500' discount_amount?: string; // '500' } interface Buyer { email: string; phone: string; name: string; dob?: string; // "2019-08-24" } // https://docs.tabby.ai/#operation/postCheckoutSession export interface Payment { amount: string; currency: Currency; // ISO 4217 currency code for the payment amount. order: Order; buyer: Buyer; buyer_history: BuyerHistory; order_history: OrderHistoryItem[]; shipping_address: ShippingAddress; description?: string; attachment?: {body: string; content_type: string}; } export type TabbyPurchaseType = 'installments'; export type Currency = 'AED' | 'SAR' | 'KWD' | 'BHD' | 'QAR'; export interface TabbyCheckoutPayload { merchant_code: string; // 'ae', lang: Lang; payment: Payment; } export type ProductWebURL = {web_url: string}; export interface CheckoutSession { id: string; configuration: { available_products: { installments?: ProductWebURL[]; }; products: { installments?: { type: string; // 'installments' is_available: boolean; rejection_reason?: string; }; }; }; payment: {id: string}; } export const currencyDecimals: {[key in Currency]: number} = { AED: 2, SAR: 2, KWD: 3, BHD: 3, QAR: 2, }; export const COUNTRY_NAME_BY_CURRENCY_MAP: Record = { AED: 'emirates', SAR: 'saudi', KWD: 'kuwait', BHD: 'bahrain', QAR: 'qatar', };