@nymbalhq/adapter-stripe 1.1.0 → 1.2.0

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
@@ -1,4 +1,4 @@
1
- import { Logger, PaymentsAdapter, AdapterContext } from '@nymbalhq/types';
1
+ import { Logger, PaymentsAdapter, AdapterContext, AdapterSetting } from '@nymbalhq/types';
2
2
 
3
3
  interface StripePaymentsConfig {
4
4
  secretKey: string;
@@ -18,7 +18,10 @@ declare function createStripePaymentsAdapter(deps: {
18
18
  config: StripePaymentsConfig;
19
19
  }): PaymentsAdapter;
20
20
 
21
+ /** The fields the admin's Settings may fill when the config and these variables leave them unset. */
22
+ declare const settings: AdapterSetting[];
21
23
  /** The kernel's entry: `payments: { provider: 'stripe', config: StripePaymentsConfig }`. */
22
24
  declare function createAdapter(ctx: AdapterContext): PaymentsAdapter;
23
25
 
24
- export { type StripePaymentsConfig, createAdapter, createStripePaymentsAdapter };
26
+ export { createAdapter, createStripePaymentsAdapter, settings };
27
+ export type { StripePaymentsConfig };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // src/index.ts
2
- import { ConfigError } from "@nymbalhq/types";
2
+ import {
3
+ ConfigError
4
+ } from "@nymbalhq/types";
3
5
 
4
6
  // src/stripe-adapter.ts
5
7
  import Stripe from "stripe";
@@ -216,6 +218,21 @@ function createStripePaymentsAdapter(deps) {
216
218
  }
217
219
 
218
220
  // src/index.ts
221
+ var settings = [
222
+ { path: "secretKey", label: "Secret key", secret: true, env: "STRIPE_SECRET_KEY" },
223
+ {
224
+ path: "webhookSecret",
225
+ label: "Webhook signing secret",
226
+ secret: true,
227
+ env: "STRIPE_WEBHOOK_SECRET"
228
+ },
229
+ {
230
+ path: "publishableKey",
231
+ label: "Publishable key",
232
+ secret: false,
233
+ env: "STRIPE_PUBLISHABLE_KEY"
234
+ }
235
+ ];
219
236
  function createAdapter(ctx) {
220
237
  if (ctx.slot !== "payments") {
221
238
  throw new ConfigError(`@nymbalhq/adapter-stripe serves payments, not ${ctx.slot}`, {
@@ -232,6 +249,7 @@ function createAdapter(ctx) {
232
249
  }
233
250
  export {
234
251
  createAdapter,
235
- createStripePaymentsAdapter
252
+ createStripePaymentsAdapter,
253
+ settings
236
254
  };
237
255
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/stripe-adapter.ts"],"sourcesContent":["import { ConfigError, type AdapterContext, type PaymentsAdapter } from '@nymbalhq/types'\nimport { createStripePaymentsAdapter, type StripePaymentsConfig } from './stripe-adapter.js'\n\nexport { createStripePaymentsAdapter, type StripePaymentsConfig }\n\n/** The kernel's entry: `payments: { provider: 'stripe', config: StripePaymentsConfig }`. */\nexport function createAdapter(ctx: AdapterContext): PaymentsAdapter {\n if (ctx.slot !== 'payments') {\n throw new ConfigError(`@nymbalhq/adapter-stripe serves payments, not ${ctx.slot}`, {\n code: 'adapter.wrong_slot',\n context: { slot: ctx.slot },\n })\n }\n const config = ctx.config as unknown as StripePaymentsConfig\n const publishableKey = config.publishableKey ?? ctx.env['STRIPE_PUBLISHABLE_KEY']\n return createStripePaymentsAdapter({\n logger: ctx.logger,\n config: { ...config, ...(publishableKey !== undefined && { publishableKey }) },\n })\n}\n","import Stripe from 'stripe'\nimport {\n EVT_PAYMENT_CAPTURED,\n EVT_PAYMENT_FAILED,\n EVT_PAYMENT_REFUNDED,\n PaymentError,\n type Logger,\n type PaymentCapture,\n type PaymentIntent,\n type PaymentIntentParams,\n type PaymentStatus,\n type PaymentsAdapter,\n type Refund,\n type WebhookResult,\n} from '@nymbalhq/types'\n\nexport interface StripePaymentsConfig {\n secretKey: string\n webhookSecret: string\n /** The public key the storefront's Stripe.js uses; served by GET /api/capabilities. */\n publishableKey?: string\n apiVersion?: string\n /** Override the Stripe API host (for stripe-mock style test servers). Omit in production. */\n host?: string\n /** Override the Stripe API port. Only used together with `host`. */\n port?: number\n /** Override the Stripe API protocol. Defaults to https when omitted. */\n protocol?: 'http' | 'https'\n}\n\n/**\n * Stripe returns lowercase ISO currency codes (e.g. \"gbp\"); Nymbal's canonical\n * currency format is uppercase ISO 4217 (e.g. \"GBP\") everywhere else in the\n * domain, so adapter results are normalised on the way out.\n */\nfunction toIsoCurrency(currency: string): string {\n return currency.toUpperCase()\n}\n\nfunction mapStatus(status: Stripe.PaymentIntent.Status): PaymentStatus {\n switch (status) {\n case 'requires_payment_method':\n case 'requires_confirmation':\n case 'requires_action':\n case 'processing':\n case 'requires_capture':\n case 'succeeded':\n case 'canceled':\n return status === 'canceled' ? 'cancelled' : (status as PaymentStatus)\n default:\n return 'failed'\n }\n}\n\nfunction refundStatus(status: string | null): Refund['status'] {\n if (status === 'succeeded') return 'succeeded'\n if (status === 'failed' || status === 'canceled') return 'failed'\n return 'pending'\n}\n\n/**\n * Stripe refused the refund outright (a card error, an invalid request): no money moved. Anything else (an API error,\n * a timeout, a dropped connection) leaves the outcome unknown.\n */\nfunction isDefiniteRefusal(err: unknown): boolean {\n const type = (err as { type?: unknown } | null)?.type\n return type === 'StripeCardError' || type === 'StripeInvalidRequestError'\n}\n\nfunction toIntent(intent: Stripe.PaymentIntent): PaymentIntent {\n return {\n id: intent.id,\n clientSecret: intent.client_secret ?? '',\n amountMinor: intent.amount,\n currency: toIsoCurrency(intent.currency),\n status: mapStatus(intent.status),\n }\n}\n\nexport function createStripePaymentsAdapter(deps: {\n logger: Logger\n config: StripePaymentsConfig\n}): PaymentsAdapter {\n const { logger } = deps\n const cfg = deps.config\n if (!cfg.secretKey) throw new PaymentError('not_configured', 'Stripe secretKey missing')\n if (!cfg.webhookSecret) throw new PaymentError('not_configured', 'Stripe webhookSecret missing')\n // The publishable key is served to every shopper: a secret or restricted key pasted there must never be.\n if (cfg.publishableKey !== undefined && /^(sk|rk)_/.test(cfg.publishableKey)) {\n throw new PaymentError(\n 'not_configured',\n 'Stripe publishableKey holds a secret key; use the pk_ key',\n )\n }\n const stripeClient = new Stripe(cfg.secretKey, {\n ...(cfg.apiVersion !== undefined && {\n apiVersion: cfg.apiVersion as Stripe.LatestApiVersion,\n }),\n ...(cfg.host !== undefined && { host: cfg.host }),\n ...(cfg.port !== undefined && { port: cfg.port }),\n ...(cfg.protocol !== undefined && { protocol: cfg.protocol }),\n })\n return {\n kind: 'payments',\n providerName: 'stripe',\n capabilities: () => ['intent', 'capture', 'refund', 'webhook'],\n // Without a key the storefront's stripe driver reports it cannot mount, which keeps Place Order disabled.\n client: () => ({\n driver: 'stripe',\n options: cfg.publishableKey ? { publishableKey: cfg.publishableKey } : {},\n }),\n producesEvents: [EVT_PAYMENT_CAPTURED, EVT_PAYMENT_FAILED, EVT_PAYMENT_REFUNDED],\n consumesEvents: [],\n async initialize() {\n // no-op: Stripe client already constructed\n },\n async healthCheck() {\n try {\n await stripeClient.balance.retrieve()\n return { status: 'healthy' }\n } catch (err) {\n return {\n status: 'down',\n detail: err instanceof Error ? err.message : String(err),\n }\n }\n },\n async createPaymentIntent(params: PaymentIntentParams): Promise<PaymentIntent> {\n try {\n const intent = await stripeClient.paymentIntents.create({\n amount: params.amountMinor,\n currency: params.currency.toLowerCase(),\n automatic_payment_methods: { enabled: true },\n ...(params.receiptEmail !== undefined && { receipt_email: params.receiptEmail }),\n metadata: {\n ...(params.metadata ?? {}),\n ...(params.orderRef !== undefined ? { orderRef: params.orderRef } : {}),\n ...(params.customerId !== undefined ? { customerId: params.customerId } : {}),\n },\n })\n return toIntent(intent)\n } catch (err) {\n throw new PaymentError('intent_failed', 'Stripe createPaymentIntent failed', { cause: err })\n }\n },\n async capturePayment(intentId, amountMinor): Promise<PaymentCapture> {\n try {\n const captured = await stripeClient.paymentIntents.capture(intentId, {\n ...(amountMinor !== undefined && { amount_to_capture: amountMinor }),\n })\n return {\n paymentId: captured.id,\n capturedAmountMinor: captured.amount_received ?? captured.amount,\n currency: toIsoCurrency(captured.currency),\n status: mapStatus(captured.status),\n }\n } catch (err) {\n throw new PaymentError('capture_failed', 'Stripe capturePayment failed', { cause: err })\n }\n },\n async refund(paymentId, amountMinor, reason, opts): Promise<Refund> {\n const params: Stripe.RefundCreateParams = {\n payment_intent: paymentId,\n ...(amountMinor !== undefined && { amount: amountMinor }),\n ...(reason !== undefined && { reason: reason as Stripe.RefundCreateParams.Reason }),\n }\n try {\n const refund =\n opts?.idempotencyKey === undefined\n ? await stripeClient.refunds.create(params)\n : await stripeClient.refunds.create(params, { idempotencyKey: opts.idempotencyKey })\n return {\n refundId: refund.id,\n paymentId,\n amountMinor: refund.amount,\n currency: toIsoCurrency(refund.currency),\n reason: refund.reason ?? null,\n status: refundStatus(refund.status),\n }\n } catch (err) {\n if (isDefiniteRefusal(err)) {\n throw new PaymentError('refund_rejected', 'Stripe refused the refund', { cause: err })\n }\n throw new PaymentError('refund_unknown', 'Stripe refund outcome unknown', { cause: err })\n }\n },\n async getPaymentStatus(intentId): Promise<PaymentStatus> {\n const intent = await stripeClient.paymentIntents.retrieve(intentId)\n return mapStatus(intent.status)\n },\n async getPaymentIntent(intentId): Promise<PaymentIntent> {\n try {\n return toIntent(await stripeClient.paymentIntents.retrieve(intentId))\n } catch (err) {\n throw new PaymentError('intent_failed', 'Stripe getPaymentIntent failed', { cause: err })\n }\n },\n async cancelPaymentIntent(intentId): Promise<void> {\n try {\n await stripeClient.paymentIntents.cancel(intentId)\n } catch (err) {\n // A cancel that lost a race with an earlier one of ours is done; anything else (processing, captured) stays.\n const status = await stripeClient.paymentIntents\n .retrieve(intentId)\n .then((intent) => intent.status)\n .catch(() => undefined)\n if (status === 'canceled') return\n throw new PaymentError('cancel_refused', `Stripe would not cancel ${intentId}`, {\n cause: err,\n })\n }\n },\n async parseWebhook(rawBody, signature): Promise<WebhookResult> {\n let event: Stripe.Event\n try {\n event = stripeClient.webhooks.constructEvent(rawBody, signature, cfg.webhookSecret)\n } catch (err) {\n throw new PaymentError('webhook_invalid', 'Stripe webhook signature invalid', {\n cause: err,\n })\n }\n const baseResult = { verified: true, eventId: event.id } as const\n switch (event.type) {\n case 'payment_intent.succeeded': {\n const intent = event.data.object as Stripe.PaymentIntent\n return {\n ...baseResult,\n kind: 'payment.captured',\n paymentIntentId: intent.id,\n amountMinor: intent.amount_received ?? intent.amount,\n currency: toIsoCurrency(intent.currency),\n raw: { ...intent } as unknown as Record<string, unknown>,\n }\n }\n case 'payment_intent.payment_failed': {\n const intent = event.data.object as Stripe.PaymentIntent\n return {\n ...baseResult,\n kind: 'payment.failed',\n paymentIntentId: intent.id,\n reason: intent.last_payment_error?.message ?? 'payment failed',\n }\n }\n case 'charge.refunded': {\n const charge = event.data.object as Stripe.Charge\n const pi =\n typeof charge.payment_intent === 'string'\n ? charge.payment_intent\n : charge.payment_intent?.id\n return {\n ...baseResult,\n kind: 'payment.refunded',\n ...(pi !== undefined && { paymentIntentId: pi }),\n amountMinor: charge.amount_refunded,\n currency: toIsoCurrency(charge.currency),\n }\n }\n default:\n logger.debug({ type: event.type }, 'stripe webhook ignored')\n return { ...baseResult, kind: 'ignored' }\n }\n },\n }\n}\n"],"mappings":";AAAA,SAAS,mBAA8D;;;ACAvE,OAAO,YAAY;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASK;AAqBP,SAAS,cAAc,UAA0B;AAC/C,SAAO,SAAS,YAAY;AAC9B;AAEA,SAAS,UAAU,QAAoD;AACrE,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW,aAAa,cAAe;AAAA,IAChD;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,aAAa,QAAyC;AAC7D,MAAI,WAAW,YAAa,QAAO;AACnC,MAAI,WAAW,YAAY,WAAW,WAAY,QAAO;AACzD,SAAO;AACT;AAMA,SAAS,kBAAkB,KAAuB;AAChD,QAAM,OAAQ,KAAmC;A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MAAM;AAAA,YACN,GAAI,OAAO,UAAa,EAAE,iBAAiB,GAAG;AAAA,YAC9C,aAAa,OAAO;AAAA,YACpB,UAAU,cAAc,OAAO,QAAQ;AAAA,UACzC;AAAA,QACF;AAAA,QACA;AACE,iBAAO,MAAM,EAAE,MAAM,MAAM,KAAK,GAAG,wBAAwB;AAC3D,iBAAO,EAAE,GAAG,YAAY,MAAM,UAAU;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;;;ADjQO,SAAS,cAAc,KAAsC;AAClE,MAAI,IAAI,SAAS,YAAY;AAC3B,UAAM,IAAI,YAAY,iDAAiD,IAAI,IAAI,IAAI;AAAA,MACjF,MAAM;AAAA,MACN,SAAS,EAAE,MAAM,IAAI,KAAK;AAAA,IAC5B,CAAC;AAAA,EACH;AACA,QAAM,SAAS,IAAI;AACnB,QAAM,iBAAiB,OAAO,kBAAkB,IAAI,IAAI,wBAAwB;AAChF,SAAO,4BAA4B;AAAA,IACjC,QAAQ,IAAI;AAAA,IACZ,QAAQ,EAAE,GAAG,QAAQ,GAAI,mBAAmB,UAAa,EAAE,eAAe,EAAG;AAAA,EAC/E,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/stripe-adapter.ts"],"sourcesContent":["import {\n ConfigError,\n type AdapterContext,\n type AdapterSetting,\n type PaymentsAdapter,\n} from '@nymbalhq/types'\nimport { createStripePaymentsAdapter, type StripePaymentsConfig } from './stripe-adapter.js'\n\nexport { createStripePaymentsAdapter, type StripePaymentsConfig }\n\n/** The fields the admin's Settings may fill when the config and these variables leave them unset. */\nexport const settings: AdapterSetting[] = [\n { path: 'secretKey', label: 'Secret key', secret: true, env: 'STRIPE_SECRET_KEY' },\n {\n path: 'webhookSecret',\n label: 'Webhook signing secret',\n secret: true,\n env: 'STRIPE_WEBHOOK_SECRET',\n },\n {\n path: 'publishableKey',\n label: 'Publishable key',\n secret: false,\n env: 'STRIPE_PUBLISHABLE_KEY',\n },\n]\n\n/** The kernel's entry: `payments: { provider: 'stripe', config: StripePaymentsConfig }`. */\nexport function createAdapter(ctx: AdapterContext): PaymentsAdapter {\n if (ctx.slot !== 'payments') {\n throw new ConfigError(`@nymbalhq/adapter-stripe serves payments, not ${ctx.slot}`, {\n code: 'adapter.wrong_slot',\n context: { slot: ctx.slot },\n })\n }\n const config = ctx.config as unknown as StripePaymentsConfig\n const publishableKey = config.publishableKey ?? ctx.env['STRIPE_PUBLISHABLE_KEY']\n return createStripePaymentsAdapter({\n logger: ctx.logger,\n config: { ...config, ...(publishableKey !== undefined && { publishableKey }) },\n })\n}\n","import Stripe from 'stripe'\nimport {\n EVT_PAYMENT_CAPTURED,\n EVT_PAYMENT_FAILED,\n EVT_PAYMENT_REFUNDED,\n PaymentError,\n type Logger,\n type PaymentCapture,\n type PaymentIntent,\n type PaymentIntentParams,\n type PaymentStatus,\n type PaymentsAdapter,\n type Refund,\n type WebhookResult,\n} from '@nymbalhq/types'\n\nexport interface StripePaymentsConfig {\n secretKey: string\n webhookSecret: string\n /** The public key the storefront's Stripe.js uses; served by GET /api/capabilities. */\n publishableKey?: string\n apiVersion?: string\n /** Override the Stripe API host (for stripe-mock style test servers). Omit in production. */\n host?: string\n /** Override the Stripe API port. Only used together with `host`. */\n port?: number\n /** Override the Stripe API protocol. Defaults to https when omitted. */\n protocol?: 'http' | 'https'\n}\n\n/**\n * Stripe returns lowercase ISO currency codes (e.g. \"gbp\"); Nymbal's canonical\n * currency format is uppercase ISO 4217 (e.g. \"GBP\") everywhere else in the\n * domain, so adapter results are normalised on the way out.\n */\nfunction toIsoCurrency(currency: string): string {\n return currency.toUpperCase()\n}\n\nfunction mapStatus(status: Stripe.PaymentIntent.Status): PaymentStatus {\n switch (status) {\n case 'requires_payment_method':\n case 'requires_confirmation':\n case 'requires_action':\n case 'processing':\n case 'requires_capture':\n case 'succeeded':\n case 'canceled':\n return status === 'canceled' ? 'cancelled' : (status as PaymentStatus)\n default:\n return 'failed'\n }\n}\n\nfunction refundStatus(status: string | null): Refund['status'] {\n if (status === 'succeeded') return 'succeeded'\n if (status === 'failed' || status === 'canceled') return 'failed'\n return 'pending'\n}\n\n/**\n * Stripe refused the refund outright (a card error, an invalid request): no money moved. Anything else (an API error,\n * a timeout, a dropped connection) leaves the outcome unknown.\n */\nfunction isDefiniteRefusal(err: unknown): boolean {\n const type = (err as { type?: unknown } | null)?.type\n return type === 'StripeCardError' || type === 'StripeInvalidRequestError'\n}\n\nfunction toIntent(intent: Stripe.PaymentIntent): PaymentIntent {\n return {\n id: intent.id,\n clientSecret: intent.client_secret ?? '',\n amountMinor: intent.amount,\n currency: toIsoCurrency(intent.currency),\n status: mapStatus(intent.status),\n }\n}\n\nexport function createStripePaymentsAdapter(deps: {\n logger: Logger\n config: StripePaymentsConfig\n}): PaymentsAdapter {\n const { logger } = deps\n const cfg = deps.config\n if (!cfg.secretKey) throw new PaymentError('not_configured', 'Stripe secretKey missing')\n if (!cfg.webhookSecret) throw new PaymentError('not_configured', 'Stripe webhookSecret missing')\n // The publishable key is served to every shopper: a secret or restricted key pasted there must never be.\n if (cfg.publishableKey !== undefined && /^(sk|rk)_/.test(cfg.publishableKey)) {\n throw new PaymentError(\n 'not_configured',\n 'Stripe publishableKey holds a secret key; use the pk_ key',\n )\n }\n const stripeClient = new Stripe(cfg.secretKey, {\n ...(cfg.apiVersion !== undefined && {\n apiVersion: cfg.apiVersion as Stripe.LatestApiVersion,\n }),\n ...(cfg.host !== undefined && { host: cfg.host }),\n ...(cfg.port !== undefined && { port: cfg.port }),\n ...(cfg.protocol !== undefined && { protocol: cfg.protocol }),\n })\n return {\n kind: 'payments',\n providerName: 'stripe',\n capabilities: () => ['intent', 'capture', 'refund', 'webhook'],\n // Without a key the storefront's stripe driver reports it cannot mount, which keeps Place Order disabled.\n client: () => ({\n driver: 'stripe',\n options: cfg.publishableKey ? { publishableKey: cfg.publishableKey } : {},\n }),\n producesEvents: [EVT_PAYMENT_CAPTURED, EVT_PAYMENT_FAILED, EVT_PAYMENT_REFUNDED],\n consumesEvents: [],\n async initialize() {\n // no-op: Stripe client already constructed\n },\n async healthCheck() {\n try {\n await stripeClient.balance.retrieve()\n return { status: 'healthy' }\n } catch (err) {\n return {\n status: 'down',\n detail: err instanceof Error ? err.message : String(err),\n }\n }\n },\n async createPaymentIntent(params: PaymentIntentParams): Promise<PaymentIntent> {\n try {\n const intent = await stripeClient.paymentIntents.create({\n amount: params.amountMinor,\n currency: params.currency.toLowerCase(),\n automatic_payment_methods: { enabled: true },\n ...(params.receiptEmail !== undefined && { receipt_email: params.receiptEmail }),\n metadata: {\n ...(params.metadata ?? {}),\n ...(params.orderRef !== undefined ? { orderRef: params.orderRef } : {}),\n ...(params.customerId !== undefined ? { customerId: params.customerId } : {}),\n },\n })\n return toIntent(intent)\n } catch (err) {\n throw new PaymentError('intent_failed', 'Stripe createPaymentIntent failed', { cause: err })\n }\n },\n async capturePayment(intentId, amountMinor): Promise<PaymentCapture> {\n try {\n const captured = await stripeClient.paymentIntents.capture(intentId, {\n ...(amountMinor !== undefined && { amount_to_capture: amountMinor }),\n })\n return {\n paymentId: captured.id,\n capturedAmountMinor: captured.amount_received ?? captured.amount,\n currency: toIsoCurrency(captured.currency),\n status: mapStatus(captured.status),\n }\n } catch (err) {\n throw new PaymentError('capture_failed', 'Stripe capturePayment failed', { cause: err })\n }\n },\n async refund(paymentId, amountMinor, reason, opts): Promise<Refund> {\n const params: Stripe.RefundCreateParams = {\n payment_intent: paymentId,\n ...(amountMinor !== undefined && { amount: amountMinor }),\n ...(reason !== undefined && { reason: reason as Stripe.RefundCreateParams.Reason }),\n }\n try {\n const refund =\n opts?.idempotencyKey === undefined\n ? await stripeClient.refunds.create(params)\n : await stripeClient.refunds.create(params, { idempotencyKey: opts.idempotencyKey })\n return {\n refundId: refund.id,\n paymentId,\n amountMinor: refund.amount,\n currency: toIsoCurrency(refund.currency),\n reason: refund.reason ?? null,\n status: refundStatus(refund.status),\n }\n } catch (err) {\n if (isDefiniteRefusal(err)) {\n throw new PaymentError('refund_rejected', 'Stripe refused the refund', { cause: err })\n }\n throw new PaymentError('refund_unknown', 'Stripe refund outcome unknown', { cause: err })\n }\n },\n async getPaymentStatus(intentId): Promise<PaymentStatus> {\n const intent = await stripeClient.paymentIntents.retrieve(intentId)\n return mapStatus(intent.status)\n },\n async getPaymentIntent(intentId): Promise<PaymentIntent> {\n try {\n return toIntent(await stripeClient.paymentIntents.retrieve(intentId))\n } catch (err) {\n throw new PaymentError('intent_failed', 'Stripe getPaymentIntent failed', { cause: err })\n }\n },\n async cancelPaymentIntent(intentId): Promise<void> {\n try {\n await stripeClient.paymentIntents.cancel(intentId)\n } catch (err) {\n // A cancel that lost a race with an earlier one of ours is done; anything else (processing, captured) stays.\n const status = await stripeClient.paymentIntents\n .retrieve(intentId)\n .then((intent) => intent.status)\n .catch(() => undefined)\n if (status === 'canceled') return\n throw new PaymentError('cancel_refused', `Stripe would not cancel ${intentId}`, {\n cause: err,\n })\n }\n },\n async parseWebhook(rawBody, signature): Promise<WebhookResult> {\n let event: Stripe.Event\n try {\n event = stripeClient.webhooks.constructEvent(rawBody, signature, cfg.webhookSecret)\n } catch (err) {\n throw new PaymentError('webhook_invalid', 'Stripe webhook signature invalid', {\n cause: err,\n })\n }\n const baseResult = { verified: true, eventId: event.id } as const\n switch (event.type) {\n case 'payment_intent.succeeded': {\n const intent = event.data.object as Stripe.PaymentIntent\n return {\n ...baseResult,\n kind: 'payment.captured',\n paymentIntentId: intent.id,\n amountMinor: intent.amount_received ?? intent.amount,\n currency: toIsoCurrency(intent.currency),\n raw: { ...intent } as unknown as Record<string, unknown>,\n }\n }\n case 'payment_intent.payment_failed': {\n const intent = event.data.object as Stripe.PaymentIntent\n return {\n ...baseResult,\n kind: 'payment.failed',\n paymentIntentId: intent.id,\n reason: intent.last_payment_error?.message ?? 'payment failed',\n }\n }\n case 'charge.refunded': {\n const charge = event.data.object as Stripe.Charge\n const pi =\n typeof charge.payment_intent === 'string'\n ? charge.payment_intent\n : charge.payment_intent?.id\n return {\n ...baseResult,\n kind: 'payment.refunded',\n ...(pi !== undefined && { paymentIntentId: pi }),\n amountMinor: charge.amount_refunded,\n currency: toIsoCurrency(charge.currency),\n }\n }\n default:\n logger.debug({ type: event.type }, 'stripe webhook ignored')\n return { ...baseResult, kind: 'ignored' }\n }\n },\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAIK;;;ACLP,OAAO,YAAY;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OASK;AAqBP,SAAS,cAAc,UAA0B;AAC/C,SAAO,SAAS,YAAY;AAC9B;AAEA,SAAS,UAAU,QAAoD;AACrE,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW,aAAa,cAAe;AAAA,IAChD;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,aAAa,QAAyC;AAC7D,MAAI,WAAW,YAAa,QAAO;AACnC,MAAI,WAAW,YAAY,WAAW,WAAY,QAAO;AACzD,SAAO;AACT;AAMA,SAAS,kBAAkB,KAAuB;AAChD,QAAM,OAAQ,KAAmC;AACjD,SAAO,SAAS,qBAAqB,SAAS;AAChD;AAEA,SAAS,SAAS,QAA6C;AAC7D,SAAO;AAAA,IACL,IAAI,OAAO;AAAA,IACX,cAAc,OAAO,iBAAiB;AAAA,IACtC,aAAa,OAAO;AAAA,IACpB,UAAU,cAAc,OAAO,QAAQ;AAAA,IACvC,QAAQ,UAAU,OAAO,MAAM;AAAA,EACjC;AACF;AAEO,SAAS,4BAA4B,MAGxB;AAClB,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,MAAM,KAAK;AACjB,MAAI,CAAC,IAAI,UAAW,OAAM,IAAI,aAAa,kBAAkB,0BAA0B;AACvF,MAAI,CAAC,IAAI,cAAe,OAAM,IAAI,aAAa,kBAAkB,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AAAA,IACR,KAAK;AAAA,EACP;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AACF;AAGO,SAAS,cAAc,KAAsC;AAClE,MAAI,IAAI,SAAS,YAAY;AAC3B,UAAM,IAAI,YAAY,iDAAiD,IAAI,IAAI,IAAI;AAAA,MACjF,MAAM;AAAA,MACN,SAAS,EAAE,MAAM,IAAI,KAAK;AAAA,IAC5B,CAAC;AAAA,EACH;AACA,QAAM,SAAS,IAAI;AACnB,QAAM,iBAAiB,OAAO,kBAAkB,IAAI,IAAI,wBAAwB;AAChF,SAAO,4BAA4B;AAAA,IACjC,QAAQ,IAAI;AAAA,IACZ,QAAQ,EAAE,GAAG,QAAQ,GAAI,mBAAmB,UAAa,EAAE,eAAe,EAAG;AAAA,EAC/E,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nymbalhq/adapter-stripe",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Stripe payments for Nymbal: the `stripe` payments provider",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,21 +29,22 @@
29
29
  "recipes"
30
30
  ],
31
31
  "dependencies": {
32
- "@nymbalhq/types": "1.1.0"
32
+ "@nymbalhq/types": "1.2.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "stripe": "^17.4.0"
36
36
  },
37
37
  "devDependencies": {
38
+ "@typescript/native": "npm:typescript@^7.0.2",
38
39
  "fast-check": "^4.10.2",
39
40
  "stripe": "^17.4.0",
40
- "tsup": "^8.3.5",
41
- "typescript": "^5.6.3",
41
+ "tsup": "^9.0.0",
42
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
42
43
  "vitest": "^3.0.0"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "tsup",
46
47
  "dev": "tsup --watch",
47
- "typecheck": "tsc -p tsconfig.json --noEmit"
48
+ "typecheck": "tsc -p tsconfig.json --noEmit --rootDir ../.."
48
49
  }
49
50
  }
@@ -6,11 +6,7 @@
6
6
  {
7
7
  "path": "commerce.payments",
8
8
  "value": {
9
- "provider": "stripe",
10
- "config": {
11
- "secretKey": { "env": "STRIPE_SECRET_KEY" },
12
- "webhookSecret": { "env": "STRIPE_WEBHOOK_SECRET" }
13
- }
9
+ "provider": "stripe"
14
10
  }
15
11
  }
16
12
  ],