@sergdudko/stripe-js 1.0.2 → 1.0.4

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/lib/index.d.ts +24 -0
  3. package/lib/index.js +32 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/methods/addPaymentMethodToCustomer.d.ts +11 -0
  6. package/lib/methods/addPaymentMethodToCustomer.js +43 -0
  7. package/lib/methods/addPaymentMethodToCustomer.js.map +1 -0
  8. package/lib/methods/addSourceToCustomer.d.ts +11 -0
  9. package/lib/methods/addSourceToCustomer.js +43 -0
  10. package/lib/methods/addSourceToCustomer.js.map +1 -0
  11. package/lib/methods/confirmPaymentIntentByCard.d.ts +10 -0
  12. package/lib/methods/confirmPaymentIntentByCard.js +43 -0
  13. package/lib/methods/confirmPaymentIntentByCard.js.map +1 -0
  14. package/lib/methods/confirmPaymentIntentByPaymentMethod.d.ts +8 -0
  15. package/lib/methods/confirmPaymentIntentByPaymentMethod.js +13 -0
  16. package/lib/methods/confirmPaymentIntentByPaymentMethod.js.map +1 -0
  17. package/lib/methods/deletePaymentMethodFromCustomer.d.ts +10 -0
  18. package/lib/methods/deletePaymentMethodFromCustomer.js +41 -0
  19. package/lib/methods/deletePaymentMethodFromCustomer.js.map +1 -0
  20. package/lib/methods/deleteSourceFromCustomer.d.ts +11 -0
  21. package/lib/methods/deleteSourceFromCustomer.js +41 -0
  22. package/lib/methods/deleteSourceFromCustomer.js.map +1 -0
  23. package/lib/methods/getAllCards.d.ts +9 -0
  24. package/lib/methods/getAllCards.js +40 -0
  25. package/lib/methods/getAllCards.js.map +1 -0
  26. package/lib/methods/getAllPaymentMethods.d.ts +9 -0
  27. package/lib/methods/getAllPaymentMethods.js +40 -0
  28. package/lib/methods/getAllPaymentMethods.js.map +1 -0
  29. package/lib/methods/getCustomer.d.ts +9 -0
  30. package/lib/methods/getCustomer.js +39 -0
  31. package/lib/methods/getCustomer.js.map +1 -0
  32. package/lib/methods/getDefaultCard.d.ts +9 -0
  33. package/lib/methods/getDefaultCard.js +41 -0
  34. package/lib/methods/getDefaultCard.js.map +1 -0
  35. package/lib/methods/index.d.ts +18 -0
  36. package/lib/methods/index.js +35 -0
  37. package/lib/methods/index.js.map +1 -0
  38. package/lib/methods/setDefaultCard.d.ts +10 -0
  39. package/lib/methods/setDefaultCard.js +43 -0
  40. package/lib/methods/setDefaultCard.js.map +1 -0
  41. package/lib/methods/setDefaultPaymentMethod.d.ts +10 -0
  42. package/lib/methods/setDefaultPaymentMethod.js +43 -0
  43. package/lib/methods/setDefaultPaymentMethod.js.map +1 -0
  44. package/lib/utils/constants.d.ts +2 -0
  45. package/lib/utils/constants.js +6 -0
  46. package/lib/utils/constants.js.map +1 -0
  47. package/lib/utils/handlers.d.ts +7 -0
  48. package/lib/utils/handlers.js +26 -0
  49. package/lib/utils/handlers.js.map +1 -0
  50. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 1.0.4 / 2023-01-08
2
+
3
+ ### :tada: Enhancements
4
+ - Updated dependencies: jsdom, typedoc
5
+
6
+ # 1.0.3 / 2023-01-06
7
+
8
+ ### :bug: Fixes
9
+ - Deployment bug fixes
10
+
1
11
  # 1.0.2 / 2023-01-06
2
12
 
3
13
  ### :tada: Enhancements
