@dime-technology/dime-js-sdk 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -230,9 +230,50 @@ await dime.invoices.delete('000010', copy.id!) // drafts only
230
230
  const page = await dime.invoices.list('000010', { status: 'sent' })
231
231
  ```
232
232
 
233
+ #### Making the customer cover processing fees
234
+
235
+ Set `cover_fee_required` and the customer must pay the processing fee — it is not an optional
236
+ checkbox at checkout. The fee is **not** a line item and is **not** part of `total`: the merchant is
237
+ still owed `total`, and the fee is added on top of whatever the customer pays.
238
+
239
+ Card and ACH rates differ, so the charge depends on how the customer pays. `coverFeeQuote` gives you
240
+ both, quoted against the outstanding balance:
241
+
242
+ ```ts
243
+ const invoice = await dime.invoices.create('000010', {
244
+ customer_uuid: customer.uuid,
245
+ customer_name: 'Jane Doe',
246
+ customer_email: 'jane@example.com',
247
+ payment_terms: 'net_15',
248
+ cover_fee_required: true, // omit to inherit the merchant's invoice setting
249
+ lines: [{ item_id: 5, name: 'Consulting', quantity: 1, unit_price: 100 }],
250
+ })
251
+
252
+ invoice.total // '100.00' — what the merchant is owed
253
+ invoice.coverFeeQuote?.ccTotal // '104.32' — charged if they pay by card
254
+ invoice.coverFeeQuote?.achTotal // '101.26' — charged if they pay by bank
255
+ ```
256
+
257
+ The card figure is the higher of the two and is what the invoice and its emails lead with. A partial
258
+ payment re-quotes the fee against the partial amount, so treat the quote as "settling in full today"
259
+ rather than a fixed charge. `coverFeeQuote` is `undefined` when no fee is required.
260
+
261
+ To reconcile a payment, `amount` was credited to the invoice and `coverFee` was charged on top:
262
+
263
+ ```ts
264
+ const payment = invoice.payments[0]!
265
+ payment.amount // '100.00' — applied to the balance
266
+ payment.coverFee // '4.32' — the fee the customer also paid
267
+ // The customer was charged amount + coverFee.
268
+ ```
269
+
270
+ `pay()` behaves the same way: the fee for the `payment_type` you pass is added to `amount`, so the
271
+ card or bank account is debited more than the invoice is credited.
272
+
233
273
  ### Recurring invoices
234
274
 
235
- Recurring-invoice templates generate and send invoices on a schedule.
275
+ Recurring-invoice templates generate and send invoices on a schedule. `cover_fee_required` is copied
276
+ onto every invoice a template generates.
236
277
 
237
278
  ```ts
