@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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/config.ts
2
2
  var DEFAULT_BASE_URL = "https://app.dimepayments.com";
3
- var VERSION = "1.2.0";
3
+ var VERSION = "1.3.0";
4
4
  var Config = class {
5
5
  token;
6
6
  baseUrl;
@@ -777,6 +777,36 @@ var Deposits = class extends AbstractResource {
777
777
  }
778
778
  };
779
779
 
780
+ // src/data-objects/cover-fee-quote.ts
781
+ var CoverFeeQuote = class _CoverFeeQuote {
782
+ constructor(basis, base, ccFee, ccTotal, achFee, achTotal) {
783
+ this.basis = basis;
784
+ this.base = base;
785
+ this.ccFee = ccFee;
786
+ this.ccTotal = ccTotal;
787
+ this.achFee = achFee;
788
+ this.achTotal = achTotal;
789
+ }
790
+ basis;
791
+ base;
792
+ ccFee;
793
+ ccTotal;
794
+ achFee;
795
+ achTotal;
796
+ static fromRaw(data) {
797
+ const cc = arrObjectFrom(data, ["cc"]);
798
+ const ach = arrObjectFrom(data, ["ach"]);
799
+ return new _CoverFeeQuote(
800
+ arrString(data, "basis"),
801
+ arrString(data, "base"),
802
+ arrString(cc, "fee"),
803
+ arrString(cc, "total"),
804
+ arrString(ach, "fee"),
805
+ arrString(ach, "total")
806
+ );
807
+ }
808
+ };
809
+
780
810
  // src/data-objects/invoice-customer.ts
