@fastaar/nextjs 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -154,7 +154,19 @@ const payment = await fastaar.findByInvoiceNumber('ORDER-42');
154
154
  const payments = await fastaar.listPayments({ status: 'completed', per_page: 10 });
155
155
  ```
156
156
 
157
- ### 5. Customers
157
+ ### 5. Refund a Payment
158
+
159
+ Refund a completed payment. Only payments with status `completed` can be refunded. A `payment.refunded` webhook fires automatically.
160
+
161
+ ```typescript
162
+ import { getFastaarClient } from '@fastaar/nextjs';
163
+
164
+ const fastaar = getFastaarClient();
165
+ const payment = await fastaar.refundPayment('01jxyz...');
166
+ // payment.status === 'refunded'
167
+ ```
168
+
169
+ ### 6. Customers
158
170
 
159
171
  Store customer records to attach them to payments collected via payment links.
160
172
 
package/dist/client.cjs CHANGED
@@ -94,6 +94,15 @@ class FastaarClient {
94
94
  const payments = await this.listPayments({ invoice_number: invoiceNumber });
95
95
  return payments[0] ?? null;
96
96
  }
97
+ /**
98
+ * Refund a completed payment. Only payments with status `completed` can be refunded.
99
+ *
100
+ * @returns The updated payment object with status `refunded`.
101
+ * @throws FastaarError if the payment is not in a refundable state.
102
+ */
103
+ async refundPayment(paymentId) {
104
+ return this.request("POST", `/api/v1/payments/${encodeURIComponent(paymentId)}/refund`);
105
+ }
97
106
  // ---------------------------------------------------------------------------
98
107
  // Customers
99
108
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import {\n CreateCustomerParams,\n CreatePaymentParams,\n Customer,\n CustomerParams,\n FastaarClientOptions,\n ListCustomersParams,\n ListPaymentsParams,\n Payment,\n} from './types';\n\nconst API_BASE_URL = 'https://fastaar.com';\n\n/**\n * Custom error class for Fastaar API errors.\n */\nexport class FastaarError extends Error {\n /**\n * The type of the error returned by the API (e.g. 'authentication_error', 'validation_error').\n */\n errorType: string;\n\n /**\n * The HTTP status code returned by the API.\n */\n statusCode: number;\n\n constructor(message: string, errorType = 'api_error', statusCode = 0) {\n super(message);\n this.name = 'FastaarError';\n this.errorType = errorType;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Client for interacting with the Fastaar Payment Gateway API.\n */\nexport class FastaarClient {\n private apiKey: string;\n private timeoutMs: number;\n\n /**\n * @param apiKey Your Fastaar API Key (fk_live_... or fk_test_...)\n * @param options Client configuration options\n */\n constructor(apiKey: string, options: FastaarClientOptions = {}) {\n if (!apiKey) {\n throw new FastaarError('API key is required to initialize FastaarClient.', 'authentication_error');\n }\n this.apiKey = apiKey;\n this.timeoutMs = options.timeoutMs ?? 15000;\n }\n\n // ---------------------------------------------------------------------------\n // Payments\n // ---------------------------------------------------------------------------\n\n /**\n * Create a payment intent. Returns the payment object including\n * `id`, `status`, and `checkout_url`.\n *\n * Reusing the same `invoice_number` returns the existing payment instead of\n * creating a duplicate, so retries are safe. Supply `success_url`/`cancel_url`\n * to return the customer to your site after checkout.\n */\n async createPayment(params: CreatePaymentParams): Promise<Payment> {\n return this.request<Payment>('POST', '/api/v1/payments', params);\n }\n\n /**\n * Retrieve a payment by its reference ID.\n */\n async getPayment(paymentId: string): Promise<Payment> {\n return this.request<Payment>('GET', `/api/v1/payments/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * List payments, newest first.\n */\n async listPayments(params: ListPaymentsParams = {}): Promise<Payment[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Payment[]>('GET', `/api/v1/payments${query ? `?${query}` : ''}`);\n }\n\n /**\n * Find the most recent payment for one of your invoice numbers, or null if none exist.\n */\n async findByInvoiceNumber(invoiceNumber: string): Promise<Payment | null> {\n const payments = await this.listPayments({ invoice_number: invoiceNumber });\n return payments[0] ?? null;\n }\n\n // ---------------------------------------------------------------------------\n // Customers\n // ---------------------------------------------------------------------------\n\n async listCustomers(params: ListCustomersParams = {}): Promise<Customer[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Customer[]>('GET', `/api/v1/customers${query ? `?${query}` : ''}`);\n }\n\n async createCustomer(params: CreateCustomerParams): Promise<Customer> {\n return this.request<Customer>('POST', '/api/v1/customers', params);\n }\n\n async getCustomer(customerId: number): Promise<Customer> {\n return this.request<Customer>('GET', `/api/v1/customers/${customerId}`);\n }\n\n async updateCustomer(customerId: number, params: CustomerParams): Promise<Customer> {\n return this.request<Customer>('PATCH', `/api/v1/customers/${customerId}`, params);\n }\n\n /**\n * Helper to perform HTTP request to Fastaar API.\n */\n private async request<T>(method: string, path: string, body?: any): Promise<T> {\n let response: Response;\n\n try {\n response = await fetch(API_BASE_URL + path, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n ...(body ? { 'Content-Type': 'application/json' } : {}),\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (error: any) {\n throw new FastaarError(`Could not reach the Fastaar API: ${error.message}`, 'connection_error');\n }\n\n const payload = await response.json().catch(() => null);\n\n if (!response.ok || payload === null) {\n throw new FastaarError(\n payload?.error?.message ?? `Fastaar API returned HTTP ${response.status}.`,\n payload?.error?.type ?? 'api_error',\n response.status,\n );\n }\n\n return (payload.data ?? payload) as T;\n }\n}\n\n// Global caching pattern for Next.js hot-reloading\nconst globalForFastaar = globalThis as unknown as {\n fastaarClient?: FastaarClient;\n};\n\n/**\n * Retrieves a cached singleton instance of FastaarClient initialized with\n * environment variables (FASTAAR_API_KEY, FASTAAR_TIMEOUT_MS).\n * Useful in Next.js API route handlers, Server Actions, and Server Components.\n */\nexport function getFastaarClient(): FastaarClient {\n if (!globalForFastaar.fastaarClient) {\n const apiKey = process.env.FASTAAR_API_KEY;\n if (!apiKey) {\n throw new FastaarError(\n 'FASTAAR_API_KEY environment variable is not defined.',\n 'authentication_error'\n );\n }\n\n const timeoutMs = process.env.FASTAAR_TIMEOUT_MS\n ? parseInt(process.env.FASTAAR_TIMEOUT_MS, 10)\n : undefined;\n\n globalForFastaar.fastaarClient = new FastaarClient(apiKey, { timeoutMs });\n }\n\n return globalForFastaar.fastaarClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,eAAe;AAKd,MAAM,qBAAqB,MAAM;AAAA;AAAA;AAAA;AAAA,EAItC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEA,YAAY,SAAiB,YAAY,aAAa,aAAa,GAAG;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;AAKO,MAAM,cAAc;AAAA,EACjB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,YAAY,QAAgB,UAAgC,CAAC,GAAG;AAC9D,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,aAAa,oDAAoD,sBAAsB;AAAA,IACnG;AACA,SAAK,SAAS;AACd,SAAK,YAAY,QAAQ,aAAa;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,cAAc,QAA+C;AACjE,WAAO,KAAK,QAAiB,QAAQ,oBAAoB,MAAM;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,WAAqC;AACpD,WAAO,KAAK,QAAiB,OAAO,oBAAoB,mBAAmB,SAAS,CAAC,EAAE;AAAA,EACzF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAAa,SAA6B,CAAC,GAAuB;AACtE,UAAM,eAAuC,CAAC;AAC9C,eAAW,CAAC,KAAK,KAAK,KAAK,OAA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UACP,eAAe,UAAU,KAAK,MAAM;AAAA,UACpC,QAAQ;AAAA,UACR,GAAI,OAAO,EAAE,gBAAgB,mBAAmB,IAAI,CAAC;AAAA,QACvD;AAAA,QACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AAAA,QACpC,QAAQ,YAAY,QAAQ,KAAK,SAAS;AAAA,MAC5C,CAAC;AAAA,IACH,SAAS,OAAY;AACnB,YAAM,IAAI,aAAa,oCAAoC,MAAM,OAAO,IAAI,kBAAkB;AAAA,IAChG;AAEA,UAAM,UAAU,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,IAAI;AAEtD,QAAI,CAAC,SAAS,MAAM,YAAY,MAAM;AACpC,YAAM,IAAI;AAAA,QACR,SAAS,OAAO,WAAW,6BAA6B,SAAS,MAAM;AAAA,QACvE,SAAS,OAAO,QAAQ;AAAA,QACxB,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WAAQ,QAAQ,QAAQ;AAAA,EAC1B;AACF;AAGA,MAAM,mBAAmB;AASlB,SAAS,mBAAkC;AAChD,MAAI,CAAC,iBAAiB,eAAe;AACnC,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAY,QAAQ,IAAI,qBAC1B,SAAS,QAAQ,IAAI,oBAAoB,EAAE,IAC3C;AAEJ,qBAAiB,gBAAgB,IAAI,cAAc,QAAQ,EAAE,UAAU,CAAC;AAAA,EAC1E;AAEA,SAAO,iBAAiB;AAC1B;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import {\n CreateCustomerParams,\n CreatePaymentParams,\n Customer,\n CustomerParams,\n FastaarClientOptions,\n ListCustomersParams,\n ListPaymentsParams,\n Payment,\n} from './types';\n\nconst API_BASE_URL = 'https://fastaar.com';\n\n/**\n * Custom error class for Fastaar API errors.\n */\nexport class FastaarError extends Error {\n /**\n * The type of the error returned by the API (e.g. 'authentication_error', 'validation_error').\n */\n errorType: string;\n\n /**\n * The HTTP status code returned by the API.\n */\n statusCode: number;\n\n constructor(message: string, errorType = 'api_error', statusCode = 0) {\n super(message);\n this.name = 'FastaarError';\n this.errorType = errorType;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Client for interacting with the Fastaar Payment Gateway API.\n */\nexport class FastaarClient {\n private apiKey: string;\n private timeoutMs: number;\n\n /**\n * @param apiKey Your Fastaar API Key (fk_live_... or fk_test_...)\n * @param options Client configuration options\n */\n constructor(apiKey: string, options: FastaarClientOptions = {}) {\n if (!apiKey) {\n throw new FastaarError('API key is required to initialize FastaarClient.', 'authentication_error');\n }\n this.apiKey = apiKey;\n this.timeoutMs = options.timeoutMs ?? 15000;\n }\n\n // ---------------------------------------------------------------------------\n // Payments\n // ---------------------------------------------------------------------------\n\n /**\n * Create a payment intent. Returns the payment object including\n * `id`, `status`, and `checkout_url`.\n *\n * Reusing the same `invoice_number` returns the existing payment instead of\n * creating a duplicate, so retries are safe. Supply `success_url`/`cancel_url`\n * to return the customer to your site after checkout.\n */\n async createPayment(params: CreatePaymentParams): Promise<Payment> {\n return this.request<Payment>('POST', '/api/v1/payments', params);\n }\n\n /**\n * Retrieve a payment by its reference ID.\n */\n async getPayment(paymentId: string): Promise<Payment> {\n return this.request<Payment>('GET', `/api/v1/payments/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * List payments, newest first.\n */\n async listPayments(params: ListPaymentsParams = {}): Promise<Payment[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Payment[]>('GET', `/api/v1/payments${query ? `?${query}` : ''}`);\n }\n\n /**\n * Find the most recent payment for one of your invoice numbers, or null if none exist.\n */\n async findByInvoiceNumber(invoiceNumber: string): Promise<Payment | null> {\n const payments = await this.listPayments({ invoice_number: invoiceNumber });\n return payments[0] ?? null;\n }\n\n /**\n * Refund a completed payment. Only payments with status `completed` can be refunded.\n *\n * @returns The updated payment object with status `refunded`.\n * @throws FastaarError if the payment is not in a refundable state.\n */\n async refundPayment(paymentId: string): Promise<Payment> {\n return this.request<Payment>('POST', `/api/v1/payments/${encodeURIComponent(paymentId)}/refund`);\n }\n\n // ---------------------------------------------------------------------------\n // Customers\n // ---------------------------------------------------------------------------\n\n async listCustomers(params: ListCustomersParams = {}): Promise<Customer[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Customer[]>('GET', `/api/v1/customers${query ? `?${query}` : ''}`);\n }\n\n async createCustomer(params: CreateCustomerParams): Promise<Customer> {\n return this.request<Customer>('POST', '/api/v1/customers', params);\n }\n\n async getCustomer(customerId: number): Promise<Customer> {\n return this.request<Customer>('GET', `/api/v1/customers/${customerId}`);\n }\n\n async updateCustomer(customerId: number, params: CustomerParams): Promise<Customer> {\n return this.request<Customer>('PATCH', `/api/v1/customers/${customerId}`, params);\n }\n\n /**\n * Helper to perform HTTP request to Fastaar API.\n */\n private async request<T>(method: string, path: string, body?: any): Promise<T> {\n let response: Response;\n\n try {\n response = await fetch(API_BASE_URL + path, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n ...(body ? { 'Content-Type': 'application/json' } : {}),\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (error: any) {\n throw new FastaarError(`Could not reach the Fastaar API: ${error.message}`, 'connection_error');\n }\n\n const payload = await response.json().catch(() => null);\n\n if (!response.ok || payload === null) {\n throw new FastaarError(\n payload?.error?.message ?? `Fastaar API returned HTTP ${response.status}.`,\n payload?.error?.type ?? 'api_error',\n response.status,\n );\n }\n\n return (payload.data ?? payload) as T;\n }\n}\n\n// Global caching pattern for Next.js hot-reloading\nconst globalForFastaar = globalThis as unknown as {\n fastaarClient?: FastaarClient;\n};\n\n/**\n * Retrieves a cached singleton instance of FastaarClient initialized with\n * environment variables (FASTAAR_API_KEY, FASTAAR_TIMEOUT_MS).\n * Useful in Next.js API route handlers, Server Actions, and Server Components.\n */\nexport function getFastaarClient(): FastaarClient {\n if (!globalForFastaar.fastaarClient) {\n const apiKey = process.env.FASTAAR_API_KEY;\n if (!apiKey) {\n throw new FastaarError(\n 'FASTAAR_API_KEY environment variable is not defined.',\n 'authentication_error'\n );\n }\n\n const timeoutMs = process.env.FASTAAR_TIMEOUT_MS\n ? parseInt(process.env.FASTAAR_TIMEOUT_MS, 10)\n : undefined;\n\n globalForFastaar.fastaarClient = new FastaarClient(apiKey, { timeoutMs });\n }\n\n return globalForFastaar.fastaarClient;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,eAAe;AAKd,MAAM,qBAAqB,MAAM;AAAA;AAAA;AAAA;AAAA,EAItC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEA,YAAY,SAAiB,YAAY,aAAa,aAAa,GAAG;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;AAKO,MAAM,cAAc;AAAA,EACjB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,YAAY,QAAgB,UAAgC,CAAC,GAAG;AAC9D,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,aAAa,oDAAoD,sBAAsB;AAAA,IACnG;AACA,SAAK,SAAS;AACd,SAAK,YAAY,QAAQ,aAAa;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,cAAc,QAA+C;AACjE,WAAO,KAAK,QAAiB,QAAQ,oBAAoB,MAAM;AAAA,EACjE;AAAA;AAAA;AA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AS,QAAQ,IAAI,oBAAoB,EAAE,IAC3C;AAEJ,qBAAiB,gBAAgB,IAAI,cAAc,QAAQ,EAAE,UAAU,CAAC;AAAA,EAC1E;AAEA,SAAO,iBAAiB;AAC1B;","names":[]}
package/dist/client.d.cts CHANGED
@@ -46,6 +46,13 @@ declare class FastaarClient {
46
46
  * Find the most recent payment for one of your invoice numbers, or null if none exist.
47
47
  */
48
48
  findByInvoiceNumber(invoiceNumber: string): Promise<Payment | null>;
49
+ /**
50
+ * Refund a completed payment. Only payments with status `completed` can be refunded.
51
+ *
52
+ * @returns The updated payment object with status `refunded`.
53
+ * @throws FastaarError if the payment is not in a refundable state.
54
+ */
55
+ refundPayment(paymentId: string): Promise<Payment>;
49
56
  listCustomers(params?: ListCustomersParams): Promise<Customer[]>;
50
57
  createCustomer(params: CreateCustomerParams): Promise<Customer>;
51
58
  getCustomer(customerId: number): Promise<Customer>;
package/dist/client.d.ts CHANGED
@@ -46,6 +46,13 @@ declare class FastaarClient {
46
46
  * Find the most recent payment for one of your invoice numbers, or null if none exist.
47
47
  */
48
48
  findByInvoiceNumber(invoiceNumber: string): Promise<Payment | null>;
49
+ /**
50
+ * Refund a completed payment. Only payments with status `completed` can be refunded.
51
+ *
52
+ * @returns The updated payment object with status `refunded`.
53
+ * @throws FastaarError if the payment is not in a refundable state.
54
+ */
55
+ refundPayment(paymentId: string): Promise<Payment>;
49
56
  listCustomers(params?: ListCustomersParams): Promise<Customer[]>;
50
57
  createCustomer(params: CreateCustomerParams): Promise<Customer>;
51
58
  getCustomer(customerId: number): Promise<Customer>;
package/dist/client.js CHANGED
@@ -69,6 +69,15 @@ class FastaarClient {
69
69
  const payments = await this.listPayments({ invoice_number: invoiceNumber });
70
70
  return payments[0] ?? null;
71
71
  }
72
+ /**
73
+ * Refund a completed payment. Only payments with status `completed` can be refunded.
74
+ *
75
+ * @returns The updated payment object with status `refunded`.
76
+ * @throws FastaarError if the payment is not in a refundable state.
77
+ */
78
+ async refundPayment(paymentId) {
79
+ return this.request("POST", `/api/v1/payments/${encodeURIComponent(paymentId)}/refund`);
80
+ }
72
81
  // ---------------------------------------------------------------------------
73
82
  // Customers
74
83
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import {\n CreateCustomerParams,\n CreatePaymentParams,\n Customer,\n CustomerParams,\n FastaarClientOptions,\n ListCustomersParams,\n ListPaymentsParams,\n Payment,\n} from './types';\n\nconst API_BASE_URL = 'https://fastaar.com';\n\n/**\n * Custom error class for Fastaar API errors.\n */\nexport class FastaarError extends Error {\n /**\n * The type of the error returned by the API (e.g. 'authentication_error', 'validation_error').\n */\n errorType: string;\n\n /**\n * The HTTP status code returned by the API.\n */\n statusCode: number;\n\n constructor(message: string, errorType = 'api_error', statusCode = 0) {\n super(message);\n this.name = 'FastaarError';\n this.errorType = errorType;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Client for interacting with the Fastaar Payment Gateway API.\n */\nexport class FastaarClient {\n private apiKey: string;\n private timeoutMs: number;\n\n /**\n * @param apiKey Your Fastaar API Key (fk_live_... or fk_test_...)\n * @param options Client configuration options\n */\n constructor(apiKey: string, options: FastaarClientOptions = {}) {\n if (!apiKey) {\n throw new FastaarError('API key is required to initialize FastaarClient.', 'authentication_error');\n }\n this.apiKey = apiKey;\n this.timeoutMs = options.timeoutMs ?? 15000;\n }\n\n // ---------------------------------------------------------------------------\n // Payments\n // ---------------------------------------------------------------------------\n\n /**\n * Create a payment intent. Returns the payment object including\n * `id`, `status`, and `checkout_url`.\n *\n * Reusing the same `invoice_number` returns the existing payment instead of\n * creating a duplicate, so retries are safe. Supply `success_url`/`cancel_url`\n * to return the customer to your site after checkout.\n */\n async createPayment(params: CreatePaymentParams): Promise<Payment> {\n return this.request<Payment>('POST', '/api/v1/payments', params);\n }\n\n /**\n * Retrieve a payment by its reference ID.\n */\n async getPayment(paymentId: string): Promise<Payment> {\n return this.request<Payment>('GET', `/api/v1/payments/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * List payments, newest first.\n */\n async listPayments(params: ListPaymentsParams = {}): Promise<Payment[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Payment[]>('GET', `/api/v1/payments${query ? `?${query}` : ''}`);\n }\n\n /**\n * Find the most recent payment for one of your invoice numbers, or null if none exist.\n */\n async findByInvoiceNumber(invoiceNumber: string): Promise<Payment | null> {\n const payments = await this.listPayments({ invoice_number: invoiceNumber });\n return payments[0] ?? null;\n }\n\n // ---------------------------------------------------------------------------\n // Customers\n // ---------------------------------------------------------------------------\n\n async listCustomers(params: ListCustomersParams = {}): Promise<Customer[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Customer[]>('GET', `/api/v1/customers${query ? `?${query}` : ''}`);\n }\n\n async createCustomer(params: CreateCustomerParams): Promise<Customer> {\n return this.request<Customer>('POST', '/api/v1/customers', params);\n }\n\n async getCustomer(customerId: number): Promise<Customer> {\n return this.request<Customer>('GET', `/api/v1/customers/${customerId}`);\n }\n\n async updateCustomer(customerId: number, params: CustomerParams): Promise<Customer> {\n return this.request<Customer>('PATCH', `/api/v1/customers/${customerId}`, params);\n }\n\n /**\n * Helper to perform HTTP request to Fastaar API.\n */\n private async request<T>(method: string, path: string, body?: any): Promise<T> {\n let response: Response;\n\n try {\n response = await fetch(API_BASE_URL + path, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n ...(body ? { 'Content-Type': 'application/json' } : {}),\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (error: any) {\n throw new FastaarError(`Could not reach the Fastaar API: ${error.message}`, 'connection_error');\n }\n\n const payload = await response.json().catch(() => null);\n\n if (!response.ok || payload === null) {\n throw new FastaarError(\n payload?.error?.message ?? `Fastaar API returned HTTP ${response.status}.`,\n payload?.error?.type ?? 'api_error',\n response.status,\n );\n }\n\n return (payload.data ?? payload) as T;\n }\n}\n\n// Global caching pattern for Next.js hot-reloading\nconst globalForFastaar = globalThis as unknown as {\n fastaarClient?: FastaarClient;\n};\n\n/**\n * Retrieves a cached singleton instance of FastaarClient initialized with\n * environment variables (FASTAAR_API_KEY, FASTAAR_TIMEOUT_MS).\n * Useful in Next.js API route handlers, Server Actions, and Server Components.\n */\nexport function getFastaarClient(): FastaarClient {\n if (!globalForFastaar.fastaarClient) {\n const apiKey = process.env.FASTAAR_API_KEY;\n if (!apiKey) {\n throw new FastaarError(\n 'FASTAAR_API_KEY environment variable is not defined.',\n 'authentication_error'\n );\n }\n\n const timeoutMs = process.env.FASTAAR_TIMEOUT_MS\n ? parseInt(process.env.FASTAAR_TIMEOUT_MS, 10)\n : undefined;\n\n globalForFastaar.fastaarClient = new FastaarClient(apiKey, { timeoutMs });\n }\n\n return globalForFastaar.fastaarClient;\n}\n"],"mappings":"AAWA,MAAM,eAAe;AAKd,MAAM,qBAAqB,MAAM;AAAA;AAAA;AAAA;AAAA,EAItC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEA,YAAY,SAAiB,YAAY,aAAa,aAAa,GAAG;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;AAKO,MAAM,cAAc;AAAA,EACjB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,YAAY,QAAgB,UAAgC,CAAC,GAAG;AAC9D,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,aAAa,oDAAoD,sBAAsB;AAAA,IACnG;AACA,SAAK,SAAS;AACd,SAAK,YAAY,QAAQ,aAAa;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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oB,EAAE,IAC3C;AAEJ,qBAAiB,gBAAgB,IAAI,cAAc,QAAQ,EAAE,UAAU,CAAC;AAAA,EAC1E;AAEA,SAAO,iBAAiB;AAC1B;","names":[]}
1
+ {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import {\n CreateCustomerParams,\n CreatePaymentParams,\n Customer,\n CustomerParams,\n FastaarClientOptions,\n ListCustomersParams,\n ListPaymentsParams,\n Payment,\n} from './types';\n\nconst API_BASE_URL = 'https://fastaar.com';\n\n/**\n * Custom error class for Fastaar API errors.\n */\nexport class FastaarError extends Error {\n /**\n * The type of the error returned by the API (e.g. 'authentication_error', 'validation_error').\n */\n errorType: string;\n\n /**\n * The HTTP status code returned by the API.\n */\n statusCode: number;\n\n constructor(message: string, errorType = 'api_error', statusCode = 0) {\n super(message);\n this.name = 'FastaarError';\n this.errorType = errorType;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Client for interacting with the Fastaar Payment Gateway API.\n */\nexport class FastaarClient {\n private apiKey: string;\n private timeoutMs: number;\n\n /**\n * @param apiKey Your Fastaar API Key (fk_live_... or fk_test_...)\n * @param options Client configuration options\n */\n constructor(apiKey: string, options: FastaarClientOptions = {}) {\n if (!apiKey) {\n throw new FastaarError('API key is required to initialize FastaarClient.', 'authentication_error');\n }\n this.apiKey = apiKey;\n this.timeoutMs = options.timeoutMs ?? 15000;\n }\n\n // ---------------------------------------------------------------------------\n // Payments\n // ---------------------------------------------------------------------------\n\n /**\n * Create a payment intent. Returns the payment object including\n * `id`, `status`, and `checkout_url`.\n *\n * Reusing the same `invoice_number` returns the existing payment instead of\n * creating a duplicate, so retries are safe. Supply `success_url`/`cancel_url`\n * to return the customer to your site after checkout.\n */\n async createPayment(params: CreatePaymentParams): Promise<Payment> {\n return this.request<Payment>('POST', '/api/v1/payments', params);\n }\n\n /**\n * Retrieve a payment by its reference ID.\n */\n async getPayment(paymentId: string): Promise<Payment> {\n return this.request<Payment>('GET', `/api/v1/payments/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * List payments, newest first.\n */\n async listPayments(params: ListPaymentsParams = {}): Promise<Payment[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Payment[]>('GET', `/api/v1/payments${query ? `?${query}` : ''}`);\n }\n\n /**\n * Find the most recent payment for one of your invoice numbers, or null if none exist.\n */\n async findByInvoiceNumber(invoiceNumber: string): Promise<Payment | null> {\n const payments = await this.listPayments({ invoice_number: invoiceNumber });\n return payments[0] ?? null;\n }\n\n /**\n * Refund a completed payment. Only payments with status `completed` can be refunded.\n *\n * @returns The updated payment object with status `refunded`.\n * @throws FastaarError if the payment is not in a refundable state.\n */\n async refundPayment(paymentId: string): Promise<Payment> {\n return this.request<Payment>('POST', `/api/v1/payments/${encodeURIComponent(paymentId)}/refund`);\n }\n\n // ---------------------------------------------------------------------------\n // Customers\n // ---------------------------------------------------------------------------\n\n async listCustomers(params: ListCustomersParams = {}): Promise<Customer[]> {\n const stringParams: Record<string, string> = {};\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n stringParams[key] = String(value);\n }\n }\n const query = new URLSearchParams(stringParams).toString();\n return this.request<Customer[]>('GET', `/api/v1/customers${query ? `?${query}` : ''}`);\n }\n\n async createCustomer(params: CreateCustomerParams): Promise<Customer> {\n return this.request<Customer>('POST', '/api/v1/customers', params);\n }\n\n async getCustomer(customerId: number): Promise<Customer> {\n return this.request<Customer>('GET', `/api/v1/customers/${customerId}`);\n }\n\n async updateCustomer(customerId: number, params: CustomerParams): Promise<Customer> {\n return this.request<Customer>('PATCH', `/api/v1/customers/${customerId}`, params);\n }\n\n /**\n * Helper to perform HTTP request to Fastaar API.\n */\n private async request<T>(method: string, path: string, body?: any): Promise<T> {\n let response: Response;\n\n try {\n response = await fetch(API_BASE_URL + path, {\n method,\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n ...(body ? { 'Content-Type': 'application/json' } : {}),\n },\n body: body ? JSON.stringify(body) : undefined,\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (error: any) {\n throw new FastaarError(`Could not reach the Fastaar API: ${error.message}`, 'connection_error');\n }\n\n const payload = await response.json().catch(() => null);\n\n if (!response.ok || payload === null) {\n throw new FastaarError(\n payload?.error?.message ?? `Fastaar API returned HTTP ${response.status}.`,\n payload?.error?.type ?? 'api_error',\n response.status,\n );\n }\n\n return (payload.data ?? payload) as T;\n }\n}\n\n// Global caching pattern for Next.js hot-reloading\nconst globalForFastaar = globalThis as unknown as {\n fastaarClient?: FastaarClient;\n};\n\n/**\n * Retrieves a cached singleton instance of FastaarClient initialized with\n * environment variables (FASTAAR_API_KEY, FASTAAR_TIMEOUT_MS).\n * Useful in Next.js API route handlers, Server Actions, and Server Components.\n */\nexport function getFastaarClient(): FastaarClient {\n if (!globalForFastaar.fastaarClient) {\n const apiKey = process.env.FASTAAR_API_KEY;\n if (!apiKey) {\n throw new FastaarError(\n 'FASTAAR_API_KEY environment variable is not defined.',\n 'authentication_error'\n );\n }\n\n const timeoutMs = process.env.FASTAAR_TIMEOUT_MS\n ? parseInt(process.env.FASTAAR_TIMEOUT_MS, 10)\n : undefined;\n\n globalForFastaar.fastaarClient = new FastaarClient(apiKey, { timeoutMs });\n }\n\n return globalForFastaar.fastaarClient;\n}\n"],"mappings":"AAWA,MAAM,eAAe;AAKd,MAAM,qBAAqB,MAAM;AAAA;AAAA;AAAA;AAAA,EAItC;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA,EAEA,YAAY,SAAiB,YAAY,aAAa,aAAa,GAAG;AACpE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;AAKO,MAAM,cAAc;AAAA,EACjB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,YAAY,QAAgB,UAAgC,CAAC,GAAG;AAC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AS;AAAA,MACX;AAAA,IACF;AAEA,WAAQ,QAAQ,QAAQ;AAAA,EAC1B;AACF;AAGA,MAAM,mBAAmB;AASlB,SAAS,mBAAkC;AAChD,MAAI,CAAC,iBAAiB,eAAe;AACnC,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAAY,QAAQ,IAAI,qBAC1B,SAAS,QAAQ,IAAI,oBAAoB,EAAE,IAC3C;AAEJ,qBAAiB,gBAAgB,IAAI,cAAc,QAAQ,EAAE,UAAU,CAAC;AAAA,EAC1E;AAEA,SAAO,iBAAiB;AAC1B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastaar/nextjs",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Next.js React Server Components & Route Handlers integration for Fastaar payment gateway",
5
5
  "license": "MIT",
6
6
  "type": "module",