238
279
  const template = await dime.recurringInvoices.create('000010', {
@@ -241,6 +282,7 @@ const template = await dime.recurringInvoices.create('000010', {
241
282
  recurring_frequency: 'Monthly', // Weekly | Biweekly | FirstFifteenth | Monthly | Yearly
242
283
  recurring_start_date: '2026-08-01',
243
284
  recurring_end_date: '2027-08-01', // optional
285
+ cover_fee_required: true, // optional
244
286
  lines: [{ item_id: 5, name: 'Monthly retainer', quantity: 1, unit_price: 500 }],
245
287
  })
246
288
 
package/dist/index.cjs CHANGED
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  Client: () => Client,
27
27
  Config: () => Config,
28
28
  ConnectionException: () => ConnectionException,
29
+ CoverFeeQuote: () => CoverFeeQuote,
29
30
  CursorPage: () => CursorPage,
30
31
  Customer: () => Customer,
31
32
  DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
@@ -61,7 +62,7 @@ module.exports = __toCommonJS(index_exports);
61
62
 
62
63
  // src/config.ts
63
64
  var DEFAULT_BASE_URL = "https://app.dimepayments.com";
64
- var VERSION = "1.2.0";
65
+ var VERSION = "1.3.0";
65
66
  var Config = class {
66
67
  token;
67
68
  baseUrl;
@@ -838,6 +839,36 @@ var Deposits = class extends AbstractResource {
838
839
  }
839
840
  };
840
841
 
842
+ // src/data-objects/cover-fee-quote.ts
843
+ var CoverFeeQuote = class _CoverFeeQuote {
844
+ constructor(basis, base, ccFee, ccTotal, achFee, achTotal) {
845
+ this.basis = basis;
846
+ this.base = base;
847
+ this.ccFee = ccFee;
848
+ this.ccTotal = ccTotal;
849
+ this.achFee = achFee;
850
+ this.achTotal = achTotal;
851
+ }
852
+ basis;
853
+ base;
854
+ ccFee;
855
+ ccTotal;
856
+ achFee;
857
+ achTotal;
858
+ static fromRaw(data) {
859
+ const cc = arrObjectFrom(data, ["cc"]);
860
+ const ach = arrObjectFrom(data, ["ach"]);
861
+ return new _CoverFeeQuote(
862
+ arrString(data, "basis"),
863
+ arrString(data, "base"),
864
+ arrString(cc, "fee"),
865
+ arrString(cc, "total"),
866
+ arrString(ach, "fee"),
867
+ arrString(ach, "total")
868
+ );
869
+ }
870
+ };
871
+
841
872
  // src/data-objects/invoice-customer.ts
842
873
  var InvoiceCustomer = class _InvoiceCustomer {
843
874
  constructor(id, name, email) {
@@ -912,29 +943,32 @@ var InvoiceLineItem = class _InvoiceLineItem {
912
943
 
913
944
  // src/data-objects/invoice-payment.ts
914
945
  var InvoicePayment = class _InvoicePayment {
915
- constructor(amount, paidAt, method, transactionId) {
946
+ constructor(amount, paidAt, method, transactionId, coverFee) {
916
947
  this.amount = amount;
917
948
  this.paidAt = paidAt;
918
949
  this.method = method;
919
950
  this.transactionId = transactionId;
951
+ this.coverFee = coverFee;
920
952
  }
921
953
  amount;
922
954
  paidAt;
923
955
  method;
924
956
  transactionId;
957
+ coverFee;
925
958
  static fromRaw(data) {
926
959
  return new _InvoicePayment(
927
960
  arrString(data, "amount"),
928
961
  arrString(data, "paid_at"),
929
962
  arrString(data, "method"),
930
- arrString(data, "transaction_id")
963
+ arrString(data, "transaction_id"),
964
+ arrString(data, "cover_fee")
931
965
  );
932
966
  }
933
967
  };
934
968
 
935
969
  // src/data-objects/invoice.ts
936
970
  var Invoice = class _Invoice {
937
- constructor(id, invoiceNumber, status, token, paymentTerms, issueDate, dueDate, isOverdue = false, subtotal, total, amountPaid, balance, allowPartialPayment = false, thankYouNote, customerName, customerEmail, publicUrl, customer = new InvoiceCustomer(), items = [], payments = [], events = []) {
971
+ constructor(id, invoiceNumber, status, token, paymentTerms, issueDate, dueDate, isOverdue = false, subtotal, total, amountPaid, balance, allowPartialPayment = false, thankYouNote, customerName, customerEmail, publicUrl, customer = new InvoiceCustomer(), items = [], payments = [], events = [], coverFeeRequired = false, coverFeeQuote) {
938
972
  this.id = id;
939
973
  this.invoiceNumber = invoiceNumber;
940
974
  this.status = status;
@@ -956,6 +990,8 @@ var Invoice = class _Invoice {
956
990
  this.items = items;
957
991
  this.payments = payments;
958
992
  this.events = events;
993
+ this.coverFeeRequired = coverFeeRequired;
994
+ this.coverFeeQuote = coverFeeQuote;
959
995
  }
960
996
  id;
961
997
  invoiceNumber;
@@ -978,6 +1014,8 @@ var Invoice = class _Invoice {
978
1014
  items;
979
1015
  payments;
980
1016
  events;
1017
+ coverFeeRequired;
1018
+ coverFeeQuote;
981
1019
  static fromRaw(data) {
982
1020
  return new _Invoice(
983
1021
  arrInt(data, "id"),
@@ -1000,7 +1038,9 @@ var Invoice = class _Invoice {
1000
1038
  InvoiceCustomer.fromRaw(arrObjectFrom(data, ["customer"])),
1001
1039
  arrArrayFrom(data, "items").map(InvoiceLineItem.fromRaw),
1002
1040
  arrArrayFrom(data, "payments").map(InvoicePayment.fromRaw),
1003
- arrArrayFrom(data, "events").map(InvoiceEvent.fromRaw)
1041
+ arrArrayFrom(data, "events").map(InvoiceEvent.fromRaw),
1042
+ arrBool(data, "cover_fee_required"),
1043
+ data["cover_fee_quote"] && typeof data["cover_fee_quote"] === "object" ? CoverFeeQuote.fromRaw(data["cover_fee_quote"]) : void 0
1004
1044
  );
1005
1045
  }
1006
1046
  };
@@ -1072,7 +1112,13 @@ var Invoices = class extends AbstractResource {
1072
1112
  * `unit_price` and optional `description`. Optional: `invoice_number`,
1073
1113
  * `issue_date` (Y-m-d, defaults to today — `due_date` is derived from
1074
1114
  * `payment_terms`), `thank_you_note`, `allow_partial_payment`,
1075
- * `reminder_settings`.
1115
+ * `cover_fee_required`, `reminder_settings`.
1116
+ *
1117
+ * Set `cover_fee_required` to make the customer pay the processing fee. The
1118
+ * fee is added on top of the invoice at payment time rather than becoming a
1119
+ * line item, so `total` stays the amount owed to the merchant — read
1120
+ * `invoice.coverFeeQuote` for what the customer will actually be charged.
1121
+ * Omitting the field inherits the merchant's invoice setting.
1076
1122
  */
1077
1123
  async create(sid, attributes) {
1078
1124
  const raw = await this.transport.request(
@@ -1150,6 +1196,12 @@ var Invoices = class extends AbstractResource {
1150
1196
  * `account_type` (Checking | Savings) / `account_name`. Omit `amount` to pay
1151
1197
  * the full balance — partial amounts require the invoice to allow them.
1152
1198
  * Optional: `memo`, `billing_address`.
1199
+ *
1200
+ * On a cover-fee invoice the processing fee for `payment_type` is charged on
1201
+ * top of `amount`, so the card or bank account is debited more than the
1202
+ * invoice is credited. The fee lands as `coverFee` on the matching entry in
1203
+ * `invoice.payments`. Card and ACH rates differ, so the same `amount` settles
1204
+ * differently per `payment_type`.
1153
1205
  */
1154
1206
  async pay(sid, invoiceId, attributes) {
1155
1207
  const raw = await this.transport.request(
@@ -1475,7 +1527,7 @@ var PaymentMethods = class extends AbstractResource {
1475
1527
 
1476
1528
  // src/data-objects/recurring-invoice.ts
1477
1529
  var RecurringInvoice = class _RecurringInvoice {
1478
- constructor(id, status, recurrenceSchedule, paymentTerms, startDate, endDate, nextRunDate, lastRunDate, customerName, thankYouNote, customer = new InvoiceCustomer(), items = [], upcomingRunDates = [], invoices = []) {
1530
+ constructor(id, status, recurrenceSchedule, paymentTerms, startDate, endDate, nextRunDate, lastRunDate, customerName, thankYouNote, customer = new InvoiceCustomer(), items = [], upcomingRunDates = [], invoices = [], coverFeeRequired = false) {
1479
1531
  this.id = id;
1480
1532
  this.status = status;
1481
1533
  this.recurrenceSchedule = recurrenceSchedule;
@@ -1490,6 +1542,7 @@ var RecurringInvoice = class _RecurringInvoice {
1490
1542
  this.items = items;
1491
1543
  this.upcomingRunDates = upcomingRunDates;
1492
1544
  this.invoices = invoices;
1545
+ this.coverFeeRequired = coverFeeRequired;
1493
1546
  }
1494
1547
  id;
1495
1548
  status;
@@ -1505,6 +1558,7 @@ var RecurringInvoice = class _RecurringInvoice {
1505
1558
  items;
1506
1559
  upcomingRunDates;
1507
1560
  invoices;
1561
+ coverFeeRequired;
1508
1562
  static fromRaw(data) {
1509
1563
  const runDates = data["upcoming_run_dates"];
1510
1564
  return new _RecurringInvoice(
@@ -1521,7 +1575,8 @@ var RecurringInvoice = class _RecurringInvoice {
1521
1575
  InvoiceCustomer.fromRaw(arrObjectFrom(data, ["customer"])),
1522
1576
  arrArrayFrom(data, "items").map(InvoiceLineItem.fromRaw),
1523
1577
  Array.isArray(runDates) ? runDates.map((d) => String(d)) : [],
1524
- arrArrayFrom(data, "invoices").map(Invoice.fromRaw)
1578
+ arrArrayFrom(data, "invoices").map(Invoice.fromRaw),
1579
+ arrBool(data, "cover_fee_required")
1525
1580
  );
1526
1581
  }
1527
1582
  };
@@ -1560,6 +1615,9 @@ var RecurringInvoices = class extends AbstractResource {
1560
1615
  * `recurring_start_date` (Y-m-d) and `lines` are required. Optional:
1561
1616
  * `recurring_end_date` (Y-m-d, on or after the start date),
1562
1617
  * `thank_you_note`.
1618
+ *
1619
+ * `cover_fee_required` makes the customer cover the processing fee on every
1620
+ * invoice this template generates.
1563
1621
  */
1564
1622
  async create(sid, attributes) {
1565
1623
  const raw = await this.transport.request(
@@ -1875,6 +1933,7 @@ var Client = class {
1875
1933
  Client,
1876
1934
  Config,
1877
1935
  ConnectionException,
1936
+ CoverFeeQuote,
1878
1937
  CursorPage,
1879
1938
  Customer,
1880
1939
  DEFAULT_BASE_URL,