@sergdudko/stripe-js 1.2.68 → 1.3.0
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/lib/index.js +9 -15
- package/lib/index.js.map +1 -1
- package/lib/methods/addPaymentMethodToCustomer.js +14 -27
- package/lib/methods/addPaymentMethodToCustomer.js.map +1 -1
- package/lib/methods/addSourceToCustomer.js +14 -27
- package/lib/methods/addSourceToCustomer.js.map +1 -1
- package/lib/methods/confirmPaymentIntentByCard.js +15 -28
- package/lib/methods/confirmPaymentIntentByCard.js.map +1 -1
- package/lib/methods/deletePaymentMethodFromCustomer.js +13 -26
- package/lib/methods/deletePaymentMethodFromCustomer.js.map +1 -1
- package/lib/methods/deleteSourceFromCustomer.js +12 -25
- package/lib/methods/deleteSourceFromCustomer.js.map +1 -1
- package/lib/methods/getAllCards.js +12 -25
- package/lib/methods/getAllCards.js.map +1 -1
- package/lib/methods/getAllPaymentMethods.js +12 -25
- package/lib/methods/getAllPaymentMethods.js.map +1 -1
- package/lib/methods/getCustomer.js +11 -24
- package/lib/methods/getCustomer.js.map +1 -1
- package/lib/methods/getDefaultCard.js +13 -26
- package/lib/methods/getDefaultCard.js.map +1 -1
- package/lib/methods/setDefaultCard.js +14 -27
- package/lib/methods/setDefaultCard.js.map +1 -1
- package/lib/methods/setDefaultPaymentMethod.js +14 -27
- package/lib/methods/setDefaultPaymentMethod.js.map +1 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +1 -1
- package/lib/utils/constants.js.map +1 -1
- package/lib/utils/handlers.js +2 -11
- package/lib/utils/handlers.js.map +1 -1
- package/package.json +11 -10
package/lib/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.loadStripe = void 0;
|
|
13
4
|
const stripe_js_1 = require("@stripe/stripe-js");
|
|
@@ -19,14 +10,17 @@ const index_1 = require("./methods/index");
|
|
|
19
10
|
* @param options - stripe initialization options
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const loadStripe = (publishableKey, options) =>
|
|
23
|
-
const stripeDefault =
|
|
13
|
+
const loadStripe = async (publishableKey, options) => {
|
|
14
|
+
const stripeDefault = await (0, stripe_js_1.loadStripe)(publishableKey, options);
|
|
24
15
|
if (stripeDefault === null ||
|
|
25
|
-
|
|
16
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
17
|
+
typeof stripeDefault?._apiKey !== "string")
|
|
26
18
|
throw new Error("Initialization error.");
|
|
27
|
-
const stripeExtension = new index_1.StripeExtension(
|
|
28
|
-
|
|
19
|
+
const stripeExtension = new index_1.StripeExtension(
|
|
20
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
21
|
+
stripeDefault._apiKey);
|
|
22
|
+
const stripe = Object.assign(stripeDefault, stripeExtension);
|
|
29
23
|
return stripe;
|
|
30
|
-
}
|
|
24
|
+
};
|
|
31
25
|
exports.loadStripe = loadStripe;
|
|
32
26
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAI2B;AAC3B,2CAAkD;AAiBlD;;;;;;GAMG;AACI,MAAM,UAAU,GAAG,KAAK,EAC7B,cAAsB,EACtB,OAA6C,EAC5B,EAAE;IACnB,MAAM,aAAa,GAAyB,MAAM,IAAA,sBAAiB,EACjE,cAAc,EACd,OAAO,CACR,CAAC;IACF,IACE,aAAa,KAAK,IAAI;QACtB,gDAAgD;QAChD,OAAQ,aAA2C,EAAE,OAAO,KAAK,QAAQ;QAEzE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAG,IAAI,uBAAe;IACzC,gDAAgD;IAC/C,aAA2C,CAAC,OAAO,CACrD,CAAC;IACF,MAAM,MAAM,GAAW,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACrE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AApBW,QAAA,UAAU,cAoBrB"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addPaymentMethodToCustomer = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -20,24 +11,20 @@ const constants_1 = require("../utils/constants");
|
|
|
20
11
|
* @param ephemeralKey - customer ephemeral key
|
|
21
12
|
* @returns
|
|
22
13
|
*/
|
|
23
|
-
const addPaymentMethodToCustomer = function (paymentMethodId, customerId, ephemeralKey) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
method: "POST",
|
|
39
|
-
}).then(handlers_1.responseHandler);
|
|
40
|
-
});
|
|
14
|
+
const addPaymentMethodToCustomer = async function (paymentMethodId, customerId, ephemeralKey) {
|
|
15
|
+
const stripeApiKey = this._apiKey;
|
|
16
|
+
if (typeof stripeApiKey !== "string")
|
|
17
|
+
throw new Error("Initialization failed.");
|
|
18
|
+
// make request
|
|
19
|
+
return fetch(`${constants_1.stripeApiUrl}/payment_methods/${paymentMethodId}/attach`, {
|
|
20
|
+
body: `customer=${customerId}`,
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
+
"Stripe-Version": `${constants_1.stripeApiVersion}`,
|
|
25
|
+
},
|
|
26
|
+
method: "POST",
|
|
27
|
+
}).then(handlers_1.responseHandler);
|
|
41
28
|
};
|
|
42
29
|
exports.addPaymentMethodToCustomer = addPaymentMethodToCustomer;
|
|
43
30
|
//# sourceMappingURL=addPaymentMethodToCustomer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addPaymentMethodToCustomer.js","sourceRoot":"","sources":["../../src/methods/addPaymentMethodToCustomer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addPaymentMethodToCustomer.js","sourceRoot":"","sources":["../../src/methods/addPaymentMethodToCustomer.ts"],"names":[],"mappings":";;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,0BAA0B,GAAG,KAAK,WAE7C,eAAuB,EACvB,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CAAC,GAAG,wBAAY,oBAAoB,eAAe,SAAS,EAAE;QACxE,IAAI,EAAE,YAAY,UAAU,EAAE;QAC9B,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;SACxC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC3B,CAAC,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addSourceToCustomer = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -20,24 +11,20 @@ const constants_1 = require("../utils/constants");
|
|
|
20
11
|
* @param ephemeralKey - customer ephemeral key
|
|
21
12
|
* @returns
|
|
22
13
|
*/
|
|
23
|
-
const addSourceToCustomer = function (token, customerId, ephemeralKey) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
method: "POST",
|
|
39
|
-
}).then(handlers_1.responseHandler);
|
|
40
|
-
});
|
|
14
|
+
const addSourceToCustomer = async function (token, customerId, ephemeralKey) {
|
|
15
|
+
const stripeApiKey = this._apiKey;
|
|
16
|
+
if (typeof stripeApiKey !== "string")
|
|
17
|
+
throw new Error("Initialization failed.");
|
|
18
|
+
// make request
|
|
19
|
+
return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}/sources`, {
|
|
20
|
+
body: `source=${token}`,
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
+
"Stripe-Version": `${constants_1.stripeApiVersion}`,
|
|
25
|
+
},
|
|
26
|
+
method: "POST",
|
|
27
|
+
}).then(handlers_1.responseHandler);
|
|
41
28
|
};
|
|
42
29
|
exports.addSourceToCustomer = addSourceToCustomer;
|
|
43
30
|
//# sourceMappingURL=addSourceToCustomer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addSourceToCustomer.js","sourceRoot":"","sources":["../../src/methods/addSourceToCustomer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addSourceToCustomer.js","sourceRoot":"","sources":["../../src/methods/addSourceToCustomer.ts"],"names":[],"mappings":";;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,KAAK,WAEtC,KAAa,EACb,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,UAAU,EAAE;QAC9D,IAAI,EAAE,UAAU,KAAK,EAAE;QACvB,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;SACxC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC3B,CAAC,CAAC;AAtBW,QAAA,mBAAmB,uBAsB9B"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.confirmPaymentIntentByCard = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -19,25 +10,21 @@ const constants_1 = require("../utils/constants");
|
|
|
19
10
|
* @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const confirmPaymentIntentByCard = function (paymentIntentSecret, paymentMethodId, returnUrl) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
method: `POST`,
|
|
39
|
-
}).then(handlers_1.responseHandler);
|
|
40
|
-
});
|
|
13
|
+
const confirmPaymentIntentByCard = async function (paymentIntentSecret, paymentMethodId, returnUrl) {
|
|
14
|
+
const stripeApiKey = this._apiKey;
|
|
15
|
+
if (typeof stripeApiKey !== "string")
|
|
16
|
+
throw new Error("Initialization failed.");
|
|
17
|
+
// make request
|
|
18
|
+
const paymentIntentId = paymentIntentSecret.replace(/_secret_.+$/i, "");
|
|
19
|
+
return fetch(`${constants_1.stripeApiUrl}/payment_intents/${paymentIntentId}/confirm?client_secret=${paymentIntentSecret}`, {
|
|
20
|
+
body: `payment_method=${paymentMethodId}${typeof returnUrl === 'string' ? `&return_url=${returnUrl}` : ''}`,
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${stripeApiKey}`,
|
|
23
|
+
"Content-Type": `application/x-www-form-urlencoded`,
|
|
24
|
+
"Stripe-Version": `${constants_1.stripeApiVersion}`,
|
|
25
|
+
},
|
|
26
|
+
method: `POST`,
|
|
27
|
+
}).then(handlers_1.responseHandler);
|
|
41
28
|
};
|
|
42
29
|
exports.confirmPaymentIntentByCard = confirmPaymentIntentByCard;
|
|
43
30
|
//# sourceMappingURL=confirmPaymentIntentByCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirmPaymentIntentByCard.js","sourceRoot":"","sources":["../../src/methods/confirmPaymentIntentByCard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"confirmPaymentIntentByCard.js","sourceRoot":"","sources":["../../src/methods/confirmPaymentIntentByCard.ts"],"names":[],"mappings":";;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,0BAA0B,GAAG,KAAK,WAE7C,mBAA2B,EAC3B,eAAuB,EACvB,SAAkB;IAGlB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,MAAM,eAAe,GAAG,mBAAmB,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACxE,OAAO,KAAK,CACV,GAAG,wBAAY,oBAAoB,eAAe,0BAA0B,mBAAmB,EAAE,EACjG;QACE,IAAI,EAAE,kBAAkB,eAAe,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3G,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;SACxC;QACD,MAAM,EAAE,MAAM;KACf,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC1B,CAAC,CAAC;AA1BW,QAAA,0BAA0B,8BA0BrC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.deletePaymentMethodFromCustomer = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -19,23 +10,19 @@ const constants_1 = require("../utils/constants");
|
|
|
19
10
|
* @param ephemeralKey - customer ephemeral key
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const deletePaymentMethodFromCustomer = function (paymentMethodId, ephemeralKey) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
method: "POST",
|
|
37
|
-
}).then(handlers_1.responseHandler);
|
|
38
|
-
});
|
|
13
|
+
const deletePaymentMethodFromCustomer = async function (paymentMethodId, ephemeralKey) {
|
|
14
|
+
const stripeApiKey = this._apiKey;
|
|
15
|
+
if (typeof stripeApiKey !== "string")
|
|
16
|
+
throw new Error("Initialization failed.");
|
|
17
|
+
// make request
|
|
18
|
+
return fetch(`${constants_1.stripeApiUrl}/payment_methods/${paymentMethodId}/detach`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
22
|
+
"Stripe-Version": `${constants_1.stripeApiVersion}`,
|
|
23
|
+
},
|
|
24
|
+
method: "POST",
|
|
25
|
+
}).then(handlers_1.responseHandler);
|
|
39
26
|
};
|
|
40
27
|
exports.deletePaymentMethodFromCustomer = deletePaymentMethodFromCustomer;
|
|
41
28
|
//# sourceMappingURL=deletePaymentMethodFromCustomer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deletePaymentMethodFromCustomer.js","sourceRoot":"","sources":["../../src/methods/deletePaymentMethodFromCustomer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deletePaymentMethodFromCustomer.js","sourceRoot":"","sources":["../../src/methods/deletePaymentMethodFromCustomer.ts"],"names":[],"mappings":";;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,+BAA+B,GAAG,KAAK,WAElD,eAAuB,EACvB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CAAC,GAAG,wBAAY,oBAAoB,eAAe,SAAS,EAAE;QACxE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;SACxC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC3B,CAAC,CAAC;AApBW,QAAA,+BAA+B,mCAoB1C"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.deleteSourceFromCustomer = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -20,22 +11,18 @@ const constants_1 = require("../utils/constants");
|
|
|
20
11
|
* @param ephemeralKey - customer ephemeral key
|
|
21
12
|
* @returns
|
|
22
13
|
*/
|
|
23
|
-
const deleteSourceFromCustomer = function (sourceId, customerId, ephemeralKey) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
method: "DELETE",
|
|
37
|
-
}).then(handlers_1.responseHandler);
|
|
38
|
-
});
|
|
14
|
+
const deleteSourceFromCustomer = async function (sourceId, customerId, ephemeralKey) {
|
|
15
|
+
const stripeApiKey = this._apiKey;
|
|
16
|
+
if (typeof stripeApiKey !== "string")
|
|
17
|
+
throw new Error("Initialization failed.");
|
|
18
|
+
// make request
|
|
19
|
+
return await fetch(`${constants_1.stripeApiUrl}/customers/${customerId}/sources/${sourceId}`, {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
22
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
23
|
+
},
|
|
24
|
+
method: "DELETE",
|
|
25
|
+
}).then(handlers_1.responseHandler);
|
|
39
26
|
};
|
|
40
27
|
exports.deleteSourceFromCustomer = deleteSourceFromCustomer;
|
|
41
28
|
//# sourceMappingURL=deleteSourceFromCustomer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteSourceFromCustomer.js","sourceRoot":"","sources":["../../src/methods/deleteSourceFromCustomer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deleteSourceFromCustomer.js","sourceRoot":"","sources":["../../src/methods/deleteSourceFromCustomer.ts"],"names":[],"mappings":";;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,wBAAwB,GAAG,KAAK,WAE3C,QAAgB,EAChB,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,MAAM,KAAK,CAChB,GAAG,wBAAY,cAAc,UAAU,YAAY,QAAQ,EAAE,EAC7D;QACE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,gBAAgB,EAAE,4BAAgB;SACnC;QACD,MAAM,EAAE,QAAQ;KACjB,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC1B,CAAC,CAAC;AAvBW,QAAA,wBAAwB,4BAuBnC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getAllCards = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -19,22 +10,18 @@ const constants_1 = require("../utils/constants");
|
|
|
19
10
|
* @param ephemeralKey - customer ephemeral key
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const getAllCards = function (customerId, ephemeralKey) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
method: "GET",
|
|
36
|
-
}).then(handlers_1.responseHandler);
|
|
37
|
-
});
|
|
13
|
+
const getAllCards = async function (customerId, ephemeralKey) {
|
|
14
|
+
const stripeApiKey = this._apiKey;
|
|
15
|
+
if (typeof stripeApiKey !== "string")
|
|
16
|
+
throw new Error("Initialization failed.");
|
|
17
|
+
// make request
|
|
18
|
+
return fetch(`${constants_1.stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
22
|
+
},
|
|
23
|
+
method: "GET",
|
|
24
|
+
}).then(handlers_1.responseHandler);
|
|
38
25
|
};
|
|
39
26
|
exports.getAllCards = getAllCards;
|
|
40
27
|
//# sourceMappingURL=getAllCards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAllCards.js","sourceRoot":"","sources":["../../src/methods/getAllCards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getAllCards.js","sourceRoot":"","sources":["../../src/methods/getAllCards.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,KAAK,WAE9B,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CACV,GAAG,wBAAY,6BAA6B,UAAU,sBAAsB,EAC5E;QACE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,gBAAgB,EAAE,4BAAgB;SACnC;QACD,MAAM,EAAE,KAAK;KACd,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC1B,CAAC,CAAC;AAtBW,QAAA,WAAW,eAsBtB"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getAllPaymentMethods = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -19,22 +10,18 @@ const constants_1 = require("../utils/constants");
|
|
|
19
10
|
* @param ephemeralKey - customer ephemeral key
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const getAllPaymentMethods = function (customerId, ephemeralKey) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
method: "GET",
|
|
36
|
-
}).then(handlers_1.responseHandler);
|
|
37
|
-
});
|
|
13
|
+
const getAllPaymentMethods = async function (customerId, ephemeralKey) {
|
|
14
|
+
const stripeApiKey = this._apiKey;
|
|
15
|
+
if (typeof stripeApiKey !== "string")
|
|
16
|
+
throw new Error("Initialization failed.");
|
|
17
|
+
// make request
|
|
18
|
+
return fetch(`${constants_1.stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
22
|
+
},
|
|
23
|
+
method: "GET",
|
|
24
|
+
}).then(handlers_1.responseHandler);
|
|
38
25
|
};
|
|
39
26
|
exports.getAllPaymentMethods = getAllPaymentMethods;
|
|
40
27
|
//# sourceMappingURL=getAllPaymentMethods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAllPaymentMethods.js","sourceRoot":"","sources":["../../src/methods/getAllPaymentMethods.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getAllPaymentMethods.js","sourceRoot":"","sources":["../../src/methods/getAllPaymentMethods.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,KAAK,WAEvC,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CACV,GAAG,wBAAY,6BAA6B,UAAU,sBAAsB,EAC5E;QACE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,gBAAgB,EAAE,4BAAgB;SACnC;QACD,MAAM,EAAE,KAAK;KACd,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC1B,CAAC,CAAC;AAtBW,QAAA,oBAAoB,wBAsB/B"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getCustomer = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -19,21 +10,17 @@ const constants_1 = require("../utils/constants");
|
|
|
19
10
|
* @param ephemeralKey - customer ephemeral key
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const getCustomer = function (customerId, ephemeralKey) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"Stripe-Version": constants_1.stripeApiVersion,
|
|
34
|
-
},
|
|
35
|
-
}).then(handlers_1.responseHandler);
|
|
36
|
-
});
|
|
13
|
+
const getCustomer = async function (customerId, ephemeralKey) {
|
|
14
|
+
const stripeApiKey = this._apiKey;
|
|
15
|
+
if (typeof stripeApiKey !== "string")
|
|
16
|
+
throw new Error("Initialization failed.");
|
|
17
|
+
// make request
|
|
18
|
+
return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
22
|
+
},
|
|
23
|
+
}).then(handlers_1.responseHandler);
|
|
37
24
|
};
|
|
38
25
|
exports.getCustomer = getCustomer;
|
|
39
26
|
//# sourceMappingURL=getCustomer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomer.js","sourceRoot":"","sources":["../../src/methods/getCustomer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCustomer.js","sourceRoot":"","sources":["../../src/methods/getCustomer.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,KAAK,WAE9B,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;QACtD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,gBAAgB,EAAE,4BAAgB;SACnC;KACF,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC3B,CAAC,CAAC;AAlBW,QAAA,WAAW,eAkBtB"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getDefaultCard = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -19,23 +10,19 @@ const constants_1 = require("../utils/constants");
|
|
|
19
10
|
* @param ephemeralKey - customer ephemeral key
|
|
20
11
|
* @returns
|
|
21
12
|
*/
|
|
22
|
-
const getDefaultCard = function (customerId, ephemeralKey) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
.then(handlers_1.responseHandler)
|
|
37
|
-
.then((e) => ((e === null || e === void 0 ? void 0 : e.default_source) ? e.default_source : undefined));
|
|
38
|
-
});
|
|
13
|
+
const getDefaultCard = async function (customerId, ephemeralKey) {
|
|
14
|
+
const stripeApiKey = this._apiKey;
|
|
15
|
+
if (typeof stripeApiKey !== "string")
|
|
16
|
+
throw new Error("Initialization failed.");
|
|
17
|
+
// make request
|
|
18
|
+
return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
21
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
.then(handlers_1.responseHandler)
|
|
25
|
+
.then((e) => (e?.default_source ? e.default_source : undefined));
|
|
39
26
|
};
|
|
40
27
|
exports.getDefaultCard = getDefaultCard;
|
|
41
28
|
//# sourceMappingURL=getDefaultCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultCard.js","sourceRoot":"","sources":["../../src/methods/getDefaultCard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDefaultCard.js","sourceRoot":"","sources":["../../src/methods/getDefaultCard.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,KAAK,WAEjC,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;QACtD,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,gBAAgB,EAAE,4BAAgB;SACnC;KACF,CAAC;SACC,IAAI,CAAC,0BAAe,CAAC;SACrB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.setDefaultCard = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -20,24 +11,20 @@ const constants_1 = require("../utils/constants");
|
|
|
20
11
|
* @param ephemeralKey - customer ephemeral key
|
|
21
12
|
* @returns
|
|
22
13
|
*/
|
|
23
|
-
const setDefaultCard = function (cardId, customerId, ephemeralKey) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
method: "POST",
|
|
39
|
-
}).then(handlers_1.responseHandler);
|
|
40
|
-
});
|
|
14
|
+
const setDefaultCard = async function (cardId, customerId, ephemeralKey) {
|
|
15
|
+
const stripeApiKey = this._apiKey;
|
|
16
|
+
if (typeof stripeApiKey !== "string")
|
|
17
|
+
throw new Error("Initialization failed.");
|
|
18
|
+
// make request
|
|
19
|
+
return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
|
|
20
|
+
body: `default_source=${cardId}`,
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
25
|
+
},
|
|
26
|
+
method: "POST",
|
|
27
|
+
}).then(handlers_1.responseHandler);
|
|
41
28
|
};
|
|
42
29
|
exports.setDefaultCard = setDefaultCard;
|
|
43
30
|
//# sourceMappingURL=setDefaultCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setDefaultCard.js","sourceRoot":"","sources":["../../src/methods/setDefaultCard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setDefaultCard.js","sourceRoot":"","sources":["../../src/methods/setDefaultCard.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,cAAc,GAAG,KAAK,WAEjC,MAAc,EACd,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAE5C,eAAe;IACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;QACtD,IAAI,EAAE,kBAAkB,MAAM,EAAE;QAChC,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,4BAAgB;SACnC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC3B,CAAC,CAAC;AAtBW,QAAA,cAAc,kBAsBzB"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.setDefaultPaymentMethod = void 0;
|
|
13
4
|
const handlers_1 = require("../utils/handlers");
|
|
@@ -20,24 +11,20 @@ const constants_1 = require("../utils/constants");
|
|
|
20
11
|
* @param ephemeralKey - customer ephemeral key
|
|
21
12
|
* @returns
|
|
22
13
|
*/
|
|
23
|
-
const setDefaultPaymentMethod = function (paymentMethodId, customerId, ephemeralKey) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
method: "POST",
|
|
39
|
-
}).then(handlers_1.responseHandler);
|
|
40
|
-
});
|
|
14
|
+
const setDefaultPaymentMethod = async function (paymentMethodId, customerId, ephemeralKey) {
|
|
15
|
+
const stripeApiKey = this._apiKey;
|
|
16
|
+
if (typeof stripeApiKey !== "string")
|
|
17
|
+
throw new Error("Initialization failed.");
|
|
18
|
+
// make request for payment method api
|
|
19
|
+
return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
|
|
20
|
+
body: `invoice_settings[default_payment_method]=${paymentMethodId}`,
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${ephemeralKey}`,
|
|
23
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
24
|
+
"Stripe-Version": constants_1.stripeApiVersion,
|
|
25
|
+
},
|
|
26
|
+
method: "POST",
|
|
27
|
+
}).then(handlers_1.responseHandler);
|
|
41
28
|
};
|
|
42
29
|
exports.setDefaultPaymentMethod = setDefaultPaymentMethod;
|
|
43
30
|
//# sourceMappingURL=setDefaultPaymentMethod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setDefaultPaymentMethod.js","sourceRoot":"","sources":["../../src/methods/setDefaultPaymentMethod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setDefaultPaymentMethod.js","sourceRoot":"","sources":["../../src/methods/setDefaultPaymentMethod.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,KAAK,WAE1C,eAAuB,EACvB,UAAkB,EAClB,YAAoB;IAGpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;IAElC,IAAI,OAAO,YAAY,KAAK,QAAQ;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,sCAAsC;IACtC,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;QACtD,IAAI,EAAE,4CAA4C,eAAe,EAAE;QACnE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,YAAY,EAAE;YACvC,cAAc,EAAE,mCAAmC;YACnD,gBAAgB,EAAE,4BAAgB;SACnC;QACD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;AAC3B,CAAC,CAAC;AArBW,QAAA,uBAAuB,2BAqBlC"}
|
package/lib/utils/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const stripeApiUrl = "https://api.stripe.com/v1";
|
|
2
|
-
export declare const stripeApiVersion = "
|
|
2
|
+
export declare const stripeApiVersion = "2025-05-28.basil";
|
package/lib/utils/constants.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripeApiVersion = exports.stripeApiUrl = void 0;
|
|
4
4
|
exports.stripeApiUrl = "https://api.stripe.com/v1";
|
|
5
|
-
exports.stripeApiVersion = "
|
|
5
|
+
exports.stripeApiVersion = "2025-05-28.basil";
|
|
6
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,2BAA2B,CAAC;AAC3C,QAAA,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,2BAA2B,CAAC;AAC3C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
|
package/lib/utils/handlers.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.responseHandler = void 0;
|
|
13
4
|
/**
|
|
@@ -16,11 +7,11 @@ exports.responseHandler = void 0;
|
|
|
16
7
|
* @param res - fetch response object
|
|
17
8
|
* @returns
|
|
18
9
|
*/
|
|
19
|
-
const responseHandler = (res) =>
|
|
10
|
+
const responseHandler = async (res) => {
|
|
20
11
|
const data = res.json();
|
|
21
12
|
if (!res.ok)
|
|
22
13
|
throw data;
|
|
23
14
|
return data;
|
|
24
|
-
}
|
|
15
|
+
};
|
|
25
16
|
exports.responseHandler = responseHandler;
|
|
26
17
|
//# sourceMappingURL=handlers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/utils/handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/utils/handlers.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,GAAa,EAAE,EAAE;IACrD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sergdudko/stripe-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Additional methods for working with stripe-js",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"prebuild": "npm run lint",
|
|
10
10
|
"build": "./node_modules/.bin/tsc --declaration",
|
|
11
11
|
"test": "./node_modules/.bin/nyc node --test ./test/*.test.js",
|
|
12
|
+
"test-local": "./node_modules/.bin/nyc node --env-file=.env.local --test ./test/*.test.js",
|
|
12
13
|
"doc": "./node_modules/.bin/typedoc --entryPointStrategy expand src",
|
|
13
14
|
"update": "eval \"$(node -e 'const t = require(`./package.json`);const ignore = require(`./ignoreUpdatesModules.json`);console.log(`npm i ${(Object.keys(t.dependencies||{}).filter((e)=>ignore.base.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save&&npm i ${(Object.keys(t.devDependencies||{}).filter((e)=>ignore.dev.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save-dev`);')\""
|
|
14
15
|
},
|
|
@@ -50,18 +51,18 @@
|
|
|
50
51
|
},
|
|
51
52
|
"homepage": "https://github.com/siarheidudko/stripe-js#readme",
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@eslint/js": "^9.
|
|
54
|
-
"eslint": "^9.
|
|
55
|
-
"jsdom": "^26.
|
|
54
|
+
"@eslint/js": "^9.28.0",
|
|
55
|
+
"eslint": "^9.28.0",
|
|
56
|
+
"jsdom": "^26.1.0",
|
|
56
57
|
"jsdom-global": "^3.0.2",
|
|
57
58
|
"nyc": "^17.1.0",
|
|
58
|
-
"prettier": "^3.5.
|
|
59
|
-
"stripe": "^
|
|
60
|
-
"typedoc": "^0.
|
|
61
|
-
"typescript": "^5.
|
|
62
|
-
"typescript-eslint": "^8.
|
|
59
|
+
"prettier": "^3.5.3",
|
|
60
|
+
"stripe": "^18.2.1",
|
|
61
|
+
"typedoc": "^0.28.5",
|
|
62
|
+
"typescript": "^5.8.3",
|
|
63
|
+
"typescript-eslint": "^8.33.1"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
|
-
"@stripe/stripe-js": "^
|
|
66
|
+
"@stripe/stripe-js": "^7.3.1"
|
|
66
67
|
}
|
|
67
68
|
}
|