package/lib/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { StripeConstructorOptions, Stripe as StripeDefault } from "@stripe/stripe-js";
2
+ import { StripeExtension } from "./methods/index";
3
+ /**
4
+ * Stripe default interface
5
+ */
6
+ export interface StripeDefaultWithInternal extends StripeDefault {
7
+ /**
8
+ * Stripe api key after initialization, like pk_...
9
+ */
10
+ _apiKey: string;
11
+ }
12
+ /**
13
+ * Stripe patched library
14
+ */
15
+ export interface Stripe extends StripeExtension, StripeDefault {
16
+ }
17
+ /**
18
+ * Initialize stripe
19
+ *
20
+ * @param publishableKey - stripe public key, like pk_...
21
+ * @param options - stripe initialization options
22
+ * @returns
23
+ */
24
+ export declare const loadStripe: (publishableKey: string, options: StripeConstructorOptions | undefined) => Promise<Stripe>;
package/lib/index.js ADDED
@@ -0,0 +1,32 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadStripe = void 0;
13
+ const stripe_js_1 = require("@stripe/stripe-js");
14
+ const index_1 = require("./methods/index");
15
+ /**
16
+ * Initialize stripe
17
+ *
18
+ * @param publishableKey - stripe public key, like pk_...
19
+ * @param options - stripe initialization options
20
+ * @returns
21
+ */
22
+ const loadStripe = (publishableKey, options) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const stripeDefault = yield (0, stripe_js_1.loadStripe)(publishableKey, options);
24
+ if (stripeDefault === null ||
25
+ typeof (stripeDefault === null || stripeDefault === void 0 ? void 0 : stripeDefault._apiKey) !== "string")
26
+ throw new Error("Initialization error.");
27
+ const stripeExtension = new index_1.StripeExtension(stripeDefault._apiKey);
28
+ const stripe = Object.assign(stripeExtension, stripeDefault);
29
+ return stripe;
30
+ });
31
+ exports.loadStripe = loadStripe;
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAI2B;AAC3B,2CAAkD;AAiBlD;;;;;;GAMG;AACI,MAAM,UAAU,GAAG,CACxB,cAAsB,EACtB,OAA6C,EAC7C,EAAE;IACF,MAAM,aAAa,GAAyB,MAAM,IAAA,sBAAiB,EACjE,cAAc,EACd,OAAO,CACR,CAAC;IACF,IACE,aAAa,KAAK,IAAI;QACtB,OAAO,CAAC,aAA2C,aAA3C,aAAa,uBAAb,aAAa,CAAgC,OAAO,CAAA,KAAK,QAAQ;QAEzE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAG,IAAI,uBAAe,CACxC,aAA2C,CAAC,OAAO,CACrD,CAAC;IACF,MAAM,MAAM,GAAW,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IACrE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA,CAAC;AAlBW,QAAA,UAAU,cAkBrB"}
@@ -0,0 +1,11 @@
1
+ import { PaymentMethod } from "@stripe/stripe-js";
2
+ import { StripeExtension } from "./index";
3
+ /**
4
+ * Add payment method to customer.
5
+ *
6
+ * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id)
7
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
8
+ * @param ephemeralKey - customer ephemeral key
9
+ * @returns
10
+ */
11
+ export declare const addPaymentMethodToCustomer: (this: StripeExtension, paymentMethodId: string, customerId: string, ephemeralKey: string) => Promise<PaymentMethod | undefined>;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.addPaymentMethodToCustomer = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Add payment method to customer.
17
+ *
18
+ * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id)
19
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
20
+ * @param ephemeralKey - customer ephemeral key
21
+ * @returns
22
+ */
23
+ const addPaymentMethodToCustomer = function (paymentMethodId, customerId, ephemeralKey) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ /* eslint-disable */
26
+ const stripeApiKey = this._apiKey;
27
+ /* eslint-enable */
28
+ if (typeof stripeApiKey !== "string")
29
+ throw new Error("Initialization failed.");
30
+ // make request
31
+ return fetch(`${constants_1.stripeApiUrl}/payment_methods/${paymentMethodId}/attach`, {
32
+ body: `customer=${customerId}`,
33
+ headers: {
34
+ Authorization: `Bearer ${ephemeralKey}`,
35
+ "Content-Type": "application/x-www-form-urlencoded",
36
+ "Stripe-Version": `${constants_1.stripeApiVersion}`,
37
+ },
38
+ method: "POST",
39
+ }).then(handlers_1.responseHandler);
40
+ });
41
+ };
42
+ exports.addPaymentMethodToCustomer = addPaymentMethodToCustomer;
43
+ //# sourceMappingURL=addPaymentMethodToCustomer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addPaymentMethodToCustomer.js","sourceRoot":"","sources":["../../src/methods/addPaymentMethodToCustomer.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,0BAA0B,GAAG,UAExC,eAAuB,EACvB,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CAAC,GAAG,wBAAY,oBAAoB,eAAe,SAAS,EAAE;YACxE,IAAI,EAAE,YAAY,UAAU,EAAE;YAC9B,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,cAAc,EAAE,mCAAmC;gBACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;aACxC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC3B,CAAC;CAAA,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC"}
@@ -0,0 +1,11 @@
1
+ import { Card } from "@stripe/stripe-js";
2
+ import { StripeExtension } from "./index";
3
+ /**
4
+ * Add card to customer (from source or token).
5
+ *
6
+ * @param token - source or token string (see: https://stripe.com/docs/api/sources/object)
7
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
8
+ * @param ephemeralKey - customer ephemeral key
9
+ * @returns
10
+ */
11
+ export declare const addSourceToCustomer: (this: StripeExtension, token: string, customerId: string, ephemeralKey: string) => Promise<Card | undefined>;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.addSourceToCustomer = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Add card to customer (from source or token).
17
+ *
18
+ * @param token - source or token string (see: https://stripe.com/docs/api/sources/object)
19
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
20
+ * @param ephemeralKey - customer ephemeral key
21
+ * @returns
22
+ */
23
+ const addSourceToCustomer = function (token, customerId, ephemeralKey) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ /* eslint-disable */
26
+ const stripeApiKey = this._apiKey;
27
+ /* eslint-enable */
28
+ if (typeof stripeApiKey !== "string")
29
+ throw new Error("Initialization failed.");
30
+ // make request
31
+ return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}/sources`, {
32
+ body: `source=${token}`,
33
+ headers: {
34
+ Authorization: `Bearer ${ephemeralKey}`,
35
+ "Content-Type": "application/x-www-form-urlencoded",
36
+ "Stripe-Version": `${constants_1.stripeApiVersion}`,
37
+ },
38
+ method: "POST",
39
+ }).then(handlers_1.responseHandler);
40
+ });
41
+ };
42
+ exports.addSourceToCustomer = addSourceToCustomer;
43
+ //# sourceMappingURL=addSourceToCustomer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addSourceToCustomer.js","sourceRoot":"","sources":["../../src/methods/addSourceToCustomer.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,UAEjC,KAAa,EACb,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,UAAU,EAAE;YAC9D,IAAI,EAAE,UAAU,KAAK,EAAE;YACvB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,cAAc,EAAE,mCAAmC;gBACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;aACxC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC3B,CAAC;CAAA,CAAC;AAtBW,QAAA,mBAAmB,uBAsB9B"}
@@ -0,0 +1,10 @@
1
+ import { PaymentIntentResult } from "@stripe/stripe-js";
2
+ import { StripeExtension } from "./index";
3
+ /**
4
+ * Confirm payment intent by customer's card
5
+ *
6
+ * @param paymentIntentSecret - stripe payment intent secret (see: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret)
7
+ * @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
8
+ * @returns
9
+ */
10
+ export declare const confirmPaymentIntentByCard: (this: StripeExtension, paymentIntentSecret: string, paymentMethodId: string, returnUrl?: string) => Promise<PaymentIntentResult["paymentIntent"] | undefined>;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.confirmPaymentIntentByCard = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Confirm payment intent by customer's card
17
+ *
18
+ * @param paymentIntentSecret - stripe payment intent secret (see: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret)
19
+ * @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
20
+ * @returns
21
+ */
22
+ const confirmPaymentIntentByCard = function (paymentIntentSecret, paymentMethodId, returnUrl) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ /* eslint-disable */
25
+ const stripeApiKey = this._apiKey;
26
+ /* eslint-enable */
27
+ if (typeof stripeApiKey !== "string")
28
+ throw new Error("Initialization failed.");
29
+ // make request
30
+ const paymentIntentId = paymentIntentSecret.replace(/_secret_.+$/i, "");
31
+ return fetch(`${constants_1.stripeApiUrl}/payment_intents/${paymentIntentId}/confirm?client_secret=${paymentIntentSecret}`, {
32
+ body: `payment_method=${paymentMethodId}${typeof returnUrl === 'string' ? `&return_url=${returnUrl}` : ''}`,
33
+ headers: {
34
+ Authorization: `Bearer ${stripeApiKey}`,
35
+ "Content-Type": `application/x-www-form-urlencoded`,
36
+ "Stripe-Version": `${constants_1.stripeApiVersion}`,
37
+ },
38
+ method: `POST`,
39
+ }).then(handlers_1.responseHandler);
40
+ });
41
+ };
42
+ exports.confirmPaymentIntentByCard = confirmPaymentIntentByCard;
43
+ //# sourceMappingURL=confirmPaymentIntentByCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmPaymentIntentByCard.js","sourceRoot":"","sources":["../../src/methods/confirmPaymentIntentByCard.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,0BAA0B,GAAG,UAExC,mBAA2B,EAC3B,eAAuB,EACvB,SAAkB;;QAElB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,MAAM,eAAe,GAAG,mBAAmB,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QACxE,OAAO,KAAK,CACV,GAAG,wBAAY,oBAAoB,eAAe,0BAA0B,mBAAmB,EAAE,EACjG;YACE,IAAI,EAAE,kBAAkB,eAAe,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3G,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,cAAc,EAAE,mCAAmC;gBACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;aACxC;YACD,MAAM,EAAE,MAAM;SACf,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC1B,CAAC;CAAA,CAAC;AA1BW,QAAA,0BAA0B,8BA0BrC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Confirm payment intent by customer's payment method
3
+ *
4
+ * @param paymentIntentSecret - stripe payment intent secret (see: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret)
5
+ * @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
6
+ * @returns
7
+ */
8
+ export declare const confirmPaymentIntentByPaymentMethod: (this: import(".").StripeExtension, paymentIntentSecret: string, paymentMethodId: string, returnUrl?: string | undefined) => Promise<import("@stripe/stripe-js").PaymentIntent | undefined>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.confirmPaymentIntentByPaymentMethod = void 0;
4
+ const confirmPaymentIntentByCard_1 = require("./confirmPaymentIntentByCard");
5
+ /**
6
+ * Confirm payment intent by customer's payment method
7
+ *
8
+ * @param paymentIntentSecret - stripe payment intent secret (see: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret)
9
+ * @param paymentMethodId - stripe customer payment method id (see: https://stripe.com/docs/api/cards/object#card_object-id)
10
+ * @returns
11
+ */
12
+ exports.confirmPaymentIntentByPaymentMethod = confirmPaymentIntentByCard_1.confirmPaymentIntentByCard;
13
+ //# sourceMappingURL=confirmPaymentIntentByPaymentMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmPaymentIntentByPaymentMethod.js","sourceRoot":"","sources":["../../src/methods/confirmPaymentIntentByPaymentMethod.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAE1E;;;;;;GAMG;AACU,QAAA,mCAAmC,GAAG,uDAA0B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { PaymentMethod } from "@stripe/stripe-js";
2
+ import { StripeExtension } from "./index";
3
+ /**
4
+ * Delete payment method from customer.
5
+ *
6
+ * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id)
7
+ * @param ephemeralKey - customer ephemeral key
8
+ * @returns
9
+ */
10
+ export declare const deletePaymentMethodFromCustomer: (this: StripeExtension, paymentMethodId: string, ephemeralKey: string) => Promise<PaymentMethod | undefined>;
@@ -0,0 +1,41 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.deletePaymentMethodFromCustomer = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Delete payment method from customer.
17
+ *
18
+ * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id)
19
+ * @param ephemeralKey - customer ephemeral key
20
+ * @returns
21
+ */
22
+ const deletePaymentMethodFromCustomer = function (paymentMethodId, ephemeralKey) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ /* eslint-disable */
25
+ const stripeApiKey = this._apiKey;
26
+ /* eslint-enable */
27
+ if (typeof stripeApiKey !== "string")
28
+ throw new Error("Initialization failed.");
29
+ // make request
30
+ return fetch(`${constants_1.stripeApiUrl}/payment_methods/${paymentMethodId}/detach`, {
31
+ headers: {
32
+ Authorization: `Bearer ${ephemeralKey}`,
33
+ "Content-Type": "application/x-www-form-urlencoded",
34
+ "Stripe-Version": `${constants_1.stripeApiVersion}`,
35
+ },
36
+ method: "POST",
37
+ }).then(handlers_1.responseHandler);
38
+ });
39
+ };
40
+ exports.deletePaymentMethodFromCustomer = deletePaymentMethodFromCustomer;
41
+ //# sourceMappingURL=deletePaymentMethodFromCustomer.js.map
@@ -0,0 +1 @@
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,UAE7C,eAAuB,EACvB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CAAC,GAAG,wBAAY,oBAAoB,eAAe,SAAS,EAAE;YACxE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,cAAc,EAAE,mCAAmC;gBACnD,gBAAgB,EAAE,GAAG,4BAAgB,EAAE;aACxC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC3B,CAAC;CAAA,CAAC;AApBW,QAAA,+BAA+B,mCAoB1C"}
@@ -0,0 +1,11 @@
1
+ import { Card } from "@stripe/stripe-js";
2
+ import { StripeExtension } from "./index";
3
+ /**
4
+ * Delete card from customer.
5
+ *
6
+ * @param sourceId - source or card id (see: https://stripe.com/docs/api/sources/object#source_object-id)
7
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
8
+ * @param ephemeralKey - customer ephemeral key
9
+ * @returns
10
+ */
11
+ export declare const deleteSourceFromCustomer: (this: StripeExtension, sourceId: string, customerId: string, ephemeralKey: string) => Promise<Card | undefined>;
@@ -0,0 +1,41 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.deleteSourceFromCustomer = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Delete card from customer.
17
+ *
18
+ * @param sourceId - source or card id (see: https://stripe.com/docs/api/sources/object#source_object-id)
19
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
20
+ * @param ephemeralKey - customer ephemeral key
21
+ * @returns
22
+ */
23
+ const deleteSourceFromCustomer = function (sourceId, customerId, ephemeralKey) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ /* eslint-disable */
26
+ const stripeApiKey = this._apiKey;
27
+ /* eslint-enable */
28
+ if (typeof stripeApiKey !== "string")
29
+ throw new Error("Initialization failed.");
30
+ // make request
31
+ return yield fetch(`${constants_1.stripeApiUrl}/customers/${customerId}/sources/${sourceId}`, {
32
+ headers: {
33
+ Authorization: `Bearer ${ephemeralKey}`,
34
+ "Stripe-Version": constants_1.stripeApiVersion,
35
+ },
36
+ method: "DELETE",
37
+ }).then(handlers_1.responseHandler);
38
+ });
39
+ };
40
+ exports.deleteSourceFromCustomer = deleteSourceFromCustomer;
41
+ //# sourceMappingURL=deleteSourceFromCustomer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteSourceFromCustomer.js","sourceRoot":"","sources":["../../src/methods/deleteSourceFromCustomer.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,wBAAwB,GAAG,UAEtC,QAAgB,EAChB,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,MAAM,KAAK,CAChB,GAAG,wBAAY,cAAc,UAAU,YAAY,QAAQ,EAAE,EAC7D;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,gBAAgB,EAAE,4BAAgB;aACnC;YACD,MAAM,EAAE,QAAQ;SACjB,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC1B,CAAC;CAAA,CAAC;AAvBW,QAAA,wBAAwB,4BAuBnC"}
@@ -0,0 +1,9 @@
1
+ import { StripeExtension } from ".";
2
+ /**
3
+ * Get all customer's card
4
+ *
5
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
6
+ * @param ephemeralKey - customer ephemeral key
7
+ * @returns
8
+ */
9
+ export declare const getAllCards: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<any>;
@@ -0,0 +1,40 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getAllCards = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Get all customer's card
17
+ *
18
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
19
+ * @param ephemeralKey - customer ephemeral key
20
+ * @returns
21
+ */
22
+ const getAllCards = function (customerId, ephemeralKey) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ /* eslint-disable */
25
+ const stripeApiKey = this._apiKey;
26
+ /* eslint-enable */
27
+ if (typeof stripeApiKey !== "string")
28
+ throw new Error("Initialization failed.");
29
+ // make request
30
+ return fetch(`${constants_1.stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`, {
31
+ headers: {
32
+ Authorization: `Bearer ${ephemeralKey}`,
33
+ "Stripe-Version": constants_1.stripeApiVersion,
34
+ },
35
+ method: "GET",
36
+ }).then(handlers_1.responseHandler);
37
+ });
38
+ };
39
+ exports.getAllCards = getAllCards;
40
+ //# sourceMappingURL=getAllCards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllCards.js","sourceRoot":"","sources":["../../src/methods/getAllCards.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,UAEzB,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CACV,GAAG,wBAAY,6BAA6B,UAAU,sBAAsB,EAC5E;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,gBAAgB,EAAE,4BAAgB;aACnC;YACD,MAAM,EAAE,KAAK;SACd,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC1B,CAAC;CAAA,CAAC;AAtBW,QAAA,WAAW,eAsBtB"}
@@ -0,0 +1,9 @@
1
+ import { StripeExtension } from ".";
2
+ /**
3
+ * Get all customer's payment methods
4
+ *
5
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
6
+ * @param ephemeralKey - customer ephemeral key
7
+ * @returns
8
+ */
9
+ export declare const getAllPaymentMethods: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<any>;
@@ -0,0 +1,40 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getAllPaymentMethods = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Get all customer's payment methods
17
+ *
18
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
19
+ * @param ephemeralKey - customer ephemeral key
20
+ * @returns
21
+ */
22
+ const getAllPaymentMethods = function (customerId, ephemeralKey) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ /* eslint-disable */
25
+ const stripeApiKey = this._apiKey;
26
+ /* eslint-enable */
27
+ if (typeof stripeApiKey !== "string")
28
+ throw new Error("Initialization failed.");
29
+ // make request
30
+ return fetch(`${constants_1.stripeApiUrl}/payment_methods?customer=${customerId}&type=card&limit=100`, {
31
+ headers: {
32
+ Authorization: `Bearer ${ephemeralKey}`,
33
+ "Stripe-Version": constants_1.stripeApiVersion,
34
+ },
35
+ method: "GET",
36
+ }).then(handlers_1.responseHandler);
37
+ });
38
+ };
39
+ exports.getAllPaymentMethods = getAllPaymentMethods;
40
+ //# sourceMappingURL=getAllPaymentMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllPaymentMethods.js","sourceRoot":"","sources":["../../src/methods/getAllPaymentMethods.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,UAElC,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CACV,GAAG,wBAAY,6BAA6B,UAAU,sBAAsB,EAC5E;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,gBAAgB,EAAE,4BAAgB;aACnC;YACD,MAAM,EAAE,KAAK;SACd,CACF,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC1B,CAAC;CAAA,CAAC;AAtBW,QAAA,oBAAoB,wBAsB/B"}
@@ -0,0 +1,9 @@
1
+ import { StripeExtension } from ".";
2
+ /**
3
+ * Get customer data
4
+ *
5
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
6
+ * @param ephemeralKey - customer ephemeral key
7
+ * @returns
8
+ */
9
+ export declare const getCustomer: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<any>;
@@ -0,0 +1,39 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getCustomer = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Get customer data
17
+ *
18
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
19
+ * @param ephemeralKey - customer ephemeral key
20
+ * @returns
21
+ */
22
+ const getCustomer = function (customerId, ephemeralKey) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ /* eslint-disable */
25
+ const stripeApiKey = this._apiKey;
26
+ /* eslint-enable */
27
+ if (typeof stripeApiKey !== "string")
28
+ throw new Error("Initialization failed.");
29
+ // make request
30
+ return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
31
+ headers: {
32
+ Authorization: `Bearer ${ephemeralKey}`,
33
+ "Stripe-Version": constants_1.stripeApiVersion,
34
+ },
35
+ }).then(handlers_1.responseHandler);
36
+ });
37
+ };
38
+ exports.getCustomer = getCustomer;
39
+ //# sourceMappingURL=getCustomer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCustomer.js","sourceRoot":"","sources":["../../src/methods/getCustomer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,UAEzB,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,gBAAgB,EAAE,4BAAgB;aACnC;SACF,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC3B,CAAC;CAAA,CAAC;AAlBW,QAAA,WAAW,eAkBtB"}
@@ -0,0 +1,9 @@
1
+ import { StripeExtension } from ".";
2
+ /**
3
+ * Get customer's default card id
4
+ *
5
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
6
+ * @param ephemeralKey - customer ephemeral key
7
+ * @returns
8
+ */
9
+ export declare const getDefaultCard: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<string | undefined>;
@@ -0,0 +1,41 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getDefaultCard = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Get customer's default card id
17
+ *
18
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
19
+ * @param ephemeralKey - customer ephemeral key
20
+ * @returns
21
+ */
22
+ const getDefaultCard = function (customerId, ephemeralKey) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ /* eslint-disable */
25
+ const stripeApiKey = this._apiKey;
26
+ /* eslint-enable */
27
+ if (typeof stripeApiKey !== "string")
28
+ throw new Error("Initialization failed.");
29
+ // make request
30
+ return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
31
+ headers: {
32
+ Authorization: `Bearer ${ephemeralKey}`,
33
+ "Stripe-Version": constants_1.stripeApiVersion,
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
+ });
39
+ };
40
+ exports.getDefaultCard = getDefaultCard;
41
+ //# sourceMappingURL=getDefaultCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultCard.js","sourceRoot":"","sources":["../../src/methods/getDefaultCard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,UAE5B,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,gBAAgB,EAAE,4BAAgB;aACnC;SACF,CAAC;aACC,IAAI,CAAC,0BAAe,CAAC;aACrB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,EAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACrE,CAAC;CAAA,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * additional stripe methods
3
+ */
4
+ export declare class StripeExtension {
5
+ constructor(apiKey: string);
6
+ _apiKey: string;
7
+ confirmPaymentIntentByCard: (this: StripeExtension, paymentIntentSecret: string, paymentMethodId: string, returnUrl?: string | undefined) => Promise<import("@stripe/stripe-js").PaymentIntent | undefined>;
8
+ confirmPaymentIntentByPaymentMethod: (this: StripeExtension, paymentIntentSecret: string, paymentMethodId: string, returnUrl?: string | undefined) => Promise<import("@stripe/stripe-js").PaymentIntent | undefined>;
9
+ addSourceToCustomer: (this: StripeExtension, token: string, customerId: string, ephemeralKey: string) => Promise<import("@stripe/stripe-js").Card | undefined>;
10
+ deleteSourceFromCustomer: (this: StripeExtension, sourceId: string, customerId: string, ephemeralKey: string) => Promise<import("@stripe/stripe-js").Card | undefined>;
11
+ getAllCards: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<any>;
12
+ getCustomer: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<any>;
13
+ setDefaultCard: (this: StripeExtension, cardId: string, customerId: string, ephemeralKey: string) => Promise<any>;
14
+ addPaymentMethodToCustomer: (this: StripeExtension, paymentMethodId: string, customerId: string, ephemeralKey: string) => Promise<import("@stripe/stripe-js").PaymentMethod | undefined>;
15
+ deletePaymentMethodFromCustomer: (this: StripeExtension, paymentMethodId: string, ephemeralKey: string) => Promise<import("@stripe/stripe-js").PaymentMethod | undefined>;
16
+ getAllPaymentMethods: (this: StripeExtension, customerId: string, ephemeralKey: string) => Promise<any>;
17
+ setDefaultPaymentMethod: (this: StripeExtension, paymentMethodId: string, customerId: string, ephemeralKey: string) => Promise<any>;
18
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StripeExtension = void 0;
4
+ const confirmPaymentIntentByCard_1 = require("./confirmPaymentIntentByCard");
5
+ const confirmPaymentIntentByPaymentMethod_1 = require("./confirmPaymentIntentByPaymentMethod");
6
+ const addSourceToCustomer_1 = require("./addSourceToCustomer");
7
+ const deleteSourceFromCustomer_1 = require("./deleteSourceFromCustomer");
8
+ const getAllCards_1 = require("./getAllCards");
9
+ const getCustomer_1 = require("./getCustomer");
10
+ const setDefaultCard_1 = require("./setDefaultCard");
11
+ const addPaymentMethodToCustomer_1 = require("./addPaymentMethodToCustomer");
12
+ const deletePaymentMethodFromCustomer_1 = require("./deletePaymentMethodFromCustomer");
13
+ const getAllPaymentMethods_1 = require("./getAllPaymentMethods");
14
+ const setDefaultPaymentMethod_1 = require("./setDefaultPaymentMethod");
15
+ /**
16
+ * additional stripe methods
17
+ */
18
+ class StripeExtension {
19
+ constructor(apiKey) {
20
+ this.confirmPaymentIntentByCard = confirmPaymentIntentByCard_1.confirmPaymentIntentByCard;
21
+ this.confirmPaymentIntentByPaymentMethod = confirmPaymentIntentByPaymentMethod_1.confirmPaymentIntentByPaymentMethod;
22
+ this.addSourceToCustomer = addSourceToCustomer_1.addSourceToCustomer;
23
+ this.deleteSourceFromCustomer = deleteSourceFromCustomer_1.deleteSourceFromCustomer;
24
+ this.getAllCards = getAllCards_1.getAllCards;
25
+ this.getCustomer = getCustomer_1.getCustomer;
26
+ this.setDefaultCard = setDefaultCard_1.setDefaultCard;
27
+ this.addPaymentMethodToCustomer = addPaymentMethodToCustomer_1.addPaymentMethodToCustomer;
28
+ this.deletePaymentMethodFromCustomer = deletePaymentMethodFromCustomer_1.deletePaymentMethodFromCustomer;
29
+ this.getAllPaymentMethods = getAllPaymentMethods_1.getAllPaymentMethods;
30
+ this.setDefaultPaymentMethod = setDefaultPaymentMethod_1.setDefaultPaymentMethod;
31
+ this._apiKey = apiKey;
32
+ }
33
+ }
34
+ exports.StripeExtension = StripeExtension;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/methods/index.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAC1E,+FAA4F;AAC5F,+DAA4D;AAC5D,yEAAsE;AACtE,+CAA4C;AAC5C,+CAA4C;AAC5C,qDAAkD;AAClD,6EAA0E;AAC1E,uFAAoF;AACpF,iEAA8D;AAC9D,uEAAoE;AAEpE;;GAEG;AACH,MAAa,eAAe;IAC1B,YAAY,MAAc;QAInB,+BAA0B,GAAG,uDAA0B,CAAC;QACxD,wCAAmC,GACxC,yEAAmC,CAAC;QAC/B,wBAAmB,GAAG,yCAAmB,CAAC;QAC1C,6BAAwB,GAAG,mDAAwB,CAAC;QACpD,gBAAW,GAAG,yBAAW,CAAC;QAC1B,gBAAW,GAAG,yBAAW,CAAC;QAC1B,mBAAc,GAAG,+BAAc,CAAC;QAChC,+BAA0B,GAAG,uDAA0B,CAAC;QACxD,oCAA+B,GAAG,iEAA+B,CAAC;QAClE,yBAAoB,GAAG,2CAAoB,CAAC;QAC5C,4BAAuB,GAAG,iDAAuB,CAAC;QAdvD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;CAcF;AAjBD,0CAiBC"}
@@ -0,0 +1,10 @@
1
+ import { StripeExtension } from ".";
2
+ /**
3
+ * Set default customer card
4
+ *
5
+ * @param cardId - card id (see: https://stripe.com/docs/api/customers/object#card_object-id)
6
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
7
+ * @param ephemeralKey - customer ephemeral key
8
+ * @returns
9
+ */
10
+ export declare const setDefaultCard: (this: StripeExtension, cardId: string, customerId: string, ephemeralKey: string) => Promise<any>;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.setDefaultCard = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Set default customer card
17
+ *
18
+ * @param cardId - card id (see: https://stripe.com/docs/api/customers/object#card_object-id)
19
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
20
+ * @param ephemeralKey - customer ephemeral key
21
+ * @returns
22
+ */
23
+ const setDefaultCard = function (cardId, customerId, ephemeralKey) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ /* eslint-disable */
26
+ const stripeApiKey = this._apiKey;
27
+ /* eslint-enable */
28
+ if (typeof stripeApiKey !== "string")
29
+ throw new Error("Initialization failed.");
30
+ // make request
31
+ return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
32
+ body: `default_source=${cardId}`,
33
+ headers: {
34
+ Authorization: `Bearer ${ephemeralKey}`,
35
+ "Content-Type": "application/x-www-form-urlencoded",
36
+ "Stripe-Version": constants_1.stripeApiVersion,
37
+ },
38
+ method: "POST",
39
+ }).then(handlers_1.responseHandler);
40
+ });
41
+ };
42
+ exports.setDefaultCard = setDefaultCard;
43
+ //# sourceMappingURL=setDefaultCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setDefaultCard.js","sourceRoot":"","sources":["../../src/methods/setDefaultCard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,cAAc,GAAG,UAE5B,MAAc,EACd,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAE5C,eAAe;QACf,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;YACtD,IAAI,EAAE,kBAAkB,MAAM,EAAE;YAChC,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,cAAc,EAAE,mCAAmC;gBACnD,gBAAgB,EAAE,4BAAgB;aACnC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC3B,CAAC;CAAA,CAAC;AAtBW,QAAA,cAAc,kBAsBzB"}
@@ -0,0 +1,10 @@
1
+ import { StripeExtension } from ".";
2
+ /**
3
+ * Set default customer payment method
4
+ *
5
+ * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id)
6
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
7
+ * @param ephemeralKey - customer ephemeral key
8
+ * @returns
9
+ */
10
+ export declare const setDefaultPaymentMethod: (this: StripeExtension, paymentMethodId: string, customerId: string, ephemeralKey: string) => Promise<any>;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.setDefaultPaymentMethod = void 0;
13
+ const handlers_1 = require("../utils/handlers");
14
+ const constants_1 = require("../utils/constants");
15
+ /**
16
+ * Set default customer payment method
17
+ *
18
+ * @param paymentMethodId - payment method id (see: https://stripe.com/docs/api/customers/object#payment_method_object-id)
19
+ * @param customerId - customer id (see: https://stripe.com/docs/api/customers/object#customer_object-id)
20
+ * @param ephemeralKey - customer ephemeral key
21
+ * @returns
22
+ */
23
+ const setDefaultPaymentMethod = function (paymentMethodId, customerId, ephemeralKey) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ /* eslint-disable */
26
+ const stripeApiKey = this._apiKey;
27
+ /* eslint-enable */
28
+ if (typeof stripeApiKey !== "string")
29
+ throw new Error("Initialization failed.");
30
+ // make request for payment method api
31
+ return fetch(`${constants_1.stripeApiUrl}/customers/${customerId}`, {
32
+ body: `invoice_settings[default_payment_method]=${paymentMethodId}`,
33
+ headers: {
34
+ Authorization: `Bearer ${ephemeralKey}`,
35
+ "Content-Type": "application/x-www-form-urlencoded",
36
+ "Stripe-Version": constants_1.stripeApiVersion,
37
+ },
38
+ method: "POST",
39
+ }).then(handlers_1.responseHandler);
40
+ });
41
+ };
42
+ exports.setDefaultPaymentMethod = setDefaultPaymentMethod;
43
+ //# sourceMappingURL=setDefaultPaymentMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setDefaultPaymentMethod.js","sourceRoot":"","sources":["../../src/methods/setDefaultPaymentMethod.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAoD;AACpD,kDAAoE;AAGpE;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,UAErC,eAAuB,EACvB,UAAkB,EAClB,YAAoB;;QAEpB,oBAAoB;QACpB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,mBAAmB;QACnB,IAAI,OAAO,YAAY,KAAK,QAAQ;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,sCAAsC;QACtC,OAAO,KAAK,CAAC,GAAG,wBAAY,cAAc,UAAU,EAAE,EAAE;YACtD,IAAI,EAAE,4CAA4C,eAAe,EAAE;YACnE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,YAAY,EAAE;gBACvC,cAAc,EAAE,mCAAmC;gBACnD,gBAAgB,EAAE,4BAAgB;aACnC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CAAC,IAAI,CAAC,0BAAe,CAAC,CAAC;IAC3B,CAAC;CAAA,CAAC;AArBW,QAAA,uBAAuB,2BAqBlC"}
@@ -0,0 +1,2 @@
1
+ export declare const stripeApiUrl = "https://api.stripe.com/v1";
2
+ export declare const stripeApiVersion = "2022-11-15";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripeApiVersion = exports.stripeApiUrl = void 0;
4
+ exports.stripeApiUrl = "https://api.stripe.com/v1";
5
+ exports.stripeApiVersion = "2022-11-15";
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Response handler
3
+ *
4
+ * @param res - fetch response object
5
+ * @returns
6
+ */
7
+ export declare const responseHandler: (res: Response) => Promise<any>;
@@ -0,0 +1,26 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.responseHandler = void 0;
13
+ /**
14
+ * Response handler
15
+ *
16
+ * @param res - fetch response object
17
+ * @returns
18
+ */
19
+ const responseHandler = (res) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const data = res.json();
21
+ if (!res.ok)
22
+ throw data;
23
+ return data;
24
+ });
25
+ exports.responseHandler = responseHandler;
26
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/utils/handlers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAAO,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,CAAA,CAAC;AAJW,QAAA,eAAe,mBAI1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sergdudko/stripe-js",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Additional methods for working with stripe-js",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -41,13 +41,13 @@
41
41
  "eslint": "^8.31.0",
42
42
  "eslint-config-prettier": "^8.6.0",
43
43
  "eslint-plugin-import": "^2.26.0",
44
- "jsdom": "^20.0.3",
44
+ "jsdom": "^21.0.0",
45
45
  "jsdom-global": "^3.0.2",
46
46
  "mocha": "^10.2.0",
47
47
  "node-fetch": "^2.6.7",
48
48
  "nyc": "^15.1.0",
49
49
  "stripe": "^11.6.0",
50
- "typedoc": "^0.23.23",
50
+ "typedoc": "^0.23.24",
51
51
  "typescript": "^4.9.4"
52
52
  },
53
53
  "dependencies": {