@sergdudko/stripe-js 2.0.9 → 2.0.11
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/cjs/esm.js +2 -3
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/methods/addPaymentMethodToCustomer.js +5 -6
- package/dist/cjs/methods/addSourceToCustomer.js +5 -6
- package/dist/cjs/methods/confirmPaymentIntentByCard.js +5 -6
- package/dist/cjs/methods/confirmPaymentIntentByPaymentMethod.js +2 -3
- package/dist/cjs/methods/deletePaymentMethodFromCustomer.js +5 -6
- package/dist/cjs/methods/deleteSourceFromCustomer.js +5 -6
- package/dist/cjs/methods/getAllCards.js +5 -6
- package/dist/cjs/methods/getAllPaymentMethods.js +5 -6
- package/dist/cjs/methods/getCustomer.js +5 -6
- package/dist/cjs/methods/getDefaultCard.js +5 -6
- package/dist/cjs/methods/index.js +24 -25
- package/dist/cjs/methods/setDefaultCard.js +5 -6
- package/dist/cjs/methods/setDefaultPaymentMethod.js +5 -6
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/utils/constants.js +0 -1
- package/dist/cjs/utils/handlers.js +0 -1
- package/dist/esm/esm.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/methods/addPaymentMethodToCustomer.js +2 -3
- package/dist/esm/methods/addSourceToCustomer.js +2 -3
- package/dist/esm/methods/confirmPaymentIntentByCard.js +2 -3
- package/dist/esm/methods/confirmPaymentIntentByPaymentMethod.js +1 -2
- package/dist/esm/methods/deletePaymentMethodFromCustomer.js +2 -3
- package/dist/esm/methods/deleteSourceFromCustomer.js +2 -3
- package/dist/esm/methods/getAllCards.js +2 -3
- package/dist/esm/methods/getAllPaymentMethods.js +2 -3
- package/dist/esm/methods/getCustomer.js +2 -3
- package/dist/esm/methods/getDefaultCard.js +2 -3
- package/dist/esm/methods/index.js +12 -13
- package/dist/esm/methods/setDefaultCard.js +2 -3
- package/dist/esm/methods/setDefaultPaymentMethod.js +2 -3
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.js +0 -1
- package/dist/esm/utils/constants.js +0 -1
- package/dist/esm/utils/handlers.js +0 -1
- package/dist/types/esm.d.ts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/methods/addPaymentMethodToCustomer.d.ts +1 -1
- package/dist/types/methods/addSourceToCustomer.d.ts +1 -1
- package/dist/types/methods/confirmPaymentIntentByCard.d.ts +1 -1
- package/dist/types/methods/confirmPaymentIntentByPaymentMethod.d.ts +1 -1
- package/dist/types/methods/deletePaymentMethodFromCustomer.d.ts +1 -1
- package/dist/types/methods/deleteSourceFromCustomer.d.ts +1 -1
- package/dist/types/methods/getAllCards.d.ts +1 -1
- package/dist/types/methods/getAllPaymentMethods.d.ts +1 -1
- package/dist/types/methods/getCustomer.d.ts +1 -1
- package/dist/types/methods/getDefaultCard.d.ts +1 -1
- package/dist/types/methods/setDefaultCard.d.ts +1 -1
- package/dist/types/methods/setDefaultPaymentMethod.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/esm.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadStripe = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "loadStripe", { enumerable: true, get: function () { return
|
|
6
|
-
//# sourceMappingURL=esm.js.map
|
|
4
|
+
var index_js_1 = require("./index.js");
|
|
5
|
+
Object.defineProperty(exports, "loadStripe", { enumerable: true, get: function () { return index_js_1.loadStripe; } });
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadStripe = void 0;
|
|
4
4
|
const stripe_js_1 = require("@stripe/stripe-js");
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("./methods/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Initialize stripe
|
|
8
8
|
*
|
|
@@ -16,11 +16,10 @@ const loadStripe = async (publishableKey, options) => {
|
|
|
16
16
|
// eslint-disable-next-line no-underscore-dangle
|
|
17
17
|
typeof stripeDefault?._apiKey !== "string")
|
|
18
18
|
throw new Error("Initialization error.");
|
|
19
|
-
const stripeExtension = new
|
|
19
|
+
const stripeExtension = new index_js_1.StripeExtension(
|
|
20
20
|
// eslint-disable-next-line no-underscore-dangle
|
|
21
21
|
stripeDefault._apiKey);
|
|
22
22
|
const stripe = Object.assign(stripeDefault, stripeExtension);
|
|
23
23
|
return stripe;
|
|
24
24
|
};
|
|
25
25
|
exports.loadStripe = loadStripe;
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addPaymentMethodToCustomer = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Add payment method to customer.
|
|
8
8
|
*
|
|
@@ -16,15 +16,14 @@ const addPaymentMethodToCustomer = async function (paymentMethodId, customerId,
|
|
|
16
16
|
if (typeof stripeApiKey !== "string")
|
|
17
17
|
throw new Error("Initialization failed.");
|
|
18
18
|
// make request
|
|
19
|
-
return fetch(`${
|
|
19
|
+
return fetch(`${constants_js_1.stripeApiUrl}/payment_methods/${paymentMethodId}/attach`, {
|
|
20
20
|
body: `customer=${customerId}`,
|
|
21
21
|
headers: {
|
|
22
22
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
23
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
-
"Stripe-Version": `${
|
|
24
|
+
"Stripe-Version": `${constants_js_1.stripeApiVersion}`,
|
|
25
25
|
},
|
|
26
26
|
method: "POST",
|
|
27
|
-
}).then(
|
|
27
|
+
}).then(handlers_js_1.responseHandler);
|
|
28
28
|
};
|
|
29
29
|
exports.addPaymentMethodToCustomer = addPaymentMethodToCustomer;
|
|
30
|
-
//# sourceMappingURL=addPaymentMethodToCustomer.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addSourceToCustomer = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Add card to customer (from source or token).
|
|
8
8
|
*
|
|
@@ -16,15 +16,14 @@ const addSourceToCustomer = async function (token, customerId, ephemeralKey) {
|
|
|
16
16
|
if (typeof stripeApiKey !== "string")
|
|
17
17
|
throw new Error("Initialization failed.");
|
|
18
18
|
// make request
|
|
19
|
-
return fetch(`${
|
|
19
|
+
return fetch(`${constants_js_1.stripeApiUrl}/customers/${customerId}/sources`, {
|
|
20
20
|
body: `source=${token}`,
|
|
21
21
|
headers: {
|
|
22
22
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
23
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
-
"Stripe-Version": `${
|
|
24
|
+
"Stripe-Version": `${constants_js_1.stripeApiVersion}`,
|
|
25
25
|
},
|
|
26
26
|
method: "POST",
|
|
27
|
-
}).then(
|
|
27
|
+
}).then(handlers_js_1.responseHandler);
|
|
28
28
|
};
|
|
29
29
|
exports.addSourceToCustomer = addSourceToCustomer;
|
|
30
|
-
//# sourceMappingURL=addSourceToCustomer.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.confirmPaymentIntentByCard = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Confirm payment intent by customer's card
|
|
8
8
|
*
|
|
@@ -16,15 +16,14 @@ const confirmPaymentIntentByCard = async function (paymentIntentSecret, paymentM
|
|
|
16
16
|
throw new Error("Initialization failed.");
|
|
17
17
|
// make request
|
|
18
18
|
const paymentIntentId = paymentIntentSecret.replace(/_secret_.+$/i, "");
|
|
19
|
-
return fetch(`${
|
|
19
|
+
return fetch(`${constants_js_1.stripeApiUrl}/payment_intents/${paymentIntentId}/confirm?client_secret=${paymentIntentSecret}`, {
|
|
20
20
|
body: `payment_method=${paymentMethodId}${typeof returnUrl === 'string' ? `&return_url=${returnUrl}` : ''}`,
|
|
21
21
|
headers: {
|
|
22
22
|
Authorization: `Bearer ${stripeApiKey}`,
|
|
23
23
|
"Content-Type": `application/x-www-form-urlencoded`,
|
|
24
|
-
"Stripe-Version": `${
|
|
24
|
+
"Stripe-Version": `${constants_js_1.stripeApiVersion}`,
|
|
25
25
|
},
|
|
26
26
|
method: `POST`,
|
|
27
|
-
}).then(
|
|
27
|
+
}).then(handlers_js_1.responseHandler);
|
|
28
28
|
};
|
|
29
29
|
exports.confirmPaymentIntentByCard = confirmPaymentIntentByCard;
|
|
30
|
-
//# sourceMappingURL=confirmPaymentIntentByCard.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.confirmPaymentIntentByPaymentMethod = void 0;
|
|
4
|
-
const
|
|
4
|
+
const confirmPaymentIntentByCard_js_1 = require("./confirmPaymentIntentByCard.js");
|
|
5
5
|
/**
|
|
6
6
|
* Confirm payment intent by customer's payment method
|
|
7
7
|
*
|
|
@@ -9,5 +9,4 @@ const confirmPaymentIntentByCard_1 = require("./confirmPaymentIntentByCard");
|
|
|
9
9
|
* @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
exports.confirmPaymentIntentByPaymentMethod =
|
|
13
|
-
//# sourceMappingURL=confirmPaymentIntentByPaymentMethod.js.map
|
|
12
|
+
exports.confirmPaymentIntentByPaymentMethod = confirmPaymentIntentByCard_js_1.confirmPaymentIntentByCard;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deletePaymentMethodFromCustomer = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Delete payment method from customer.
|
|
8
8
|
*
|
|
@@ -15,14 +15,13 @@ const deletePaymentMethodFromCustomer = async function (paymentMethodId, ephemer
|
|
|
15
15
|
if (typeof stripeApiKey !== "string")
|
|
16
16
|
throw new Error("Initialization failed.");
|
|
17
17
|
// make request
|
|
18
|
-
return fetch(`${
|
|
18
|
+
return fetch(`${constants_js_1.stripeApiUrl}/payment_methods/${paymentMethodId}/detach`, {
|
|
19
19
|
headers: {
|
|
20
20
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
21
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
22
|
-
"Stripe-Version": `${
|
|
22
|
+
"Stripe-Version": `${constants_js_1.stripeApiVersion}`,
|
|
23
23
|
},
|
|
24
24
|
method: "POST",
|
|
25
|
-
}).then(
|
|
25
|
+
}).then(handlers_js_1.responseHandler);
|
|
26
26
|
};
|
|
27
27
|
exports.deletePaymentMethodFromCustomer = deletePaymentMethodFromCustomer;
|
|
28
|
-
//# sourceMappingURL=deletePaymentMethodFromCustomer.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteSourceFromCustomer = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Delete card from customer.
|
|
8
8
|
*
|
|
@@ -16,13 +16,12 @@ const deleteSourceFromCustomer = async function (sourceId, customerId, ephemeral
|
|
|
16
16
|
if (typeof stripeApiKey !== "string")
|
|
17
17
|
throw new Error("Initialization failed.");
|
|
18
18
|
// make request
|
|
19
|
-
return await fetch(`${
|
|
19
|
+
return await fetch(`${constants_js_1.stripeApiUrl}/customers/${customerId}/sources/${sourceId}`, {
|
|
20
20
|
headers: {
|
|
21
21
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
22
|
-
"Stripe-Version":
|
|
22
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
23
23
|
},
|
|
24
24
|
method: "DELETE",
|
|
25
|
-
}).then(
|
|
25
|
+
}).then(handlers_js_1.responseHandler);
|
|
26
26
|
};
|
|
27
27
|
exports.deleteSourceFromCustomer = deleteSourceFromCustomer;
|
|
28
|
-
//# sourceMappingURL=deleteSourceFromCustomer.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllCards = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Get all customer's card
|
|
8
8
|
*
|
|
@@ -15,13 +15,12 @@ const getAllCards = async function (customerId, ephemeralKey) {
|
|
|
15
15
|
if (typeof stripeApiKey !== "string")
|
|
16
16
|
throw new Error("Initialization failed.");
|
|
17
17
|
// make request
|
|
18
|
-
return fetch(`${
|
|
18
|
+
return fetch(`${constants_js_1.stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`, {
|
|
19
19
|
headers: {
|
|
20
20
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
-
"Stripe-Version":
|
|
21
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
22
22
|
},
|
|
23
23
|
method: "GET",
|
|
24
|
-
}).then(
|
|
24
|
+
}).then(handlers_js_1.responseHandler);
|
|
25
25
|
};
|
|
26
26
|
exports.getAllCards = getAllCards;
|
|
27
|
-
//# sourceMappingURL=getAllCards.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllPaymentMethods = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Get all customer's payment methods
|
|
8
8
|
*
|
|
@@ -15,13 +15,12 @@ const getAllPaymentMethods = async function (customerId, ephemeralKey) {
|
|
|
15
15
|
if (typeof stripeApiKey !== "string")
|
|
16
16
|
throw new Error("Initialization failed.");
|
|
17
17
|
// make request
|
|
18
|
-
return fetch(`${
|
|
18
|
+
return fetch(`${constants_js_1.stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`, {
|
|
19
19
|
headers: {
|
|
20
20
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
-
"Stripe-Version":
|
|
21
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
22
22
|
},
|
|
23
23
|
method: "GET",
|
|
24
|
-
}).then(
|
|
24
|
+
}).then(handlers_js_1.responseHandler);
|
|
25
25
|
};
|
|
26
26
|
exports.getAllPaymentMethods = getAllPaymentMethods;
|
|
27
|
-
//# sourceMappingURL=getAllPaymentMethods.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCustomer = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Get customer data
|
|
8
8
|
*
|
|
@@ -15,12 +15,11 @@ const getCustomer = async function (customerId, ephemeralKey) {
|
|
|
15
15
|
if (typeof stripeApiKey !== "string")
|
|
16
16
|
throw new Error("Initialization failed.");
|
|
17
17
|
// make request
|
|
18
|
-
return fetch(`${
|
|
18
|
+
return fetch(`${constants_js_1.stripeApiUrl}/customers/${customerId}`, {
|
|
19
19
|
headers: {
|
|
20
20
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
-
"Stripe-Version":
|
|
21
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
22
22
|
},
|
|
23
|
-
}).then(
|
|
23
|
+
}).then(handlers_js_1.responseHandler);
|
|
24
24
|
};
|
|
25
25
|
exports.getCustomer = getCustomer;
|
|
26
|
-
//# sourceMappingURL=getCustomer.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultCard = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Get customer's default card id
|
|
8
8
|
*
|
|
@@ -15,14 +15,13 @@ const getDefaultCard = async function (customerId, ephemeralKey) {
|
|
|
15
15
|
if (typeof stripeApiKey !== "string")
|
|
16
16
|
throw new Error("Initialization failed.");
|
|
17
17
|
// make request
|
|
18
|
-
return fetch(`${
|
|
18
|
+
return fetch(`${constants_js_1.stripeApiUrl}/customers/${customerId}`, {
|
|
19
19
|
headers: {
|
|
20
20
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
-
"Stripe-Version":
|
|
21
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
22
22
|
},
|
|
23
23
|
})
|
|
24
|
-
.then(
|
|
24
|
+
.then(handlers_js_1.responseHandler)
|
|
25
25
|
.then((e) => (e?.default_source ? e.default_source : undefined));
|
|
26
26
|
};
|
|
27
27
|
exports.getDefaultCard = getDefaultCard;
|
|
28
|
-
//# sourceMappingURL=getDefaultCard.js.map
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StripeExtension = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
4
|
+
const confirmPaymentIntentByCard_js_1 = require("./confirmPaymentIntentByCard.js");
|
|
5
|
+
const confirmPaymentIntentByPaymentMethod_js_1 = require("./confirmPaymentIntentByPaymentMethod.js");
|
|
6
|
+
const addSourceToCustomer_js_1 = require("./addSourceToCustomer.js");
|
|
7
|
+
const deleteSourceFromCustomer_js_1 = require("./deleteSourceFromCustomer.js");
|
|
8
|
+
const getAllCards_js_1 = require("./getAllCards.js");
|
|
9
|
+
const getCustomer_js_1 = require("./getCustomer.js");
|
|
10
|
+
const setDefaultCard_js_1 = require("./setDefaultCard.js");
|
|
11
|
+
const getDefaultCard_js_1 = require("./getDefaultCard.js");
|
|
12
|
+
const addPaymentMethodToCustomer_js_1 = require("./addPaymentMethodToCustomer.js");
|
|
13
|
+
const deletePaymentMethodFromCustomer_js_1 = require("./deletePaymentMethodFromCustomer.js");
|
|
14
|
+
const getAllPaymentMethods_js_1 = require("./getAllPaymentMethods.js");
|
|
15
|
+
const setDefaultPaymentMethod_js_1 = require("./setDefaultPaymentMethod.js");
|
|
16
16
|
/**
|
|
17
17
|
* additional stripe methods
|
|
18
18
|
*/
|
|
19
19
|
class StripeExtension {
|
|
20
20
|
constructor(apiKey) {
|
|
21
|
-
this.confirmPaymentIntentByCard =
|
|
22
|
-
this.confirmPaymentIntentByPaymentMethod =
|
|
23
|
-
this.addSourceToCustomer =
|
|
24
|
-
this.deleteSourceFromCustomer =
|
|
25
|
-
this.getAllCards =
|
|
26
|
-
this.getCustomer =
|
|
27
|
-
this.setDefaultCard =
|
|
28
|
-
this.getDefaultCard =
|
|
29
|
-
this.addPaymentMethodToCustomer =
|
|
30
|
-
this.deletePaymentMethodFromCustomer =
|
|
31
|
-
this.getAllPaymentMethods =
|
|
32
|
-
this.setDefaultPaymentMethod =
|
|
21
|
+
this.confirmPaymentIntentByCard = confirmPaymentIntentByCard_js_1.confirmPaymentIntentByCard;
|
|
22
|
+
this.confirmPaymentIntentByPaymentMethod = confirmPaymentIntentByPaymentMethod_js_1.confirmPaymentIntentByPaymentMethod;
|
|
23
|
+
this.addSourceToCustomer = addSourceToCustomer_js_1.addSourceToCustomer;
|
|
24
|
+
this.deleteSourceFromCustomer = deleteSourceFromCustomer_js_1.deleteSourceFromCustomer;
|
|
25
|
+
this.getAllCards = getAllCards_js_1.getAllCards;
|
|
26
|
+
this.getCustomer = getCustomer_js_1.getCustomer;
|
|
27
|
+
this.setDefaultCard = setDefaultCard_js_1.setDefaultCard;
|
|
28
|
+
this.getDefaultCard = getDefaultCard_js_1.getDefaultCard;
|
|
29
|
+
this.addPaymentMethodToCustomer = addPaymentMethodToCustomer_js_1.addPaymentMethodToCustomer;
|
|
30
|
+
this.deletePaymentMethodFromCustomer = deletePaymentMethodFromCustomer_js_1.deletePaymentMethodFromCustomer;
|
|
31
|
+
this.getAllPaymentMethods = getAllPaymentMethods_js_1.getAllPaymentMethods;
|
|
32
|
+
this.setDefaultPaymentMethod = setDefaultPaymentMethod_js_1.setDefaultPaymentMethod;
|
|
33
33
|
this._apiKey = apiKey;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.StripeExtension = StripeExtension;
|
|
37
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setDefaultCard = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Set default customer card
|
|
8
8
|
*
|
|
@@ -16,15 +16,14 @@ const setDefaultCard = async function (cardId, customerId, ephemeralKey) {
|
|
|
16
16
|
if (typeof stripeApiKey !== "string")
|
|
17
17
|
throw new Error("Initialization failed.");
|
|
18
18
|
// make request
|
|
19
|
-
return fetch(`${
|
|
19
|
+
return fetch(`${constants_js_1.stripeApiUrl}/customers/${customerId}`, {
|
|
20
20
|
body: `default_source=${cardId}`,
|
|
21
21
|
headers: {
|
|
22
22
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
23
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
-
"Stripe-Version":
|
|
24
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
25
25
|
},
|
|
26
26
|
method: "POST",
|
|
27
|
-
}).then(
|
|
27
|
+
}).then(handlers_js_1.responseHandler);
|
|
28
28
|
};
|
|
29
29
|
exports.setDefaultCard = setDefaultCard;
|
|
30
|
-
//# sourceMappingURL=setDefaultCard.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setDefaultPaymentMethod = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const handlers_js_1 = require("../utils/handlers.js");
|
|
5
|
+
const constants_js_1 = require("../utils/constants.js");
|
|
6
6
|
/**
|
|
7
7
|
* Set default customer payment method
|
|
8
8
|
*
|
|
@@ -16,15 +16,14 @@ const setDefaultPaymentMethod = async function (paymentMethodId, customerId, eph
|
|
|
16
16
|
if (typeof stripeApiKey !== "string")
|
|
17
17
|
throw new Error("Initialization failed.");
|
|
18
18
|
// make request for payment method api
|
|
19
|
-
return fetch(`${
|
|
19
|
+
return fetch(`${constants_js_1.stripeApiUrl}/customers/${customerId}`, {
|
|
20
20
|
body: `invoice_settings[default_payment_method]=${paymentMethodId}`,
|
|
21
21
|
headers: {
|
|
22
22
|
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
23
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
-
"Stripe-Version":
|
|
24
|
+
"Stripe-Version": constants_js_1.stripeApiVersion,
|
|
25
25
|
},
|
|
26
26
|
method: "POST",
|
|
27
|
-
}).then(
|
|
27
|
+
}).then(handlers_js_1.responseHandler);
|
|
28
28
|
};
|
|
29
29
|
exports.setDefaultPaymentMethod = setDefaultPaymentMethod;
|
|
30
|
-
//# sourceMappingURL=setDefaultPaymentMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/dist/cjs/types.js
CHANGED
package/dist/esm/esm.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { loadStripe } from "./index";
|
|
2
|
-
//# sourceMappingURL=esm.js.map
|
|
1
|
+
export { loadStripe } from "./index.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadStripe as loadStripeDefault, } from "@stripe/stripe-js";
|
|
2
|
-
import { StripeExtension } from "./methods/index";
|
|
2
|
+
import { StripeExtension } from "./methods/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Initialize stripe
|
|
5
5
|
*
|
|
@@ -19,4 +19,3 @@ export const loadStripe = async (publishableKey, options) => {
|
|
|
19
19
|
const stripe = Object.assign(stripeDefault, stripeExtension);
|
|
20
20
|
return stripe;
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Add payment method to customer.
|
|
5
5
|
*
|
|
@@ -23,4 +23,3 @@ export const addPaymentMethodToCustomer = async function (paymentMethodId, custo
|
|
|
23
23
|
method: "POST",
|
|
24
24
|
}).then(responseHandler);
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=addPaymentMethodToCustomer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Add card to customer (from source or token).
|
|
5
5
|
*
|
|
@@ -23,4 +23,3 @@ export const addSourceToCustomer = async function (token, customerId, ephemeralK
|
|
|
23
23
|
method: "POST",
|
|
24
24
|
}).then(responseHandler);
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=addSourceToCustomer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Confirm payment intent by customer's card
|
|
5
5
|
*
|
|
@@ -23,4 +23,3 @@ export const confirmPaymentIntentByCard = async function (paymentIntentSecret, p
|
|
|
23
23
|
method: `POST`,
|
|
24
24
|
}).then(responseHandler);
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=confirmPaymentIntentByCard.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { confirmPaymentIntentByCard } from "./confirmPaymentIntentByCard";
|
|
1
|
+
import { confirmPaymentIntentByCard } from "./confirmPaymentIntentByCard.js";
|
|
2
2
|
/**
|
|
3
3
|
* Confirm payment intent by customer's payment method
|
|
4
4
|
*
|
|
@@ -7,4 +7,3 @@ import { confirmPaymentIntentByCard } from "./confirmPaymentIntentByCard";
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
export const confirmPaymentIntentByPaymentMethod = confirmPaymentIntentByCard;
|
|
10
|
-
//# sourceMappingURL=confirmPaymentIntentByPaymentMethod.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Delete payment method from customer.
|
|
5
5
|
*
|
|
@@ -21,4 +21,3 @@ export const deletePaymentMethodFromCustomer = async function (paymentMethodId,
|
|
|
21
21
|
method: "POST",
|
|
22
22
|
}).then(responseHandler);
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=deletePaymentMethodFromCustomer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Delete card from customer.
|
|
5
5
|
*
|
|
@@ -21,4 +21,3 @@ export const deleteSourceFromCustomer = async function (sourceId, customerId, ep
|
|
|
21
21
|
method: "DELETE",
|
|
22
22
|
}).then(responseHandler);
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=deleteSourceFromCustomer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get all customer's card
|
|
5
5
|
*
|
|
@@ -20,4 +20,3 @@ export const getAllCards = async function (customerId, ephemeralKey) {
|
|
|
20
20
|
method: "GET",
|
|
21
21
|
}).then(responseHandler);
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=getAllCards.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get all customer's payment methods
|
|
5
5
|
*
|
|
@@ -20,4 +20,3 @@ export const getAllPaymentMethods = async function (customerId, ephemeralKey) {
|
|
|
20
20
|
method: "GET",
|
|
21
21
|
}).then(responseHandler);
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=getAllPaymentMethods.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get customer data
|
|
5
5
|
*
|
|
@@ -19,4 +19,3 @@ export const getCustomer = async function (customerId, ephemeralKey) {
|
|
|
19
19
|
},
|
|
20
20
|
}).then(responseHandler);
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=getCustomer.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Get customer's default card id
|
|
5
5
|
*
|
|
@@ -21,4 +21,3 @@ export const getDefaultCard = async function (customerId, ephemeralKey) {
|
|
|
21
21
|
.then(responseHandler)
|
|
22
22
|
.then((e) => (e?.default_source ? e.default_source : undefined));
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=getDefaultCard.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { confirmPaymentIntentByCard } from "./confirmPaymentIntentByCard";
|
|
2
|
-
import { confirmPaymentIntentByPaymentMethod } from "./confirmPaymentIntentByPaymentMethod";
|
|
3
|
-
import { addSourceToCustomer } from "./addSourceToCustomer";
|
|
4
|
-
import { deleteSourceFromCustomer } from "./deleteSourceFromCustomer";
|
|
5
|
-
import { getAllCards } from "./getAllCards";
|
|
6
|
-
import { getCustomer } from "./getCustomer";
|
|
7
|
-
import { setDefaultCard } from "./setDefaultCard";
|
|
8
|
-
import { getDefaultCard } from "./getDefaultCard";
|
|
9
|
-
import { addPaymentMethodToCustomer } from "./addPaymentMethodToCustomer";
|
|
10
|
-
import { deletePaymentMethodFromCustomer } from "./deletePaymentMethodFromCustomer";
|
|
11
|
-
import { getAllPaymentMethods } from "./getAllPaymentMethods";
|
|
12
|
-
import { setDefaultPaymentMethod } from "./setDefaultPaymentMethod";
|
|
1
|
+
import { confirmPaymentIntentByCard } from "./confirmPaymentIntentByCard.js";
|
|
2
|
+
import { confirmPaymentIntentByPaymentMethod } from "./confirmPaymentIntentByPaymentMethod.js";
|
|
3
|
+
import { addSourceToCustomer } from "./addSourceToCustomer.js";
|
|
4
|
+
import { deleteSourceFromCustomer } from "./deleteSourceFromCustomer.js";
|
|
5
|
+
import { getAllCards } from "./getAllCards.js";
|
|
6
|
+
import { getCustomer } from "./getCustomer.js";
|
|
7
|
+
import { setDefaultCard } from "./setDefaultCard.js";
|
|
8
|
+
import { getDefaultCard } from "./getDefaultCard.js";
|
|
9
|
+
import { addPaymentMethodToCustomer } from "./addPaymentMethodToCustomer.js";
|
|
10
|
+
import { deletePaymentMethodFromCustomer } from "./deletePaymentMethodFromCustomer.js";
|
|
11
|
+
import { getAllPaymentMethods } from "./getAllPaymentMethods.js";
|
|
12
|
+
import { setDefaultPaymentMethod } from "./setDefaultPaymentMethod.js";
|
|
13
13
|
/**
|
|
14
14
|
* additional stripe methods
|
|
15
15
|
*/
|
|
@@ -30,4 +30,3 @@ export class StripeExtension {
|
|
|
30
30
|
this._apiKey = apiKey;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Set default customer card
|
|
5
5
|
*
|
|
@@ -23,4 +23,3 @@ export const setDefaultCard = async function (cardId, customerId, ephemeralKey)
|
|
|
23
23
|
method: "POST",
|
|
24
24
|
}).then(responseHandler);
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=setDefaultCard.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { responseHandler } from "../utils/handlers";
|
|
2
|
-
import { stripeApiUrl, stripeApiVersion } from "../utils/constants";
|
|
1
|
+
import { responseHandler } from "../utils/handlers.js";
|
|
2
|
+
import { stripeApiUrl, stripeApiVersion } from "../utils/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Set default customer payment method
|
|
5
5
|
*
|
|
@@ -23,4 +23,3 @@ export const setDefaultPaymentMethod = async function (paymentMethodId, customer
|
|
|
23
23
|
method: "POST",
|
|
24
24
|
}).then(responseHandler);
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=setDefaultPaymentMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/dist/esm/types.js
CHANGED
package/dist/types/esm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { loadStripe } from "./index";
|
|
2
|
-
export type { Stripe, StripeDefaultWithInternal } from "./types";
|
|
1
|
+
export { loadStripe } from "./index.js";
|
|
2
|
+
export type { Stripe, StripeDefaultWithInternal } from "./types.js";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StripeConstructorOptions } from "@stripe/stripe-js";
|
|
2
|
-
import { Stripe } from "./types";
|
|
2
|
+
import { Stripe } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Initialize stripe
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import { Stripe } from "./types";
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export declare const loadStripe: (publishableKey: string, options?: StripeConstructorOptions) => Promise<Stripe>;
|
|
11
|
-
export type { Stripe, StripeDefaultWithInternal } from "./types";
|
|
11
|
+
export type { Stripe, StripeDefaultWithInternal } from "./types.js";
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const confirmPaymentIntentByPaymentMethod: (this: import(".").StripeExtension, paymentIntentSecret: string, paymentMethodId: string, returnUrl?: string) => Promise<import("@stripe/stripe-js").PaymentIntentResult["paymentIntent"] | undefined>;
|
|
8
|
+
export declare const confirmPaymentIntentByPaymentMethod: (this: import("./index.js").StripeExtension, paymentIntentSecret: string, paymentMethodId: string, returnUrl?: string) => Promise<import("@stripe/stripe-js").PaymentIntentResult["paymentIntent"] | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sergdudko/stripe-js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "Supercharge Your Stripe Integration with Enhanced Methods for stripe-js: Take Full Control of Customer Card Management Right from Your Frontend! Elevate Your Payment Processing Capabilities with Ease and Efficiency.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist/esm/**/*.js",
|
|
23
|
-
"dist/cjs/**/*.js",
|
|
22
|
+
"dist/esm/**/*.js{,on}",
|
|
23
|
+
"dist/cjs/**/*.js{,on}",
|
|
24
24
|
"dist/types/**/*",
|
|
25
25
|
"README.md",
|
|
26
26
|
"LICENSE"
|