@paykit-sdk/stripe 1.1.102 → 1.1.104

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
@@ -90,11 +90,16 @@ export async function POST(request: NextRequest) {
90
90
 
91
91
  const body = await request.text();
92
92
  const headers = Object.fromEntries(request.headers.entries());
93
- const url = request.url
94
- await webhook.handle({ body, headers, fullUrl: url });
93
+ const url = request.url;
95
94
 
96
- // Return immediately, processing happens in background
97
- return NextResponse.json({ success: true });
95
+ try {
96
+ console.log('Webhook handled');
97
+ await webhook.handle({ body, headers, fullUrl: url });
98
+ return NextResponse.json({ success: true });
99
+ } catch (error) {
100
+ console.log('Webhook Error', error);
101
+ return NextResponse.json({ success: false });
102
+ }
98
103
  }
99
104
  ```
100
105
 
package/dist/index.js CHANGED
@@ -4042,20 +4042,24 @@ var ostring = () => stringType().optional();
4042
4042
  var onumber = () => numberType().optional();
4043
4043
  var oboolean = () => booleanType().optional();
4044
4044
  var coerce = {
4045
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
4046
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4047
- boolean: (arg) => ZodBoolean.create({
4045
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4046
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4047
+ boolean: ((arg) => ZodBoolean.create({
4048
4048
  ...arg,
4049
4049
  coerce: true
4050
- }),
4051
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4052
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
4050
+ })),
4051
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4052
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4053
4053
  };
4054
4054
  var NEVER = INVALID;
4055
4055
  var paykitCheckout$InboundSchema = (checkout, lineItems) => {
4056
+ let customer = null;
4057
+ if (typeof checkout.customer === "string") customer = checkout.customer;
4058
+ else if (checkout.customer?.id) customer = checkout.customer.id;
4059
+ else customer = { email: checkout.customer_email ?? "" };
4056
4060
  return {
4057
4061
  id: checkout.id,
4058
- customer: typeof checkout.customer === "string" ? checkout.customer : checkout.customer?.id ?? "",
4062
+ customer,
4059
4063
  session_type: checkout.mode === "subscription" ? "recurring" : "one_time",
4060
4064
  payment_url: checkout.url,
4061
4065
  products: lineItems.map((item) => ({
@@ -4074,7 +4078,15 @@ var paykitCustomer$InboundSchema = (customer) => {
4074
4078
  email: customer.email ?? "",
4075
4079
  name: customer.name ?? "",
4076
4080
  phone: customer.phone ?? "",
4077
- metadata: core.omitInternalMetadata(customer.metadata ?? {})
4081
+ metadata: core.omitInternalMetadata(customer.metadata ?? {}),
4082
+ created_at: new Date(customer.created * 1e3),
4083
+ updated_at: null,
4084
+ custom_fields: {
4085
+ default_payment_method: typeof customer.invoice_settings?.default_payment_method === "string" ? customer.invoice_settings.default_payment_method : customer.invoice_settings?.default_payment_method?.id ?? null,
4086
+ balance: customer.balance,
4087
+ currency: customer.currency ?? null,
4088
+ delinquent: customer.delinquent ?? false
4089
+ }
4078
4090
  };
4079
4091
  };
4080
4092
  var paykitSubscription$InboundSchema = (subscription) => {
@@ -4100,7 +4112,9 @@ var paykitSubscription$InboundSchema = (subscription) => {
4100
4112
  current_period_start: new Date(subscription.start_date),
4101
4113
  current_period_end: new Date(subscription.cancel_at),
4102
4114
  metadata,
4103
- custom_fields: null
4115
+ custom_fields: null,
4116
+ requires_action: false,
4117
+ payment_url: null
4104
4118
  };
4105
4119
  };
4106
4120
  var paykitInvoice$InboundSchema = (invoice) => {
@@ -4362,7 +4376,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
4362
4376
  ...data.provider_metadata,
4363
4377
  ...defaultPaymentMethod && { default_payment_method: defaultPaymentMethod },
4364
4378
  customer: data.customer,
4365
- items: [{ price: data.item_id }],
4379
+ items: [{ price: data.item_id, quantity: data.quantity }],
4366
4380
  metadata: core.stringifyMetadataValues(data.metadata ?? {}),
4367
4381
  payment_behavior: "default_incomplete"
4368
4382
  // customer's default payment method will be used if available
@@ -4408,7 +4422,6 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
4408
4422
  * Payment management
4409
4423
  * Create a payment intent or checkout session for a payment
4410
4424
  */
4411
- // In packages/stripe/src/stripe-provider.ts
4412
4425
  this.createPayment = async (params) => {
4413
4426
  const { error, data } = core.createPaymentSchema.safeParse(params);
4414
4427
  if (error)
package/dist/index.mjs CHANGED
@@ -4036,20 +4036,24 @@ var ostring = () => stringType().optional();
4036
4036
  var onumber = () => numberType().optional();
4037
4037
  var oboolean = () => booleanType().optional();
4038
4038
  var coerce = {
4039
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
4040
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4041
- boolean: (arg) => ZodBoolean.create({
4039
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4040
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4041
+ boolean: ((arg) => ZodBoolean.create({
4042
4042
  ...arg,
4043
4043
  coerce: true
4044
- }),
4045
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4046
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
4044
+ })),
4045
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4046
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4047
4047
  };
4048
4048
  var NEVER = INVALID;
4049
4049
  var paykitCheckout$InboundSchema = (checkout, lineItems) => {
4050
+ let customer = null;
4051
+ if (typeof checkout.customer === "string") customer = checkout.customer;
4052
+ else if (checkout.customer?.id) customer = checkout.customer.id;
4053
+ else customer = { email: checkout.customer_email ?? "" };
4050
4054
  return {
4051
4055
  id: checkout.id,
4052
- customer: typeof checkout.customer === "string" ? checkout.customer : checkout.customer?.id ?? "",
4056
+ customer,
4053
4057
  session_type: checkout.mode === "subscription" ? "recurring" : "one_time",
4054
4058
  payment_url: checkout.url,
4055
4059
  products: lineItems.map((item) => ({
@@ -4068,7 +4072,15 @@ var paykitCustomer$InboundSchema = (customer) => {
4068
4072
  email: customer.email ?? "",
4069
4073
  name: customer.name ?? "",
4070
4074
  phone: customer.phone ?? "",
4071
- metadata: omitInternalMetadata(customer.metadata ?? {})
4075
+ metadata: omitInternalMetadata(customer.metadata ?? {}),
4076
+ created_at: new Date(customer.created * 1e3),
4077
+ updated_at: null,
4078
+ custom_fields: {
4079
+ default_payment_method: typeof customer.invoice_settings?.default_payment_method === "string" ? customer.invoice_settings.default_payment_method : customer.invoice_settings?.default_payment_method?.id ?? null,
4080
+ balance: customer.balance,
4081
+ currency: customer.currency ?? null,
4082
+ delinquent: customer.delinquent ?? false
4083
+ }
4072
4084
  };
4073
4085
  };
4074
4086
  var paykitSubscription$InboundSchema = (subscription) => {
@@ -4094,7 +4106,9 @@ var paykitSubscription$InboundSchema = (subscription) => {
4094
4106
  current_period_start: new Date(subscription.start_date),
4095
4107
  current_period_end: new Date(subscription.cancel_at),
4096
4108
  metadata,
4097
- custom_fields: null
4109
+ custom_fields: null,
4110
+ requires_action: false,
4111
+ payment_url: null
4098
4112
  };
4099
4113
  };
4100
4114
  var paykitInvoice$InboundSchema = (invoice) => {
@@ -4356,7 +4370,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
4356
4370
  ...data.provider_metadata,
4357
4371
  ...defaultPaymentMethod && { default_payment_method: defaultPaymentMethod },
4358
4372
  customer: data.customer,
4359
- items: [{ price: data.item_id }],
4373
+ items: [{ price: data.item_id, quantity: data.quantity }],
4360
4374
  metadata: stringifyMetadataValues(data.metadata ?? {}),
4361
4375
  payment_behavior: "default_incomplete"
4362
4376
  // customer's default payment method will be used if available
@@ -4402,7 +4416,6 @@ var StripeProvider = class extends AbstractPayKitProvider {
4402
4416
  * Payment management
4403
4417
  * Create a payment intent or checkout session for a payment
4404
4418
  */
4405
- // In packages/stripe/src/stripe-provider.ts
4406
4419
  this.createPayment = async (params) => {
4407
4420
  const { error, data } = createPaymentSchema.safeParse(params);
4408
4421
  if (error)
@@ -4042,20 +4042,24 @@ var ostring = () => stringType().optional();
4042
4042
  var onumber = () => numberType().optional();
4043
4043
  var oboolean = () => booleanType().optional();
4044
4044
  var coerce = {
4045
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
4046
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4047
- boolean: (arg) => ZodBoolean.create({
4045
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4046
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4047
+ boolean: ((arg) => ZodBoolean.create({
4048
4048
  ...arg,
4049
4049
  coerce: true
4050
- }),
4051
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4052
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
4050
+ })),
4051
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4052
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4053
4053
  };
4054
4054
  var NEVER = INVALID;
4055
4055
  var paykitCheckout$InboundSchema = (checkout, lineItems) => {
4056
+ let customer = null;
4057
+ if (typeof checkout.customer === "string") customer = checkout.customer;
4058
+ else if (checkout.customer?.id) customer = checkout.customer.id;
4059
+ else customer = { email: checkout.customer_email ?? "" };
4056
4060
  return {
4057
4061
  id: checkout.id,
4058
- customer: typeof checkout.customer === "string" ? checkout.customer : checkout.customer?.id ?? "",
4062
+ customer,
4059
4063
  session_type: checkout.mode === "subscription" ? "recurring" : "one_time",
4060
4064
  payment_url: checkout.url,
4061
4065
  products: lineItems.map((item) => ({
@@ -4074,7 +4078,15 @@ var paykitCustomer$InboundSchema = (customer) => {
4074
4078
  email: customer.email ?? "",
4075
4079
  name: customer.name ?? "",
4076
4080
  phone: customer.phone ?? "",
4077
- metadata: core.omitInternalMetadata(customer.metadata ?? {})
4081
+ metadata: core.omitInternalMetadata(customer.metadata ?? {}),
4082
+ created_at: new Date(customer.created * 1e3),
4083
+ updated_at: null,
4084
+ custom_fields: {
4085
+ default_payment_method: typeof customer.invoice_settings?.default_payment_method === "string" ? customer.invoice_settings.default_payment_method : customer.invoice_settings?.default_payment_method?.id ?? null,
4086
+ balance: customer.balance,
4087
+ currency: customer.currency ?? null,
4088
+ delinquent: customer.delinquent ?? false
4089
+ }
4078
4090
  };
4079
4091
  };
4080
4092
  var paykitSubscription$InboundSchema = (subscription) => {
@@ -4100,7 +4112,9 @@ var paykitSubscription$InboundSchema = (subscription) => {
4100
4112
  current_period_start: new Date(subscription.start_date),
4101
4113
  current_period_end: new Date(subscription.cancel_at),
4102
4114
  metadata,
4103
- custom_fields: null
4115
+ custom_fields: null,
4116
+ requires_action: false,
4117
+ payment_url: null
4104
4118
  };
4105
4119
  };
4106
4120
  var paykitInvoice$InboundSchema = (invoice) => {
@@ -4362,7 +4376,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
4362
4376
  ...data.provider_metadata,
4363
4377
  ...defaultPaymentMethod && { default_payment_method: defaultPaymentMethod },
4364
4378
  customer: data.customer,
4365
- items: [{ price: data.item_id }],
4379
+ items: [{ price: data.item_id, quantity: data.quantity }],
4366
4380
  metadata: core.stringifyMetadataValues(data.metadata ?? {}),
4367
4381
  payment_behavior: "default_incomplete"
4368
4382
  // customer's default payment method will be used if available
@@ -4408,7 +4422,6 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
4408
4422
  * Payment management
4409
4423
  * Create a payment intent or checkout session for a payment
4410
4424
  */
4411
- // In packages/stripe/src/stripe-provider.ts
4412
4425
  this.createPayment = async (params) => {
4413
4426
  const { error, data } = core.createPaymentSchema.safeParse(params);
4414
4427
  if (error)
@@ -4036,20 +4036,24 @@ var ostring = () => stringType().optional();
4036
4036
  var onumber = () => numberType().optional();
4037
4037
  var oboolean = () => booleanType().optional();
4038
4038
  var coerce = {
4039
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
4040
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4041
- boolean: (arg) => ZodBoolean.create({
4039
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4040
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4041
+ boolean: ((arg) => ZodBoolean.create({
4042
4042
  ...arg,
4043
4043
  coerce: true
4044
- }),
4045
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4046
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
4044
+ })),
4045
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4046
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4047
4047
  };
4048
4048
  var NEVER = INVALID;
4049
4049
  var paykitCheckout$InboundSchema = (checkout, lineItems) => {
4050
+ let customer = null;
4051
+ if (typeof checkout.customer === "string") customer = checkout.customer;
4052
+ else if (checkout.customer?.id) customer = checkout.customer.id;
4053
+ else customer = { email: checkout.customer_email ?? "" };
4050
4054
  return {
4051
4055
  id: checkout.id,
4052
- customer: typeof checkout.customer === "string" ? checkout.customer : checkout.customer?.id ?? "",
4056
+ customer,
4053
4057
  session_type: checkout.mode === "subscription" ? "recurring" : "one_time",
4054
4058
  payment_url: checkout.url,
4055
4059
  products: lineItems.map((item) => ({
@@ -4068,7 +4072,15 @@ var paykitCustomer$InboundSchema = (customer) => {
4068
4072
  email: customer.email ?? "",
4069
4073
  name: customer.name ?? "",
4070
4074
  phone: customer.phone ?? "",
4071
- metadata: omitInternalMetadata(customer.metadata ?? {})
4075
+ metadata: omitInternalMetadata(customer.metadata ?? {}),
4076
+ created_at: new Date(customer.created * 1e3),
4077
+ updated_at: null,
4078
+ custom_fields: {
4079
+ default_payment_method: typeof customer.invoice_settings?.default_payment_method === "string" ? customer.invoice_settings.default_payment_method : customer.invoice_settings?.default_payment_method?.id ?? null,
4080
+ balance: customer.balance,
4081
+ currency: customer.currency ?? null,
4082
+ delinquent: customer.delinquent ?? false
4083
+ }
4072
4084
  };
4073
4085
  };
4074
4086
  var paykitSubscription$InboundSchema = (subscription) => {
@@ -4094,7 +4106,9 @@ var paykitSubscription$InboundSchema = (subscription) => {
4094
4106
  current_period_start: new Date(subscription.start_date),
4095
4107
  current_period_end: new Date(subscription.cancel_at),
4096
4108
  metadata,
4097
- custom_fields: null
4109
+ custom_fields: null,
4110
+ requires_action: false,
4111
+ payment_url: null
4098
4112
  };
4099
4113
  };
4100
4114
  var paykitInvoice$InboundSchema = (invoice) => {
@@ -4356,7 +4370,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
4356
4370
  ...data.provider_metadata,
4357
4371
  ...defaultPaymentMethod && { default_payment_method: defaultPaymentMethod },
4358
4372
  customer: data.customer,
4359
- items: [{ price: data.item_id }],
4373
+ items: [{ price: data.item_id, quantity: data.quantity }],
4360
4374
  metadata: stringifyMetadataValues(data.metadata ?? {}),
4361
4375
  payment_behavior: "default_incomplete"
4362
4376
  // customer's default payment method will be used if available
@@ -4402,7 +4416,6 @@ var StripeProvider = class extends AbstractPayKitProvider {
4402
4416
  * Payment management
4403
4417
  * Create a payment intent or checkout session for a payment
4404
4418
  */
4405
- // In packages/stripe/src/stripe-provider.ts
4406
4419
  this.createPayment = async (params) => {
4407
4420
  const { error, data } = createPaymentSchema.safeParse(params);
4408
4421
  if (error)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykit-sdk/stripe",
3
- "version": "1.1.102",
3
+ "version": "1.1.104",
4
4
  "description": "Stripe provider for PayKit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,9 +8,6 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
- "scripts": {
12
- "build": "tsup"
13
- },
14
11
  "keywords": [
15
12
  "stripe",
16
13
  "paykit",
@@ -23,22 +20,25 @@
23
20
  "stripe": "^18.2.1"
24
21
  },
25
22
  "peerDependencies": {
26
- "@paykit-sdk/core": ">=1.1.101"
23
+ "@paykit-sdk/core": ">=1.1.102"
27
24
  },
28
25
  "devDependencies": {
29
- "@paykit-sdk/core": "workspace:*",
30
26
  "tsup": "^8.0.0",
31
27
  "typescript": "^5.0.0",
32
- "zod": "^3.24.2"
28
+ "zod": "^3.24.2",
29
+ "@paykit-sdk/core": "1.1.102"
33
30
  },
34
31
  "publishConfig": {
35
32
  "access": "public"
36
33
  },
37
34
  "repository": {
38
35
  "type": "git",
39
- "url": "git+https://github.com/devodii/paykit.git"
36
+ "url": "git+https://github.com/usepaykit/paykit-sdk.git"
40
37
  },
41
38
  "bugs": {
42
- "url": "https://github.com/devodii/paykit/issues"
39
+ "url": "https://github.com/usepaykit/paykit-sdk/issues"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup"
43
43
  }
44
- }
44
+ }