@orcarail/node 1.0.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/checkout.ts","../src/resources/payment-intents.ts","../src/webhooks.ts","../src/index.ts"],"names":["createHmac","timingSafeEqual"],"mappings":";;;;;;;AAGO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,KAAA,CAAM,iBAAA,CAAkB,IAAA,EAAM,IAAA,CAAK,WAAW,CAAA;AAAA,EAChD;AACF;AAKO,IAAM,gBAAA,GAAN,cAA+B,aAAA,CAAc;AAAA;AAAA;AAAA;AAAA,EAIlC,UAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA;AAAA,EAEhB,WAAA,CACE,OAAA,EACA,UAAA,EACA,IAAA,EACA,OAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF;AAKO,IAAM,2BAAA,GAAN,cAA0C,gBAAA,CAAiB;AAAA,EAChE,WAAA,CAAY,UAAkB,8DAAA,EAAgE;AAC5F,IAAA,KAAA,CAAM,OAAA,EAAS,KAAK,sBAAsB,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,6BAAA;AAAA,EACd;AACF;AAKO,IAAM,kCAAA,GAAN,cAAiD,aAAA,CAAc;AAAA;AAAA;AAAA;AAAA,EAIpD,SAAA;AAA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AA,OACF;AAAA,IACF;AAGA,IAAA,MAAM,aACJ,OAAO,OAAA,KAAY,WAAW,OAAA,GAAU,OAAA,CAAQ,SAAS,MAAM,CAAA;AAEjE,IAAA,IAAI;AACF,MAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,UAAU,CAAA;AACnC,MAAA,OAAO,KAAA;AAAA,IACT,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,IAAI,kCAAA;AAAA,QACR,CAAA,8BAAA,EAAiC,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,eAAe,CAAA;AAAA,OAC3F;AAAA,IACF;AAAA,EACF;AACF,CAAA;;;AChCO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA,EAIJ,cAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA;AAAA,EAEC,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjB,WAAA,CACE,MAAA,EACA,SAAA,EACA,MAAA,EACA;AACA,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,UAAA,CAAW,MAAA,EAAQ,WAAW,MAAM,CAAA;AACtD,IAAA,IAAA,CAAK,cAAA,GAAiB,IAAI,cAAA,CAAe,IAAA,CAAK,MAAM,CAAA;AACpD,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,QAAA,CAAS,IAAA,CAAK,MAAM,CAAA;AACxC,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,QAAA,EAAS;AAAA,EAC/B;AACF;AAEA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Base error class for all OrcaRail errors\n */\nexport class OrcaRailError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'OrcaRailError';\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\n/**\n * Error thrown when the API returns a non-2xx status code\n */\nexport class OrcaRailAPIError extends OrcaRailError {\n /**\n * HTTP status code\n */\n public readonly statusCode: number;\n\n /**\n * Error type from the API response\n */\n public readonly type?: string;\n\n /**\n * Additional error details from the API\n */\n public readonly details?: unknown;\n\n constructor(\n message: string,\n statusCode: number,\n type?: string,\n details?: unknown\n ) {\n super(message);\n this.name = 'OrcaRailAPIError';\n this.statusCode = statusCode;\n this.type = type;\n this.details = details;\n }\n}\n\n/**\n * Error thrown when authentication fails (401)\n */\nexport class OrcaRailAuthenticationError extends OrcaRailAPIError {\n constructor(message: string = 'Authentication failed. Please check your API key and secret.') {\n super(message, 401, 'authentication_error');\n this.name = 'OrcaRailAuthenticationError';\n }\n}\n\n/**\n * Error thrown when webhook signature verification fails\n */\nexport class OrcaRailSignatureVerificationError extends OrcaRailError {\n /**\n * The signature that was provided\n */\n public readonly signature: string;\n\n constructor(\n message: string = 'Webhook signature verification failed',\n signature?: string\n ) {\n super(message);\n this.name = 'OrcaRailSignatureVerificationError';\n this.signature = signature || '';\n }\n}\n","import {\n OrcaRailAPIError,\n OrcaRailAuthenticationError,\n OrcaRailError,\n} from './errors';\nimport type { OrcaRailConfig } from './types';\n\nconst DEFAULT_BASE_URL = 'https://api.orcarail.com/api/v1';\nconst DEFAULT_TIMEOUT = 30000;\nconst SDK_VERSION = '1.0.0';\n\n/**\n * HTTP client for making requests to the OrcaRail API\n */\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly apiSecret: string;\n private readonly baseUrl: string;\n private readonly timeout: number;\n\n constructor(apiKey: string, apiSecret: string, config?: OrcaRailConfig) {\n if (!apiKey || !apiSecret) {\n throw new OrcaRailError('API key and secret are required');\n }\n\n this.apiKey = apiKey;\n this.apiSecret = apiSecret;\n this.baseUrl = config?.baseUrl || DEFAULT_BASE_URL;\n this.timeout = config?.timeout || DEFAULT_TIMEOUT;\n }\n\n /**\n * Create Basic Auth header from API key and secret\n */\n private getAuthHeader(): string {\n const credentials = Buffer.from(`${this.apiKey}:${this.apiSecret}`).toString(\n 'base64'\n );\n return `Basic ${credentials}`;\n }\n\n /**\n * Build full URL from path\n */\n private buildUrl(path: string): string {\n // Remove leading slash if present\n const cleanPath = path.startsWith('/') ? path.slice(1) : path;\n return `${this.baseUrl}/${cleanPath}`;\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n requireAuth: boolean = true\n ): Promise<T> {\n const url = this.buildUrl(path);\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'User-Agent': `orcarail-node/${SDK_VERSION}`,\n };\n\n if (requireAuth) {\n headers['Authorization'] = this.getAuthHeader();\n }\n\n const options: RequestInit = {\n method,\n headers,\n };\n\n if (body) {\n options.body = JSON.stringify(body);\n }\n\n // Create AbortController for timeout\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\n options.signal = controller.signal;\n\n try {\n const response = await fetch(url, options);\n clearTimeout(timeoutId);\n\n // Parse response body\n let responseData: unknown;\n const contentType = response.headers.get('content-type');\n if (contentType && contentType.includes('application/json')) {\n responseData = await response.json();\n } else {\n responseData = await response.text();\n }\n\n // Handle non-2xx responses\n if (!response.ok) {\n const errorMessage =\n typeof responseData === 'object' &&\n responseData !== null &&\n 'message' in responseData\n ? String((responseData as { message: unknown }).message)\n : `API request failed with status ${response.status}`;\n\n const errorType =\n typeof responseData === 'object' &&\n responseData !== null &&\n 'error' in responseData\n ? String((responseData as { error: unknown }).error)\n : undefined;\n\n if (response.status === 401) {\n throw new OrcaRailAuthenticationError(errorMessage);\n }\n\n throw new OrcaRailAPIError(\n errorMessage,\n response.status,\n errorType,\n responseData\n );\n }\n\n return responseData as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof OrcaRailError) {\n throw error;\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n throw new OrcaRailError(\n `Request timeout after ${this.timeout}ms`\n );\n }\n throw new OrcaRailError(`Request failed: ${error.message}`);\n }\n\n throw new OrcaRailError('An unknown error occurred');\n }\n }\n\n /**\n * GET request\n */\n public async get<T>(path: string, requireAuth: boolean = true): Promise<T> {\n return this.request<T>('GET', path, undefined, requireAuth);\n }\n\n /**\n * POST request\n */\n public async post<T>(\n path: string,\n body?: unknown,\n requireAuth: boolean = true\n ): Promise<T> {\n return this.request<T>('POST', path, body, requireAuth);\n }\n\n /**\n * PATCH request\n */\n public async patch<T>(\n path: string,\n body?: unknown,\n requireAuth: boolean = true\n ): Promise<T> {\n return this.request<T>('PATCH', path, body, requireAuth);\n }\n\n /**\n * PUT request\n */\n public async put<T>(\n path: string,\n body?: unknown,\n requireAuth: boolean = true\n ): Promise<T> {\n return this.request<T>('PUT', path, body, requireAuth);\n }\n\n /**\n * DELETE request\n */\n public async delete<T>(\n path: string,\n requireAuth: boolean = true\n ): Promise<T> {\n return this.request<T>('DELETE', path, undefined, requireAuth);\n }\n}\n","import { HttpClient } from '../client';\nimport type { PaymentIntent } from '../types';\n\n/**\n * Checkout resource for slug-based checkout flows (public endpoints)\n */\nexport class Checkout {\n private readonly client: HttpClient;\n\n constructor(client: HttpClient) {\n this.client = client;\n }\n\n /**\n * Get checkout details by slug\n *\n * @param slug - Checkout slug from the payment link URL\n * @returns Checkout details including payment intent\n */\n public async get(slug: string): Promise<PaymentIntent & Record<string, unknown>> {\n const path = `checkout/${encodeURIComponent(slug)}`;\n return this.client.get<PaymentIntent & Record<string, unknown>>(path, true);\n }\n\n /**\n * Cancel payment intent by checkout slug\n *\n * @param slug - Checkout slug from the payment link URL\n * @returns The canceled payment intent and optional cancel_url for redirect\n */\n public async cancel(slug: string): Promise<PaymentIntent & { cancel_url?: string }> {\n const path = `checkout/${encodeURIComponent(slug)}/cancel`;\n return this.client.post<PaymentIntent & { cancel_url?: string }>(path, {}, true);\n }\n}\n","import { HttpClient } from '../client';\nimport type {\n PaymentIntent,\n PaymentIntentConfirmParams,\n PaymentIntentCreateParams,\n PaymentIntentUpdateParams,\n} from '../types';\n\n/**\n * Payment Intents resource for managing payment intents\n */\nexport class PaymentIntents {\n private readonly client: HttpClient;\n\n constructor(client: HttpClient) {\n this.client = client;\n }\n\n /**\n * Create a new Payment Intent\n *\n * @param params - Payment Intent creation parameters\n * @returns The created Payment Intent\n */\n public async create(\n params: PaymentIntentCreateParams\n ): Promise<PaymentIntent> {\n // Ensure payment_method_types defaults to ['crypto'] if empty\n const requestBody = {\n ...params,\n payment_method_types:\n params.payment_method_types && params.payment_method_types.length > 0\n ? params.payment_method_types\n : ['crypto'],\n };\n\n return this.client.post<PaymentIntent>(\n 'payment_intents',\n requestBody,\n true\n );\n }\n\n /**\n * Retrieve a Payment Intent by ID\n *\n * @param id - Payment Intent ID (e.g., \"pi_1234567890\")\n * @returns The Payment Intent\n */\n public async retrieve(id: string): Promise<PaymentIntent> {\n const cleanId = id.startsWith('pi_') ? id : `pi_${id}`;\n const path = `payment_intents/${cleanId}`;\n\n return this.client.get<PaymentIntent>(path, true);\n }\n\n /**\n * Cancel a Payment Intent (API: POST /payment_intents/:id/cancel).\n * Use when the user is redirected to your cancel_url (e.g. https://yourapp.com/cancel?payment_intent=pi_20)\n * and you want to mark the intent as canceled on the backend.\n *\n * @param id - Payment Intent ID (e.g. \"pi_20\" or \"20\")\n * @returns The canceled Payment Intent\n *\n * @example\n * // When user lands on https://localhost:3001/cancel?payment_intent=pi_20\n * const intent = await orcarail.paymentIntents.cancel('pi_20');\n */\n public async cancel(id: string): Promise<PaymentIntent> {\n const cleanId = id.startsWith('pi_') ? id : `pi_${id}`;\n const path = `payment_intents/${cleanId}/cancel`;\n\n return this.client.post<PaymentIntent>(path, {}, true);\n }\n\n /**\n * Confirm a Payment Intent (API: POST /payment_intents/:id/confirm).\n * Redirects the customer to the hosted checkout page.\n *\n * @param id - Payment Intent ID (e.g. \"pi_20\" or \"20\")\n * @param params - Confirmation parameters including client_secret and return_url\n * @returns The confirmed Payment Intent\n *\n * @example\n * const intent = await orcarail.paymentIntents.confirm('pi_20', {\n * client_secret: intent.client_secret,\n * return_url: 'https://yourapp.com/return',\n * });\n */\n public async confirm(\n id: string,\n params: PaymentIntentConfirmParams\n ): Promise<PaymentIntent> {\n const cleanId = id.startsWith('pi_') ? id : `pi_${id}`;\n const path = `payment_intents/${cleanId}/confirm`;\n\n return this.client.post<PaymentIntent>(path, params, false);\n }\n\n /**\n * Complete a Payment Intent (API: POST /payment_intents/:id/complete).\n * Sets the intent to processing and fires the payment_intent.processing webhook.\n * Use when the user is redirected to your success/return URL (e.g. https://yourapp.com/success?payment_intent=pi_34).\n *\n * @param id - Payment Intent ID (e.g. \"pi_34\" or \"34\")\n * @returns The updated Payment Intent (status processing)\n *\n * @example\n * // When user lands on https://localhost:3001/success?payment_intent=pi_34\n * const intent = await orcarail.paymentIntents.complete('pi_34');\n */\n public async complete(id: string): Promise<PaymentIntent> {\n const cleanId = id.startsWith('pi_') ? id : `pi_${id}`;\n const path = `payment_intents/${cleanId}/complete`;\n\n return this.client.post<PaymentIntent>(path, {}, true);\n }\n\n /**\n * Update a Payment Intent\n *\n * @param id - Payment Intent ID\n * @param params - Update parameters (all optional)\n * @returns The updated Payment Intent\n */\n public async update(\n id: string,\n params: PaymentIntentUpdateParams\n ): Promise<PaymentIntent> {\n const cleanId = id.startsWith('pi_') ? id : `pi_${id}`;\n const path = `payment_intents/${cleanId}`;\n\n return this.client.patch<PaymentIntent>(path, params, true);\n }\n}\n","import { createHmac, timingSafeEqual } from 'crypto';\nimport { OrcaRailSignatureVerificationError } from './errors';\nimport type { WebhookEvent } from './types';\n\n/**\n * Webhook utilities for verifying webhook signatures\n */\nexport class Webhooks {\n /**\n * Verify webhook signature\n *\n * @param rawBody - Raw request body (string or Buffer)\n * @param signature - Signature from x-webhook-signature header\n * @param secret - Webhook secret (API key's secretHash)\n * @returns True if signature is valid, false otherwise\n */\n public verifySignature(\n rawBody: string | Buffer,\n signature: string,\n secret: string\n ): boolean {\n if (!signature || !secret) {\n return false;\n }\n\n // Convert rawBody to string if it's a Buffer\n const bodyString =\n typeof rawBody === 'string' ? rawBody : rawBody.toString('utf8');\n\n // Compute expected signature\n const expectedSignature = createHmac('sha256', secret)\n .update(bodyString)\n .digest('hex');\n\n // Compare signatures using timing-safe comparison\n const signatureBuffer = Buffer.from(signature, 'hex');\n const expectedBuffer = Buffer.from(expectedSignature, 'hex');\n\n // Length check first (prevents timing attacks)\n if (signatureBuffer.length !== expectedBuffer.length) {\n return false;\n }\n\n return timingSafeEqual(signatureBuffer, expectedBuffer);\n }\n\n /**\n * Construct and verify a webhook event from raw body and signature\n *\n * @param rawBody - Raw request body (string or Buffer)\n * @param signature - Signature from x-webhook-signature header\n * @param secret - Webhook secret (API key's secretHash)\n * @returns Parsed webhook event\n * @throws OrcaRailSignatureVerificationError if signature is invalid\n */\n public constructEvent(\n rawBody: string | Buffer,\n signature: string,\n secret: string\n ): WebhookEvent {\n if (!this.verifySignature(rawBody, signature, secret)) {\n throw new OrcaRailSignatureVerificationError(\n 'Webhook signature verification failed. The signature does not match the expected signature.',\n signature\n );\n }\n\n // Parse JSON body\n const bodyString =\n typeof rawBody === 'string' ? rawBody : rawBody.toString('utf8');\n\n try {\n const event = JSON.parse(bodyString) as WebhookEvent;\n return event;\n } catch (error) {\n throw new OrcaRailSignatureVerificationError(\n `Failed to parse webhook body: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n}\n","import { HttpClient } from './client';\nimport { Checkout } from './resources/checkout';\nimport { PaymentIntents } from './resources/payment-intents';\nimport { Webhooks } from './webhooks';\nimport type { OrcaRailConfig } from './types';\n\n// Re-export all types\nexport type {\n OrcaRailConfig,\n PaymentIntent,\n PaymentIntentCreateParams,\n PaymentIntentUpdateParams,\n PaymentIntentConfirmParams,\n PaymentLink,\n LatestTransaction,\n WebhookEvent,\n WebhookEventType,\n WebhookEventData,\n} from './types';\n\n// Re-export all errors\nexport {\n OrcaRailError,\n OrcaRailAPIError,\n OrcaRailAuthenticationError,\n OrcaRailSignatureVerificationError,\n} from './errors';\n\n/**\n * OrcaRail Node.js SDK\n *\n * @example\n * ```typescript\n * import OrcaRail from '@orcarail/node';\n *\n * const orcarail = new OrcaRail('ak_live_xxx', 'sk_live_xxx');\n *\n * // Create a payment intent\n * const intent = await orcarail.paymentIntents.create({\n * amount: '100.00',\n * currency: 'usd',\n * payment_method_types: ['crypto'],\n * tokenId: 1,\n * networkId: 1,\n * return_url: 'https://merchant.example.com/return',\n * });\n * ```\n */\nexport class OrcaRail {\n /**\n * Payment Intents resource\n */\n public readonly paymentIntents: PaymentIntents;\n\n /**\n * Checkout resource (slug-based get/cancel)\n */\n public readonly checkout: Checkout;\n\n /**\n * Webhooks utilities\n */\n public readonly webhooks: Webhooks;\n\n private readonly client: HttpClient;\n\n /**\n * Create a new OrcaRail client instance\n *\n * @param apiKey - Your OrcaRail API key (e.g., \"ak_live_xxx\")\n * @param apiSecret - Your OrcaRail API secret (e.g., \"sk_live_xxx\")\n * @param config - Optional configuration\n */\n constructor(\n apiKey: string,\n apiSecret: string,\n config?: OrcaRailConfig\n ) {\n this.client = new HttpClient(apiKey, apiSecret, config);\n this.paymentIntents = new PaymentIntents(this.client);\n this.checkout = new Checkout(this.client);\n this.webhooks = new Webhooks();\n }\n}\n\nexport default OrcaRail;\n"]}
@@ -0,0 +1,519 @@
1
+ /**
2
+ * Configuration options for the OrcaRail client
3
+ */
4
+ interface OrcaRailConfig {
5
+ /**
6
+ * Base URL for the OrcaRail API
7
+ * @default "https://api.orcarail.com/api/v1"
8
+ */
9
+ baseUrl?: string;
10
+ /**
11
+ * API version
12
+ * @default "v1"
13
+ */
14
+ apiVersion?: string;
15
+ /**
16
+ * Request timeout in milliseconds
17
+ * @default 30000
18
+ */
19
+ timeout?: number;
20
+ }
21
+ /**
22
+ * Parameters for creating a Payment Intent
23
+ */
24
+ interface PaymentIntentCreateParams {
25
+ /**
26
+ * Amount to charge (e.g., "100.00")
27
+ */
28
+ amount: string;
29
+ /**
30
+ * Currency code (e.g., "usd")
31
+ */
32
+ currency: string;
33
+ /**
34
+ * Payment method types (must include "crypto")
35
+ * @default ["crypto"]
36
+ */
37
+ payment_method_types?: string[];
38
+ /**
39
+ * Token ID (e.g., USDC, USDT)
40
+ */
41
+ tokenId: number;
42
+ /**
43
+ * Network ID (e.g., Ethereum, Polygon)
44
+ */
45
+ networkId: number;
46
+ /**
47
+ * Return URL after payment completion
48
+ */
49
+ return_url: string;
50
+ /**
51
+ * Cancel URL if payment is canceled
52
+ */
53
+ cancel_url?: string | null;
54
+ /**
55
+ * Payment description
56
+ */
57
+ description?: string;
58
+ /**
59
+ * Custom metadata object
60
+ */
61
+ metadata?: Record<string, unknown> | null;
62
+ /**
63
+ * ISO 8601 expiration timestamp
64
+ */
65
+ expires_at?: string | null;
66
+ }
67
+ /**
68
+ * Parameters for updating a Payment Intent
69
+ */
70
+ interface PaymentIntentUpdateParams {
71
+ /**
72
+ * Updated amount
73
+ */
74
+ amount?: string;
75
+ /**
76
+ * Updated currency
77
+ */
78
+ currency?: string;
79
+ /**
80
+ * Updated payment method types
81
+ */
82
+ payment_method_types?: string[];
83
+ /**
84
+ * Updated token ID
85
+ */
86
+ tokenId?: number;
87
+ /**
88
+ * Updated network ID
89
+ */
90
+ networkId?: number;
91
+ /**
92
+ * Updated return URL
93
+ */
94
+ return_url?: string;
95
+ /**
96
+ * Updated cancel URL
97
+ */
98
+ cancel_url?: string | null;
99
+ /**
100
+ * Updated description
101
+ */
102
+ description?: string;
103
+ /**
104
+ * Updated metadata
105
+ */
106
+ metadata?: Record<string, unknown> | null;
107
+ /**
108
+ * Updated expiration timestamp
109
+ */
110
+ expires_at?: string | null;
111
+ }
112
+ /**
113
+ * Parameters for confirming a Payment Intent
114
+ */
115
+ interface PaymentIntentConfirmParams {
116
+ /**
117
+ * Client secret for the payment intent (from create/retrieve response)
118
+ */
119
+ client_secret: string;
120
+ /**
121
+ * Return URL after payment completion
122
+ */
123
+ return_url: string;
124
+ }
125
+ /**
126
+ * Payment Link object
127
+ */
128
+ interface PaymentLink {
129
+ /**
130
+ * Payment link ID
131
+ */
132
+ id: number;
133
+ /**
134
+ * Unique slug
135
+ */
136
+ unique_slug?: string;
137
+ /**
138
+ * Payment link URL
139
+ */
140
+ link: string;
141
+ }
142
+ /**
143
+ * Latest transaction details
144
+ */
145
+ interface LatestTransaction {
146
+ /**
147
+ * Transaction ID
148
+ */
149
+ id: string;
150
+ /**
151
+ * Transaction status
152
+ */
153
+ status: string;
154
+ /**
155
+ * Transaction hash
156
+ */
157
+ hash?: string;
158
+ /**
159
+ * Transaction amount
160
+ */
161
+ amount?: string;
162
+ /**
163
+ * Transaction address
164
+ */
165
+ address?: string;
166
+ }
167
+ /**
168
+ * Payment Intent object
169
+ */
170
+ interface PaymentIntent {
171
+ /**
172
+ * Payment Intent ID (e.g., "pi_1234567890")
173
+ */
174
+ id: string;
175
+ /**
176
+ * Object type (always "payment_intent")
177
+ */
178
+ object: string;
179
+ /**
180
+ * Amount to charge
181
+ */
182
+ amount: string;
183
+ /**
184
+ * Currency code
185
+ */
186
+ currency: string;
187
+ /**
188
+ * Current status
189
+ */
190
+ status: string;
191
+ /**
192
+ * Payment method types
193
+ */
194
+ payment_method_types: string[];
195
+ /**
196
+ * Client secret used to confirm the payment intent from the frontend
197
+ */
198
+ client_secret?: string;
199
+ /**
200
+ * Checkout URL (clean URL without secrets)
201
+ */
202
+ checkout_url?: string;
203
+ /**
204
+ * Return URL
205
+ */
206
+ return_url: string;
207
+ /**
208
+ * Cancel URL
209
+ */
210
+ cancel_url?: string | null;
211
+ /**
212
+ * Payment description
213
+ */
214
+ description?: string | null;
215
+ /**
216
+ * Custom metadata
217
+ */
218
+ metadata?: Record<string, unknown> | null;
219
+ /**
220
+ * Payment link object
221
+ */
222
+ payment_link?: PaymentLink;
223
+ /**
224
+ * Expiration timestamp
225
+ */
226
+ expiresAt?: string;
227
+ /**
228
+ * Latest transaction details (for complete intents)
229
+ */
230
+ latestTransaction?: LatestTransaction;
231
+ /**
232
+ * Creation timestamp
233
+ */
234
+ createdAt: string;
235
+ /**
236
+ * Last update timestamp
237
+ */
238
+ updatedAt: string;
239
+ }
240
+ /**
241
+ * Webhook event types
242
+ */
243
+ type WebhookEventType = 'payment_intent.complete' | 'payment_intent.processing' | 'payment_intent.canceled' | 'payment_intent.requires_payment_method' | 'payment_intent.requires_confirmation';
244
+ /**
245
+ * Webhook event data object
246
+ */
247
+ interface WebhookEventData {
248
+ /**
249
+ * Payment Intent object
250
+ */
251
+ object: PaymentIntent;
252
+ }
253
+ /**
254
+ * Webhook event structure
255
+ */
256
+ interface WebhookEvent {
257
+ /**
258
+ * Event type
259
+ */
260
+ type: WebhookEventType;
261
+ /**
262
+ * Event data
263
+ */
264
+ data: WebhookEventData;
265
+ /**
266
+ * Unix timestamp when the event was created
267
+ */
268
+ created: number;
269
+ }
270
+
271
+ /**
272
+ * HTTP client for making requests to the OrcaRail API
273
+ */
274
+ declare class HttpClient {
275
+ private readonly apiKey;
276
+ private readonly apiSecret;
277
+ private readonly baseUrl;
278
+ private readonly timeout;
279
+ constructor(apiKey: string, apiSecret: string, config?: OrcaRailConfig);
280
+ /**
281
+ * Create Basic Auth header from API key and secret
282
+ */
283
+ private getAuthHeader;
284
+ /**
285
+ * Build full URL from path
286
+ */
287
+ private buildUrl;
288
+ /**
289
+ * Make an HTTP request with timeout and error handling
290
+ */
291
+ private request;
292
+ /**
293
+ * GET request
294
+ */
295
+ get<T>(path: string, requireAuth?: boolean): Promise<T>;
296
+ /**
297
+ * POST request
298
+ */
299
+ post<T>(path: string, body?: unknown, requireAuth?: boolean): Promise<T>;
300
+ /**
301
+ * PATCH request
302
+ */
303
+ patch<T>(path: string, body?: unknown, requireAuth?: boolean): Promise<T>;
304
+ /**
305
+ * PUT request
306
+ */
307
+ put<T>(path: string, body?: unknown, requireAuth?: boolean): Promise<T>;
308
+ /**
309
+ * DELETE request
310
+ */
311
+ delete<T>(path: string, requireAuth?: boolean): Promise<T>;
312
+ }
313
+
314
+ /**
315
+ * Checkout resource for slug-based checkout flows (public endpoints)
316
+ */
317
+ declare class Checkout {
318
+ private readonly client;
319
+ constructor(client: HttpClient);
320
+ /**
321
+ * Get checkout details by slug
322
+ *
323
+ * @param slug - Checkout slug from the payment link URL
324
+ * @returns Checkout details including payment intent
325
+ */
326
+ get(slug: string): Promise<PaymentIntent & Record<string, unknown>>;
327
+ /**
328
+ * Cancel payment intent by checkout slug
329
+ *
330
+ * @param slug - Checkout slug from the payment link URL
331
+ * @returns The canceled payment intent and optional cancel_url for redirect
332
+ */
333
+ cancel(slug: string): Promise<PaymentIntent & {
334
+ cancel_url?: string;
335
+ }>;
336
+ }
337
+
338
+ /**
339
+ * Payment Intents resource for managing payment intents
340
+ */
341
+ declare class PaymentIntents {
342
+ private readonly client;
343
+ constructor(client: HttpClient);
344
+ /**
345
+ * Create a new Payment Intent
346
+ *
347
+ * @param params - Payment Intent creation parameters
348
+ * @returns The created Payment Intent
349
+ */
350
+ create(params: PaymentIntentCreateParams): Promise<PaymentIntent>;
351
+ /**
352
+ * Retrieve a Payment Intent by ID
353
+ *
354
+ * @param id - Payment Intent ID (e.g., "pi_1234567890")
355
+ * @returns The Payment Intent
356
+ */
357
+ retrieve(id: string): Promise<PaymentIntent>;
358
+ /**
359
+ * Cancel a Payment Intent (API: POST /payment_intents/:id/cancel).
360
+ * Use when the user is redirected to your cancel_url (e.g. https://yourapp.com/cancel?payment_intent=pi_20)
361
+ * and you want to mark the intent as canceled on the backend.
362
+ *
363
+ * @param id - Payment Intent ID (e.g. "pi_20" or "20")
364
+ * @returns The canceled Payment Intent
365
+ *
366
+ * @example
367
+ * // When user lands on https://localhost:3001/cancel?payment_intent=pi_20
368
+ * const intent = await orcarail.paymentIntents.cancel('pi_20');
369
+ */
370
+ cancel(id: string): Promise<PaymentIntent>;
371
+ /**
372
+ * Confirm a Payment Intent (API: POST /payment_intents/:id/confirm).
373
+ * Redirects the customer to the hosted checkout page.
374
+ *
375
+ * @param id - Payment Intent ID (e.g. "pi_20" or "20")
376
+ * @param params - Confirmation parameters including client_secret and return_url
377
+ * @returns The confirmed Payment Intent
378
+ *
379
+ * @example
380
+ * const intent = await orcarail.paymentIntents.confirm('pi_20', {
381
+ * client_secret: intent.client_secret,
382
+ * return_url: 'https://yourapp.com/return',
383
+ * });
384
+ */
385
+ confirm(id: string, params: PaymentIntentConfirmParams): Promise<PaymentIntent>;
386
+ /**
387
+ * Complete a Payment Intent (API: POST /payment_intents/:id/complete).
388
+ * Sets the intent to processing and fires the payment_intent.processing webhook.
389
+ * Use when the user is redirected to your success/return URL (e.g. https://yourapp.com/success?payment_intent=pi_34).
390
+ *
391
+ * @param id - Payment Intent ID (e.g. "pi_34" or "34")
392
+ * @returns The updated Payment Intent (status processing)
393
+ *
394
+ * @example
395
+ * // When user lands on https://localhost:3001/success?payment_intent=pi_34
396
+ * const intent = await orcarail.paymentIntents.complete('pi_34');
397
+ */
398
+ complete(id: string): Promise<PaymentIntent>;
399
+ /**
400
+ * Update a Payment Intent
401
+ *
402
+ * @param id - Payment Intent ID
403
+ * @param params - Update parameters (all optional)
404
+ * @returns The updated Payment Intent
405
+ */
406
+ update(id: string, params: PaymentIntentUpdateParams): Promise<PaymentIntent>;
407
+ }
408
+
409
+ /**
410
+ * Webhook utilities for verifying webhook signatures
411
+ */
412
+ declare class Webhooks {
413
+ /**
414
+ * Verify webhook signature
415
+ *
416
+ * @param rawBody - Raw request body (string or Buffer)
417
+ * @param signature - Signature from x-webhook-signature header
418
+ * @param secret - Webhook secret (API key's secretHash)
419
+ * @returns True if signature is valid, false otherwise
420
+ */
421
+ verifySignature(rawBody: string | Buffer, signature: string, secret: string): boolean;
422
+ /**
423
+ * Construct and verify a webhook event from raw body and signature
424
+ *
425
+ * @param rawBody - Raw request body (string or Buffer)
426
+ * @param signature - Signature from x-webhook-signature header
427
+ * @param secret - Webhook secret (API key's secretHash)
428
+ * @returns Parsed webhook event
429
+ * @throws OrcaRailSignatureVerificationError if signature is invalid
430
+ */
431
+ constructEvent(rawBody: string | Buffer, signature: string, secret: string): WebhookEvent;
432
+ }
433
+
434
+ /**
435
+ * Base error class for all OrcaRail errors
436
+ */
437
+ declare class OrcaRailError extends Error {
438
+ constructor(message: string);
439
+ }
440
+ /**
441
+ * Error thrown when the API returns a non-2xx status code
442
+ */
443
+ declare class OrcaRailAPIError extends OrcaRailError {
444
+ /**
445
+ * HTTP status code
446
+ */
447
+ readonly statusCode: number;
448
+ /**
449
+ * Error type from the API response
450
+ */
451
+ readonly type?: string;
452
+ /**
453
+ * Additional error details from the API
454
+ */
455
+ readonly details?: unknown;
456
+ constructor(message: string, statusCode: number, type?: string, details?: unknown);
457
+ }
458
+ /**
459
+ * Error thrown when authentication fails (401)
460
+ */
461
+ declare class OrcaRailAuthenticationError extends OrcaRailAPIError {
462
+ constructor(message?: string);
463
+ }
464
+ /**
465
+ * Error thrown when webhook signature verification fails
466
+ */
467
+ declare class OrcaRailSignatureVerificationError extends OrcaRailError {
468
+ /**
469
+ * The signature that was provided
470
+ */
471
+ readonly signature: string;
472
+ constructor(message?: string, signature?: string);
473
+ }
474
+
475
+ /**
476
+ * OrcaRail Node.js SDK
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * import OrcaRail from '@orcarail/node';
481
+ *
482
+ * const orcarail = new OrcaRail('ak_live_xxx', 'sk_live_xxx');
483
+ *
484
+ * // Create a payment intent
485
+ * const intent = await orcarail.paymentIntents.create({
486
+ * amount: '100.00',
487
+ * currency: 'usd',
488
+ * payment_method_types: ['crypto'],
489
+ * tokenId: 1,
490
+ * networkId: 1,
491
+ * return_url: 'https://merchant.example.com/return',
492
+ * });
493
+ * ```
494
+ */
495
+ declare class OrcaRail {
496
+ /**
497
+ * Payment Intents resource
498
+ */
499
+ readonly paymentIntents: PaymentIntents;
500
+ /**
501
+ * Checkout resource (slug-based get/cancel)
502
+ */
503
+ readonly checkout: Checkout;
504
+ /**
505
+ * Webhooks utilities
506
+ */
507
+ readonly webhooks: Webhooks;
508
+ private readonly client;
509
+ /**
510
+ * Create a new OrcaRail client instance
511
+ *
512
+ * @param apiKey - Your OrcaRail API key (e.g., "ak_live_xxx")
513
+ * @param apiSecret - Your OrcaRail API secret (e.g., "sk_live_xxx")
514
+ * @param config - Optional configuration
515
+ */
516
+ constructor(apiKey: string, apiSecret: string, config?: OrcaRailConfig);
517
+ }
518
+
519
+ export { type LatestTransaction, OrcaRail, OrcaRailAPIError, OrcaRailAuthenticationError, type OrcaRailConfig, OrcaRailError, OrcaRailSignatureVerificationError, type PaymentIntent, type PaymentIntentConfirmParams, type PaymentIntentCreateParams, type PaymentIntentUpdateParams, type PaymentLink, type WebhookEvent, type WebhookEventData, type WebhookEventType, OrcaRail as default };