@paykit-sdk/stripe 1.1.98 → 1.1.99
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 +12 -6
- package/dist/index.mjs +12 -6
- package/dist/stripe-provider.js +12 -6
- package/dist/stripe-provider.mjs +12 -6
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -4415,11 +4415,15 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4415
4415
|
method: "createPayment"
|
|
4416
4416
|
});
|
|
4417
4417
|
const { provider_metadata, customer, capture_method, ...rest } = data;
|
|
4418
|
+
let customerId = customer;
|
|
4418
4419
|
if (typeof customer === "object") {
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4420
|
+
const newCustomer = await this.createCustomer({
|
|
4421
|
+
email: customer.email,
|
|
4422
|
+
name: customer.email.split("@")[0],
|
|
4423
|
+
phone: "",
|
|
4424
|
+
metadata: {}
|
|
4422
4425
|
});
|
|
4426
|
+
customerId = newCustomer.id;
|
|
4423
4427
|
}
|
|
4424
4428
|
const paymentMetadata = core.stringifyMetadataValues({
|
|
4425
4429
|
...rest.metadata,
|
|
@@ -4427,7 +4431,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4427
4431
|
[core.PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4428
4432
|
});
|
|
4429
4433
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4430
|
-
|
|
4434
|
+
customerId,
|
|
4431
4435
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4432
4436
|
);
|
|
4433
4437
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4438,7 +4442,9 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4438
4442
|
}
|
|
4439
4443
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4440
4444
|
if (!defaultPaymentMethod) {
|
|
4441
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4445
|
+
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4446
|
+
customer: customerId
|
|
4447
|
+
});
|
|
4442
4448
|
if (paymentMethods.data.length === 0) {
|
|
4443
4449
|
throw new core.ValidationError(
|
|
4444
4450
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4451,7 +4457,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4451
4457
|
currency: rest.currency,
|
|
4452
4458
|
amount: rest.amount,
|
|
4453
4459
|
metadata: paymentMetadata,
|
|
4454
|
-
customer,
|
|
4460
|
+
customer: customerId,
|
|
4455
4461
|
capture_method,
|
|
4456
4462
|
confirm: true,
|
|
4457
4463
|
// automatically confirms the payment
|
package/dist/index.mjs
CHANGED
|
@@ -4409,11 +4409,15 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4409
4409
|
method: "createPayment"
|
|
4410
4410
|
});
|
|
4411
4411
|
const { provider_metadata, customer, capture_method, ...rest } = data;
|
|
4412
|
+
let customerId = customer;
|
|
4412
4413
|
if (typeof customer === "object") {
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4414
|
+
const newCustomer = await this.createCustomer({
|
|
4415
|
+
email: customer.email,
|
|
4416
|
+
name: customer.email.split("@")[0],
|
|
4417
|
+
phone: "",
|
|
4418
|
+
metadata: {}
|
|
4416
4419
|
});
|
|
4420
|
+
customerId = newCustomer.id;
|
|
4417
4421
|
}
|
|
4418
4422
|
const paymentMetadata = stringifyMetadataValues({
|
|
4419
4423
|
...rest.metadata,
|
|
@@ -4421,7 +4425,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4421
4425
|
[PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4422
4426
|
});
|
|
4423
4427
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4424
|
-
|
|
4428
|
+
customerId,
|
|
4425
4429
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4426
4430
|
);
|
|
4427
4431
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4432,7 +4436,9 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4432
4436
|
}
|
|
4433
4437
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4434
4438
|
if (!defaultPaymentMethod) {
|
|
4435
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4439
|
+
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4440
|
+
customer: customerId
|
|
4441
|
+
});
|
|
4436
4442
|
if (paymentMethods.data.length === 0) {
|
|
4437
4443
|
throw new ValidationError(
|
|
4438
4444
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4445,7 +4451,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4445
4451
|
currency: rest.currency,
|
|
4446
4452
|
amount: rest.amount,
|
|
4447
4453
|
metadata: paymentMetadata,
|
|
4448
|
-
customer,
|
|
4454
|
+
customer: customerId,
|
|
4449
4455
|
capture_method,
|
|
4450
4456
|
confirm: true,
|
|
4451
4457
|
// automatically confirms the payment
|
package/dist/stripe-provider.js
CHANGED
|
@@ -4415,11 +4415,15 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4415
4415
|
method: "createPayment"
|
|
4416
4416
|
});
|
|
4417
4417
|
const { provider_metadata, customer, capture_method, ...rest } = data;
|
|
4418
|
+
let customerId = customer;
|
|
4418
4419
|
if (typeof customer === "object") {
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4420
|
+
const newCustomer = await this.createCustomer({
|
|
4421
|
+
email: customer.email,
|
|
4422
|
+
name: customer.email.split("@")[0],
|
|
4423
|
+
phone: "",
|
|
4424
|
+
metadata: {}
|
|
4422
4425
|
});
|
|
4426
|
+
customerId = newCustomer.id;
|
|
4423
4427
|
}
|
|
4424
4428
|
const paymentMetadata = core.stringifyMetadataValues({
|
|
4425
4429
|
...rest.metadata,
|
|
@@ -4427,7 +4431,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4427
4431
|
[core.PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4428
4432
|
});
|
|
4429
4433
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4430
|
-
|
|
4434
|
+
customerId,
|
|
4431
4435
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4432
4436
|
);
|
|
4433
4437
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4438,7 +4442,9 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4438
4442
|
}
|
|
4439
4443
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4440
4444
|
if (!defaultPaymentMethod) {
|
|
4441
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4445
|
+
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4446
|
+
customer: customerId
|
|
4447
|
+
});
|
|
4442
4448
|
if (paymentMethods.data.length === 0) {
|
|
4443
4449
|
throw new core.ValidationError(
|
|
4444
4450
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4451,7 +4457,7 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
4451
4457
|
currency: rest.currency,
|
|
4452
4458
|
amount: rest.amount,
|
|
4453
4459
|
metadata: paymentMetadata,
|
|
4454
|
-
customer,
|
|
4460
|
+
customer: customerId,
|
|
4455
4461
|
capture_method,
|
|
4456
4462
|
confirm: true,
|
|
4457
4463
|
// automatically confirms the payment
|
package/dist/stripe-provider.mjs
CHANGED
|
@@ -4409,11 +4409,15 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4409
4409
|
method: "createPayment"
|
|
4410
4410
|
});
|
|
4411
4411
|
const { provider_metadata, customer, capture_method, ...rest } = data;
|
|
4412
|
+
let customerId = customer;
|
|
4412
4413
|
if (typeof customer === "object") {
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4414
|
+
const newCustomer = await this.createCustomer({
|
|
4415
|
+
email: customer.email,
|
|
4416
|
+
name: customer.email.split("@")[0],
|
|
4417
|
+
phone: "",
|
|
4418
|
+
metadata: {}
|
|
4416
4419
|
});
|
|
4420
|
+
customerId = newCustomer.id;
|
|
4417
4421
|
}
|
|
4418
4422
|
const paymentMetadata = stringifyMetadataValues({
|
|
4419
4423
|
...rest.metadata,
|
|
@@ -4421,7 +4425,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4421
4425
|
[PAYKIT_METADATA_KEY]: JSON.stringify({ itemId: data.item_id ?? null })
|
|
4422
4426
|
});
|
|
4423
4427
|
const customerWithDefaultPaymentMethod = await this.stripe.customers.retrieve(
|
|
4424
|
-
|
|
4428
|
+
customerId,
|
|
4425
4429
|
{ expand: ["invoice_settings.default_payment_method"] }
|
|
4426
4430
|
);
|
|
4427
4431
|
if ("deleted" in customerWithDefaultPaymentMethod) {
|
|
@@ -4432,7 +4436,9 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4432
4436
|
}
|
|
4433
4437
|
let defaultPaymentMethod = customerWithDefaultPaymentMethod.invoice_settings?.default_payment_method;
|
|
4434
4438
|
if (!defaultPaymentMethod) {
|
|
4435
|
-
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4439
|
+
const paymentMethods = await this.stripe.paymentMethods.list({
|
|
4440
|
+
customer: customerId
|
|
4441
|
+
});
|
|
4436
4442
|
if (paymentMethods.data.length === 0) {
|
|
4437
4443
|
throw new ValidationError(
|
|
4438
4444
|
`Customer ${customer} has no payment methods. Add a payment method for the customer before creating a payment intent`,
|
|
@@ -4445,7 +4451,7 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
4445
4451
|
currency: rest.currency,
|
|
4446
4452
|
amount: rest.amount,
|
|
4447
4453
|
metadata: paymentMetadata,
|
|
4448
|
-
customer,
|
|
4454
|
+
customer: customerId,
|
|
4449
4455
|
capture_method,
|
|
4450
4456
|
confirm: true,
|
|
4451
4457
|
// automatically confirms the payment
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykit-sdk/stripe",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.99",
|
|
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.
|
|
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
|
+
}
|