@paykit-sdk/stripe 1.1.98 → 1.1.100

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.js CHANGED
@@ -4415,11 +4415,44 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
4415
4415
  method: "createPayment"
4416
4416
  });
4417
4417
  const { provider_metadata, customer, capture_method, ...rest } = data;
4418
- if (typeof customer === "object") {
4419
- throw new core.InvalidTypeError("customer", "string (customer ID)", "object", {
4420
- provider: this.providerName,
4421
- method: "createPayment"
4418
+ if (typeof customer === "object" && "email" in customer) {
4419
+ const checkoutMetadata = core.stringifyMetadataValues({
4420
+ ...rest.metadata,
4421
+ ...provider_metadata?.metadata ?? {},
4422
+ [core.PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
4422
4423
  });
4424
+ const checkoutSession = await this.stripe.checkout.sessions.create({
4425
+ mode: "payment",
4426
+ customer_email: customer.email,
4427
+ line_items: [
4428
+ {
4429
+ price_data: {
4430
+ currency: rest.currency,
4431
+ product_data: {
4432
+ name: `Payment for ${data.item_id || "item"}`
4433
+ },
4434
+ unit_amount: rest.amount
4435
+ },
4436
+ quantity: 1
4437
+ }
4438
+ ],
4439
+ metadata: checkoutMetadata,
4440
+ payment_intent_data: {
4441
+ capture_method,
4442
+ setup_future_usage: "off_session"
4443
+ }
4444
+ });
4445
+ return {
4446
+ id: checkoutSession.id,
4447
+ amount: rest.amount,
4448
+ currency: rest.currency,
4449
+ customer: customer.email,
4450
+ status: "requires_action",
4451
+ metadata: core.omitInternalMetadata(checkoutMetadata),
4452
+ item_id: data.item_id ?? null,
4453
+ requires_action: true,
4454
+ payment_url: checkoutSession.url
4455
+ };
4423
4456
  }
4424
4457
  const paymentMetadata = core.stringifyMetadataValues({
4425
4458
  ...rest.metadata,
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { schema, validateRequiredKeys, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, InvalidTypeError, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, createSubscriptionSchema, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, deletePaymentSchema, capturePaymentSchema, createRefundSchema, WebhookError, paykitEvent$InboundSchema, billingModeSchema, omitInternalMetadata, invoiceStatusSchema } from '@paykit-sdk/core';
1
+ import { schema, validateRequiredKeys, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, InvalidTypeError, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, createSubscriptionSchema, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, omitInternalMetadata, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, deletePaymentSchema, capturePaymentSchema, createRefundSchema, WebhookError, paykitEvent$InboundSchema, billingModeSchema, invoiceStatusSchema } from '@paykit-sdk/core';
2
2
  import Stripe from 'stripe';
3
3
 
4
4
  var __defProp = Object.defineProperty;
@@ -4409,11 +4409,44 @@ var StripeProvider = class extends AbstractPayKitProvider {
4409
4409
  method: "createPayment"
4410
4410
  });
4411
4411
  const { provider_metadata, customer, capture_method, ...rest } = data;
4412
- if (typeof customer === "object") {
4413
- throw new InvalidTypeError("customer", "string (customer ID)", "object", {
4414
- provider: this.providerName,
4415
- method: "createPayment"
4412
+ if (typeof customer === "object" && "email" in customer) {
4413
+ const checkoutMetadata = stringifyMetadataValues({
4414
+ ...rest.metadata,
4415
+ ...provider_metadata?.metadata ?? {},
4416
+ [PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
4416
4417
  });
4418
+ const checkoutSession = await this.stripe.checkout.sessions.create({
4419
+ mode: "payment",
4420
+ customer_email: customer.email,
4421
+ line_items: [
4422
+ {
4423
+ price_data: {
4424
+ currency: rest.currency,
4425
+ product_data: {
4426
+ name: `Payment for ${data.item_id || "item"}`
4427
+ },
4428
+ unit_amount: rest.amount
4429
+ },
4430
+ quantity: 1
4431
+ }
4432
+ ],
4433
+ metadata: checkoutMetadata,
4434
+ payment_intent_data: {
4435
+ capture_method,
4436
+ setup_future_usage: "off_session"
4437
+ }
4438
+ });
4439
+ return {
4440
+ id: checkoutSession.id,
4441
+ amount: rest.amount,
4442
+ currency: rest.currency,
4443
+ customer: customer.email,
4444
+ status: "requires_action",
4445
+ metadata: omitInternalMetadata(checkoutMetadata),
4446
+ item_id: data.item_id ?? null,
4447
+ requires_action: true,
4448
+ payment_url: checkoutSession.url
4449
+ };
4417
4450
  }
4418
4451
  const paymentMetadata = stringifyMetadataValues({
4419
4452
  ...rest.metadata,
@@ -4415,11 +4415,44 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
4415
4415
  method: "createPayment"
4416
4416
  });
4417
4417
  const { provider_metadata, customer, capture_method, ...rest } = data;
4418
- if (typeof customer === "object") {
4419
- throw new core.InvalidTypeError("customer", "string (customer ID)", "object", {
4420
- provider: this.providerName,
4421
- method: "createPayment"
4418
+ if (typeof customer === "object" && "email" in customer) {
4419
+ const checkoutMetadata = core.stringifyMetadataValues({
4420
+ ...rest.metadata,
4421
+ ...provider_metadata?.metadata ?? {},
4422
+ [core.PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
4422
4423
  });
4424
+ const checkoutSession = await this.stripe.checkout.sessions.create({
4425
+ mode: "payment",
4426
+ customer_email: customer.email,
4427
+ line_items: [
4428
+ {
4429
+ price_data: {
4430
+ currency: rest.currency,
4431
+ product_data: {
4432
+ name: `Payment for ${data.item_id || "item"}`
4433
+ },
4434
+ unit_amount: rest.amount
4435
+ },
4436
+ quantity: 1
4437
+ }
4438
+ ],
4439
+ metadata: checkoutMetadata,
4440
+ payment_intent_data: {
4441
+ capture_method,
4442
+ setup_future_usage: "off_session"
4443
+ }
4444
+ });
4445
+ return {
4446
+ id: checkoutSession.id,
4447
+ amount: rest.amount,
4448
+ currency: rest.currency,
4449
+ customer: customer.email,
4450
+ status: "requires_action",
4451
+ metadata: core.omitInternalMetadata(checkoutMetadata),
4452
+ item_id: data.item_id ?? null,
4453
+ requires_action: true,
4454
+ payment_url: checkoutSession.url
4455
+ };
4423
4456
  }
4424
4457
  const paymentMetadata = core.stringifyMetadataValues({
4425
4458
  ...rest.metadata,
@@ -1,4 +1,4 @@
1
- import { schema, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, InvalidTypeError, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, createSubscriptionSchema, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, deletePaymentSchema, capturePaymentSchema, createRefundSchema, WebhookError, paykitEvent$InboundSchema, billingModeSchema, omitInternalMetadata, invoiceStatusSchema } from '@paykit-sdk/core';
1
+ import { schema, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, InvalidTypeError, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, createSubscriptionSchema, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, omitInternalMetadata, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, deletePaymentSchema, capturePaymentSchema, createRefundSchema, WebhookError, paykitEvent$InboundSchema, billingModeSchema, invoiceStatusSchema } from '@paykit-sdk/core';
2
2
  import Stripe from 'stripe';
3
3
 
4
4
  var __defProp = Object.defineProperty;
@@ -4409,11 +4409,44 @@ var StripeProvider = class extends AbstractPayKitProvider {
4409
4409
  method: "createPayment"
4410
4410
  });
4411
4411
  const { provider_metadata, customer, capture_method, ...rest } = data;
4412
- if (typeof customer === "object") {
4413
- throw new InvalidTypeError("customer", "string (customer ID)", "object", {
4414
- provider: this.providerName,
4415
- method: "createPayment"
4412
+ if (typeof customer === "object" && "email" in customer) {
4413
+ const checkoutMetadata = stringifyMetadataValues({
4414
+ ...rest.metadata,
4415
+ ...provider_metadata?.metadata ?? {},
4416
+ [PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
4416
4417
  });
4418
+ const checkoutSession = await this.stripe.checkout.sessions.create({
4419
+ mode: "payment",
4420
+ customer_email: customer.email,
4421
+ line_items: [
4422
+ {
4423
+ price_data: {
4424
+ currency: rest.currency,
4425
+ product_data: {
4426
+ name: `Payment for ${data.item_id || "item"}`
4427
+ },
4428
+ unit_amount: rest.amount
4429
+ },
4430
+ quantity: 1
4431
+ }
4432
+ ],
4433
+ metadata: checkoutMetadata,
4434
+ payment_intent_data: {
4435
+ capture_method,
4436
+ setup_future_usage: "off_session"
4437
+ }
4438
+ });
4439
+ return {
4440
+ id: checkoutSession.id,
4441
+ amount: rest.amount,
4442
+ currency: rest.currency,
4443
+ customer: customer.email,
4444
+ status: "requires_action",
4445
+ metadata: omitInternalMetadata(checkoutMetadata),
4446
+ item_id: data.item_id ?? null,
4447
+ requires_action: true,
4448
+ payment_url: checkoutSession.url
4449
+ };
4417
4450
  }
4418
4451
  const paymentMetadata = stringifyMetadataValues({
4419
4452
  ...rest.metadata,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykit-sdk/stripe",
3
- "version": "1.1.98",
3
+ "version": "1.1.100",
4
4
  "description": "Stripe provider for PayKit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,6 +8,9 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
+ "scripts": {
12
+ "build": "tsup"
13
+ },
11
14
  "keywords": [
12
15
  "stripe",
13
16
  "paykit",
@@ -20,13 +23,13 @@
20
23
  "stripe": "^18.2.1"
21
24
  },
22
25
  "peerDependencies": {
23
- "@paykit-sdk/core": ">=1.1.98"
26
+ "@paykit-sdk/core": ">=1.1.101"
24
27
  },
25
28
  "devDependencies": {
29
+ "@paykit-sdk/core": "workspace:*",
26
30
  "tsup": "^8.0.0",
27
31
  "typescript": "^5.0.0",
28
- "zod": "^3.24.2",
29
- "@paykit-sdk/core": "1.1.98"
32
+ "zod": "^3.24.2"
30
33
  },
31
34
  "publishConfig": {
32
35
  "access": "public"
@@ -37,8 +40,5 @@
37
40
  },
38
41
  "bugs": {
39
42
  "url": "https://github.com/devodii/paykit/issues"
40
- },
41
- "scripts": {
42
- "build": "tsup"
43
43
  }
44
- }
44
+ }