781
811
  var InvoiceCustomer = class _InvoiceCustomer {
782
812
  constructor(id, name, email) {
@@ -851,29 +881,32 @@ var InvoiceLineItem = class _InvoiceLineItem {
851
881
 
852
882
  // src/data-objects/invoice-payment.ts
853
883
  var InvoicePayment = class _InvoicePayment {
854
- constructor(amount, paidAt, method, transactionId) {
884
+ constructor(amount, paidAt, method, transactionId, coverFee) {
855
885
  this.amount = amount;
856
886
  this.paidAt = paidAt;
857
887
  this.method = method;
858
888
  this.transactionId = transactionId;
889
+ this.coverFee = coverFee;
859
890
  }
860
891
  amount;
861
892
  paidAt;
862
893
  method;
863
894
  transactionId;
895
+ coverFee;
864
896
  static fromRaw(data) {
865
897
  return new _InvoicePayment(
866
898
  arrString(data, "amount"),
867
899
  arrString(data, "paid_at"),
868
900
  arrString(data, "method"),
869
- arrString(data, "transaction_id")
901
+ arrString(data, "transaction_id"),
902
+ arrString(data, "cover_fee")
870
903
  );
871
904
  }
872
905
  };
873
906
 
874
907
  // src/data-objects/invoice.ts
875
908
  var Invoice = class _Invoice {
876
- 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 = []) {
909
+ 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) {
877
910
  this.id = id;
878
911
  this.invoiceNumber = invoiceNumber;
879
912
  this.status = status;
@@ -895,6 +928,8 @@ var Invoice = class _Invoice {
895
928
  this.items = items;
896
929
  this.payments = payments;
897
930
  this.events = events;
931
+ this.coverFeeRequired = coverFeeRequired;
932
+ this.coverFeeQuote = coverFeeQuote;
898
933
  }
899
934
  id;
900
935
  invoiceNumber;
@@ -917,6 +952,8 @@ var Invoice = class _Invoice {
917
952
  items;
918
953
  payments;
919
954
  events;
955
+ coverFeeRequired;
956
+ coverFeeQuote;
920
957
  static fromRaw(data) {
921
958
  return new _Invoice(
922
959
  arrInt(data, "id"),
@@ -939,7 +976,9 @@ var Invoice = class _Invoice {
939
976
  InvoiceCustomer.fromRaw(arrObjectFrom(data, ["customer"])),
940
977
  arrArrayFrom(data, "items").map(InvoiceLineItem.fromRaw),
941
978
  arrArrayFrom(data, "payments").map(InvoicePayment.fromRaw),
942
- arrArrayFrom(data, "events").map(InvoiceEvent.fromRaw)
979
+ arrArrayFrom(data, "events").map(InvoiceEvent.fromRaw),
980
+ arrBool(data, "cover_fee_required"),
981
+ data["cover_fee_quote"] && typeof data["cover_fee_quote"] === "object" ? CoverFeeQuote.fromRaw(data["cover_fee_quote"]) : void 0
943
982
  );
944
983
  }
945
984
  };
@@ -1011,7 +1050,13 @@ var Invoices = class extends AbstractResource {
1011
1050
  * `unit_price` and optional `description`. Optional: `invoice_number`,
1012
1051
  * `issue_date` (Y-m-d, defaults to today — `due_date` is derived from
1013
1052
  * `payment_terms`), `thank_you_note`, `allow_partial_payment`,
1014
- * `reminder_settings`.
1053
+ * `cover_fee_required`, `reminder_settings`.
1054
+ *
1055
+ * Set `cover_fee_required` to make the customer pay the processing fee. The
1056
+ * fee is added on top of the invoice at payment time rather than becoming a
1057
+ * line item, so `total` stays the amount owed to the merchant — read
1058
+ * `invoice.coverFeeQuote` for what the customer will actually be charged.
1059
+ * Omitting the field inherits the merchant's invoice setting.
1015
1060
  */
1016
1061
  async create(sid, attributes) {
1017
1062
  const raw = await this.transport.request(
@@ -1089,6 +1134,12 @@ var Invoices = class extends AbstractResource {
1089
1134
  * `account_type` (Checking | Savings) / `account_name`. Omit `amount` to pay
1090
1135
  * the full balance — partial amounts require the invoice to allow them.
1091
1136
  * Optional: `memo`, `billing_address`.
1137
+ *
1138
+ * On a cover-fee invoice the processing fee for `payment_type` is charged on
1139
+ * top of `amount`, so the card or bank account is debited more than the
1140
+ * invoice is credited. The fee lands as `coverFee` on the matching entry in
1141
+ * `invoice.payments`. Card and ACH rates differ, so the same `amount` settles
1142
+ * differently per `payment_type`.
1092
1143
  */
1093
1144
  async pay(sid, invoiceId, attributes) {
1094
1145
  const raw = await this.transport.request(
@@ -1414,7 +1465,7 @@ var PaymentMethods = class extends AbstractResource {
1414
1465
 
1415
1466
  // src/data-objects/recurring-invoice.ts
1416
1467
  var RecurringInvoice = class _RecurringInvoice {
1417
- constructor(id, status, recurrenceSchedule, paymentTerms, startDate, endDate, nextRunDate, lastRunDate, customerName, thankYouNote, customer = new InvoiceCustomer(), items = [], upcomingRunDates = [], invoices = []) {
1468
+ constructor(id, status, recurrenceSchedule, paymentTerms, startDate, endDate, nextRunDate, lastRunDate, customerName, thankYouNote, customer = new InvoiceCustomer(), items = [], upcomingRunDates = [], invoices = [], coverFeeRequired = false) {
1418
1469
  this.id = id;
1419
1470
  this.status = status;
1420
1471
  this.recurrenceSchedule = recurrenceSchedule;
@@ -1429,6 +1480,7 @@ var RecurringInvoice = class _RecurringInvoice {
1429
1480
  this.items = items;
1430
1481
  this.upcomingRunDates = upcomingRunDates;
1431
1482
  this.invoices = invoices;
1483
+ this.coverFeeRequired = coverFeeRequired;
1432
1484
  }
1433
1485
  id;
1434
1486
  status;
@@ -1444,6 +1496,7 @@ var RecurringInvoice = class _RecurringInvoice {
1444
1496
  items;
1445
1497
  upcomingRunDates;
1446
1498
  invoices;
1499
+ coverFeeRequired;
1447
1500
  static fromRaw(data) {
1448
1501
  const runDates = data["upcoming_run_dates"];
1449
1502
  return new _RecurringInvoice(
@@ -1460,7 +1513,8 @@ var RecurringInvoice = class _RecurringInvoice {
1460
1513
  InvoiceCustomer.fromRaw(arrObjectFrom(data, ["customer"])),
1461
1514
  arrArrayFrom(data, "items").map(InvoiceLineItem.fromRaw),
1462
1515
  Array.isArray(runDates) ? runDates.map((d) => String(d)) : [],
1463
- arrArrayFrom(data, "invoices").map(Invoice.fromRaw)
1516
+ arrArrayFrom(data, "invoices").map(Invoice.fromRaw),
1517
+ arrBool(data, "cover_fee_required")
1464
1518
  );
1465
1519
  }
1466
1520
  };
@@ -1499,6 +1553,9 @@ var RecurringInvoices = class extends AbstractResource {
1499
1553
  * `recurring_start_date` (Y-m-d) and `lines` are required. Optional:
1500
1554
  * `recurring_end_date` (Y-m-d, on or after the start date),
1501
1555
  * `thank_you_note`.
1556
+ *
1557
+ * `cover_fee_required` makes the customer cover the processing fee on every
1558
+ * invoice this template generates.
1502
1559
  */
1503
1560
  async create(sid, attributes) {
1504
1561
  const raw = await this.transport.request(
@@ -1813,6 +1870,7 @@ export {
1813
1870
  Client,
1814
1871
  Config,
1815
1872
  ConnectionException,
1873
+ CoverFeeQuote,
1816
1874
  CursorPage,
1817
1875
  Customer,
1818
1876
  DEFAULT_BASE_URL,