torque-checkout 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -127,8 +127,9 @@ export interface UpdateSubscriptionData {
127
127
  metadata?: any;
128
128
  }
129
129
  export interface TorqueConfig {
130
- businessId?: string;
131
- apiKey?: string;
130
+ businessId: string;
131
+ apiKey: string;
132
+ baseUrl?: string;
132
133
  timeout?: number;
133
134
  }
134
135
  export interface BusinessCreationData {
package/dist/index.esm.js CHANGED
@@ -1,8 +1,9 @@
1
1
  class TorqueCheckout {
2
2
  constructor(config) {
3
- this.baseUrl = '';
3
+ this.baseUrl = 'https://app.torque.fi';
4
4
  this.businessId = config.businessId;
5
5
  this.apiKey = config.apiKey;
6
+ this.baseUrl = config.baseUrl || 'https://app.torque.fi';
6
7
  this.timeout = config.timeout || 30000;
7
8
  }
8
9
  /**
@@ -343,8 +344,11 @@ class TorqueCheckout {
343
344
  const controller = new AbortController();
344
345
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
345
346
  try {
347
+ const { body, ...fetchOptions } = options;
346
348
  const response = await fetch(url, {
347
- ...options,
349
+ ...fetchOptions,
350
+ method: options.method || 'GET',
351
+ body: body ? JSON.stringify(body) : undefined,
348
352
  headers: {
349
353
  'Content-Type': 'application/json',
350
354
  'Authorization': `Bearer ${this.apiKey}`,
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["export interface CartItem {\n productId: string\n quantity: number\n variant?: string\n price?: number\n metadata?: Record<string, any>\n}\n\nexport interface CustomerData {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n shippingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n billingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n}\n\nexport interface CartOptions {\n domain?: string\n expiresIn?: number\n metadata?: Record<string, any>\n redirectUrl?: string\n}\n\nexport interface CartData {\n items: CartItem[]\n customer?: CustomerData\n options?: CartOptions\n}\n\n// New: Payment Plan Interface\nexport interface PaymentPlan {\n id: string\n name: string\n price: number\n interval: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\"\n intervalCount: number\n trialDays?: number\n maxCycles?: number\n description?: string\n}\n\n// New: Subscription Product Interface\nexport interface SubscriptionProduct {\n id: string\n name: string\n description?: string\n isSubscription: boolean\n paymentPlans?: PaymentPlan[]\n subscriptionContract?: {\n address: string\n chainId: number\n abi?: string\n }\n basePrice: number\n currency: string\n image?: string\n images?: string[]\n requiresShipping: boolean\n shippingCost?: number\n taxRate?: number\n inventory: number\n status: 'active' | 'inactive' | 'draft' | 'archived'\n sku?: string\n category?: string\n tags?: string[]\n variants?: Array<{\n id: string\n name: string\n price: number\n inventory?: number\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Interface\nexport interface Subscription {\n id: string\n businessId: string\n productId: string\n customerId?: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n status: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n currentPeriodStart: number\n currentPeriodEnd: number\n nextBillingDate: number\n trialStart?: number\n trialEnd?: number\n totalCycles: number\n maxCycles?: number\n lastPaymentDate?: number\n nextPaymentAmount: number\n currency: string\n contractSubscriptionId?: string\n contractAddress?: string\n billingHistory?: Array<{\n cycleNumber: number\n amount: number\n date: number\n status: \"paid\" | \"failed\" | \"pending\"\n transactionId?: string\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Creation Data\nexport interface CreateSubscriptionData {\n businessId: string\n productId: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n customerId?: string\n metadata?: any\n}\n\n// New: Subscription Update Data\nexport interface UpdateSubscriptionData {\n status?: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n pauseUntil?: number\n resumeDate?: number\n metadata?: any\n}\n\nexport interface TorqueConfig {\n businessId?: string\n apiKey?: string\n timeout?: number\n}\n\nexport interface BusinessCreationData {\n name: string\n description?: string\n email: string\n phone?: string\n website?: string\n currency?: string\n timezone?: string\n walletAddress: string\n logo?: string\n}\n\nexport interface BusinessProfile {\n id: string\n name: string\n email: string\n apiKey: string\n walletAddress: string\n logo?: string\n website?: string\n status: 'active' | 'pending' | 'suspended'\n}\n\nexport interface CheckoutResponse {\n success: boolean\n checkoutUrl: string\n expiresAt: string\n cartSummary: {\n itemCount: number\n productCount: number\n estimatedTotal: number\n }\n business: {\n id: string\n name: string\n logo?: string\n }\n}\n\nexport interface OrderStatus {\n orderId: string\n status: string\n customer: {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n } | null\n items: Array<{\n productId: string\n productName: string\n productImage?: string\n quantity: number\n variant?: string\n price: number\n total: number\n }>\n totals: {\n subtotal: number\n shipping: number\n tax: number\n total: number\n }\n paymentStatus: string\n shippingAddress?: any\n billingAddress?: any\n createdAt: number\n updatedAt: number\n metadata: Record<string, any>\n}\n\nexport interface CartValidation {\n valid: boolean\n errors: string[]\n warnings: string[]\n estimatedTotal: number\n}\n\nexport class TorqueCheckout {\n private businessId: string\n private apiKey: string\n private baseUrl: string = ''\n private timeout: number\n\n constructor(config: TorqueConfig) {\n this.businessId = config.businessId\n this.apiKey = config.apiKey\n this.timeout = config.timeout || 30000\n }\n\n /**\n * Generate a cart checkout URL\n */\n async generateCartCheckoutUrl(cart: CartData): Promise<string> {\n const response = await this.makeRequest('/api/torque-checkout', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: {\n items: cart.items\n },\n customerData: cart.customer,\n options: cart.options\n }\n })\n\n if (!response.success) {\n throw new Error(`Failed to generate checkout URL: ${response.error || 'Unknown error'}`)\n }\n\n return response.checkoutUrl\n }\n\n /**\n * Generate a single product checkout URL\n */\n async generateProductCheckoutUrl(productId: string, quantity: number = 1, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ productId, quantity }],\n customer,\n options\n })\n }\n\n /**\n * Generate a subscription checkout URL\n */\n async generateSubscriptionCheckoutUrl(productId: string, paymentPlanId: string, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ \n productId, \n quantity: 1,\n metadata: { \n isSubscription: true, \n paymentPlanId \n }\n }],\n customer,\n options\n })\n }\n\n /**\n * Validate cart data before checkout\n */\n async validateCart(cart: CartData): Promise<CartValidation> {\n try {\n const response = await this.makeRequest('/api/checkout/validate-cart', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: cart.items,\n customer: cart.customer\n }\n })\n\n return response\n } catch (error) {\n return {\n valid: false,\n errors: [error instanceof Error ? error.message : 'Validation failed'],\n warnings: [],\n estimatedTotal: 0\n }\n }\n }\n\n /**\n * Get order status\n */\n async getOrderStatus(orderId: string): Promise<OrderStatus> {\n const response = await this.makeRequest(`/api/checkout/order-status/${orderId}?businessId=${this.businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get order status: ${response.error}`)\n }\n\n return response\n }\n\n // New: Subscription Management Methods\n\n /**\n * Create a new subscription\n */\n async createSubscription(data: CreateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest('/api/subscriptions/create', {\n method: 'POST',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to create subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscription by ID\n */\n async getSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a business\n */\n async getBusinessSubscriptions(businessId: string, status?: string, limit?: number): Promise<Subscription[]> {\n const params = new URLSearchParams({ businessId })\n if (status) params.append('status', status)\n if (limit) params.append('limit', limit.toString())\n\n const response = await this.makeRequest(`/api/subscriptions/business?${params}`)\n \n if (response.error) {\n throw new Error(`Failed to get business subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a customer\n */\n async getCustomerSubscriptions(customerEmail: string): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/customer/${encodeURIComponent(customerEmail)}`)\n \n if (response.error) {\n throw new Error(`Failed to get customer subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Update subscription status\n */\n async updateSubscription(subscriptionId: string, data: UpdateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/update`, {\n method: 'PUT',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to update subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Cancel subscription\n */\n async cancelSubscription(subscriptionId: string, effectiveDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/cancel`, {\n method: 'PUT',\n body: { effectiveDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to cancel subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Pause subscription\n */\n async pauseSubscription(subscriptionId: string, resumeDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/pause`, {\n method: 'PUT',\n body: { resumeDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to pause subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Resume subscription\n */\n async resumeSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/resume`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to resume subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Process subscription renewal\n */\n async processSubscriptionRenewal(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/renew`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to process subscription renewal: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions due for renewal\n */\n async getSubscriptionsDueForRenewal(daysAhead: number = 7): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/due-for-renewal?daysAhead=${daysAhead}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscriptions due for renewal: ${response.error}`)\n }\n\n return response\n }\n\n // New: Product Management Methods\n\n /**\n * Get subscription products for a business\n */\n async getSubscriptionProducts(businessId: string): Promise<SubscriptionProduct[]> {\n const response = await this.makeRequest(`/api/products/subscriptions?businessId=${businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription products: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get product with payment plans\n */\n async getProductWithPaymentPlans(productId: string): Promise<SubscriptionProduct> {\n const response = await this.makeRequest(`/api/products/${productId}`)\n \n if (response.error) {\n throw new Error(`Failed to get product: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Send webhook event\n */\n async sendWebhookEvent(orderId: string, status: string, customerData?: any, metadata?: Record<string, any>): Promise<void> {\n await this.makeRequest('/api/webhooks/order-update', {\n method: 'POST',\n body: {\n orderId,\n status,\n customerData,\n metadata\n }\n })\n }\n\n /**\n * Track cart view for analytics\n */\n async trackCartView(cartId: string, cartData: CartData): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/cart-view', {\n method: 'POST',\n body: {\n cartId,\n businessId: this.businessId,\n cartData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track cart view:', error)\n }\n }\n\n /**\n * Track checkout completion for analytics\n */\n async trackCheckoutComplete(orderId: string, checkoutData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/checkout-complete', {\n method: 'POST',\n body: {\n orderId,\n businessId: this.businessId,\n checkoutData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track checkout completion:', error)\n }\n }\n\n /**\n * Track subscription creation for analytics\n */\n async trackSubscriptionCreated(subscriptionId: string, subscriptionData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/subscription-created', {\n method: 'POST',\n body: {\n subscriptionId,\n businessId: this.businessId,\n subscriptionData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track subscription creation:', error)\n }\n }\n\n /**\n * Generate cart hash for caching\n */\n generateCartHash(cart: CartData): string {\n const cartString = JSON.stringify({\n items: cart.items.sort((a, b) => a.productId.localeCompare(b.productId)),\n customer: cart.customer ? { email: cart.customer.email } : null\n })\n \n // Simple hash function for cart identification\n let hash = 0\n for (let i = 0; i < cartString.length; i++) {\n const char = cartString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash // Convert to 32-bit integer\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Generate subscription hash for caching\n */\n generateSubscriptionHash(subscriptionData: CreateSubscriptionData): string {\n const subscriptionString = JSON.stringify({\n businessId: subscriptionData.businessId,\n productId: subscriptionData.productId,\n customerEmail: subscriptionData.customerEmail,\n paymentPlanId: subscriptionData.paymentPlanId\n })\n \n let hash = 0\n for (let i = 0; i < subscriptionString.length; i++) {\n const char = subscriptionString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Make HTTP request to Torque API\n */\n private async makeRequest(endpoint: string, options: RequestInit = {}): Promise<any> {\n const url = `${this.baseUrl}${endpoint}`\n \n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), this.timeout)\n\n try {\n const response = await fetch(url, {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.apiKey}`,\n ...options.headers\n },\n signal: controller.signal\n })\n\n clearTimeout(timeoutId)\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`)\n }\n\n return await response.json()\n } catch (error) {\n clearTimeout(timeoutId)\n \n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new Error('Request timeout')\n }\n throw error\n }\n \n throw new Error('Request failed')\n }\n }\n}\n\n// Export default instance factory\nexport const createTorqueCheckout = (config: TorqueConfig) => new TorqueCheckout(config)\n\n// Export types\nexport type {\n CartItem,\n CustomerData,\n CartOptions,\n CartData,\n PaymentPlan,\n SubscriptionProduct,\n Subscription,\n CreateSubscriptionData,\n UpdateSubscriptionData,\n TorqueConfig,\n CheckoutResponse,\n OrderStatus,\n CartValidation\n}\n"],"names":[],"mappings":"MAkOa,cAAc,CAAA;AAMzB,IAAA,WAAA,CAAY,MAAoB,EAAA;QAHxB,IAAA,CAAA,OAAO,GAAW,EAAE;AAI1B,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK;IACxC;AAEA;;AAEG;IACH,MAAM,uBAAuB,CAAC,IAAc,EAAA;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,EAAE;AAC9D,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,IAAI,EAAE;gBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;AAC3B,gBAAA,IAAI,EAAE;oBACJ,KAAK,EAAE,IAAI,CAAC;AACb,iBAAA;gBACD,YAAY,EAAE,IAAI,CAAC,QAAQ;gBAC3B,OAAO,EAAE,IAAI,CAAC;AACf;AACF,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,CAAA,iCAAA,EAAoC,QAAQ,CAAC,KAAK,IAAI,eAAe,CAAA,CAAE,CAAC;QAC1F;QAEA,OAAO,QAAQ,CAAC,WAAW;IAC7B;AAEA;;AAEG;IACH,MAAM,0BAA0B,CAAC,SAAiB,EAAE,WAAmB,CAAC,EAAE,QAAuB,EAAE,OAAqB,EAAA;QACtH,OAAO,IAAI,CAAC,uBAAuB,CAAC;AAClC,YAAA,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,QAA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AAO,IAAI,CAAA,KAAA,EAAQ,QAAQ,CAAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE,CAAC;YACzF;AAEA,YAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE;QAC9B;QAAE,OAAO,KAAK,EAAE;YACd,YAAY,CAAC,SAAS,CAAC;AAEvB,YAAA,IAAI,KAAK,YAAY,KAAK,EAAE;AAC1B,gBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AAC/B,oBAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;gBACpC;AACA,gBAAA,MAAM,KAAK;YACb;AAEA,YAAA,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;QACnC;IACF;AACD;AAED;AACO,MAAM,oBAAoB,GAAG,CAAC,MAAoB,KAAK,IAAI,cAAc,CAAC,MAAM;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["export interface CartItem {\n productId: string\n quantity: number\n variant?: string\n price?: number\n metadata?: Record<string, any>\n}\n\nexport interface CustomerData {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n shippingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n billingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n}\n\nexport interface CartOptions {\n domain?: string\n expiresIn?: number\n metadata?: Record<string, any>\n redirectUrl?: string\n}\n\nexport interface CartData {\n items: CartItem[]\n customer?: CustomerData\n options?: CartOptions\n}\n\n// New: Payment Plan Interface\nexport interface PaymentPlan {\n id: string\n name: string\n price: number\n interval: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\"\n intervalCount: number\n trialDays?: number\n maxCycles?: number\n description?: string\n}\n\n// New: Subscription Product Interface\nexport interface SubscriptionProduct {\n id: string\n name: string\n description?: string\n isSubscription: boolean\n paymentPlans?: PaymentPlan[]\n subscriptionContract?: {\n address: string\n chainId: number\n abi?: string\n }\n basePrice: number\n currency: string\n image?: string\n images?: string[]\n requiresShipping: boolean\n shippingCost?: number\n taxRate?: number\n inventory: number\n status: 'active' | 'inactive' | 'draft' | 'archived'\n sku?: string\n category?: string\n tags?: string[]\n variants?: Array<{\n id: string\n name: string\n price: number\n inventory?: number\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Interface\nexport interface Subscription {\n id: string\n businessId: string\n productId: string\n customerId?: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n status: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n currentPeriodStart: number\n currentPeriodEnd: number\n nextBillingDate: number\n trialStart?: number\n trialEnd?: number\n totalCycles: number\n maxCycles?: number\n lastPaymentDate?: number\n nextPaymentAmount: number\n currency: string\n contractSubscriptionId?: string\n contractAddress?: string\n billingHistory?: Array<{\n cycleNumber: number\n amount: number\n date: number\n status: \"paid\" | \"failed\" | \"pending\"\n transactionId?: string\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Creation Data\nexport interface CreateSubscriptionData {\n businessId: string\n productId: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n customerId?: string\n metadata?: any\n}\n\n// New: Subscription Update Data\nexport interface UpdateSubscriptionData {\n status?: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n pauseUntil?: number\n resumeDate?: number\n metadata?: any\n}\n\nexport interface TorqueConfig {\n businessId: string\n apiKey: string\n baseUrl?: string\n timeout?: number\n}\n\nexport interface BusinessCreationData {\n name: string\n description?: string\n email: string\n phone?: string\n website?: string\n currency?: string\n timezone?: string\n walletAddress: string\n logo?: string\n}\n\nexport interface BusinessProfile {\n id: string\n name: string\n email: string\n apiKey: string\n walletAddress: string\n logo?: string\n website?: string\n status: 'active' | 'pending' | 'suspended'\n}\n\nexport interface CheckoutResponse {\n success: boolean\n checkoutUrl: string\n expiresAt: string\n cartSummary: {\n itemCount: number\n productCount: number\n estimatedTotal: number\n }\n business: {\n id: string\n name: string\n logo?: string\n }\n}\n\nexport interface OrderStatus {\n orderId: string\n status: string\n customer: {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n } | null\n items: Array<{\n productId: string\n productName: string\n productImage?: string\n quantity: number\n variant?: string\n price: number\n total: number\n }>\n totals: {\n subtotal: number\n shipping: number\n tax: number\n total: number\n }\n paymentStatus: string\n shippingAddress?: any\n billingAddress?: any\n createdAt: number\n updatedAt: number\n metadata: Record<string, any>\n}\n\nexport interface CartValidation {\n valid: boolean\n errors: string[]\n warnings: string[]\n estimatedTotal: number\n}\n\nexport class TorqueCheckout {\n private businessId: string\n private apiKey: string\n private baseUrl: string = 'https://app.torque.fi'\n private timeout: number\n\n constructor(config: TorqueConfig) {\n this.businessId = config.businessId\n this.apiKey = config.apiKey\n this.baseUrl = config.baseUrl || 'https://app.torque.fi'\n this.timeout = config.timeout || 30000\n }\n\n /**\n * Generate a cart checkout URL\n */\n async generateCartCheckoutUrl(cart: CartData): Promise<string> {\n const response = await this.makeRequest('/api/torque-checkout', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: {\n items: cart.items\n },\n customerData: cart.customer,\n options: cart.options\n }\n })\n\n if (!response.success) {\n throw new Error(`Failed to generate checkout URL: ${response.error || 'Unknown error'}`)\n }\n\n return response.checkoutUrl\n }\n\n /**\n * Generate a single product checkout URL\n */\n async generateProductCheckoutUrl(productId: string, quantity: number = 1, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ productId, quantity }],\n customer,\n options\n })\n }\n\n /**\n * Generate a subscription checkout URL\n */\n async generateSubscriptionCheckoutUrl(productId: string, paymentPlanId: string, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ \n productId, \n quantity: 1,\n metadata: { \n isSubscription: true, \n paymentPlanId \n }\n }],\n customer,\n options\n })\n }\n\n /**\n * Validate cart data before checkout\n */\n async validateCart(cart: CartData): Promise<CartValidation> {\n try {\n const response = await this.makeRequest('/api/checkout/validate-cart', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: cart.items,\n customer: cart.customer\n }\n })\n\n return response\n } catch (error) {\n return {\n valid: false,\n errors: [error instanceof Error ? error.message : 'Validation failed'],\n warnings: [],\n estimatedTotal: 0\n }\n }\n }\n\n /**\n * Get order status\n */\n async getOrderStatus(orderId: string): Promise<OrderStatus> {\n const response = await this.makeRequest(`/api/checkout/order-status/${orderId}?businessId=${this.businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get order status: ${response.error}`)\n }\n\n return response\n }\n\n // New: Subscription Management Methods\n\n /**\n * Create a new subscription\n */\n async createSubscription(data: CreateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest('/api/subscriptions/create', {\n method: 'POST',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to create subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscription by ID\n */\n async getSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a business\n */\n async getBusinessSubscriptions(businessId: string, status?: string, limit?: number): Promise<Subscription[]> {\n const params = new URLSearchParams({ businessId })\n if (status) params.append('status', status)\n if (limit) params.append('limit', limit.toString())\n\n const response = await this.makeRequest(`/api/subscriptions/business?${params}`)\n \n if (response.error) {\n throw new Error(`Failed to get business subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a customer\n */\n async getCustomerSubscriptions(customerEmail: string): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/customer/${encodeURIComponent(customerEmail)}`)\n \n if (response.error) {\n throw new Error(`Failed to get customer subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Update subscription status\n */\n async updateSubscription(subscriptionId: string, data: UpdateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/update`, {\n method: 'PUT',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to update subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Cancel subscription\n */\n async cancelSubscription(subscriptionId: string, effectiveDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/cancel`, {\n method: 'PUT',\n body: { effectiveDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to cancel subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Pause subscription\n */\n async pauseSubscription(subscriptionId: string, resumeDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/pause`, {\n method: 'PUT',\n body: { resumeDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to pause subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Resume subscription\n */\n async resumeSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/resume`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to resume subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Process subscription renewal\n */\n async processSubscriptionRenewal(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/renew`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to process subscription renewal: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions due for renewal\n */\n async getSubscriptionsDueForRenewal(daysAhead: number = 7): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/due-for-renewal?daysAhead=${daysAhead}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscriptions due for renewal: ${response.error}`)\n }\n\n return response\n }\n\n // New: Product Management Methods\n\n /**\n * Get subscription products for a business\n */\n async getSubscriptionProducts(businessId: string): Promise<SubscriptionProduct[]> {\n const response = await this.makeRequest(`/api/products/subscriptions?businessId=${businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription products: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get product with payment plans\n */\n async getProductWithPaymentPlans(productId: string): Promise<SubscriptionProduct> {\n const response = await this.makeRequest(`/api/products/${productId}`)\n \n if (response.error) {\n throw new Error(`Failed to get product: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Send webhook event\n */\n async sendWebhookEvent(orderId: string, status: string, customerData?: any, metadata?: Record<string, any>): Promise<void> {\n await this.makeRequest('/api/webhooks/order-update', {\n method: 'POST',\n body: {\n orderId,\n status,\n customerData,\n metadata\n }\n })\n }\n\n /**\n * Track cart view for analytics\n */\n async trackCartView(cartId: string, cartData: CartData): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/cart-view', {\n method: 'POST',\n body: {\n cartId,\n businessId: this.businessId,\n cartData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track cart view:', error)\n }\n }\n\n /**\n * Track checkout completion for analytics\n */\n async trackCheckoutComplete(orderId: string, checkoutData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/checkout-complete', {\n method: 'POST',\n body: {\n orderId,\n businessId: this.businessId,\n checkoutData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track checkout completion:', error)\n }\n }\n\n /**\n * Track subscription creation for analytics\n */\n async trackSubscriptionCreated(subscriptionId: string, subscriptionData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/subscription-created', {\n method: 'POST',\n body: {\n subscriptionId,\n businessId: this.businessId,\n subscriptionData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track subscription creation:', error)\n }\n }\n\n /**\n * Generate cart hash for caching\n */\n generateCartHash(cart: CartData): string {\n const cartString = JSON.stringify({\n items: cart.items.sort((a, b) => a.productId.localeCompare(b.productId)),\n customer: cart.customer ? { email: cart.customer.email } : null\n })\n \n // Simple hash function for cart identification\n let hash = 0\n for (let i = 0; i < cartString.length; i++) {\n const char = cartString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash // Convert to 32-bit integer\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Generate subscription hash for caching\n */\n generateSubscriptionHash(subscriptionData: CreateSubscriptionData): string {\n const subscriptionString = JSON.stringify({\n businessId: subscriptionData.businessId,\n productId: subscriptionData.productId,\n customerEmail: subscriptionData.customerEmail,\n paymentPlanId: subscriptionData.paymentPlanId\n })\n \n let hash = 0\n for (let i = 0; i < subscriptionString.length; i++) {\n const char = subscriptionString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Make HTTP request to Torque API\n */\n private async makeRequest(endpoint: string, options: { method?: string; body?: any; headers?: Record<string, string> } = {}): Promise<any> {\n const url = `${this.baseUrl}${endpoint}`\n \n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), this.timeout)\n\n try {\n const { body, ...fetchOptions } = options\n const response = await fetch(url, {\n ...fetchOptions,\n method: options.method || 'GET',\n body: body ? JSON.stringify(body) : undefined,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.apiKey}`,\n ...options.headers\n },\n signal: controller.signal\n })\n\n clearTimeout(timeoutId)\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`)\n }\n\n return await response.json()\n } catch (error) {\n clearTimeout(timeoutId)\n \n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new Error('Request timeout')\n }\n throw error\n }\n \n throw new Error('Request failed')\n }\n }\n}\n\n// Export default instance factory\nexport const createTorqueCheckout = (config: TorqueConfig) => new TorqueCheckout(config)\n\n// Export types\nexport type {\n CartItem,\n CustomerData,\n CartOptions,\n CartData,\n PaymentPlan,\n SubscriptionProduct,\n Subscription,\n CreateSubscriptionData,\n UpdateSubscriptionData,\n TorqueConfig,\n CheckoutResponse,\n OrderStatus,\n CartValidation\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AAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACzD,gBAAA,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,CAAA,KAAA,EAAQ,QAAQ,CAAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE,CAAC;YACzF;AAEA,YAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE;QAC9B;QAAE,OAAO,KAAK,EAAE;YACd,YAAY,CAAC,SAAS,CAAC;AAEvB,YAAA,IAAI,KAAK,YAAY,KAAK,EAAE;AAC1B,gBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AAC/B,oBAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;gBACpC;AACA,gBAAA,MAAM,KAAK;YACb;AAEA,YAAA,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;QACnC;IACF;AACD;AAED;AACO,MAAM,oBAAoB,GAAG,CAAC,MAAoB,KAAK,IAAI,cAAc,CAAC,MAAM;;;;"}
package/dist/index.js CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  class TorqueCheckout {
4
4
  constructor(config) {
5
- this.baseUrl = '';
5
+ this.baseUrl = 'https://app.torque.fi';
6
6
  this.businessId = config.businessId;
7
7
  this.apiKey = config.apiKey;
8
+ this.baseUrl = config.baseUrl || 'https://app.torque.fi';
8
9
  this.timeout = config.timeout || 30000;
9
10
  }
10
11
  /**
@@ -345,8 +346,11 @@ class TorqueCheckout {
345
346
  const controller = new AbortController();
346
347
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
347
348
  try {
349
+ const { body, ...fetchOptions } = options;
348
350
  const response = await fetch(url, {
349
- ...options,
351
+ ...fetchOptions,
352
+ method: options.method || 'GET',
353
+ body: body ? JSON.stringify(body) : undefined,
350
354
  headers: {
351
355
  'Content-Type': 'application/json',
352
356
  'Authorization': `Bearer ${this.apiKey}`,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export interface CartItem {\n productId: string\n quantity: number\n variant?: string\n price?: number\n metadata?: Record<string, any>\n}\n\nexport interface CustomerData {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n shippingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n billingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n}\n\nexport interface CartOptions {\n domain?: string\n expiresIn?: number\n metadata?: Record<string, any>\n redirectUrl?: string\n}\n\nexport interface CartData {\n items: CartItem[]\n customer?: CustomerData\n options?: CartOptions\n}\n\n// New: Payment Plan Interface\nexport interface PaymentPlan {\n id: string\n name: string\n price: number\n interval: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\"\n intervalCount: number\n trialDays?: number\n maxCycles?: number\n description?: string\n}\n\n// New: Subscription Product Interface\nexport interface SubscriptionProduct {\n id: string\n name: string\n description?: string\n isSubscription: boolean\n paymentPlans?: PaymentPlan[]\n subscriptionContract?: {\n address: string\n chainId: number\n abi?: string\n }\n basePrice: number\n currency: string\n image?: string\n images?: string[]\n requiresShipping: boolean\n shippingCost?: number\n taxRate?: number\n inventory: number\n status: 'active' | 'inactive' | 'draft' | 'archived'\n sku?: string\n category?: string\n tags?: string[]\n variants?: Array<{\n id: string\n name: string\n price: number\n inventory?: number\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Interface\nexport interface Subscription {\n id: string\n businessId: string\n productId: string\n customerId?: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n status: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n currentPeriodStart: number\n currentPeriodEnd: number\n nextBillingDate: number\n trialStart?: number\n trialEnd?: number\n totalCycles: number\n maxCycles?: number\n lastPaymentDate?: number\n nextPaymentAmount: number\n currency: string\n contractSubscriptionId?: string\n contractAddress?: string\n billingHistory?: Array<{\n cycleNumber: number\n amount: number\n date: number\n status: \"paid\" | \"failed\" | \"pending\"\n transactionId?: string\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Creation Data\nexport interface CreateSubscriptionData {\n businessId: string\n productId: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n customerId?: string\n metadata?: any\n}\n\n// New: Subscription Update Data\nexport interface UpdateSubscriptionData {\n status?: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n pauseUntil?: number\n resumeDate?: number\n metadata?: any\n}\n\nexport interface TorqueConfig {\n businessId?: string\n apiKey?: string\n timeout?: number\n}\n\nexport interface BusinessCreationData {\n name: string\n description?: string\n email: string\n phone?: string\n website?: string\n currency?: string\n timezone?: string\n walletAddress: string\n logo?: string\n}\n\nexport interface BusinessProfile {\n id: string\n name: string\n email: string\n apiKey: string\n walletAddress: string\n logo?: string\n website?: string\n status: 'active' | 'pending' | 'suspended'\n}\n\nexport interface CheckoutResponse {\n success: boolean\n checkoutUrl: string\n expiresAt: string\n cartSummary: {\n itemCount: number\n productCount: number\n estimatedTotal: number\n }\n business: {\n id: string\n name: string\n logo?: string\n }\n}\n\nexport interface OrderStatus {\n orderId: string\n status: string\n customer: {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n } | null\n items: Array<{\n productId: string\n productName: string\n productImage?: string\n quantity: number\n variant?: string\n price: number\n total: number\n }>\n totals: {\n subtotal: number\n shipping: number\n tax: number\n total: number\n }\n paymentStatus: string\n shippingAddress?: any\n billingAddress?: any\n createdAt: number\n updatedAt: number\n metadata: Record<string, any>\n}\n\nexport interface CartValidation {\n valid: boolean\n errors: string[]\n warnings: string[]\n estimatedTotal: number\n}\n\nexport class TorqueCheckout {\n private businessId: string\n private apiKey: string\n private baseUrl: string = ''\n private timeout: number\n\n constructor(config: TorqueConfig) {\n this.businessId = config.businessId\n this.apiKey = config.apiKey\n this.timeout = config.timeout || 30000\n }\n\n /**\n * Generate a cart checkout URL\n */\n async generateCartCheckoutUrl(cart: CartData): Promise<string> {\n const response = await this.makeRequest('/api/torque-checkout', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: {\n items: cart.items\n },\n customerData: cart.customer,\n options: cart.options\n }\n })\n\n if (!response.success) {\n throw new Error(`Failed to generate checkout URL: ${response.error || 'Unknown error'}`)\n }\n\n return response.checkoutUrl\n }\n\n /**\n * Generate a single product checkout URL\n */\n async generateProductCheckoutUrl(productId: string, quantity: number = 1, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ productId, quantity }],\n customer,\n options\n })\n }\n\n /**\n * Generate a subscription checkout URL\n */\n async generateSubscriptionCheckoutUrl(productId: string, paymentPlanId: string, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ \n productId, \n quantity: 1,\n metadata: { \n isSubscription: true, \n paymentPlanId \n }\n }],\n customer,\n options\n })\n }\n\n /**\n * Validate cart data before checkout\n */\n async validateCart(cart: CartData): Promise<CartValidation> {\n try {\n const response = await this.makeRequest('/api/checkout/validate-cart', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: cart.items,\n customer: cart.customer\n }\n })\n\n return response\n } catch (error) {\n return {\n valid: false,\n errors: [error instanceof Error ? error.message : 'Validation failed'],\n warnings: [],\n estimatedTotal: 0\n }\n }\n }\n\n /**\n * Get order status\n */\n async getOrderStatus(orderId: string): Promise<OrderStatus> {\n const response = await this.makeRequest(`/api/checkout/order-status/${orderId}?businessId=${this.businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get order status: ${response.error}`)\n }\n\n return response\n }\n\n // New: Subscription Management Methods\n\n /**\n * Create a new subscription\n */\n async createSubscription(data: CreateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest('/api/subscriptions/create', {\n method: 'POST',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to create subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscription by ID\n */\n async getSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a business\n */\n async getBusinessSubscriptions(businessId: string, status?: string, limit?: number): Promise<Subscription[]> {\n const params = new URLSearchParams({ businessId })\n if (status) params.append('status', status)\n if (limit) params.append('limit', limit.toString())\n\n const response = await this.makeRequest(`/api/subscriptions/business?${params}`)\n \n if (response.error) {\n throw new Error(`Failed to get business subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a customer\n */\n async getCustomerSubscriptions(customerEmail: string): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/customer/${encodeURIComponent(customerEmail)}`)\n \n if (response.error) {\n throw new Error(`Failed to get customer subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Update subscription status\n */\n async updateSubscription(subscriptionId: string, data: UpdateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/update`, {\n method: 'PUT',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to update subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Cancel subscription\n */\n async cancelSubscription(subscriptionId: string, effectiveDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/cancel`, {\n method: 'PUT',\n body: { effectiveDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to cancel subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Pause subscription\n */\n async pauseSubscription(subscriptionId: string, resumeDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/pause`, {\n method: 'PUT',\n body: { resumeDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to pause subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Resume subscription\n */\n async resumeSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/resume`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to resume subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Process subscription renewal\n */\n async processSubscriptionRenewal(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/renew`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to process subscription renewal: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions due for renewal\n */\n async getSubscriptionsDueForRenewal(daysAhead: number = 7): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/due-for-renewal?daysAhead=${daysAhead}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscriptions due for renewal: ${response.error}`)\n }\n\n return response\n }\n\n // New: Product Management Methods\n\n /**\n * Get subscription products for a business\n */\n async getSubscriptionProducts(businessId: string): Promise<SubscriptionProduct[]> {\n const response = await this.makeRequest(`/api/products/subscriptions?businessId=${businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription products: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get product with payment plans\n */\n async getProductWithPaymentPlans(productId: string): Promise<SubscriptionProduct> {\n const response = await this.makeRequest(`/api/products/${productId}`)\n \n if (response.error) {\n throw new Error(`Failed to get product: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Send webhook event\n */\n async sendWebhookEvent(orderId: string, status: string, customerData?: any, metadata?: Record<string, any>): Promise<void> {\n await this.makeRequest('/api/webhooks/order-update', {\n method: 'POST',\n body: {\n orderId,\n status,\n customerData,\n metadata\n }\n })\n }\n\n /**\n * Track cart view for analytics\n */\n async trackCartView(cartId: string, cartData: CartData): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/cart-view', {\n method: 'POST',\n body: {\n cartId,\n businessId: this.businessId,\n cartData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track cart view:', error)\n }\n }\n\n /**\n * Track checkout completion for analytics\n */\n async trackCheckoutComplete(orderId: string, checkoutData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/checkout-complete', {\n method: 'POST',\n body: {\n orderId,\n businessId: this.businessId,\n checkoutData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track checkout completion:', error)\n }\n }\n\n /**\n * Track subscription creation for analytics\n */\n async trackSubscriptionCreated(subscriptionId: string, subscriptionData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/subscription-created', {\n method: 'POST',\n body: {\n subscriptionId,\n businessId: this.businessId,\n subscriptionData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track subscription creation:', error)\n }\n }\n\n /**\n * Generate cart hash for caching\n */\n generateCartHash(cart: CartData): string {\n const cartString = JSON.stringify({\n items: cart.items.sort((a, b) => a.productId.localeCompare(b.productId)),\n customer: cart.customer ? { email: cart.customer.email } : null\n })\n \n // Simple hash function for cart identification\n let hash = 0\n for (let i = 0; i < cartString.length; i++) {\n const char = cartString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash // Convert to 32-bit integer\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Generate subscription hash for caching\n */\n generateSubscriptionHash(subscriptionData: CreateSubscriptionData): string {\n const subscriptionString = JSON.stringify({\n businessId: subscriptionData.businessId,\n productId: subscriptionData.productId,\n customerEmail: subscriptionData.customerEmail,\n paymentPlanId: subscriptionData.paymentPlanId\n })\n \n let hash = 0\n for (let i = 0; i < subscriptionString.length; i++) {\n const char = subscriptionString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Make HTTP request to Torque API\n */\n private async makeRequest(endpoint: string, options: RequestInit = {}): Promise<any> {\n const url = `${this.baseUrl}${endpoint}`\n \n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), this.timeout)\n\n try {\n const response = await fetch(url, {\n ...options,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.apiKey}`,\n ...options.headers\n },\n signal: controller.signal\n })\n\n clearTimeout(timeoutId)\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`)\n }\n\n return await response.json()\n } catch (error) {\n clearTimeout(timeoutId)\n \n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new Error('Request timeout')\n }\n throw error\n }\n \n throw new Error('Request failed')\n }\n }\n}\n\n// Export default instance factory\nexport const createTorqueCheckout = (config: TorqueConfig) => new TorqueCheckout(config)\n\n// Export types\nexport type {\n CartItem,\n CustomerData,\n CartOptions,\n CartData,\n PaymentPlan,\n SubscriptionProduct,\n Subscription,\n CreateSubscriptionData,\n UpdateSubscriptionData,\n TorqueConfig,\n CheckoutResponse,\n OrderStatus,\n CartValidation\n}\n"],"names":[],"mappings":";;MAkOa,cAAc,CAAA;AAMzB,IAAA,WAAA,CAAY,MAAoB,EAAA;QAHxB,IAAA,CAAA,OAAO,GAAW,EAAE;AAI1B,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK;IACxC;AAEA;;AAEG;IACH,MAAM,uBAAuB,CAAC,IAAc,EAAA;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,EAAE;AAC9D,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,IAAI,EAAE;gBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;AAC3B,gBAAA,IAAI,EAAE;oBACJ,KAAK,EAAE,IAAI,CAAC;AACb,iBAAA;gBACD,YAAY,EAAE,IAAI,CAAC,QAAQ;gBAC3B,OAAO,EAAE,IAAI,CAAC;AACf;AACF,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;Y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AA,CAAE;oBACxC,GAAG,OAAO,CAAC;AACZ,iBAAA;gBACD,MAAM,EAAE,UAAU,CAAC;AACpB,aAAA,CAAC;YAEF,YAAY,CAAC,SAAS,CAAC;AAEvB,YAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AAChB,gBAAA,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACzD,gBAAA,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,CAAA,KAAA,EAAQ,QAAQ,CAAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE,CAAC;YACzF;AAEA,YAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE;QAC9B;QAAE,OAAO,KAAK,EAAE;YACd,YAAY,CAAC,SAAS,CAAC;AAEvB,YAAA,IAAI,KAAK,YAAY,KAAK,EAAE;AAC1B,gBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AAC/B,oBAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;gBACpC;AACA,gBAAA,MAAM,KAAK;YACb;AAEA,YAAA,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;QACnC;IACF;AACD;AAED;AACO,MAAM,oBAAoB,GAAG,CAAC,MAAoB,KAAK,IAAI,cAAc,CAAC,MAAM;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export interface CartItem {\n productId: string\n quantity: number\n variant?: string\n price?: number\n metadata?: Record<string, any>\n}\n\nexport interface CustomerData {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n shippingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n billingAddress?: {\n street: string\n city: string\n state: string\n zipCode: string\n country: string\n }\n}\n\nexport interface CartOptions {\n domain?: string\n expiresIn?: number\n metadata?: Record<string, any>\n redirectUrl?: string\n}\n\nexport interface CartData {\n items: CartItem[]\n customer?: CustomerData\n options?: CartOptions\n}\n\n// New: Payment Plan Interface\nexport interface PaymentPlan {\n id: string\n name: string\n price: number\n interval: \"weekly\" | \"monthly\" | \"quarterly\" | \"yearly\"\n intervalCount: number\n trialDays?: number\n maxCycles?: number\n description?: string\n}\n\n// New: Subscription Product Interface\nexport interface SubscriptionProduct {\n id: string\n name: string\n description?: string\n isSubscription: boolean\n paymentPlans?: PaymentPlan[]\n subscriptionContract?: {\n address: string\n chainId: number\n abi?: string\n }\n basePrice: number\n currency: string\n image?: string\n images?: string[]\n requiresShipping: boolean\n shippingCost?: number\n taxRate?: number\n inventory: number\n status: 'active' | 'inactive' | 'draft' | 'archived'\n sku?: string\n category?: string\n tags?: string[]\n variants?: Array<{\n id: string\n name: string\n price: number\n inventory?: number\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Interface\nexport interface Subscription {\n id: string\n businessId: string\n productId: string\n customerId?: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n status: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n currentPeriodStart: number\n currentPeriodEnd: number\n nextBillingDate: number\n trialStart?: number\n trialEnd?: number\n totalCycles: number\n maxCycles?: number\n lastPaymentDate?: number\n nextPaymentAmount: number\n currency: string\n contractSubscriptionId?: string\n contractAddress?: string\n billingHistory?: Array<{\n cycleNumber: number\n amount: number\n date: number\n status: \"paid\" | \"failed\" | \"pending\"\n transactionId?: string\n }>\n metadata?: any\n createdAt: number\n updatedAt: number\n}\n\n// New: Subscription Creation Data\nexport interface CreateSubscriptionData {\n businessId: string\n productId: string\n customerEmail: string\n customerName: string\n paymentPlanId: string\n customerId?: string\n metadata?: any\n}\n\n// New: Subscription Update Data\nexport interface UpdateSubscriptionData {\n status?: \"active\" | \"cancelled\" | \"paused\" | \"expired\" | \"past_due\"\n pauseUntil?: number\n resumeDate?: number\n metadata?: any\n}\n\nexport interface TorqueConfig {\n businessId: string\n apiKey: string\n baseUrl?: string\n timeout?: number\n}\n\nexport interface BusinessCreationData {\n name: string\n description?: string\n email: string\n phone?: string\n website?: string\n currency?: string\n timezone?: string\n walletAddress: string\n logo?: string\n}\n\nexport interface BusinessProfile {\n id: string\n name: string\n email: string\n apiKey: string\n walletAddress: string\n logo?: string\n website?: string\n status: 'active' | 'pending' | 'suspended'\n}\n\nexport interface CheckoutResponse {\n success: boolean\n checkoutUrl: string\n expiresAt: string\n cartSummary: {\n itemCount: number\n productCount: number\n estimatedTotal: number\n }\n business: {\n id: string\n name: string\n logo?: string\n }\n}\n\nexport interface OrderStatus {\n orderId: string\n status: string\n customer: {\n email: string\n firstName?: string\n lastName?: string\n phone?: string\n } | null\n items: Array<{\n productId: string\n productName: string\n productImage?: string\n quantity: number\n variant?: string\n price: number\n total: number\n }>\n totals: {\n subtotal: number\n shipping: number\n tax: number\n total: number\n }\n paymentStatus: string\n shippingAddress?: any\n billingAddress?: any\n createdAt: number\n updatedAt: number\n metadata: Record<string, any>\n}\n\nexport interface CartValidation {\n valid: boolean\n errors: string[]\n warnings: string[]\n estimatedTotal: number\n}\n\nexport class TorqueCheckout {\n private businessId: string\n private apiKey: string\n private baseUrl: string = 'https://app.torque.fi'\n private timeout: number\n\n constructor(config: TorqueConfig) {\n this.businessId = config.businessId\n this.apiKey = config.apiKey\n this.baseUrl = config.baseUrl || 'https://app.torque.fi'\n this.timeout = config.timeout || 30000\n }\n\n /**\n * Generate a cart checkout URL\n */\n async generateCartCheckoutUrl(cart: CartData): Promise<string> {\n const response = await this.makeRequest('/api/torque-checkout', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: {\n items: cart.items\n },\n customerData: cart.customer,\n options: cart.options\n }\n })\n\n if (!response.success) {\n throw new Error(`Failed to generate checkout URL: ${response.error || 'Unknown error'}`)\n }\n\n return response.checkoutUrl\n }\n\n /**\n * Generate a single product checkout URL\n */\n async generateProductCheckoutUrl(productId: string, quantity: number = 1, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ productId, quantity }],\n customer,\n options\n })\n }\n\n /**\n * Generate a subscription checkout URL\n */\n async generateSubscriptionCheckoutUrl(productId: string, paymentPlanId: string, customer?: CustomerData, options?: CartOptions): Promise<string> {\n return this.generateCartCheckoutUrl({\n items: [{ \n productId, \n quantity: 1,\n metadata: { \n isSubscription: true, \n paymentPlanId \n }\n }],\n customer,\n options\n })\n }\n\n /**\n * Validate cart data before checkout\n */\n async validateCart(cart: CartData): Promise<CartValidation> {\n try {\n const response = await this.makeRequest('/api/checkout/validate-cart', {\n method: 'POST',\n body: {\n businessId: this.businessId,\n cart: cart.items,\n customer: cart.customer\n }\n })\n\n return response\n } catch (error) {\n return {\n valid: false,\n errors: [error instanceof Error ? error.message : 'Validation failed'],\n warnings: [],\n estimatedTotal: 0\n }\n }\n }\n\n /**\n * Get order status\n */\n async getOrderStatus(orderId: string): Promise<OrderStatus> {\n const response = await this.makeRequest(`/api/checkout/order-status/${orderId}?businessId=${this.businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get order status: ${response.error}`)\n }\n\n return response\n }\n\n // New: Subscription Management Methods\n\n /**\n * Create a new subscription\n */\n async createSubscription(data: CreateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest('/api/subscriptions/create', {\n method: 'POST',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to create subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscription by ID\n */\n async getSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a business\n */\n async getBusinessSubscriptions(businessId: string, status?: string, limit?: number): Promise<Subscription[]> {\n const params = new URLSearchParams({ businessId })\n if (status) params.append('status', status)\n if (limit) params.append('limit', limit.toString())\n\n const response = await this.makeRequest(`/api/subscriptions/business?${params}`)\n \n if (response.error) {\n throw new Error(`Failed to get business subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions for a customer\n */\n async getCustomerSubscriptions(customerEmail: string): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/customer/${encodeURIComponent(customerEmail)}`)\n \n if (response.error) {\n throw new Error(`Failed to get customer subscriptions: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Update subscription status\n */\n async updateSubscription(subscriptionId: string, data: UpdateSubscriptionData): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/update`, {\n method: 'PUT',\n body: data\n })\n\n if (response.error) {\n throw new Error(`Failed to update subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Cancel subscription\n */\n async cancelSubscription(subscriptionId: string, effectiveDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/cancel`, {\n method: 'PUT',\n body: { effectiveDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to cancel subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Pause subscription\n */\n async pauseSubscription(subscriptionId: string, resumeDate?: number): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/pause`, {\n method: 'PUT',\n body: { resumeDate }\n })\n\n if (response.error) {\n throw new Error(`Failed to pause subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Resume subscription\n */\n async resumeSubscription(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/resume`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to resume subscription: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Process subscription renewal\n */\n async processSubscriptionRenewal(subscriptionId: string): Promise<Subscription> {\n const response = await this.makeRequest(`/api/subscriptions/${subscriptionId}/renew`, {\n method: 'PUT'\n })\n\n if (response.error) {\n throw new Error(`Failed to process subscription renewal: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get subscriptions due for renewal\n */\n async getSubscriptionsDueForRenewal(daysAhead: number = 7): Promise<Subscription[]> {\n const response = await this.makeRequest(`/api/subscriptions/due-for-renewal?daysAhead=${daysAhead}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscriptions due for renewal: ${response.error}`)\n }\n\n return response\n }\n\n // New: Product Management Methods\n\n /**\n * Get subscription products for a business\n */\n async getSubscriptionProducts(businessId: string): Promise<SubscriptionProduct[]> {\n const response = await this.makeRequest(`/api/products/subscriptions?businessId=${businessId}`)\n \n if (response.error) {\n throw new Error(`Failed to get subscription products: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Get product with payment plans\n */\n async getProductWithPaymentPlans(productId: string): Promise<SubscriptionProduct> {\n const response = await this.makeRequest(`/api/products/${productId}`)\n \n if (response.error) {\n throw new Error(`Failed to get product: ${response.error}`)\n }\n\n return response\n }\n\n /**\n * Send webhook event\n */\n async sendWebhookEvent(orderId: string, status: string, customerData?: any, metadata?: Record<string, any>): Promise<void> {\n await this.makeRequest('/api/webhooks/order-update', {\n method: 'POST',\n body: {\n orderId,\n status,\n customerData,\n metadata\n }\n })\n }\n\n /**\n * Track cart view for analytics\n */\n async trackCartView(cartId: string, cartData: CartData): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/cart-view', {\n method: 'POST',\n body: {\n cartId,\n businessId: this.businessId,\n cartData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track cart view:', error)\n }\n }\n\n /**\n * Track checkout completion for analytics\n */\n async trackCheckoutComplete(orderId: string, checkoutData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/checkout-complete', {\n method: 'POST',\n body: {\n orderId,\n businessId: this.businessId,\n checkoutData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track checkout completion:', error)\n }\n }\n\n /**\n * Track subscription creation for analytics\n */\n async trackSubscriptionCreated(subscriptionId: string, subscriptionData: any): Promise<void> {\n try {\n await this.makeRequest('/api/analytics/subscription-created', {\n method: 'POST',\n body: {\n subscriptionId,\n businessId: this.businessId,\n subscriptionData,\n timestamp: Date.now()\n }\n })\n } catch (error) {\n console.warn('Failed to track subscription creation:', error)\n }\n }\n\n /**\n * Generate cart hash for caching\n */\n generateCartHash(cart: CartData): string {\n const cartString = JSON.stringify({\n items: cart.items.sort((a, b) => a.productId.localeCompare(b.productId)),\n customer: cart.customer ? { email: cart.customer.email } : null\n })\n \n // Simple hash function for cart identification\n let hash = 0\n for (let i = 0; i < cartString.length; i++) {\n const char = cartString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash // Convert to 32-bit integer\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Generate subscription hash for caching\n */\n generateSubscriptionHash(subscriptionData: CreateSubscriptionData): string {\n const subscriptionString = JSON.stringify({\n businessId: subscriptionData.businessId,\n productId: subscriptionData.productId,\n customerEmail: subscriptionData.customerEmail,\n paymentPlanId: subscriptionData.paymentPlanId\n })\n \n let hash = 0\n for (let i = 0; i < subscriptionString.length; i++) {\n const char = subscriptionString.charCodeAt(i)\n hash = ((hash << 5) - hash) + char\n hash = hash & hash\n }\n return Math.abs(hash).toString(36)\n }\n\n /**\n * Make HTTP request to Torque API\n */\n private async makeRequest(endpoint: string, options: { method?: string; body?: any; headers?: Record<string, string> } = {}): Promise<any> {\n const url = `${this.baseUrl}${endpoint}`\n \n const controller = new AbortController()\n const timeoutId = setTimeout(() => controller.abort(), this.timeout)\n\n try {\n const { body, ...fetchOptions } = options\n const response = await fetch(url, {\n ...fetchOptions,\n method: options.method || 'GET',\n body: body ? JSON.stringify(body) : undefined,\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.apiKey}`,\n ...options.headers\n },\n signal: controller.signal\n })\n\n clearTimeout(timeoutId)\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}))\n throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`)\n }\n\n return await response.json()\n } catch (error) {\n clearTimeout(timeoutId)\n \n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new Error('Request timeout')\n }\n throw error\n }\n \n throw new Error('Request failed')\n }\n }\n}\n\n// Export default instance factory\nexport const createTorqueCheckout = (config: TorqueConfig) => new TorqueCheckout(config)\n\n// Export types\nexport type {\n CartItem,\n CustomerData,\n CartOptions,\n CartData,\n PaymentPlan,\n SubscriptionProduct,\n Subscription,\n CreateSubscriptionData,\n UpdateSubscriptionData,\n TorqueConfig,\n CheckoutResponse,\n OrderStatus,\n CartValidation\n}\n"],"names":[],"mappings":";;MAmOa,cAAc,CAAA;AAMzB,IAAA,WAAA,CAAY,MAAoB,EAAA;QAHxB,IAAA,CAAA,OAAO,GAAW,uBAAuB;AAI/C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,uBAAuB;QACxD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK;IACxC;AAEA;;AAEG;IACH,MAAM,uBAAuB,CAAC,IAAc,EAAA;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,EAAE;AAC9D,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,IAAI,EAAE;gBACJ,UAAU,EAAE,IAAI,CAAC,UAAU;AAC3B,gBAAA,IAAI,EAAE;oBACJ,KAAK,EAAE,IAAI,CAAC;AACb,iBAAA;gBACD,YAAY,EAAE,IAAI,CAAC,QAAQ;gBAC3B,OAAO,EAAE,IAAI,CAAC;AACf;AACF,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,CAAA,iCAAA,EAAoC,QAAQ,CAAC,KAAK,IAAI,eAAe,CAAA,CAAE,CAAC;QAC1F;QAEA,OAAO,Q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cAAc,EAAE,kBAAkB;AAClC,oBAAA,eAAe,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,MAAM,CAAA,CAAE;oBACxC,GAAG,OAAO,CAAC;AACZ,iBAAA;gBACD,MAAM,EAAE,UAAU,CAAC;AACpB,aAAA,CAAC;YAEF,YAAY,CAAC,SAAS,CAAC;AAEvB,YAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AAChB,gBAAA,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AACzD,gBAAA,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,CAAA,KAAA,EAAQ,QAAQ,CAAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE,CAAC;YACzF;AAEA,YAAA,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE;QAC9B;QAAE,OAAO,KAAK,EAAE;YACd,YAAY,CAAC,SAAS,CAAC;AAEvB,YAAA,IAAI,KAAK,YAAY,KAAK,EAAE;AAC1B,gBAAA,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AAC/B,oBAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;gBACpC;AACA,gBAAA,MAAM,KAAK;YACb;AAEA,YAAA,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC;QACnC;IACF;AACD;AAED;AACO,MAAM,oBAAoB,GAAG,CAAC,MAAoB,KAAK,IAAI,cAAc,CAAC,MAAM;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "torque-checkout",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "Official Torque checkout SDK for eCommerce integrations",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",