@paykit-sdk/stripe 1.1.99 → 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 +40 -13
- package/dist/index.mjs +41 -14
- package/dist/stripe-provider.js +40 -13
- package/dist/stripe-provider.mjs +41 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4415,15 +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
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
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 })
|
|
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
|
+
}
|
|
4425
4444
|
});
|
|
4426
|
-
|
|
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
|
+
};
|
|
4427
4456
|
}
|
|
4428
4457
|
const paymentMetadata = core.stringifyMetadataValues({
|
|
4429
4458
|
...rest.metadata,
|
|
@@ -4431,7 +4460,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4431
4460
|
[core.PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4432
4461
|
});
|
|
4433
4462
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4434
|
-
|
|
4463
|
+
customer,
|
|
4435
4464
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4436
4465
|
);
|
|
4437
4466
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4442,9 +4471,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4442
4471
|
}
|
|
4443
4472
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4444
4473
|
if (!defaultPaymentMethod) {
|
|
4445
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4446
|
-
customer: customerId
|
|
4447
|
-
});
|
|
4474
|
+
const paymentMethods = await this.stripe.paymentMethods.list({ customer });
|
|
4448
4475
|
if (paymentMethods.data.length === 0) {
|
|
4449
4476
|
throw new core.ValidationError(
|
|
4450
4477
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4457,7 +4484,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4457
4484
|
currency: rest.currency,
|
|
4458
4485
|
amount: rest.amount,
|
|
4459
4486
|
metadata: paymentMetadata,
|
|
4460
|
-
customer
|
|
4487
|
+
customer,
|
|
4461
4488
|
capture_method,
|
|
4462
4489
|
confirm: true,
|
|
4463
4490
|
// automatically confirms the payment
|
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,
|
|
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,15 +4409,44 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4409
4409
|
method: "createPayment"
|
|
4410
4410
|
});
|
|
4411
4411
|
const { provider_metadata, customer, capture_method, ...rest } = data;
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
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 })
|
|
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
|
+
}
|
|
4419
4438
|
});
|
|
4420
|
-
|
|
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
|
+
};
|
|
4421
4450
|
}
|
|
4422
4451
|
const paymentMetadata = stringifyMetadataValues({
|
|
4423
4452
|
...rest.metadata,
|
|
@@ -4425,7 +4454,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4425
4454
|
[PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4426
4455
|
});
|
|
4427
4456
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4428
|
-
|
|
4457
|
+
customer,
|
|
4429
4458
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4430
4459
|
);
|
|
4431
4460
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4436,9 +4465,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4436
4465
|
}
|
|
4437
4466
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4438
4467
|
if (!defaultPaymentMethod) {
|
|
4439
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4440
|
-
customer: customerId
|
|
4441
|
-
});
|
|
4468
|
+
const paymentMethods = await this.stripe.paymentMethods.list({ customer });
|
|
4442
4469
|
if (paymentMethods.data.length === 0) {
|
|
4443
4470
|
throw new ValidationError(
|
|
4444
4471
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4451,7 +4478,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4451
4478
|
currency: rest.currency,
|
|
4452
4479
|
amount: rest.amount,
|
|
4453
4480
|
metadata: paymentMetadata,
|
|
4454
|
-
customer
|
|
4481
|
+
customer,
|
|
4455
4482
|
capture_method,
|
|
4456
4483
|
confirm: true,
|
|
4457
4484
|
// automatically confirms the payment
|
package/dist/stripe-provider.js
CHANGED
|
@@ -4415,15 +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
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
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 })
|
|
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
|
+
}
|
|
4425
4444
|
});
|
|
4426
|
-
|
|
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
|
+
};
|
|
4427
4456
|
}
|
|
4428
4457
|
const paymentMetadata = core.stringifyMetadataValues({
|
|
4429
4458
|
...rest.metadata,
|
|
@@ -4431,7 +4460,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4431
4460
|
[core.PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4432
4461
|
});
|
|
4433
4462
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4434
|
-
|
|
4463
|
+
customer,
|
|
4435
4464
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4436
4465
|
);
|
|
4437
4466
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4442,9 +4471,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4442
4471
|
}
|
|
4443
4472
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4444
4473
|
if (!defaultPaymentMethod) {
|
|
4445
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4446
|
-
customer: customerId
|
|
4447
|
-
});
|
|
4474
|
+
const paymentMethods = await this.stripe.paymentMethods.list({ customer });
|
|
4448
4475
|
if (paymentMethods.data.length === 0) {
|
|
4449
4476
|
throw new core.ValidationError(
|
|
4450
4477
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4457,7 +4484,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4457
4484
|
currency: rest.currency,
|
|
4458
4485
|
amount: rest.amount,
|
|
4459
4486
|
metadata: paymentMetadata,
|
|
4460
|
-
customer
|
|
4487
|
+
customer,
|
|
4461
4488
|
capture_method,
|
|
4462
4489
|
confirm: true,
|
|
4463
4490
|
// automatically confirms the payment
|
package/dist/stripe-provider.mjs
CHANGED
|
@@ -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,
|
|
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,15 +4409,44 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4409
4409
|
method: "createPayment"
|
|
4410
4410
|
});
|
|
4411
4411
|
const { provider_metadata, customer, capture_method, ...rest } = data;
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
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 })
|
|
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
|
+
}
|
|
4419
4438
|
});
|
|
4420
|
-
|
|
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
|
+
};
|
|
4421
4450
|
}
|
|
4422
4451
|
const paymentMetadata = stringifyMetadataValues({
|
|
4423
4452
|
...rest.metadata,
|
|
@@ -4425,7 +4454,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4425
4454
|
[PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4426
4455
|
});
|
|
4427
4456
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4428
|
-
|
|
4457
|
+
customer,
|
|
4429
4458
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4430
4459
|
);
|
|
4431
4460
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4436,9 +4465,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4436
4465
|
}
|
|
4437
4466
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4438
4467
|
if (!defaultPaymentMethod) {
|
|
4439
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4440
|
-
customer: customerId
|
|
4441
|
-
});
|
|
4468
|
+
const paymentMethods = await this.stripe.paymentMethods.list({ customer });
|
|
4442
4469
|
if (paymentMethods.data.length === 0) {
|
|
4443
4470
|
throw new ValidationError(
|
|
4444
4471
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4451,7 +4478,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4451
4478
|
currency: rest.currency,
|
|
4452
4479
|
amount: rest.amount,
|
|
4453
4480
|
metadata: paymentMetadata,
|
|
4454
|
-
customer
|
|
4481
|
+
customer,
|
|
4455
4482
|
capture_method,
|
|
4456
4483
|
confirm: true,
|
|
4457
4484
|
// automatically confirms the payment
|