@paykit-sdk/stripe 1.2.1 → 1.2.3
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 +105 -19
- package/dist/index.mjs +106 -20
- package/dist/stripe-provider.d.mts +2 -0
- package/dist/stripe-provider.d.ts +2 -0
- package/dist/stripe-provider.js +103 -15
- package/dist/stripe-provider.mjs +104 -16
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -289,19 +289,33 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
289
289
|
name: data.name,
|
|
290
290
|
email: data.email
|
|
291
291
|
});
|
|
292
|
+
const {
|
|
293
|
+
billing: _billing,
|
|
294
|
+
metadata,
|
|
295
|
+
provider_metadata,
|
|
296
|
+
name: _name,
|
|
297
|
+
...stripeParams
|
|
298
|
+
} = data;
|
|
292
299
|
const customer = await this.stripe.customers.create({
|
|
293
|
-
...
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
...provider_metadata,
|
|
301
|
+
...stripeParams,
|
|
302
|
+
phone: data.phone ?? void 0,
|
|
303
|
+
name: fullName,
|
|
304
|
+
metadata: core.stringifyMetadataValues(metadata ?? {})
|
|
296
305
|
});
|
|
297
306
|
return Customer$inboundSchema(customer);
|
|
298
307
|
};
|
|
299
308
|
this.updateCustomer = async (id, params) => {
|
|
300
|
-
const {
|
|
309
|
+
const {
|
|
310
|
+
provider_metadata,
|
|
311
|
+
billing: _billing,
|
|
312
|
+
metadata,
|
|
313
|
+
...rest
|
|
314
|
+
} = params;
|
|
301
315
|
const customer = await this.stripe.customers.update(id, {
|
|
302
316
|
...provider_metadata,
|
|
303
317
|
...rest,
|
|
304
|
-
metadata: core.stringifyMetadataValues(
|
|
318
|
+
metadata: core.stringifyMetadataValues(metadata ?? {}),
|
|
305
319
|
phone: rest.phone ?? void 0
|
|
306
320
|
});
|
|
307
321
|
return Customer$inboundSchema(customer);
|
|
@@ -547,7 +561,8 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
547
561
|
);
|
|
548
562
|
}
|
|
549
563
|
const { provider_metadata, customer, ...rest } = data;
|
|
550
|
-
const
|
|
564
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
565
|
+
const payment = await this.stripe.paymentIntents.retrieve(piId);
|
|
551
566
|
const paymentOptions = {
|
|
552
567
|
...provider_metadata,
|
|
553
568
|
metadata: core.stringifyMetadataValues({
|
|
@@ -569,10 +584,10 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
569
584
|
paymentOptions.receipt_email = customer.email;
|
|
570
585
|
}
|
|
571
586
|
const updatedPayment = await this.stripe.paymentIntents.update(
|
|
572
|
-
|
|
587
|
+
piId,
|
|
573
588
|
paymentOptions
|
|
574
589
|
);
|
|
575
|
-
return Payment$inboundSchema(updatedPayment);
|
|
590
|
+
return { ...Payment$inboundSchema(updatedPayment), id };
|
|
576
591
|
};
|
|
577
592
|
this.retrievePayment = async (id) => {
|
|
578
593
|
const { error, data } = core.retrievePaymentSchema.safeParse({ id });
|
|
@@ -583,6 +598,34 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
583
598
|
"retrievePayment"
|
|
584
599
|
);
|
|
585
600
|
}
|
|
601
|
+
if (data.id.startsWith("cs_")) {
|
|
602
|
+
const [session, sessionError] = await core.tryCatchAsync(
|
|
603
|
+
this.stripe.checkout.sessions.retrieve(data.id, {
|
|
604
|
+
expand: ["payment_intent"]
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
if (!session || sessionError?.code === "resource_missing")
|
|
608
|
+
return null;
|
|
609
|
+
if (session.payment_intent && typeof session.payment_intent !== "string") {
|
|
610
|
+
return {
|
|
611
|
+
...Payment$inboundSchema(
|
|
612
|
+
session.payment_intent
|
|
613
|
+
),
|
|
614
|
+
id: data.id
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
id: data.id,
|
|
619
|
+
amount: session.amount_total ?? 0,
|
|
620
|
+
currency: session.currency ?? "",
|
|
621
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
622
|
+
status: "pending",
|
|
623
|
+
metadata: core.omitInternalMetadata(session.metadata ?? {}),
|
|
624
|
+
item_id: null,
|
|
625
|
+
requires_action: true,
|
|
626
|
+
payment_url: session.url
|
|
627
|
+
};
|
|
628
|
+
}
|
|
586
629
|
const [payment, paymentError] = await core.tryCatchAsync(
|
|
587
630
|
this.stripe.paymentIntents.retrieve(data.id)
|
|
588
631
|
);
|
|
@@ -599,6 +642,10 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
599
642
|
"deletePayment"
|
|
600
643
|
);
|
|
601
644
|
}
|
|
645
|
+
if (data.id.startsWith("cs_")) {
|
|
646
|
+
await this.stripe.checkout.sessions.expire(data.id);
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
602
649
|
await this.stripe.paymentIntents.cancel(data.id);
|
|
603
650
|
return null;
|
|
604
651
|
};
|
|
@@ -611,12 +658,27 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
611
658
|
"capturePayment"
|
|
612
659
|
);
|
|
613
660
|
}
|
|
614
|
-
const
|
|
661
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
662
|
+
const payment = await this.stripe.paymentIntents.capture(piId, {
|
|
615
663
|
amount_to_capture: data.amount
|
|
616
664
|
});
|
|
617
|
-
return Payment$inboundSchema(payment);
|
|
665
|
+
return { ...Payment$inboundSchema(payment), id };
|
|
618
666
|
};
|
|
619
667
|
this.cancelPayment = async (id) => {
|
|
668
|
+
if (id.startsWith("cs_")) {
|
|
669
|
+
const session = await this.stripe.checkout.sessions.expire(id);
|
|
670
|
+
return {
|
|
671
|
+
id,
|
|
672
|
+
amount: session.amount_total ?? 0,
|
|
673
|
+
currency: session.currency ?? "",
|
|
674
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
675
|
+
status: "canceled",
|
|
676
|
+
metadata: core.omitInternalMetadata(session.metadata ?? {}),
|
|
677
|
+
item_id: null,
|
|
678
|
+
requires_action: false,
|
|
679
|
+
payment_url: null
|
|
680
|
+
};
|
|
681
|
+
}
|
|
620
682
|
const canceledPayment = await this.stripe.paymentIntents.cancel(id);
|
|
621
683
|
return Payment$inboundSchema(canceledPayment);
|
|
622
684
|
};
|
|
@@ -646,7 +708,18 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
646
708
|
amount: rest.amount,
|
|
647
709
|
metadata: core.stringifyMetadataValues(rest.metadata ?? {})
|
|
648
710
|
};
|
|
649
|
-
if (data.payment_id.startsWith("
|
|
711
|
+
if (data.payment_id.startsWith("cs_")) {
|
|
712
|
+
const session = await this.stripe.checkout.sessions.retrieve(
|
|
713
|
+
data.payment_id
|
|
714
|
+
);
|
|
715
|
+
if (!session.payment_intent) {
|
|
716
|
+
throw new core.ValidationError(
|
|
717
|
+
"Checkout Session has no associated PaymentIntent to refund",
|
|
718
|
+
{ provider: this.providerName, method: "createRefund" }
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
stripeRefundOptions.payment_intent = typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
722
|
+
} else if (data.payment_id.startsWith("pi_")) {
|
|
650
723
|
stripeRefundOptions.payment_intent = data.payment_id;
|
|
651
724
|
} else {
|
|
652
725
|
stripeRefundOptions.charge = data.payment_id;
|
|
@@ -885,14 +958,29 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
885
958
|
}
|
|
886
959
|
return results;
|
|
887
960
|
};
|
|
888
|
-
const { debug
|
|
889
|
-
|
|
890
|
-
this.
|
|
891
|
-
this.
|
|
961
|
+
const { debug, apiKey, isSandbox, ...stripeConfig } = opts;
|
|
962
|
+
const resolvedSandbox = isSandbox ?? apiKey.includes("_test_");
|
|
963
|
+
this.stripe = new Stripe__default.default(apiKey, stripeConfig);
|
|
964
|
+
this.opts = { ...opts, debug: debug ?? resolvedSandbox };
|
|
965
|
+
this.isSandbox = resolvedSandbox;
|
|
892
966
|
}
|
|
893
967
|
get _native() {
|
|
894
968
|
return this.stripe;
|
|
895
969
|
}
|
|
970
|
+
async _resolvePaymentIntentId(id) {
|
|
971
|
+
if (!id.startsWith("cs_")) return id;
|
|
972
|
+
const session = await this.stripe.checkout.sessions.retrieve(id);
|
|
973
|
+
if (!session.payment_intent) {
|
|
974
|
+
throw new core.ValidationError(
|
|
975
|
+
"Checkout Session has no associated PaymentIntent yet",
|
|
976
|
+
{
|
|
977
|
+
provider: this.providerName,
|
|
978
|
+
method: "resolvePaymentIntentId"
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
return typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
983
|
+
}
|
|
896
984
|
};
|
|
897
985
|
|
|
898
986
|
// src/index.ts
|
|
@@ -905,12 +993,10 @@ var stripe = () => {
|
|
|
905
993
|
process.env ?? {},
|
|
906
994
|
"Missing required environment variables: {keys}"
|
|
907
995
|
);
|
|
908
|
-
const isSandbox = process.env.NODE_ENV === "development";
|
|
909
996
|
return createStripe({
|
|
910
997
|
apiKey: envVars.STRIPE_API_KEY,
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
apiVersion: "2025-07-30.basil"
|
|
998
|
+
apiVersion: "2025-07-30.basil",
|
|
999
|
+
isSandbox: envVars.STRIPE_API_KEY.includes("_test_") || process.env.NODE_ENV !== "production"
|
|
914
1000
|
});
|
|
915
1001
|
};
|
|
916
1002
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema, Schema, validateRequiredKeys, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, isIdCustomer, isEmailCustomer, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, parseCustomerName, createSubscriptionSchema, InvalidTypeError, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, deletePaymentSchema, capturePaymentSchema, createRefundSchema, refundReasonMatcher, WebhookError,
|
|
1
|
+
import { schema, Schema, validateRequiredKeys, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, isIdCustomer, isEmailCustomer, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, parseCustomerName, createSubscriptionSchema, InvalidTypeError, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, omitInternalMetadata, deletePaymentSchema, capturePaymentSchema, createRefundSchema, refundReasonMatcher, WebhookError, paykitEvent$InboundSchema, billingModeSchema, invoiceStatusSchema } from '@paykit-sdk/core';
|
|
2
2
|
import Stripe from 'stripe';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
@@ -283,19 +283,33 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
283
283
|
name: data.name,
|
|
284
284
|
email: data.email
|
|
285
285
|
});
|
|
286
|
+
const {
|
|
287
|
+
billing: _billing,
|
|
288
|
+
metadata,
|
|
289
|
+
provider_metadata,
|
|
290
|
+
name: _name,
|
|
291
|
+
...stripeParams
|
|
292
|
+
} = data;
|
|
286
293
|
const customer = await this.stripe.customers.create({
|
|
287
|
-
...
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
...provider_metadata,
|
|
295
|
+
...stripeParams,
|
|
296
|
+
phone: data.phone ?? void 0,
|
|
297
|
+
name: fullName,
|
|
298
|
+
metadata: stringifyMetadataValues(metadata ?? {})
|
|
290
299
|
});
|
|
291
300
|
return Customer$inboundSchema(customer);
|
|
292
301
|
};
|
|
293
302
|
this.updateCustomer = async (id, params) => {
|
|
294
|
-
const {
|
|
303
|
+
const {
|
|
304
|
+
provider_metadata,
|
|
305
|
+
billing: _billing,
|
|
306
|
+
metadata,
|
|
307
|
+
...rest
|
|
308
|
+
} = params;
|
|
295
309
|
const customer = await this.stripe.customers.update(id, {
|
|
296
310
|
...provider_metadata,
|
|
297
311
|
...rest,
|
|
298
|
-
metadata: stringifyMetadataValues(
|
|
312
|
+
metadata: stringifyMetadataValues(metadata ?? {}),
|
|
299
313
|
phone: rest.phone ?? void 0
|
|
300
314
|
});
|
|
301
315
|
return Customer$inboundSchema(customer);
|
|
@@ -541,7 +555,8 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
541
555
|
);
|
|
542
556
|
}
|
|
543
557
|
const { provider_metadata, customer, ...rest } = data;
|
|
544
|
-
const
|
|
558
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
559
|
+
const payment = await this.stripe.paymentIntents.retrieve(piId);
|
|
545
560
|
const paymentOptions = {
|
|
546
561
|
...provider_metadata,
|
|
547
562
|
metadata: stringifyMetadataValues({
|
|
@@ -563,10 +578,10 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
563
578
|
paymentOptions.receipt_email = customer.email;
|
|
564
579
|
}
|
|
565
580
|
const updatedPayment = await this.stripe.paymentIntents.update(
|
|
566
|
-
|
|
581
|
+
piId,
|
|
567
582
|
paymentOptions
|
|
568
583
|
);
|
|
569
|
-
return Payment$inboundSchema(updatedPayment);
|
|
584
|
+
return { ...Payment$inboundSchema(updatedPayment), id };
|
|
570
585
|
};
|
|
571
586
|
this.retrievePayment = async (id) => {
|
|
572
587
|
const { error, data } = retrievePaymentSchema.safeParse({ id });
|
|
@@ -577,6 +592,34 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
577
592
|
"retrievePayment"
|
|
578
593
|
);
|
|
579
594
|
}
|
|
595
|
+
if (data.id.startsWith("cs_")) {
|
|
596
|
+
const [session, sessionError] = await tryCatchAsync(
|
|
597
|
+
this.stripe.checkout.sessions.retrieve(data.id, {
|
|
598
|
+
expand: ["payment_intent"]
|
|
599
|
+
})
|
|
600
|
+
);
|
|
601
|
+
if (!session || sessionError?.code === "resource_missing")
|
|
602
|
+
return null;
|
|
603
|
+
if (session.payment_intent && typeof session.payment_intent !== "string") {
|
|
604
|
+
return {
|
|
605
|
+
...Payment$inboundSchema(
|
|
606
|
+
session.payment_intent
|
|
607
|
+
),
|
|
608
|
+
id: data.id
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
return {
|
|
612
|
+
id: data.id,
|
|
613
|
+
amount: session.amount_total ?? 0,
|
|
614
|
+
currency: session.currency ?? "",
|
|
615
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
616
|
+
status: "pending",
|
|
617
|
+
metadata: omitInternalMetadata(session.metadata ?? {}),
|
|
618
|
+
item_id: null,
|
|
619
|
+
requires_action: true,
|
|
620
|
+
payment_url: session.url
|
|
621
|
+
};
|
|
622
|
+
}
|
|
580
623
|
const [payment, paymentError] = await tryCatchAsync(
|
|
581
624
|
this.stripe.paymentIntents.retrieve(data.id)
|
|
582
625
|
);
|
|
@@ -593,6 +636,10 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
593
636
|
"deletePayment"
|
|
594
637
|
);
|
|
595
638
|
}
|
|
639
|
+
if (data.id.startsWith("cs_")) {
|
|
640
|
+
await this.stripe.checkout.sessions.expire(data.id);
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
596
643
|
await this.stripe.paymentIntents.cancel(data.id);
|
|
597
644
|
return null;
|
|
598
645
|
};
|
|
@@ -605,12 +652,27 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
605
652
|
"capturePayment"
|
|
606
653
|
);
|
|
607
654
|
}
|
|
608
|
-
const
|
|
655
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
656
|
+
const payment = await this.stripe.paymentIntents.capture(piId, {
|
|
609
657
|
amount_to_capture: data.amount
|
|
610
658
|
});
|
|
611
|
-
return Payment$inboundSchema(payment);
|
|
659
|
+
return { ...Payment$inboundSchema(payment), id };
|
|
612
660
|
};
|
|
613
661
|
this.cancelPayment = async (id) => {
|
|
662
|
+
if (id.startsWith("cs_")) {
|
|
663
|
+
const session = await this.stripe.checkout.sessions.expire(id);
|
|
664
|
+
return {
|
|
665
|
+
id,
|
|
666
|
+
amount: session.amount_total ?? 0,
|
|
667
|
+
currency: session.currency ?? "",
|
|
668
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
669
|
+
status: "canceled",
|
|
670
|
+
metadata: omitInternalMetadata(session.metadata ?? {}),
|
|
671
|
+
item_id: null,
|
|
672
|
+
requires_action: false,
|
|
673
|
+
payment_url: null
|
|
674
|
+
};
|
|
675
|
+
}
|
|
614
676
|
const canceledPayment = await this.stripe.paymentIntents.cancel(id);
|
|
615
677
|
return Payment$inboundSchema(canceledPayment);
|
|
616
678
|
};
|
|
@@ -640,7 +702,18 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
640
702
|
amount: rest.amount,
|
|
641
703
|
metadata: stringifyMetadataValues(rest.metadata ?? {})
|
|
642
704
|
};
|
|
643
|
-
if (data.payment_id.startsWith("
|
|
705
|
+
if (data.payment_id.startsWith("cs_")) {
|
|
706
|
+
const session = await this.stripe.checkout.sessions.retrieve(
|
|
707
|
+
data.payment_id
|
|
708
|
+
);
|
|
709
|
+
if (!session.payment_intent) {
|
|
710
|
+
throw new ValidationError(
|
|
711
|
+
"Checkout Session has no associated PaymentIntent to refund",
|
|
712
|
+
{ provider: this.providerName, method: "createRefund" }
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
stripeRefundOptions.payment_intent = typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
716
|
+
} else if (data.payment_id.startsWith("pi_")) {
|
|
644
717
|
stripeRefundOptions.payment_intent = data.payment_id;
|
|
645
718
|
} else {
|
|
646
719
|
stripeRefundOptions.charge = data.payment_id;
|
|
@@ -879,14 +952,29 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
879
952
|
}
|
|
880
953
|
return results;
|
|
881
954
|
};
|
|
882
|
-
const { debug
|
|
883
|
-
|
|
884
|
-
this.
|
|
885
|
-
this.
|
|
955
|
+
const { debug, apiKey, isSandbox, ...stripeConfig } = opts;
|
|
956
|
+
const resolvedSandbox = isSandbox ?? apiKey.includes("_test_");
|
|
957
|
+
this.stripe = new Stripe(apiKey, stripeConfig);
|
|
958
|
+
this.opts = { ...opts, debug: debug ?? resolvedSandbox };
|
|
959
|
+
this.isSandbox = resolvedSandbox;
|
|
886
960
|
}
|
|
887
961
|
get _native() {
|
|
888
962
|
return this.stripe;
|
|
889
963
|
}
|
|
964
|
+
async _resolvePaymentIntentId(id) {
|
|
965
|
+
if (!id.startsWith("cs_")) return id;
|
|
966
|
+
const session = await this.stripe.checkout.sessions.retrieve(id);
|
|
967
|
+
if (!session.payment_intent) {
|
|
968
|
+
throw new ValidationError(
|
|
969
|
+
"Checkout Session has no associated PaymentIntent yet",
|
|
970
|
+
{
|
|
971
|
+
provider: this.providerName,
|
|
972
|
+
method: "resolvePaymentIntentId"
|
|
973
|
+
}
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
return typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
977
|
+
}
|
|
890
978
|
};
|
|
891
979
|
|
|
892
980
|
// src/index.ts
|
|
@@ -899,12 +987,10 @@ var stripe = () => {
|
|
|
899
987
|
process.env ?? {},
|
|
900
988
|
"Missing required environment variables: {keys}"
|
|
901
989
|
);
|
|
902
|
-
const isSandbox = process.env.NODE_ENV === "development";
|
|
903
990
|
return createStripe({
|
|
904
991
|
apiKey: envVars.STRIPE_API_KEY,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
apiVersion: "2025-07-30.basil"
|
|
992
|
+
apiVersion: "2025-07-30.basil",
|
|
993
|
+
isSandbox: envVars.STRIPE_API_KEY.includes("_test_") || process.env.NODE_ENV !== "production"
|
|
908
994
|
});
|
|
909
995
|
};
|
|
910
996
|
|
|
@@ -9,6 +9,7 @@ interface StripeMetadata extends ProviderMetadataRegistry {
|
|
|
9
9
|
refund: Stripe.RefundCreateParams;
|
|
10
10
|
}
|
|
11
11
|
interface StripeOptions extends PaykitProviderOptions, Stripe.StripeConfig {
|
|
12
|
+
/** Stripe secret key (sk_test_... or sk_live_...) */
|
|
12
13
|
apiKey: string;
|
|
13
14
|
}
|
|
14
15
|
type StripeRawEvents = {
|
|
@@ -23,6 +24,7 @@ declare class StripeProvider extends AbstractPayKitProvider implements PayKitPro
|
|
|
23
24
|
constructor(opts: StripeOptions);
|
|
24
25
|
readonly providerName = "stripe";
|
|
25
26
|
get _native(): Stripe;
|
|
27
|
+
private _resolvePaymentIntentId;
|
|
26
28
|
createCheckout: (params: CreateCheckoutSchema<StripeMetadata["checkout"]>) => Promise<Checkout>;
|
|
27
29
|
retrieveCheckout: (id: string) => Promise<Checkout>;
|
|
28
30
|
updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>;
|
|
@@ -9,6 +9,7 @@ interface StripeMetadata extends ProviderMetadataRegistry {
|
|
|
9
9
|
refund: Stripe.RefundCreateParams;
|
|
10
10
|
}
|
|
11
11
|
interface StripeOptions extends PaykitProviderOptions, Stripe.StripeConfig {
|
|
12
|
+
/** Stripe secret key (sk_test_... or sk_live_...) */
|
|
12
13
|
apiKey: string;
|
|
13
14
|
}
|
|
14
15
|
type StripeRawEvents = {
|
|
@@ -23,6 +24,7 @@ declare class StripeProvider extends AbstractPayKitProvider implements PayKitPro
|
|
|
23
24
|
constructor(opts: StripeOptions);
|
|
24
25
|
readonly providerName = "stripe";
|
|
25
26
|
get _native(): Stripe;
|
|
27
|
+
private _resolvePaymentIntentId;
|
|
26
28
|
createCheckout: (params: CreateCheckoutSchema<StripeMetadata["checkout"]>) => Promise<Checkout>;
|
|
27
29
|
retrieveCheckout: (id: string) => Promise<Checkout>;
|
|
28
30
|
updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>;
|
package/dist/stripe-provider.js
CHANGED
|
@@ -289,19 +289,33 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
289
289
|
name: data.name,
|
|
290
290
|
email: data.email
|
|
291
291
|
});
|
|
292
|
+
const {
|
|
293
|
+
billing: _billing,
|
|
294
|
+
metadata,
|
|
295
|
+
provider_metadata,
|
|
296
|
+
name: _name,
|
|
297
|
+
...stripeParams
|
|
298
|
+
} = data;
|
|
292
299
|
const customer = await this.stripe.customers.create({
|
|
293
|
-
...
|
|
294
|
-
|
|
295
|
-
|
|
300
|
+
...provider_metadata,
|
|
301
|
+
...stripeParams,
|
|
302
|
+
phone: data.phone ?? void 0,
|
|
303
|
+
name: fullName,
|
|
304
|
+
metadata: core.stringifyMetadataValues(metadata ?? {})
|
|
296
305
|
});
|
|
297
306
|
return Customer$inboundSchema(customer);
|
|
298
307
|
};
|
|
299
308
|
this.updateCustomer = async (id, params) => {
|
|
300
|
-
const {
|
|
309
|
+
const {
|
|
310
|
+
provider_metadata,
|
|
311
|
+
billing: _billing,
|
|
312
|
+
metadata,
|
|
313
|
+
...rest
|
|
314
|
+
} = params;
|
|
301
315
|
const customer = await this.stripe.customers.update(id, {
|
|
302
316
|
...provider_metadata,
|
|
303
317
|
...rest,
|
|
304
|
-
metadata: core.stringifyMetadataValues(
|
|
318
|
+
metadata: core.stringifyMetadataValues(metadata ?? {}),
|
|
305
319
|
phone: rest.phone ?? void 0
|
|
306
320
|
});
|
|
307
321
|
return Customer$inboundSchema(customer);
|
|
@@ -547,7 +561,8 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
547
561
|
);
|
|
548
562
|
}
|
|
549
563
|
const { provider_metadata, customer, ...rest } = data;
|
|
550
|
-
const
|
|
564
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
565
|
+
const payment = await this.stripe.paymentIntents.retrieve(piId);
|
|
551
566
|
const paymentOptions = {
|
|
552
567
|
...provider_metadata,
|
|
553
568
|
metadata: core.stringifyMetadataValues({
|
|
@@ -569,10 +584,10 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
569
584
|
paymentOptions.receipt_email = customer.email;
|
|
570
585
|
}
|
|
571
586
|
const updatedPayment = await this.stripe.paymentIntents.update(
|
|
572
|
-
|
|
587
|
+
piId,
|
|
573
588
|
paymentOptions
|
|
574
589
|
);
|
|
575
|
-
return Payment$inboundSchema(updatedPayment);
|
|
590
|
+
return { ...Payment$inboundSchema(updatedPayment), id };
|
|
576
591
|
};
|
|
577
592
|
this.retrievePayment = async (id) => {
|
|
578
593
|
const { error, data } = core.retrievePaymentSchema.safeParse({ id });
|
|
@@ -583,6 +598,34 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
583
598
|
"retrievePayment"
|
|
584
599
|
);
|
|
585
600
|
}
|
|
601
|
+
if (data.id.startsWith("cs_")) {
|
|
602
|
+
const [session, sessionError] = await core.tryCatchAsync(
|
|
603
|
+
this.stripe.checkout.sessions.retrieve(data.id, {
|
|
604
|
+
expand: ["payment_intent"]
|
|
605
|
+
})
|
|
606
|
+
);
|
|
607
|
+
if (!session || sessionError?.code === "resource_missing")
|
|
608
|
+
return null;
|
|
609
|
+
if (session.payment_intent && typeof session.payment_intent !== "string") {
|
|
610
|
+
return {
|
|
611
|
+
...Payment$inboundSchema(
|
|
612
|
+
session.payment_intent
|
|
613
|
+
),
|
|
614
|
+
id: data.id
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
id: data.id,
|
|
619
|
+
amount: session.amount_total ?? 0,
|
|
620
|
+
currency: session.currency ?? "",
|
|
621
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
622
|
+
status: "pending",
|
|
623
|
+
metadata: core.omitInternalMetadata(session.metadata ?? {}),
|
|
624
|
+
item_id: null,
|
|
625
|
+
requires_action: true,
|
|
626
|
+
payment_url: session.url
|
|
627
|
+
};
|
|
628
|
+
}
|
|
586
629
|
const [payment, paymentError] = await core.tryCatchAsync(
|
|
587
630
|
this.stripe.paymentIntents.retrieve(data.id)
|
|
588
631
|
);
|
|
@@ -599,6 +642,10 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
599
642
|
"deletePayment"
|
|
600
643
|
);
|
|
601
644
|
}
|
|
645
|
+
if (data.id.startsWith("cs_")) {
|
|
646
|
+
await this.stripe.checkout.sessions.expire(data.id);
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
602
649
|
await this.stripe.paymentIntents.cancel(data.id);
|
|
603
650
|
return null;
|
|
604
651
|
};
|
|
@@ -611,12 +658,27 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
611
658
|
"capturePayment"
|
|
612
659
|
);
|
|
613
660
|
}
|
|
614
|
-
const
|
|
661
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
662
|
+
const payment = await this.stripe.paymentIntents.capture(piId, {
|
|
615
663
|
amount_to_capture: data.amount
|
|
616
664
|
});
|
|
617
|
-
return Payment$inboundSchema(payment);
|
|
665
|
+
return { ...Payment$inboundSchema(payment), id };
|
|
618
666
|
};
|
|
619
667
|
this.cancelPayment = async (id) => {
|
|
668
|
+
if (id.startsWith("cs_")) {
|
|
669
|
+
const session = await this.stripe.checkout.sessions.expire(id);
|
|
670
|
+
return {
|
|
671
|
+
id,
|
|
672
|
+
amount: session.amount_total ?? 0,
|
|
673
|
+
currency: session.currency ?? "",
|
|
674
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
675
|
+
status: "canceled",
|
|
676
|
+
metadata: core.omitInternalMetadata(session.metadata ?? {}),
|
|
677
|
+
item_id: null,
|
|
678
|
+
requires_action: false,
|
|
679
|
+
payment_url: null
|
|
680
|
+
};
|
|
681
|
+
}
|
|
620
682
|
const canceledPayment = await this.stripe.paymentIntents.cancel(id);
|
|
621
683
|
return Payment$inboundSchema(canceledPayment);
|
|
622
684
|
};
|
|
@@ -646,7 +708,18 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
646
708
|
amount: rest.amount,
|
|
647
709
|
metadata: core.stringifyMetadataValues(rest.metadata ?? {})
|
|
648
710
|
};
|
|
649
|
-
if (data.payment_id.startsWith("
|
|
711
|
+
if (data.payment_id.startsWith("cs_")) {
|
|
712
|
+
const session = await this.stripe.checkout.sessions.retrieve(
|
|
713
|
+
data.payment_id
|
|
714
|
+
);
|
|
715
|
+
if (!session.payment_intent) {
|
|
716
|
+
throw new core.ValidationError(
|
|
717
|
+
"Checkout Session has no associated PaymentIntent to refund",
|
|
718
|
+
{ provider: this.providerName, method: "createRefund" }
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
stripeRefundOptions.payment_intent = typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
722
|
+
} else if (data.payment_id.startsWith("pi_")) {
|
|
650
723
|
stripeRefundOptions.payment_intent = data.payment_id;
|
|
651
724
|
} else {
|
|
652
725
|
stripeRefundOptions.charge = data.payment_id;
|
|
@@ -885,14 +958,29 @@ var StripeProvider = class extends core.AbstractPayKitProvider {
|
|
|
885
958
|
}
|
|
886
959
|
return results;
|
|
887
960
|
};
|
|
888
|
-
const { debug
|
|
889
|
-
|
|
890
|
-
this.
|
|
891
|
-
this.
|
|
961
|
+
const { debug, apiKey, isSandbox, ...stripeConfig } = opts;
|
|
962
|
+
const resolvedSandbox = isSandbox ?? apiKey.includes("_test_");
|
|
963
|
+
this.stripe = new Stripe__default.default(apiKey, stripeConfig);
|
|
964
|
+
this.opts = { ...opts, debug: debug ?? resolvedSandbox };
|
|
965
|
+
this.isSandbox = resolvedSandbox;
|
|
892
966
|
}
|
|
893
967
|
get _native() {
|
|
894
968
|
return this.stripe;
|
|
895
969
|
}
|
|
970
|
+
async _resolvePaymentIntentId(id) {
|
|
971
|
+
if (!id.startsWith("cs_")) return id;
|
|
972
|
+
const session = await this.stripe.checkout.sessions.retrieve(id);
|
|
973
|
+
if (!session.payment_intent) {
|
|
974
|
+
throw new core.ValidationError(
|
|
975
|
+
"Checkout Session has no associated PaymentIntent yet",
|
|
976
|
+
{
|
|
977
|
+
provider: this.providerName,
|
|
978
|
+
method: "resolvePaymentIntentId"
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
return typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
983
|
+
}
|
|
896
984
|
};
|
|
897
985
|
|
|
898
986
|
exports.StripeProvider = StripeProvider;
|
package/dist/stripe-provider.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema, Schema, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, isIdCustomer, isEmailCustomer, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, parseCustomerName, createSubscriptionSchema, InvalidTypeError, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, deletePaymentSchema, capturePaymentSchema, createRefundSchema, refundReasonMatcher, WebhookError, validateRequiredKeys,
|
|
1
|
+
import { schema, Schema, AbstractPayKitProvider, createCheckoutSchema, ValidationError, stringifyMetadataValues, isIdCustomer, isEmailCustomer, updateCheckoutSchema, ResourceNotFoundError, createCustomerSchema, parseCustomerName, createSubscriptionSchema, InvalidTypeError, updateSubscriptionSchema, retrieveSubscriptionSchema, createPaymentSchema, PAYKIT_METADATA_KEY, updatePaymentSchema, retrievePaymentSchema, tryCatchAsync, omitInternalMetadata, deletePaymentSchema, capturePaymentSchema, createRefundSchema, refundReasonMatcher, WebhookError, validateRequiredKeys, paykitEvent$InboundSchema, billingModeSchema, invoiceStatusSchema } from '@paykit-sdk/core';
|
|
2
2
|
import Stripe from 'stripe';
|
|
3
3
|
|
|
4
4
|
// src/stripe-provider.ts
|
|
@@ -283,19 +283,33 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
283
283
|
name: data.name,
|
|
284
284
|
email: data.email
|
|
285
285
|
});
|
|
286
|
+
const {
|
|
287
|
+
billing: _billing,
|
|
288
|
+
metadata,
|
|
289
|
+
provider_metadata,
|
|
290
|
+
name: _name,
|
|
291
|
+
...stripeParams
|
|
292
|
+
} = data;
|
|
286
293
|
const customer = await this.stripe.customers.create({
|
|
287
|
-
...
|
|
288
|
-
|
|
289
|
-
|
|
294
|
+
...provider_metadata,
|
|
295
|
+
...stripeParams,
|
|
296
|
+
phone: data.phone ?? void 0,
|
|
297
|
+
name: fullName,
|
|
298
|
+
metadata: stringifyMetadataValues(metadata ?? {})
|
|
290
299
|
});
|
|
291
300
|
return Customer$inboundSchema(customer);
|
|
292
301
|
};
|
|
293
302
|
this.updateCustomer = async (id, params) => {
|
|
294
|
-
const {
|
|
303
|
+
const {
|
|
304
|
+
provider_metadata,
|
|
305
|
+
billing: _billing,
|
|
306
|
+
metadata,
|
|
307
|
+
...rest
|
|
308
|
+
} = params;
|
|
295
309
|
const customer = await this.stripe.customers.update(id, {
|
|
296
310
|
...provider_metadata,
|
|
297
311
|
...rest,
|
|
298
|
-
metadata: stringifyMetadataValues(
|
|
312
|
+
metadata: stringifyMetadataValues(metadata ?? {}),
|
|
299
313
|
phone: rest.phone ?? void 0
|
|
300
314
|
});
|
|
301
315
|
return Customer$inboundSchema(customer);
|
|
@@ -541,7 +555,8 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
541
555
|
);
|
|
542
556
|
}
|
|
543
557
|
const { provider_metadata, customer, ...rest } = data;
|
|
544
|
-
const
|
|
558
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
559
|
+
const payment = await this.stripe.paymentIntents.retrieve(piId);
|
|
545
560
|
const paymentOptions = {
|
|
546
561
|
...provider_metadata,
|
|
547
562
|
metadata: stringifyMetadataValues({
|
|
@@ -563,10 +578,10 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
563
578
|
paymentOptions.receipt_email = customer.email;
|
|
564
579
|
}
|
|
565
580
|
const updatedPayment = await this.stripe.paymentIntents.update(
|
|
566
|
-
|
|
581
|
+
piId,
|
|
567
582
|
paymentOptions
|
|
568
583
|
);
|
|
569
|
-
return Payment$inboundSchema(updatedPayment);
|
|
584
|
+
return { ...Payment$inboundSchema(updatedPayment), id };
|
|
570
585
|
};
|
|
571
586
|
this.retrievePayment = async (id) => {
|
|
572
587
|
const { error, data } = retrievePaymentSchema.safeParse({ id });
|
|
@@ -577,6 +592,34 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
577
592
|
"retrievePayment"
|
|
578
593
|
);
|
|
579
594
|
}
|
|
595
|
+
if (data.id.startsWith("cs_")) {
|
|
596
|
+
const [session, sessionError] = await tryCatchAsync(
|
|
597
|
+
this.stripe.checkout.sessions.retrieve(data.id, {
|
|
598
|
+
expand: ["payment_intent"]
|
|
599
|
+
})
|
|
600
|
+
);
|
|
601
|
+
if (!session || sessionError?.code === "resource_missing")
|
|
602
|
+
return null;
|
|
603
|
+
if (session.payment_intent && typeof session.payment_intent !== "string") {
|
|
604
|
+
return {
|
|
605
|
+
...Payment$inboundSchema(
|
|
606
|
+
session.payment_intent
|
|
607
|
+
),
|
|
608
|
+
id: data.id
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
return {
|
|
612
|
+
id: data.id,
|
|
613
|
+
amount: session.amount_total ?? 0,
|
|
614
|
+
currency: session.currency ?? "",
|
|
615
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
616
|
+
status: "pending",
|
|
617
|
+
metadata: omitInternalMetadata(session.metadata ?? {}),
|
|
618
|
+
item_id: null,
|
|
619
|
+
requires_action: true,
|
|
620
|
+
payment_url: session.url
|
|
621
|
+
};
|
|
622
|
+
}
|
|
580
623
|
const [payment, paymentError] = await tryCatchAsync(
|
|
581
624
|
this.stripe.paymentIntents.retrieve(data.id)
|
|
582
625
|
);
|
|
@@ -593,6 +636,10 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
593
636
|
"deletePayment"
|
|
594
637
|
);
|
|
595
638
|
}
|
|
639
|
+
if (data.id.startsWith("cs_")) {
|
|
640
|
+
await this.stripe.checkout.sessions.expire(data.id);
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
596
643
|
await this.stripe.paymentIntents.cancel(data.id);
|
|
597
644
|
return null;
|
|
598
645
|
};
|
|
@@ -605,12 +652,27 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
605
652
|
"capturePayment"
|
|
606
653
|
);
|
|
607
654
|
}
|
|
608
|
-
const
|
|
655
|
+
const piId = await this._resolvePaymentIntentId(id);
|
|
656
|
+
const payment = await this.stripe.paymentIntents.capture(piId, {
|
|
609
657
|
amount_to_capture: data.amount
|
|
610
658
|
});
|
|
611
|
-
return Payment$inboundSchema(payment);
|
|
659
|
+
return { ...Payment$inboundSchema(payment), id };
|
|
612
660
|
};
|
|
613
661
|
this.cancelPayment = async (id) => {
|
|
662
|
+
if (id.startsWith("cs_")) {
|
|
663
|
+
const session = await this.stripe.checkout.sessions.expire(id);
|
|
664
|
+
return {
|
|
665
|
+
id,
|
|
666
|
+
amount: session.amount_total ?? 0,
|
|
667
|
+
currency: session.currency ?? "",
|
|
668
|
+
customer: typeof session.customer === "string" ? { id: session.customer } : session.customer?.id ? { id: session.customer.id } : session.customer_email ? { email: session.customer_email } : null,
|
|
669
|
+
status: "canceled",
|
|
670
|
+
metadata: omitInternalMetadata(session.metadata ?? {}),
|
|
671
|
+
item_id: null,
|
|
672
|
+
requires_action: false,
|
|
673
|
+
payment_url: null
|
|
674
|
+
};
|
|
675
|
+
}
|
|
614
676
|
const canceledPayment = await this.stripe.paymentIntents.cancel(id);
|
|
615
677
|
return Payment$inboundSchema(canceledPayment);
|
|
616
678
|
};
|
|
@@ -640,7 +702,18 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
640
702
|
amount: rest.amount,
|
|
641
703
|
metadata: stringifyMetadataValues(rest.metadata ?? {})
|
|
642
704
|
};
|
|
643
|
-
if (data.payment_id.startsWith("
|
|
705
|
+
if (data.payment_id.startsWith("cs_")) {
|
|
706
|
+
const session = await this.stripe.checkout.sessions.retrieve(
|
|
707
|
+
data.payment_id
|
|
708
|
+
);
|
|
709
|
+
if (!session.payment_intent) {
|
|
710
|
+
throw new ValidationError(
|
|
711
|
+
"Checkout Session has no associated PaymentIntent to refund",
|
|
712
|
+
{ provider: this.providerName, method: "createRefund" }
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
stripeRefundOptions.payment_intent = typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
716
|
+
} else if (data.payment_id.startsWith("pi_")) {
|
|
644
717
|
stripeRefundOptions.payment_intent = data.payment_id;
|
|
645
718
|
} else {
|
|
646
719
|
stripeRefundOptions.charge = data.payment_id;
|
|
@@ -879,14 +952,29 @@ var StripeProvider = class extends AbstractPayKitProvider {
|
|
|
879
952
|
}
|
|
880
953
|
return results;
|
|
881
954
|
};
|
|
882
|
-
const { debug
|
|
883
|
-
|
|
884
|
-
this.
|
|
885
|
-
this.
|
|
955
|
+
const { debug, apiKey, isSandbox, ...stripeConfig } = opts;
|
|
956
|
+
const resolvedSandbox = isSandbox ?? apiKey.includes("_test_");
|
|
957
|
+
this.stripe = new Stripe(apiKey, stripeConfig);
|
|
958
|
+
this.opts = { ...opts, debug: debug ?? resolvedSandbox };
|
|
959
|
+
this.isSandbox = resolvedSandbox;
|
|
886
960
|
}
|
|
887
961
|
get _native() {
|
|
888
962
|
return this.stripe;
|
|
889
963
|
}
|
|
964
|
+
async _resolvePaymentIntentId(id) {
|
|
965
|
+
if (!id.startsWith("cs_")) return id;
|
|
966
|
+
const session = await this.stripe.checkout.sessions.retrieve(id);
|
|
967
|
+
if (!session.payment_intent) {
|
|
968
|
+
throw new ValidationError(
|
|
969
|
+
"Checkout Session has no associated PaymentIntent yet",
|
|
970
|
+
{
|
|
971
|
+
provider: this.providerName,
|
|
972
|
+
method: "resolvePaymentIntentId"
|
|
973
|
+
}
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
return typeof session.payment_intent === "string" ? session.payment_intent : session.payment_intent.id;
|
|
977
|
+
}
|
|
890
978
|
};
|
|
891
979
|
|
|
892
980
|
export { StripeProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykit-sdk/stripe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Stripe provider for PayKit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"stripe": "^18.2.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@paykit-sdk/core": ">=1.2.
|
|
29
|
+
"@paykit-sdk/core": ">=1.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@paykit-sdk/core": "workspace:*",
|