@wopr-network/platform-core 1.44.1 → 1.45.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.
@@ -124,4 +124,6 @@ export interface Invoice {
124
124
  status: string;
125
125
  /** URL to download the invoice PDF. Empty string if unavailable. */
126
126
  downloadUrl: string;
127
+ /** URL to the hosted invoice page. Empty string if unavailable. */
128
+ hostedUrl: string;
127
129
  }
@@ -137,6 +137,7 @@ export class StripePaymentProcessor {
137
137
  amountCents: inv.amount_due,
138
138
  status: inv.status ?? "unknown",
139
139
  downloadUrl: inv.invoice_pdf ?? "",
140
+ hostedUrl: inv.hosted_invoice_url ?? "",
140
141
  }));
141
142
  }
142
143
  async charge(opts) {
@@ -210,6 +210,7 @@ describe("StripePaymentProcessor", () => {
210
210
  amount_due: 500,
211
211
  status: "paid",
212
212
  invoice_pdf: "https://stripe.com/invoice.pdf",
213
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_1",
213
214
  },
214
215
  {
215
216
  id: "in_2",
@@ -217,6 +218,7 @@ describe("StripePaymentProcessor", () => {
217
218
  amount_due: 1000,
218
219
  status: "open",
219
220
  invoice_pdf: null,
221
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_2",
220
222
  },
221
223
  ],
222
224
  });
@@ -228,6 +230,7 @@ describe("StripePaymentProcessor", () => {
228
230
  amountCents: 500,
229
231
  status: "paid",
230
232
  downloadUrl: "https://stripe.com/invoice.pdf",
233
+ hostedUrl: "https://invoice.stripe.com/i/in_1",
231
234
  },
232
235
  {
233
236
  id: "in_2",
@@ -235,6 +238,7 @@ describe("StripePaymentProcessor", () => {
235
238
  amountCents: 1000,
236
239
  status: "open",
237
240
  downloadUrl: "",
241
+ hostedUrl: "https://invoice.stripe.com/i/in_2",
238
242
  },
239
243
  ]);
240
244
  expect(mocks.stripe.invoices.list).toHaveBeenCalledWith({
@@ -245,10 +249,20 @@ describe("StripePaymentProcessor", () => {
245
249
  it("uses 'unknown' when invoice status is null", async () => {
246
250
  vi.mocked(mocks.tenantRepo.getByTenant).mockResolvedValue(makeTenantRow());
247
251
  vi.mocked(mocks.stripe.invoices.list).mockResolvedValue({
248
- data: [{ id: "in_3", created: 1700000000, amount_due: 100, status: null, invoice_pdf: null }],
252
+ data: [
253
+ {
254
+ id: "in_3",
255
+ created: 1700000000,
256
+ amount_due: 100,
257
+ status: null,
258
+ invoice_pdf: null,
259
+ hosted_invoice_url: null,
260
+ },
261
+ ],
249
262
  });
250
263
  const result = await processor.listInvoices("tenant-1");
251
264
  expect(result[0].status).toBe("unknown");
265
+ expect(result[0].hostedUrl).toBe("");
252
266
  });
253
267
  });
254
268
  // --- charge ---
@@ -140,6 +140,7 @@ export class StripePaymentProcessor {
140
140
  amountCents: inv.amount_due,
141
141
  status: inv.status ?? "unknown",
142
142
  downloadUrl: inv.invoice_pdf ?? "",
143
+ hostedUrl: inv.hosted_invoice_url ?? "",
143
144
  }));
144
145
  }
145
146
  async charge(opts) {
@@ -216,6 +216,7 @@ describe("StripePaymentProcessor", () => {
216
216
  amount_due: 500,
217
217
  status: "paid",
218
218
  invoice_pdf: "https://stripe.com/invoice.pdf",
219
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_1",
219
220
  },
220
221
  {
221
222
  id: "in_2",
@@ -223,6 +224,7 @@ describe("StripePaymentProcessor", () => {
223
224
  amount_due: 1000,
224
225
  status: "open",
225
226
  invoice_pdf: null,
227
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_2",
226
228
  },
227
229
  ],
228
230
  });
@@ -234,6 +236,7 @@ describe("StripePaymentProcessor", () => {
234
236
  amountCents: 500,
235
237
  status: "paid",
236
238
  downloadUrl: "https://stripe.com/invoice.pdf",
239
+ hostedUrl: "https://invoice.stripe.com/i/in_1",
237
240
  },
238
241
  {
239
242
  id: "in_2",
@@ -241,6 +244,7 @@ describe("StripePaymentProcessor", () => {
241
244
  amountCents: 1000,
242
245
  status: "open",
243
246
  downloadUrl: "",
247
+ hostedUrl: "https://invoice.stripe.com/i/in_2",
244
248
  },
245
249
  ]);
246
250
  expect(mocks.stripe.invoices.list).toHaveBeenCalledWith({
@@ -251,10 +255,20 @@ describe("StripePaymentProcessor", () => {
251
255
  it("uses 'unknown' when invoice status is null", async () => {
252
256
  vi.mocked(mocks.tenantRepo.getByTenant).mockResolvedValue(makeTenantRow());
253
257
  vi.mocked(mocks.stripe.invoices.list).mockResolvedValue({
254
- data: [{ id: "in_3", created: 1700000000, amount_due: 100, status: null, invoice_pdf: null }],
258
+ data: [
259
+ {
260
+ id: "in_3",
261
+ created: 1700000000,
262
+ amount_due: 100,
263
+ status: null,
264
+ invoice_pdf: null,
265
+ hosted_invoice_url: null,
266
+ },
267
+ ],
255
268
  });
256
269
  const result = await processor.listInvoices("tenant-1");
257
270
  expect(result[0].status).toBe("unknown");
271
+ expect(result[0].hostedUrl).toBe("");
258
272
  });
259
273
  });
260
274
  // --- charge ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopr-network/platform-core",
3
- "version": "1.44.1",
3
+ "version": "1.45.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -147,4 +147,6 @@ export interface Invoice {
147
147
  status: string;
148
148
  /** URL to download the invoice PDF. Empty string if unavailable. */
149
149
  downloadUrl: string;
150
+ /** URL to the hosted invoice page. Empty string if unavailable. */
151
+ hostedUrl: string;
150
152
  }
@@ -263,6 +263,7 @@ describe("StripePaymentProcessor", () => {
263
263
  amount_due: 500,
264
264
  status: "paid",
265
265
  invoice_pdf: "https://stripe.com/invoice.pdf",
266
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_1",
266
267
  },
267
268
  {
268
269
  id: "in_2",
@@ -270,6 +271,7 @@ describe("StripePaymentProcessor", () => {
270
271
  amount_due: 1000,
271
272
  status: "open",
272
273
  invoice_pdf: null,
274
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_2",
273
275
  },
274
276
  ],
275
277
  } as unknown as Stripe.Response<Stripe.ApiList<Stripe.Invoice>>);
@@ -282,6 +284,7 @@ describe("StripePaymentProcessor", () => {
282
284
  amountCents: 500,
283
285
  status: "paid",
284
286
  downloadUrl: "https://stripe.com/invoice.pdf",
287
+ hostedUrl: "https://invoice.stripe.com/i/in_1",
285
288
  },
286
289
  {
287
290
  id: "in_2",
@@ -289,6 +292,7 @@ describe("StripePaymentProcessor", () => {
289
292
  amountCents: 1000,
290
293
  status: "open",
291
294
  downloadUrl: "",
295
+ hostedUrl: "https://invoice.stripe.com/i/in_2",
292
296
  },
293
297
  ]);
294
298
  expect(mocks.stripe.invoices.list).toHaveBeenCalledWith({
@@ -300,11 +304,21 @@ describe("StripePaymentProcessor", () => {
300
304
  it("uses 'unknown' when invoice status is null", async () => {
301
305
  vi.mocked(mocks.tenantRepo.getByTenant).mockResolvedValue(makeTenantRow());
302
306
  vi.mocked(mocks.stripe.invoices.list).mockResolvedValue({
303
- data: [{ id: "in_3", created: 1700000000, amount_due: 100, status: null, invoice_pdf: null }],
307
+ data: [
308
+ {
309
+ id: "in_3",
310
+ created: 1700000000,
311
+ amount_due: 100,
312
+ status: null,
313
+ invoice_pdf: null,
314
+ hosted_invoice_url: null,
315
+ },
316
+ ],
304
317
  } as unknown as Stripe.Response<Stripe.ApiList<Stripe.Invoice>>);
305
318
 
306
319
  const result = await processor.listInvoices("tenant-1");
307
320
  expect(result[0].status).toBe("unknown");
321
+ expect(result[0].hostedUrl).toBe("");
308
322
  });
309
323
  });
310
324
 
@@ -216,6 +216,7 @@ export class StripePaymentProcessor implements IPaymentProcessor {
216
216
  amountCents: inv.amount_due,
217
217
  status: inv.status ?? "unknown",
218
218
  downloadUrl: inv.invoice_pdf ?? "",
219
+ hostedUrl: inv.hosted_invoice_url ?? "",
219
220
  }));
220
221
  }
221
222
 
@@ -272,6 +272,7 @@ describe("StripePaymentProcessor", () => {
272
272
  amount_due: 500,
273
273
  status: "paid",
274
274
  invoice_pdf: "https://stripe.com/invoice.pdf",
275
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_1",
275
276
  },
276
277
  {
277
278
  id: "in_2",
@@ -279,6 +280,7 @@ describe("StripePaymentProcessor", () => {
279
280
  amount_due: 1000,
280
281
  status: "open",
281
282
  invoice_pdf: null,
283
+ hosted_invoice_url: "https://invoice.stripe.com/i/in_2",
282
284
  },
283
285
  ],
284
286
  } as unknown as Stripe.Response<Stripe.ApiList<Stripe.Invoice>>);
@@ -291,6 +293,7 @@ describe("StripePaymentProcessor", () => {
291
293
  amountCents: 500,
292
294
  status: "paid",
293
295
  downloadUrl: "https://stripe.com/invoice.pdf",
296
+ hostedUrl: "https://invoice.stripe.com/i/in_1",
294
297
  },
295
298
  {
296
299
  id: "in_2",
@@ -298,6 +301,7 @@ describe("StripePaymentProcessor", () => {
298
301
  amountCents: 1000,
299
302
  status: "open",
300
303
  downloadUrl: "",
304
+ hostedUrl: "https://invoice.stripe.com/i/in_2",
301
305
  },
302
306
  ]);
303
307
  expect(mocks.stripe.invoices.list).toHaveBeenCalledWith({
@@ -309,11 +313,21 @@ describe("StripePaymentProcessor", () => {
309
313
  it("uses 'unknown' when invoice status is null", async () => {
310
314
  vi.mocked(mocks.tenantRepo.getByTenant).mockResolvedValue(makeTenantRow());
311
315
  vi.mocked(mocks.stripe.invoices.list).mockResolvedValue({
312
- data: [{ id: "in_3", created: 1700000000, amount_due: 100, status: null, invoice_pdf: null }],
316
+ data: [
317
+ {
318
+ id: "in_3",
319
+ created: 1700000000,
320
+ amount_due: 100,
321
+ status: null,
322
+ invoice_pdf: null,
323
+ hosted_invoice_url: null,
324
+ },
325
+ ],
313
326
  } as unknown as Stripe.Response<Stripe.ApiList<Stripe.Invoice>>);
314
327
 
315
328
  const result = await processor.listInvoices("tenant-1");
316
329
  expect(result[0].status).toBe("unknown");
330
+ expect(result[0].hostedUrl).toBe("");
317
331
  });
318
332
  });
319
333
 
@@ -216,6 +216,7 @@ export class StripePaymentProcessor implements IPaymentProcessor {
216
216
  amountCents: inv.amount_due,
217
217
  status: inv.status ?? "unknown",
218
218
  downloadUrl: inv.invoice_pdf ?? "",
219
+ hostedUrl: inv.hosted_invoice_url ?? "",
219
220
  }));
220
221
  }
221
222