@apexara/stripe 1.0.5 → 1.1.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.
Files changed (57) hide show
  1. package/README.md +450 -28
  2. package/dist/apex-stripe.d.ts.map +1 -1
  3. package/dist/apex-stripe.js +10 -8
  4. package/dist/errors/http-error.d.ts +2 -1
  5. package/dist/errors/http-error.d.ts.map +1 -1
  6. package/dist/errors/http-error.js +3 -1
  7. package/dist/errors/stripe-error-status.d.ts +16 -0
  8. package/dist/errors/stripe-error-status.d.ts.map +1 -0
  9. package/dist/errors/stripe-error-status.js +60 -0
  10. package/dist/models/config.model.d.ts +2 -0
  11. package/dist/models/config.model.d.ts.map +1 -1
  12. package/dist/models/stripe.model.d.ts +12 -0
  13. package/dist/models/stripe.model.d.ts.map +1 -1
  14. package/dist/models/subscription.model.d.ts +1 -0
  15. package/dist/models/subscription.model.d.ts.map +1 -1
  16. package/dist/models/webhook.model.d.ts +16 -0
  17. package/dist/models/webhook.model.d.ts.map +1 -1
  18. package/dist/services/checkout/checkout.service.d.ts +8 -5
  19. package/dist/services/checkout/checkout.service.d.ts.map +1 -1
  20. package/dist/services/checkout/checkout.service.js +26 -13
  21. package/dist/services/connected-account/connected-account.service.d.ts +2 -1
  22. package/dist/services/connected-account/connected-account.service.d.ts.map +1 -1
  23. package/dist/services/connected-account/connected-account.service.js +4 -3
  24. package/dist/services/customer/customer.service.d.ts +2 -1
  25. package/dist/services/customer/customer.service.d.ts.map +1 -1
  26. package/dist/services/customer/customer.service.js +3 -2
  27. package/dist/services/invoice/invoice.service.d.ts +27 -3
  28. package/dist/services/invoice/invoice.service.d.ts.map +1 -1
  29. package/dist/services/invoice/invoice.service.js +108 -12
  30. package/dist/services/payment-link/payment-link.service.d.ts +2 -2
  31. package/dist/services/payment-link/payment-link.service.d.ts.map +1 -1
  32. package/dist/services/payment-link/payment-link.service.js +5 -4
  33. package/dist/services/payment-method/payment-method.service.d.ts +5 -4
  34. package/dist/services/payment-method/payment-method.service.d.ts.map +1 -1
  35. package/dist/services/payment-method/payment-method.service.js +35 -9
  36. package/dist/services/price/price.service.d.ts +2 -2
  37. package/dist/services/price/price.service.d.ts.map +1 -1
  38. package/dist/services/price/price.service.js +4 -3
  39. package/dist/services/subscription/subscription.service.d.ts +79 -12
  40. package/dist/services/subscription/subscription.service.d.ts.map +1 -1
  41. package/dist/services/subscription/subscription.service.js +337 -49
  42. package/dist/utils/idempotency.d.ts +29 -0
  43. package/dist/utils/idempotency.d.ts.map +1 -0
  44. package/dist/utils/idempotency.js +62 -0
  45. package/dist/webhooks/report-error.d.ts +7 -0
  46. package/dist/webhooks/report-error.d.ts.map +1 -0
  47. package/dist/webhooks/report-error.js +15 -0
  48. package/dist/webhooks/webhook.dispatcher.d.ts +15 -2
  49. package/dist/webhooks/webhook.dispatcher.d.ts.map +1 -1
  50. package/dist/webhooks/webhook.dispatcher.js +52 -9
  51. package/dist/webhooks/webhook.handler.d.ts +20 -1
  52. package/dist/webhooks/webhook.handler.d.ts.map +1 -1
  53. package/dist/webhooks/webhook.handler.js +94 -18
  54. package/package.json +5 -4
  55. package/dist/tests/helpers.d.ts +0 -5
  56. package/dist/tests/helpers.d.ts.map +0 -1
  57. package/dist/tests/helpers.js +0 -96
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvoiceService = void 0;
4
+ const http_error_1 = require("./../../errors/http-error");
5
+ const idempotency_1 = require("./../../utils/idempotency");
6
+ // The invoices Stripe still takes a payment on. Uncollectible is one of them: only a void invoice is refused.
7
+ const UNPAID_INVOICE_STATUSES = ['open', 'uncollectible'];
8
+ // Stripe's code when an invoice's payment waits for the customer's bank check (3D Secure).
9
+ const REQUIRES_ACTION_CODE = 'invoice_payment_intent_requires_action';
4
10
  class InvoiceService {
5
11
  constructor(stripe, config) {
6
12
  this.stripe = stripe;
@@ -8,23 +14,98 @@ class InvoiceService {
8
14
  }
9
15
  /**
10
16
  * Creates, finalizes, and delivers a standalone invoice for a customer.
11
- * Sends the invoice by email if invoiceCollectionMethod is 'send_invoice', otherwise finalizes it for auto-charge.
17
+ * Sends the invoice by email if invoiceCollectionMethod is 'send_invoice'. Otherwise it is finalized with automatic
18
+ * collection on, and Stripe charges the customer's default card about an hour later.
12
19
  */
13
- async createInvoice(params) {
20
+ async createInvoice(params, idempotency) {
14
21
  const { customerId, amount, description } = params;
15
- const invoice = await this.stripe.invoices.create({
22
+ const isSent = this.config.invoiceCollectionMethod === 'send_invoice';
23
+ const invoice = await (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.Invoice, (...requestOptions) => this.stripe.invoices.create({
16
24
  customer: customerId,
17
25
  collection_method: this.config.invoiceCollectionMethod,
18
- days_until_due: this.config.invoiceDaysUntilDue,
26
+ // Stripe refuses a due date on an invoice it charges itself.
27
+ ...(isSent ? { days_until_due: this.config.invoiceDaysUntilDue } : {}),
19
28
  pending_invoice_items_behavior: 'exclude',
20
29
  metadata: params.metadata,
21
30
  ...(params.transferData ? { transfer_data: params.transferData } : {}),
22
- });
23
- await this.stripe.invoiceItems.create({ customer: customerId, invoice: invoice.id, amount, currency: this.config.currency, description });
24
- if (this.config.invoiceCollectionMethod === 'send_invoice') {
25
- return this.stripe.invoices.sendInvoice(invoice.id);
31
+ }, ...requestOptions));
32
+ await (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.InvoiceLine, (...requestOptions) => this.stripe.invoiceItems.create({ customer: customerId, invoice: invoice.id, amount, currency: this.config.currency, description }, ...requestOptions));
33
+ if (isSent) {
34
+ return (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.InvoiceSend, (...requestOptions) => this.stripe.invoices.sendInvoice(invoice.id, ...requestOptions));
35
+ }
36
+ // Without automatic collection a finalized invoice stays open and is never charged.
37
+ return (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.InvoiceFinalize, (...requestOptions) => this.stripe.invoices.finalizeInvoice(invoice.id, { auto_advance: true }, ...requestOptions));
38
+ }
39
+ /**
40
+ * Voids the invoices an ended subscription left unpaid, so nobody pays for a plan that is over. Stripe keeps
41
+ * them payable after a cancel. Only a canceled subscription is touched: voiding a live subscription's latest
42
+ * invoice changes the subscription's status. An invoice paid or voided in the meantime is left as it is, so a
43
+ * second call changes nothing. Returns how many invoices this call voided.
44
+ */
45
+ async voidUnpaidInvoices(subscription) {
46
+ if (subscription.status !== 'canceled') {
47
+ return 0;
48
+ }
49
+ let voided = 0;
50
+ for (const status of UNPAID_INVOICE_STATUSES) {
51
+ const invoices = await this.stripe.invoices.list({ subscription: subscription.id, status, limit: 100 }).autoPagingToArray({ limit: 1000 });
52
+ for (const { id } of invoices) {
53
+ if (!id) {
54
+ continue;
55
+ }
56
+ const isVoided = await this.stripe.invoices.voidInvoice(id)
57
+ .then(() => true)
58
+ .catch(async (err) => {
59
+ const after = await this.stripe.invoices.retrieve(id).catch(() => null);
60
+ if (after?.status === 'void' || after?.status === 'paid') {
61
+ return false;
62
+ }
63
+ throw err;
64
+ });
65
+ voided += isVoided ? 1 : 0;
66
+ }
67
+ }
68
+ return voided;
69
+ }
70
+ /**
71
+ * Charges a past due subscription's latest invoice now, with the card the subscription charges. Call it once the
72
+ * customer has saved a new card: Stripe's retries keep their own schedule after a card change. Returns the invoice
73
+ * once it is paid, also when a retry paid it meanwhile (the subscription then reads active), and null when there is
74
+ * nothing to pay (a draft or a void invoice, or an active subscription's open one, is never charged here). Throws 402
75
+ * with the card's reason when the charge is declined, after which Stripe keeps retrying as before, or when it waits
76
+ * for the bank's check, which the customer then confirms on the invoice's page (findConfirmPaymentUrl).
77
+ */
78
+ async payPastDueInvoice(subscription, idempotency) {
79
+ const latestInvoice = subscription.latest_invoice;
80
+ const invoiceId = typeof latestInvoice === 'string' ? latestInvoice : latestInvoice?.id;
81
+ if (!invoiceId || !['past_due', 'active'].includes(subscription.status)) {
82
+ return null;
26
83
  }
27
- return this.stripe.invoices.finalizeInvoice(invoice.id);
84
+ const invoice = await this.stripe.invoices.retrieve(invoiceId);
85
+ if (!InvoiceService.isPayable(invoice)) {
86
+ return invoice.status === 'paid' ? invoice : null;
87
+ }
88
+ if (subscription.status !== 'past_due') {
89
+ return null;
90
+ }
91
+ return (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.InvoicePay, (...requestOptions) => this.stripe.invoices.pay(invoiceId, ...requestOptions))
92
+ .catch(async (err) => {
93
+ const after = await this.stripe.invoices.retrieve(invoiceId).catch(() => null);
94
+ if (after && !InvoiceService.isPayable(after)) {
95
+ return after.status === 'paid' ? after : null;
96
+ }
97
+ if (err?.code === REQUIRES_ACTION_CODE) {
98
+ throw new http_error_1.HttpError(402, 'Your bank needs you to confirm this payment.');
99
+ }
100
+ if (err?.type === 'StripeCardError') {
101
+ throw new http_error_1.HttpError(402, err.message || 'The payment did not go through.');
102
+ }
103
+ throw err;
104
+ });
105
+ }
106
+ // Open and uncollectible invoices still take a payment; a draft is not charged before Stripe finalizes it.
107
+ static isPayable(invoice) {
108
+ return UNPAID_INVOICE_STATUSES.includes(invoice.status ?? '');
28
109
  }
29
110
  /**
30
111
  * Lists payment attempts for an invoice.
@@ -41,9 +122,9 @@ class InvoiceService {
41
122
  const invoices = await this.stripe.invoices.list({
42
123
  customer: customerId,
43
124
  status: 'open',
44
- limit: 10,
45
- });
46
- const invoice = invoices.data.find(i => i.billing_reason === 'subscription_create');
125
+ limit: 100,
126
+ }).autoPagingToArray({ limit: 1000 });
127
+ const invoice = invoices.find(i => i.billing_reason === 'subscription_create');
47
128
  if (!invoice) {
48
129
  return null;
49
130
  }
@@ -61,5 +142,20 @@ class InvoiceService {
61
142
  hostedInvoiceUrl: invoice.hosted_invoice_url ?? null,
62
143
  };
63
144
  }
145
+ /**
146
+ * Returns Stripe's page for a past due subscription's latest invoice when its payment waits for the customer's bank
147
+ * check (3D Secure), or null. Stripe never retries such a payment, so only the customer's confirmation on that page
148
+ * pays it. A declined card or any other failure gives null.
149
+ */
150
+ async findConfirmPaymentUrl(subscription) {
151
+ const latestInvoice = subscription.latest_invoice;
152
+ const invoiceId = typeof latestInvoice === 'string' ? latestInvoice : latestInvoice?.id;
153
+ if (subscription.status !== 'past_due' || !invoiceId) {
154
+ return null;
155
+ }
156
+ const invoice = await this.stripe.invoices.retrieve(invoiceId, { expand: ['payments.data.payment.payment_intent'] });
157
+ const needsBank = invoice.payments?.data.some(({ payment }) => typeof payment.payment_intent !== 'string' && payment.payment_intent?.status === 'requires_action');
158
+ return invoice.status === 'open' && needsBank ? invoice.hosted_invoice_url ?? null : null;
159
+ }
64
160
  }
65
161
  exports.InvoiceService = InvoiceService;
@@ -1,6 +1,6 @@
1
1
  import Stripe from 'stripe';
2
2
  import { StripeServiceConfig } from './../../models/config.model';
3
- import { CreatePaymentLinkParams, PaymentLinkResult } from './../../models/stripe.model';
3
+ import { CreatePaymentLinkParams, IdempotencyOptions, PaymentLinkResult } from './../../models/stripe.model';
4
4
  export declare class PaymentLinkService {
5
5
  private readonly stripe;
6
6
  private readonly config;
@@ -9,7 +9,7 @@ export declare class PaymentLinkService {
9
9
  * Creates a one-time payment link with an inline price and returns its ID, URL,
10
10
  * and the associated product and price IDs.
11
11
  */
12
- createPaymentLink(params: CreatePaymentLinkParams): Promise<PaymentLinkResult>;
12
+ createPaymentLink(params: CreatePaymentLinkParams, idempotency?: IdempotencyOptions): Promise<PaymentLinkResult>;
13
13
  /**
14
14
  * Deactivates a payment link and archives its associated product and price.
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"payment-link.service.d.ts","sourceRoot":"","sources":["../../../src/services/payment-link/payment-link.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEzF,qBAAa,kBAAkB;IAG3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAExD;;;OAGG;IACU,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqC3F;;OAEG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMnG"}
1
+ {"version":3,"file":"payment-link.service.d.ts","sourceRoot":"","sources":["../../../src/services/payment-link/payment-link.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE7G,qBAAa,kBAAkB;IAG3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAExD;;;OAGG;IACU,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,EAAE,WAAW,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqC7H;;OAEG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMnG"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentLinkService = void 0;
4
+ const idempotency_1 = require("./../../utils/idempotency");
4
5
  class PaymentLinkService {
5
6
  constructor(stripe, config) {
6
7
  this.stripe = stripe;
@@ -10,13 +11,13 @@ class PaymentLinkService {
10
11
  * Creates a one-time payment link with an inline price and returns its ID, URL,
11
12
  * and the associated product and price IDs.
12
13
  */
13
- async createPaymentLink(params) {
14
+ async createPaymentLink(params, idempotency) {
14
15
  const { name, cost, redirectUrl, affiliate } = params;
15
- const price = await this.stripe.prices.create({
16
+ const price = await (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.PaymentLinkPrice, (...requestOptions) => this.stripe.prices.create({
16
17
  currency: this.config.currency,
17
18
  unit_amount: cost,
18
19
  product_data: { name },
19
- });
20
+ }, ...requestOptions));
20
21
  const linkParams = {
21
22
  line_items: [{ price: price.id, quantity: 1 }],
22
23
  after_completion: {
@@ -33,7 +34,7 @@ class PaymentLinkService {
33
34
  if (affiliate) {
34
35
  linkParams.transfer_data = { destination: affiliate.accountId, amount: affiliate.amount };
35
36
  }
36
- const link = await this.stripe.paymentLinks.create(linkParams);
37
+ const link = await (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.PaymentLink, (...requestOptions) => this.stripe.paymentLinks.create(linkParams, ...requestOptions));
37
38
  return {
38
39
  id: link.id,
39
40
  url: link.url,
@@ -7,7 +7,7 @@ export declare class PaymentMethodService {
7
7
  */
8
8
  getPaymentMethod(paymentMethodId: string): Promise<Stripe.PaymentMethod>;
9
9
  /**
10
- * Lists all payment methods attached to a customer.
10
+ * Lists all payment methods attached to a customer, reading every page Stripe returns.
11
11
  */
12
12
  listPaymentMethods(customerId: string): Promise<Stripe.PaymentMethod[]>;
13
13
  /**
@@ -21,9 +21,9 @@ export declare class PaymentMethodService {
21
21
  setDefaultPaymentMethodForCustomerAndSubscription(customerId: string, subscriptionId: string, paymentMethodId: string): Promise<void>;
22
22
  /**
23
23
  * Removes a payment method from a customer and subscription.
24
- * If it is the subscription's default, a different one is assigned first.
25
- * Throws if it is the only payment method on the customer.
26
- * Returns the new default payment method ID if the default was reassigned, otherwise null.
24
+ * If it is the subscription's default or the customer's default, another card on file takes its place first.
25
+ * Throws 404 if the payment method is not attached to this customer, and 400 if it is the only one.
26
+ * Returns the subscription's new default payment method ID if it was reassigned, otherwise null.
27
27
  */
28
28
  removePaymentMethod(customerId: string, subscriptionId: string, paymentMethodId: string): Promise<{
29
29
  newDefaultId: string | null;
@@ -39,5 +39,6 @@ export declare class PaymentMethodService {
39
39
  setDefaultPaymentMethodIfMissing(subscriptionId: string, paymentMethodId: string): Promise<{
40
40
  changed: boolean;
41
41
  }>;
42
+ private static customerDefaultOf;
42
43
  }
43
44
  //# sourceMappingURL=payment-method.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payment-method.service.d.ts","sourceRoot":"","sources":["../../../src/services/payment-method/payment-method.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,qBAAa,oBAAoB;IAG7B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAEjC;;OAEG;IACU,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;IAIrF;;OAEG;IACU,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAMpF;;OAEG;IACU,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;IAI5G;;;OAGG;IACU,iDAAiD,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlJ;;;;;OAKG;IACU,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IA4B/I;;OAEG;IACU,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpG;;;OAGG;IACU,gCAAgC,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAgB9H"}
1
+ {"version":3,"file":"payment-method.service.d.ts","sourceRoot":"","sources":["../../../src/services/payment-method/payment-method.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAK5B,qBAAa,oBAAoB;IAG7B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAEjC;;OAEG;IACU,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;IAIrF;;OAEG;IACU,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IAIpF;;OAEG;IACU,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC;IAI5G;;;OAGG;IACU,iDAAiD,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlJ;;;;;OAKG;IACU,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAsD/I;;OAEG;IACU,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpG;;;OAGG;IACU,gCAAgC,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAgB7H,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAMjC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentMethodService = void 0;
4
4
  const http_error_1 = require("./../../errors/http-error");
5
+ const stripe_error_status_1 = require("./../../errors/stripe-error-status");
5
6
  class PaymentMethodService {
6
7
  constructor(stripe) {
7
8
  this.stripe = stripe;
@@ -13,11 +14,10 @@ class PaymentMethodService {
13
14
  return this.stripe.paymentMethods.retrieve(paymentMethodId);
14
15
  }
15
16
  /**
16
- * Lists all payment methods attached to a customer.
17
+ * Lists all payment methods attached to a customer, reading every page Stripe returns.
17
18
  */
18
19
  async listPaymentMethods(customerId) {
19
- const result = await this.stripe.paymentMethods.list({ customer: customerId });
20
- return result.data;
20
+ return this.stripe.paymentMethods.list({ customer: customerId, limit: 100 }).autoPagingToArray({ limit: 1000 });
21
21
  }
22
22
  /**
23
23
  * Attaches a payment method to a customer.
@@ -38,25 +38,47 @@ class PaymentMethodService {
38
38
  }
39
39
  /**
40
40
  * Removes a payment method from a customer and subscription.
41
- * If it is the subscription's default, a different one is assigned first.
42
- * Throws if it is the only payment method on the customer.
43
- * Returns the new default payment method ID if the default was reassigned, otherwise null.
41
+ * If it is the subscription's default or the customer's default, another card on file takes its place first.
42
+ * Throws 404 if the payment method is not attached to this customer, and 400 if it is the only one.
43
+ * Returns the subscription's new default payment method ID if it was reassigned, otherwise null.
44
44
  */
45
45
  async removePaymentMethod(customerId, subscriptionId, paymentMethodId) {
46
+ // Stripe detaches any card by id, whoever it belongs to, so the owner is checked here. An id Stripe does not know
47
+ // has no owner, so it is not found either.
48
+ const paymentMethod = await this.stripe.paymentMethods.retrieve(paymentMethodId, { expand: ['customer'] })
49
+ .catch(err => {
50
+ if ((0, stripe_error_status_1.isResourceMissing)(err)) {
51
+ return null;
52
+ }
53
+ throw err;
54
+ });
55
+ const owner = paymentMethod?.customer ?? null;
56
+ const ownerId = typeof owner === 'string' ? owner : owner?.id;
57
+ if (ownerId !== customerId) {
58
+ throw new http_error_1.HttpError(404, `Payment method ${paymentMethodId} was not found on this customer.`);
59
+ }
46
60
  const paymentMethods = await this.stripe.paymentMethods.list({ customer: customerId });
47
61
  if (paymentMethods.data.length <= 1) {
48
62
  throw new http_error_1.HttpError(400, 'Cannot remove the only payment method. Add another payment method first.');
49
63
  }
50
64
  const subscription = await this.stripe.subscriptions.retrieve(subscriptionId);
51
65
  const isDefault = subscription.default_payment_method === paymentMethodId;
66
+ const isCustomerDefault = PaymentMethodService.customerDefaultOf(owner) === paymentMethodId;
52
67
  let newDefaultId = null;
53
- if (isDefault) {
68
+ if (isDefault || isCustomerDefault) {
54
69
  const alternate = paymentMethods.data.find(pm => pm.id !== paymentMethodId);
55
70
  if (!alternate) {
56
71
  throw new http_error_1.HttpError(400, 'Cannot remove the only payment method. Add another payment method first.');
57
72
  }
58
- await this.stripe.subscriptions.update(subscriptionId, { default_payment_method: alternate.id });
59
- newDefaultId = alternate.id;
73
+ // Detaching the customer's default leaves the customer with none, and a plan with no default of its own then
74
+ // has no card to charge.
75
+ if (isCustomerDefault) {
76
+ await this.stripe.customers.update(customerId, { invoice_settings: { default_payment_method: alternate.id } });
77
+ }
78
+ if (isDefault) {
79
+ await this.stripe.subscriptions.update(subscriptionId, { default_payment_method: alternate.id });
80
+ newDefaultId = alternate.id;
81
+ }
60
82
  }
61
83
  await this.stripe.paymentMethods.detach(paymentMethodId);
62
84
  return { newDefaultId };
@@ -85,5 +107,9 @@ class PaymentMethodService {
85
107
  });
86
108
  return { changed: true };
87
109
  }
110
+ static customerDefaultOf(customer) {
111
+ const value = typeof customer === 'string' ? null : customer?.invoice_settings?.default_payment_method;
112
+ return typeof value === 'string' ? value : value?.id ?? null;
113
+ }
88
114
  }
89
115
  exports.PaymentMethodService = PaymentMethodService;
@@ -1,6 +1,6 @@
1
1
  import Stripe from 'stripe';
2
2
  import { StripeServiceConfig } from './../../models/config.model';
3
- import { CreateCustomPriceParams } from './../../models/stripe.model';
3
+ import { CreateCustomPriceParams, IdempotencyOptions } from './../../models/stripe.model';
4
4
  export declare class PriceService {
5
5
  private readonly stripe;
6
6
  private readonly config;
@@ -8,7 +8,7 @@ export declare class PriceService {
8
8
  /**
9
9
  * Creates a recurring subscription price attached to an existing Stripe product.
10
10
  */
11
- createCustomSubscriptionPrice(params: CreateCustomPriceParams): Promise<Stripe.Price>;
11
+ createCustomSubscriptionPrice(params: CreateCustomPriceParams, idempotency?: IdempotencyOptions): Promise<Stripe.Price>;
12
12
  /**
13
13
  * Archives a price so it can no longer be used for new subscriptions.
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"price.service.d.ts","sourceRoot":"","sources":["../../../src/services/price/price.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,qBAAa,YAAY;IAGrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAExD;;OAEG;IACU,6BAA6B,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAclG;;OAEG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAI1D"}
1
+ {"version":3,"file":"price.service.d.ts","sourceRoot":"","sources":["../../../src/services/price/price.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAE1F,qBAAa,YAAY;IAGrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAExD;;OAEG;IACU,6BAA6B,CAAC,MAAM,EAAE,uBAAuB,EAAE,WAAW,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IAcpI;;OAEG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAI1D"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PriceService = void 0;
4
+ const idempotency_1 = require("./../../utils/idempotency");
4
5
  class PriceService {
5
6
  constructor(stripe, config) {
6
7
  this.stripe = stripe;
@@ -9,8 +10,8 @@ class PriceService {
9
10
  /**
10
11
  * Creates a recurring subscription price attached to an existing Stripe product.
11
12
  */
12
- async createCustomSubscriptionPrice(params) {
13
- return this.stripe.prices.create({
13
+ async createCustomSubscriptionPrice(params, idempotency) {
14
+ return (0, idempotency_1.withIdempotencyKey)(idempotency, idempotency_1.IdempotencyStep.Price, (...requestOptions) => this.stripe.prices.create({
14
15
  unit_amount: params.cost,
15
16
  currency: this.config.currency,
16
17
  recurring: {
@@ -20,7 +21,7 @@ class PriceService {
20
21
  nickname: params.label,
21
22
  product: params.stripeProductId,
22
23
  metadata: params.metadata,
23
- });
24
+ }, ...requestOptions));
24
25
  }
25
26
  /**
26
27
  * Archives a price so it can no longer be used for new subscriptions.
@@ -1,6 +1,6 @@
1
1
  import Stripe from 'stripe';
2
2
  import { StripeServiceConfig } from './../../models/config.model';
3
- import { SubscriptionSyncFields } from './../../models/stripe.model';
3
+ import { IdempotencyOptions, SubscriptionSyncFields, SubscriptionDiscount } from './../../models/stripe.model';
4
4
  import { ScheduleDowngradeOptions, SwitchSubscriptionPlanOptions, CreateInvoiceSubscriptionOptions, CreateInvoiceSubscriptionResult } from './../../models/subscription.model';
5
5
  export declare class SubscriptionService {
6
6
  private readonly stripe;
@@ -8,31 +8,42 @@ export declare class SubscriptionService {
8
8
  constructor(stripe: Stripe, config: Required<StripeServiceConfig>);
9
9
  private static readonly phaseTypeNew;
10
10
  private static readonly phaseTypeDowngrade;
11
+ private static readonly runningStatuses;
12
+ private static readonly holdingScheduleStatuses;
13
+ private static readonly discountExpands;
11
14
  /**
12
15
  * Retrieves a subscription with its price items expanded.
13
16
  */
14
17
  getSubscriptionById(subscriptionId: string): Promise<Stripe.Subscription>;
15
18
  /**
16
- * Lists all subscriptions for a customer across all statuses.
19
+ * Retrieves a subscription with its discounts and the promotion codes behind them expanded, the form
20
+ * getSubscriptionDiscount reads. expand adds other fields to expand, each once (e.g. ['latest_invoice']); none by
21
+ * default. A Stripe error, such as no such subscription, is thrown as it is.
22
+ */
23
+ getSubscriptionWithDiscounts(subscriptionId: string, expand?: string[]): Promise<Stripe.Subscription>;
24
+ /**
25
+ * Lists all subscriptions for a customer across all statuses, reading every page Stripe returns.
17
26
  * Returns an empty array if no customerId is provided.
18
27
  */
19
28
  getAllUserSubscriptions(customerId: string): Promise<Stripe.Subscription[]>;
20
29
  /**
21
30
  * Updates a subscription with arbitrary Stripe params.
22
31
  */
23
- updateSubscription(subscriptionId: string, params: Stripe.SubscriptionUpdateParams): Promise<Stripe.Subscription>;
32
+ updateSubscription(subscriptionId: string, params: Stripe.SubscriptionUpdateParams, idempotency?: IdempotencyOptions): Promise<Stripe.Subscription>;
24
33
  /**
25
34
  * Immediately cancels a subscription.
26
35
  */
27
36
  cancelSubscription(subscriptionId: string): Promise<Stripe.Subscription>;
28
37
  /**
29
- * Schedules a subscription to cancel at the end of the current billing period.
30
- * Throws if the subscription is not active or past_due.
38
+ * Schedules a subscription to cancel at the end of the current billing period, which for a trial is the trial's end.
39
+ * A schedule attached to it, such as a booked downgrade, is released first, since Stripe refuses the cancel while
40
+ * one is attached. Throws if the subscription is not active, past_due or trialing.
31
41
  */
32
42
  cancelSubscriptionAtPeriodEnd(subscriptionId: string): Promise<Stripe.Subscription>;
33
43
  /**
34
- * Resumes a subscription that has cancel_at_period_end set.
35
- * Throws if cancel_at_period_end is false or the subscription is not active or past_due.
44
+ * Resumes a subscription that has cancel_at_period_end set, or whose attached schedule ends it. That schedule is
45
+ * released first, since Stripe refuses the change while one is attached.
46
+ * Throws if neither is the case or the subscription is not active, past_due or trialing.
36
47
  */
37
48
  resumeSubscription(subscriptionId: string): Promise<Stripe.Subscription>;
38
49
  /**
@@ -60,20 +71,28 @@ export declare class SubscriptionService {
60
71
  * Pass a positive amount — it is stored as negative automatically.
61
72
  * Call this before switchSubscriptionPlan when managing billing credits manually.
62
73
  */
63
- applyPlanCredit(customerId: string, subscriptionId: string, amount: number, currency: string, description?: string, metadata?: Record<string, string>): Promise<void>;
74
+ applyPlanCredit(customerId: string, subscriptionId: string, amount: number, currency: string, description?: string, metadata?: Record<string, string>, idempotency?: IdempotencyOptions): Promise<void>;
64
75
  /**
65
76
  * Switches a subscription to a new price immediately, resetting the billing cycle anchor to now.
66
77
  * Defaults to proration_behavior: 'none' — pair with applyPlanCredit for manual credits,
67
78
  * or pass proration: 'create_prorations' to let Stripe calculate what's owed.
79
+ * Throws 402 with the decline reason when the charge fails; the subscription then stays on its old price
80
+ * and the switch's bill is voided.
81
+ * A schedule attached to the subscription, such as a booked downgrade, is released once the switch has gone through,
82
+ * so it cannot move the plan back when the current phase ends. A declined or refused switch leaves it attached.
83
+ * If that release fails, it throws although the plan has switched and been charged. Repeat with the same key to
84
+ * finish the release; a repeat without a key switches and charges again.
68
85
  */
69
- switchSubscriptionPlan(subscriptionId: string, itemId: string, newPriceId: string, options?: SwitchSubscriptionPlanOptions): Promise<Stripe.Subscription>;
86
+ switchSubscriptionPlan(subscriptionId: string, itemId: string, newPriceId: string, options?: SwitchSubscriptionPlanOptions, idempotency?: IdempotencyOptions): Promise<Stripe.Subscription>;
70
87
  /**
71
- * Creates a subscription with send_invoice collection and immediately emails the invoice.
88
+ * Creates a subscription with send_invoice collection, finalizes its first invoice and emails it at once, and
89
+ * answers that invoice with its payment link.
72
90
  */
73
- createInvoiceBasedSubscription(customerId: string, priceId: string, options?: CreateInvoiceSubscriptionOptions): Promise<CreateInvoiceSubscriptionResult>;
91
+ createInvoiceBasedSubscription(customerId: string, priceId: string, options?: CreateInvoiceSubscriptionOptions, idempotency?: IdempotencyOptions): Promise<CreateInvoiceSubscriptionResult>;
74
92
  /**
75
93
  * Extracts the fields needed to keep a local subscription document in sync with Stripe.
76
- * Falls back to the provided values if the subscription has no items.
94
+ * Falls back to the provided values if the subscription has no items. An end date picked in the dashboard, which
95
+ * can fall after the period's end, shows in cancelAt and isEnding; cancelAtPeriodEnd stays Stripe's own flag.
77
96
  */
78
97
  buildSubscriptionSyncFields(subscription: Stripe.Subscription, fallback?: {
79
98
  currentPeriodStart?: Date | null;
@@ -84,6 +103,54 @@ export declare class SubscriptionService {
84
103
  * Returns the primary subscription item, preferring the one matching preferredItemId if provided.
85
104
  */
86
105
  getPrimarySubscriptionItem(subscription: Stripe.Subscription, preferredItemId?: string): Stripe.SubscriptionItem | null;
106
+ /**
107
+ * Returns the discount a subscription carries (its promotion code, coupon name, percent or amount off and end), or
108
+ * null without one. Pass a subscription from getSubscriptionWithDiscounts: discounts that are only ids are skipped,
109
+ * and of several the first expanded one is read, as a checkout takes one code. Reads the basil Discount.coupon.
110
+ */
111
+ getSubscriptionDiscount(subscription: Stripe.Subscription): SubscriptionDiscount | null;
112
+ /**
113
+ * Returns what a charge of cost (in cents) on chargedAt comes to with the discount off: the percent's cut rounded
114
+ * to the cent, or the amount off, never below 0. A null discount, or one that ends on or before chargedAt, returns
115
+ * cost as it is; a chargedAt of null keeps the discount.
116
+ */
117
+ getCostWithDiscount(cost: number, discount: SubscriptionDiscount | null, chargedAt: Date | null): number;
87
118
  private buildDowngradePhases;
119
+ /**
120
+ * Releases the schedule attached to a subscription, if any: the plan stays on its current price and the schedule's
121
+ * later phases are dropped. A schedule that another call released or that ended meanwhile is passed over.
122
+ */
123
+ private releaseAttachedSchedule;
124
+ /**
125
+ * Voids a declined switch's bill, which also drops the pending update, and returns the decline reason.
126
+ * A failed void is left alone: the decline is still the answer, and the pending update expires by itself.
127
+ */
128
+ private discardSwitchInvoice;
129
+ /**
130
+ * A repeat with the first call's key comes after that call's void, which cancels the payment and clears its error.
131
+ * The declined charge still holds the reason.
132
+ */
133
+ private chargeDeclineReason;
134
+ /**
135
+ * Answers the invoice when its finalize failed but it is final already: Stripe finalizes and emails a draft itself
136
+ * about an hour after the plan is made, so a late repeat gets here. A draft, or one that cannot be read, throws err.
137
+ */
138
+ private invoiceFinalizedMeanwhile;
139
+ /**
140
+ * Sends the running phase back as Stripe holds it. A schedule update replaces every phase, and whatever the
141
+ * phase leaves out is dropped from the subscription at once: its discount, its free trial (ended and charged),
142
+ * its own card, its affiliate payout. Fields left null inherit the schedule's default_settings, as before.
143
+ */
144
+ private buildCurrentPhase;
145
+ private static buildPhaseItem;
146
+ /**
147
+ * Maps the discounts Stripe reports on a phase to the form an update takes, one of discount, promotion code or
148
+ * coupon each. A coupon that a live discount carries is sent as that discount, so it runs on with its own end
149
+ * date; each live discount is used once, taken out of liveDiscounts as it is matched. A discount id that is no
150
+ * longer live has ended or been removed, and Stripe refuses any phase that still holds it, so it is left out.
151
+ */
152
+ private static toDiscountParams;
153
+ private static liveDiscountsOf;
154
+ private static idOf;
88
155
  }
89
156
  //# sourceMappingURL=subscription.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.service.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/subscription.service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B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