@dime-technology/dime-js-sdk 1.3.1 → 1.4.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.cjs CHANGED
@@ -22,7 +22,9 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  Address: () => Address,
24
24
  ApiException: () => ApiException,
25
+ ApplicationStatus: () => ApplicationStatus,
25
26
  AuthenticationException: () => AuthenticationException,
27
+ Chargeback: () => Chargeback,
26
28
  Client: () => Client,
27
29
  Config: () => Config,
28
30
  ConnectionException: () => ConnectionException,
@@ -34,7 +36,12 @@ __export(index_exports, {
34
36
  DepositGroup: () => DepositGroup,
35
37
  DepositWithTransactions: () => DepositWithTransactions,
36
38
  DimeException: () => DimeException,
39
+ DocumentUploadFailure: () => DocumentUploadFailure,
40
+ DocumentUploadResult: () => DocumentUploadResult,
37
41
  FormLink: () => FormLink,
42
+ FundRelease: () => FundRelease,
43
+ FundReleaseResult: () => FundReleaseResult,
44
+ HeldBalance: () => HeldBalance,
38
45
  Invoice: () => Invoice,
39
46
  InvoiceCustomer: () => InvoiceCustomer,
40
47
  InvoiceEvent: () => InvoiceEvent,
@@ -43,6 +50,7 @@ __export(index_exports, {
43
50
  InvoiceLink: () => InvoiceLink,
44
51
  InvoicePayment: () => InvoicePayment,
45
52
  Merchant: () => Merchant,
53
+ MerchantDocument: () => MerchantDocument,
46
54
  MessageResult: () => MessageResult,
47
55
  NotFoundException: () => NotFoundException,
48
56
  PaymentMethod: () => PaymentMethod,
@@ -51,7 +59,13 @@ __export(index_exports, {
51
59
  RecurringInvoice: () => RecurringInvoice,
52
60
  RecurringPayment: () => RecurringPayment,
53
61
  RecurringPaymentMethod: () => RecurringPaymentMethod,
62
+ ReleasableTransaction: () => ReleasableTransaction,
63
+ ReleasableTransactions: () => ReleasableTransactions,
54
64
  ServerException: () => ServerException,
65
+ SubscribeResult: () => SubscribeResult,
66
+ Subscription: () => Subscription,
67
+ SubscriptionItem: () => SubscriptionItem,
68
+ SubscriptionPlan: () => SubscriptionPlan,
55
69
  TokenizeResult: () => TokenizeResult,
56
70
  Transaction: () => Transaction,
57
71
  TransactionAddress: () => TransactionAddress,
@@ -62,7 +76,7 @@ module.exports = __toCommonJS(index_exports);
62
76
 
63
77
  // src/config.ts
64
78
  var DEFAULT_BASE_URL = "https://app.dimepayments.com";
65
- var VERSION = "1.3.1";
79
+ var VERSION = "1.4.0";
66
80
  var Config = class {
67
81
  token;
68
82
  baseUrl;
@@ -246,11 +260,7 @@ var Transport = class {
246
260
  url += "?" + new URLSearchParams(params).toString();
247
261
  }
248
262
  const sendBody = !bodyless && Object.keys(body).length > 0;
249
- const headers = {
250
- Authorization: `Bearer ${this.config.token}`,
251
- Accept: "application/json",
252
- "X-Dime-Sdk": `dime-js-sdk/${VERSION}`
253
- };
263
+ const headers = this.headers();
254
264
  if (sendBody) headers["Content-Type"] = "application/json";
255
265
  const init = {
256
266
  method,
@@ -259,6 +269,32 @@ var Transport = class {
259
269
  };
260
270
  return this.attempt(url, init, 0);
261
271
  }
272
+ /**
273
+ * Execute a `multipart/form-data` request and return the decoded JSON body.
274
+ *
275
+ * Multipart has no JSON parsing, so the envelope is sent as bracketed form
276
+ * fields (`data[sid]=…`) — a single `data` field holding JSON would be read
277
+ * as a plain string. No Content-Type is set here: fetch derives it, boundary
278
+ * included, from the FormData body.
279
+ */
280
+ async requestMultipart(method, path, body, files) {
281
+ const url = `${this.config.baseUri()}${path.replace(/^\//, "")}`;
282
+ const form = new FormData();
283
+ for (const [name, value] of Object.entries(flattenParams(body))) {
284
+ form.append(name, value);
285
+ }
286
+ for (const file of files) {
287
+ form.append(file.field, file.content, file.filename);
288
+ }
289
+ return this.attempt(url, { method, headers: this.headers(), body: form }, 0);
290
+ }
291
+ headers() {
292
+ return {
293
+ Authorization: `Bearer ${this.config.token}`,
294
+ Accept: "application/json",
295
+ "X-Dime-Sdk": `dime-js-sdk/${VERSION}`
296
+ };
297
+ }
262
298
  async attempt(url, init, attempt) {
263
299
  let response;
264
300
  try {
@@ -533,6 +569,103 @@ var Addresses = class extends AbstractResource {
533
569
  }
534
570
  };
535
571
 
572
+ // src/data-objects/chargeback.ts
573
+ var Chargeback = class _Chargeback {
574
+ constructor(transactionInfoId, parentTransactionInfoId, gatewayTransactionId, transactionNumber, invoiceNumber, chargebackDate, merchantChargebackDate, transactionAmount, chargebackAmount, cardBrand, ccLastFour, payeeName, daysToRepresent, representmentDate, merchantRepresentmentDate, representmentStatus, result, chargebackCode, chargebackResponseCode, resolved = false) {
575
+ this.transactionInfoId = transactionInfoId;
576
+ this.parentTransactionInfoId = parentTransactionInfoId;
577
+ this.gatewayTransactionId = gatewayTransactionId;
578
+ this.transactionNumber = transactionNumber;
579
+ this.invoiceNumber = invoiceNumber;
580
+ this.chargebackDate = chargebackDate;
581
+ this.merchantChargebackDate = merchantChargebackDate;
582
+ this.transactionAmount = transactionAmount;
583
+ this.chargebackAmount = chargebackAmount;
584
+ this.cardBrand = cardBrand;
585
+ this.ccLastFour = ccLastFour;
586
+ this.payeeName = payeeName;
587
+ this.daysToRepresent = daysToRepresent;
588
+ this.representmentDate = representmentDate;
589
+ this.merchantRepresentmentDate = merchantRepresentmentDate;
590
+ this.representmentStatus = representmentStatus;
591
+ this.result = result;
592
+ this.chargebackCode = chargebackCode;
593
+ this.chargebackResponseCode = chargebackResponseCode;
594
+ this.resolved = resolved;
595
+ }
596
+ transactionInfoId;
597
+ parentTransactionInfoId;
598
+ gatewayTransactionId;
599
+ transactionNumber;
600
+ invoiceNumber;
601
+ chargebackDate;
602
+ merchantChargebackDate;
603
+ transactionAmount;
604
+ chargebackAmount;
605
+ cardBrand;
606
+ ccLastFour;
607
+ payeeName;
608
+ daysToRepresent;
609
+ representmentDate;
610
+ merchantRepresentmentDate;
611
+ representmentStatus;
612
+ result;
613
+ chargebackCode;
614
+ chargebackResponseCode;
615
+ resolved;
616
+ static fromRaw(data) {
617
+ return new _Chargeback(
618
+ arrString(data, "transaction_info_id"),
619
+ arrString(data, "parent_transaction_info_id"),
620
+ arrString(data, "gateway_transaction_id"),
621
+ arrString(data, "transaction_number"),
622
+ arrString(data, "invoice_number"),
623
+ arrString(data, "chargeback_date"),
624
+ arrString(data, "merchant_chargeback_date"),
625
+ arrString(data, "transaction_amount"),
626
+ arrString(data, "chargeback_amount"),
627
+ arrString(data, "card_brand"),
628
+ arrString(data, "cc_last_four"),
629
+ arrString(data, "payee_name"),
630
+ arrInt(data, "days_to_represent"),
631
+ arrString(data, "representment_date"),
632
+ arrString(data, "merchant_representment_date"),
633
+ arrString(data, "representment_status"),
634
+ arrString(data, "result"),
635
+ arrString(data, "chargeback_code"),
636
+ arrString(data, "chargeback_response_code"),
637
+ arrBool(data, "resolved")
638
+ );
639
+ }
640
+ };
641
+
642
+ // src/resources/chargebacks.ts
643
+ var Chargebacks = class extends AbstractResource {
644
+ /**
645
+ * List a merchant's chargebacks.
646
+ *
647
+ * @param filters `start_date` and `end_date` (UTC, `Y-m-d H:i:s`, sent
648
+ * together), `representment_status` (free text from the processor, e.g.
649
+ * `New` or `Resolved`)
650
+ */
651
+ async list(sid, filters = {}) {
652
+ return this.paginate(
653
+ "GET",
654
+ "chargeback/list",
655
+ this.envelope({ sid }, filters),
656
+ Chargeback.fromRaw
657
+ );
658
+ }
659
+ async show(sid, transactionInfoId) {
660
+ const raw = await this.transport.request(
661
+ "GET",
662
+ "chargeback/show",
663
+ this.envelope({ sid, transaction_info_id: transactionInfoId })
664
+ );
665
+ return Chargeback.fromRaw(raw["data"] ?? {});
666
+ }
667
+ };
668
+
536
669
  // src/data-objects/customer.ts
537
670
  var Customer = class _Customer {
538
671
  constructor(uuid, firstName, lastName, phone, email, addr1, addr2, addr3, city, state, zip, country) {
@@ -839,6 +972,343 @@ var Deposits = class extends AbstractResource {
839
972
  }
840
973
  };
841
974
 
975
+ // src/data-objects/document-upload-failure.ts
976
+ var DocumentUploadFailure = class _DocumentUploadFailure {
977
+ constructor(fileName, reason) {
978
+ this.fileName = fileName;
979
+ this.reason = reason;
980
+ }
981
+ fileName;
982
+ reason;
983
+ static fromRaw(data) {
984
+ return new _DocumentUploadFailure(arrString(data, "file_name"), arrString(data, "reason"));
985
+ }
986
+ };
987
+
988
+ // src/data-objects/merchant-document.ts
989
+ var MerchantDocument = class _MerchantDocument {
990
+ constructor(uuid, fileName, docType, chargebackTransactionInfoId, size, uploadedAt, uploadedVia, sentToProcessorAt, processorResponse) {
991
+ this.uuid = uuid;
992
+ this.fileName = fileName;
993
+ this.docType = docType;
994
+ this.chargebackTransactionInfoId = chargebackTransactionInfoId;
995
+ this.size = size;
996
+ this.uploadedAt = uploadedAt;
997
+ this.uploadedVia = uploadedVia;
998
+ this.sentToProcessorAt = sentToProcessorAt;
999
+ this.processorResponse = processorResponse;
1000
+ }
1001
+ uuid;
1002
+ fileName;
1003
+ docType;
1004
+ chargebackTransactionInfoId;
1005
+ size;
1006
+ uploadedAt;
1007
+ uploadedVia;
1008
+ sentToProcessorAt;
1009
+ processorResponse;
1010
+ static fromRaw(data) {
1011
+ const sent = Array.isArray(data["sent_to_processor"]) ? data["sent_to_processor"] : [];
1012
+ const [sentAt, processorResponse] = sent.map(
1013
+ (value) => value === null || value === void 0 ? void 0 : String(value)
1014
+ );
1015
+ return new _MerchantDocument(
1016
+ arrString(data, "uuid"),
1017
+ arrString(data, "file_name"),
1018
+ arrString(data, "doc_type"),
1019
+ arrString(data, "chargeback_transaction_info_id"),
1020
+ arrInt(data, "size"),
1021
+ arrString(data, "uploaded_at"),
1022
+ arrString(data, "uploaded_via"),
1023
+ sentAt,
1024
+ processorResponse
1025
+ );
1026
+ }
1027
+ };
1028
+
1029
+ // src/data-objects/document-upload-result.ts
1030
+ var DocumentUploadResult = class _DocumentUploadResult {
1031
+ constructor(message, documents = [], failed = []) {
1032
+ this.message = message;
1033
+ this.documents = documents;
1034
+ this.failed = failed;
1035
+ }
1036
+ message;
1037
+ documents;
1038
+ failed;
1039
+ static fromRaw(data) {
1040
+ return new _DocumentUploadResult(
1041
+ arrString(data, "message"),
1042
+ arrArrayFrom(data, "documents").map(MerchantDocument.fromRaw),
1043
+ arrArrayFrom(data, "failed").map(DocumentUploadFailure.fromRaw)
1044
+ );
1045
+ }
1046
+ };
1047
+
1048
+ // src/resources/documents.ts
1049
+ var Documents = class extends AbstractResource {
1050
+ /**
1051
+ * Upload up to 10 documents for a merchant (PDF, JPG, PNG, DOC, DOCX or RTF,
1052
+ * each 9 MB or smaller). Sent as `multipart/form-data`.
1053
+ *
1054
+ * Files are stored independently: check `failed` on the result and re-send
1055
+ * only those. A 413 means the request as a whole was too large — send fewer
1056
+ * files per request.
1057
+ *
1058
+ * Uploading does not forward the document to the processor; our team
1059
+ * reviews it and does that.
1060
+ *
1061
+ * @param docType `Verification`, `FraudHolds`, `Underwriting` or
1062
+ * `RetrievalRequest` (evidence for a chargeback or retrieval request)
1063
+ * @param chargebackTransactionInfoId attach the files as evidence to this
1064
+ * chargeback (its `transactionInfoId`)
1065
+ */
1066
+ async upload(sid, docType, files, chargebackTransactionInfoId) {
1067
+ const raw = await this.transport.requestMultipart(
1068
+ "POST",
1069
+ "document/upload",
1070
+ this.envelope({
1071
+ sid,
1072
+ doc_type: docType,
1073
+ chargeback_transaction_info_id: chargebackTransactionInfoId
1074
+ }),
1075
+ files.map((file) => ({ field: "files[]", ...toBlob(file) }))
1076
+ );
1077
+ return DocumentUploadResult.fromRaw(raw["data"] ?? {});
1078
+ }
1079
+ /**
1080
+ * List the documents held for a merchant, whether uploaded through the API,
1081
+ * by our team, or through the merchant application.
1082
+ *
1083
+ * @param filters `doc_type`, `chargeback_transaction_info_id`
1084
+ */
1085
+ async list(sid, filters = {}) {
1086
+ const raw = await this.transport.request(
1087
+ "GET",
1088
+ "document/list",
1089
+ this.envelope({ sid }, filters)
1090
+ );
1091
+ const documents = Array.isArray(raw["data"]) ? raw["data"] : [];
1092
+ return documents.map(MerchantDocument.fromRaw);
1093
+ }
1094
+ };
1095
+ function toBlob(file) {
1096
+ if (file instanceof Blob) {
1097
+ const name = file.name;
1098
+ return { content: file, filename: typeof name === "string" && name !== "" ? name : "document" };
1099
+ }
1100
+ const content = file.content instanceof Blob ? file.content : new Blob([file.content], file.contentType ? { type: file.contentType } : {});
1101
+ return { content, filename: file.filename };
1102
+ }
1103
+
1104
+ // src/data-objects/fund-release.ts
1105
+ var FundRelease = class _FundRelease {
1106
+ constructor(id, amount, fee, status, statusLabel, idempotencyKey, transactionInfoIds = [], failureReason, requestedAt, completedAt) {
1107
+ this.id = id;
1108
+ this.amount = amount;
1109
+ this.fee = fee;
1110
+ this.status = status;
1111
+ this.statusLabel = statusLabel;
1112
+ this.idempotencyKey = idempotencyKey;
1113
+ this.transactionInfoIds = transactionInfoIds;
1114
+ this.failureReason = failureReason;
1115
+ this.requestedAt = requestedAt;
1116
+ this.completedAt = completedAt;
1117
+ }
1118
+ id;
1119
+ amount;
1120
+ fee;
1121
+ status;
1122
+ statusLabel;
1123
+ idempotencyKey;
1124
+ transactionInfoIds;
1125
+ failureReason;
1126
+ requestedAt;
1127
+ completedAt;
1128
+ static fromRaw(data) {
1129
+ const ids = Array.isArray(data["transaction_info_ids"]) ? data["transaction_info_ids"].map(String) : [];
1130
+ return new _FundRelease(
1131
+ arrInt(data, "id"),
1132
+ arrString(data, "amount"),
1133
+ arrString(data, "fee"),
1134
+ arrString(data, "status"),
1135
+ arrString(data, "status_label"),
1136
+ arrString(data, "idempotency_key"),
1137
+ ids,
1138
+ arrString(data, "failure_reason"),
1139
+ arrString(data, "requested_at"),
1140
+ arrString(data, "completed_at")
1141
+ );
1142
+ }
1143
+ };
1144
+
1145
+ // src/data-objects/fund-release-result.ts
1146
+ var FundReleaseResult = class _FundReleaseResult {
1147
+ constructor(sid, replayed = false, release = new FundRelease()) {
1148
+ this.sid = sid;
1149
+ this.replayed = replayed;
1150
+ this.release = release;
1151
+ }
1152
+ sid;
1153
+ replayed;
1154
+ release;
1155
+ static fromRaw(data) {
1156
+ return new _FundReleaseResult(
1157
+ arrString(data, "sid"),
1158
+ arrBool(data, "replayed"),
1159
+ FundRelease.fromRaw(arrObjectFrom(data, ["release"]))
1160
+ );
1161
+ }
1162
+ };
1163
+
1164
+ // src/data-objects/held-balance.ts
1165
+ var HeldBalance = class _HeldBalance {
1166
+ constructor(sid, available, pending, reserve, atRisk, owedToSplit, unresolved, releaseFee, releasable, achSettlementDays, achOutEnabled = false, achOutLimitRemaining) {
1167
+ this.sid = sid;
1168
+ this.available = available;
1169
+ this.pending = pending;
1170
+ this.reserve = reserve;
1171
+ this.atRisk = atRisk;
1172
+ this.owedToSplit = owedToSplit;
1173
+ this.unresolved = unresolved;
1174
+ this.releaseFee = releaseFee;
1175
+ this.releasable = releasable;
1176
+ this.achSettlementDays = achSettlementDays;
1177
+ this.achOutEnabled = achOutEnabled;
1178
+ this.achOutLimitRemaining = achOutLimitRemaining;
1179
+ }
1180
+ sid;
1181
+ available;
1182
+ pending;
1183
+ reserve;
1184
+ atRisk;
1185
+ owedToSplit;
1186
+ unresolved;
1187
+ releaseFee;
1188
+ releasable;
1189
+ achSettlementDays;
1190
+ achOutEnabled;
1191
+ achOutLimitRemaining;
1192
+ static fromRaw(data) {
1193
+ return new _HeldBalance(
1194
+ arrString(data, "sid"),
1195
+ arrString(data, "available"),
1196
+ arrString(data, "pending"),
1197
+ arrString(data, "reserve"),
1198
+ arrString(data, "at_risk"),
1199
+ arrString(data, "owed_to_split"),
1200
+ arrString(data, "unresolved"),
1201
+ arrString(data, "release_fee"),
1202
+ arrString(data, "releasable"),
1203
+ arrInt(data, "ach_settlement_days"),
1204
+ arrBool(data, "ach_out_enabled"),
1205
+ arrString(data, "ach_out_limit_remaining")
1206
+ );
1207
+ }
1208
+ };
1209
+
1210
+ // src/data-objects/releasable-transaction.ts
1211
+ var ReleasableTransaction = class _ReleasableTransaction {
1212
+ constructor(transactionInfoId, type, transactionDate, grossAmount, netAmount, splitAmount, amount) {
1213
+ this.transactionInfoId = transactionInfoId;
1214
+ this.type = type;
1215
+ this.transactionDate = transactionDate;
1216
+ this.grossAmount = grossAmount;
1217
+ this.netAmount = netAmount;
1218
+ this.splitAmount = splitAmount;
1219
+ this.amount = amount;
1220
+ }
1221
+ transactionInfoId;
1222
+ type;
1223
+ transactionDate;
1224
+ grossAmount;
1225
+ netAmount;
1226
+ splitAmount;
1227
+ amount;
1228
+ static fromRaw(data) {
1229
+ return new _ReleasableTransaction(
1230
+ arrString(data, "transaction_info_id"),
1231
+ arrString(data, "type"),
1232
+ arrString(data, "transaction_date"),
1233
+ arrString(data, "gross_amount"),
1234
+ arrString(data, "net_amount"),
1235
+ arrString(data, "split_amount"),
1236
+ arrString(data, "amount")
1237
+ );
1238
+ }
1239
+ };
1240
+
1241
+ // src/data-objects/releasable-transactions.ts
1242
+ var ReleasableTransactions = class _ReleasableTransactions {
1243
+ constructor(sid, transactions = [], total, truncated = false) {
1244
+ this.sid = sid;
1245
+ this.transactions = transactions;
1246
+ this.total = total;
1247
+ this.truncated = truncated;
1248
+ }
1249
+ sid;
1250
+ transactions;
1251
+ total;
1252
+ truncated;
1253
+ static fromRaw(data) {
1254
+ return new _ReleasableTransactions(
1255
+ arrString(data, "sid"),
1256
+ arrArrayFrom(data, "transactions").map(ReleasableTransaction.fromRaw),
1257
+ arrString(data, "total"),
1258
+ arrBool(data, "truncated")
1259
+ );
1260
+ }
1261
+ };
1262
+
1263
+ // src/resources/funds.ts
1264
+ var Funds = class extends AbstractResource {
1265
+ /** The merchant's balance at the processor, and how much is releasable today. */
1266
+ async balance(sid) {
1267
+ const raw = await this.transport.request("GET", "funds/balance", this.envelope({ sid }));
1268
+ return HeldBalance.fromRaw(raw["data"] ?? {});
1269
+ }
1270
+ /** The payments that can be released right now — the list to release by `transaction_info_ids`. */
1271
+ async transactions(sid) {
1272
+ const raw = await this.transport.request("GET", "funds/transactions", this.envelope({ sid }));
1273
+ return ReleasableTransactions.fromRaw(raw["data"] ?? {});
1274
+ }
1275
+ /**
1276
+ * Send part of a merchant's held balance to the bank account on file.
1277
+ *
1278
+ * Use a fresh `idempotencyKey` per intended release and reuse it when
1279
+ * retrying: a retry with the same key and request returns the original
1280
+ * release instead of sending the money again. The SDK's own retries of
1281
+ * timeouts and 5xx responses resend the same key, so they are safe.
1282
+ *
1283
+ * Check `release.status`, not only whether this resolved. A declined release
1284
+ * (`failed`) is returned rather than thrown, alongside `released` and
1285
+ * `unknown`. Refusals that create no release — a transaction that does not
1286
+ * qualify, more than is releasable, a key reused for a different request, a
1287
+ * release already in flight — throw an {@link ApiException} whose response
1288
+ * body carries the detail (`data.ineligible`, `data.releasable`).
1289
+ *
1290
+ * @param attributes exactly one of `amount` (dollars, at most two decimal
1291
+ * places) or `transaction_info_ids` (up to 100, all or nothing)
1292
+ */
1293
+ async release(sid, idempotencyKey, attributes) {
1294
+ let raw;
1295
+ try {
1296
+ raw = await this.transport.request(
1297
+ "POST",
1298
+ "funds/release",
1299
+ this.envelope({ sid, idempotency_key: idempotencyKey, ...attributes })
1300
+ );
1301
+ } catch (e) {
1302
+ const data = e instanceof ApiException ? e.getResponseBody()["data"] : void 0;
1303
+ if (data !== null && typeof data === "object" && "release" in data) {
1304
+ return FundReleaseResult.fromRaw(data);
1305
+ }
1306
+ throw e;
1307
+ }
1308
+ return FundReleaseResult.fromRaw(raw["data"] ?? {});
1309
+ }
1310
+ };
1311
+
842
1312
  // src/data-objects/cover-fee-quote.ts
843
1313
  var CoverFeeQuote = class _CoverFeeQuote {
844
1314
  constructor(basis, base, ccFee, ccTotal, achFee, achTotal) {
@@ -1281,6 +1751,34 @@ var Invoices = class extends AbstractResource {
1281
1751
  }
1282
1752
  };
1283
1753
 
1754
+ // src/data-objects/application-status.ts
1755
+ var ApplicationStatus = class _ApplicationStatus {
1756
+ constructor(sid, name, status, applicationStatus, boarded = false, applicationSubmittedAt) {
1757
+ this.sid = sid;
1758
+ this.name = name;
1759
+ this.status = status;
1760
+ this.applicationStatus = applicationStatus;
1761
+ this.boarded = boarded;
1762
+ this.applicationSubmittedAt = applicationSubmittedAt;
1763
+ }
1764
+ sid;
1765
+ name;
1766
+ status;
1767
+ applicationStatus;
1768
+ boarded;
1769
+ applicationSubmittedAt;
1770
+ static fromRaw(data) {
1771
+ return new _ApplicationStatus(
1772
+ arrString(data, "sid"),
1773
+ arrString(data, "name"),
1774
+ arrString(data, "status"),
1775
+ arrString(data, "application_status"),
1776
+ arrBool(data, "boarded"),
1777
+ arrString(data, "application_submitted_at")
1778
+ );
1779
+ }
1780
+ };
1781
+
1284
1782
  // src/data-objects/form-link.ts
1285
1783
  var FormLink = class _FormLink {
1286
1784
  constructor(link) {
@@ -1394,6 +1892,19 @@ var Merchants = class extends AbstractResource {
1394
1892
  );
1395
1893
  return FormLink.fromRaw(raw["data"] ?? {});
1396
1894
  }
1895
+ /**
1896
+ * Where the merchant sits in onboarding — follow up an application sent with
1897
+ * {@link Merchants.getFormLink}. Prefer the `application_status_changed`
1898
+ * webhook to polling; poll only to reconcile after an outage.
1899
+ */
1900
+ async applicationStatus(sid) {
1901
+ const raw = await this.transport.request(
1902
+ "GET",
1903
+ "merchant/application-status",
1904
+ this.envelope({ sid })
1905
+ );
1906
+ return ApplicationStatus.fromRaw(raw["data"] ?? {});
1907
+ }
1397
1908
  };
1398
1909
 
1399
1910
  // src/data-objects/payment-method.ts
@@ -1816,6 +2327,342 @@ var RecurringPayments = class extends AbstractResource {
1816
2327
  }
1817
2328
  };
1818
2329
 
2330
+ // src/data-objects/subscribe-result.ts
2331
+ var SubscribeResult = class _SubscribeResult {
2332
+ constructor(subscriptionId, status, nextRunDate, transactionNumber, amount) {
2333
+ this.subscriptionId = subscriptionId;
2334
+ this.status = status;
2335
+ this.nextRunDate = nextRunDate;
2336
+ this.transactionNumber = transactionNumber;
2337
+ this.amount = amount;
2338
+ }
2339
+ subscriptionId;
2340
+ status;
2341
+ nextRunDate;
2342
+ transactionNumber;
2343
+ amount;
2344
+ static fromRaw(data) {
2345
+ return new _SubscribeResult(
2346
+ arrInt(data, "subscription_id"),
2347
+ arrString(data, "status"),
2348
+ arrString(data, "next_run_date"),
2349
+ arrString(data, "transaction_number"),
2350
+ arrString(data, "amount")
2351
+ );
2352
+ }
2353
+ };
2354
+
2355
+ // src/data-objects/subscription-item.ts
2356
+ var SubscriptionItem = class _SubscriptionItem {
2357
+ constructor(name, description, quantity, unitPrice, amount) {
2358
+ this.name = name;
2359
+ this.description = description;
2360
+ this.quantity = quantity;
2361
+ this.unitPrice = unitPrice;
2362
+ this.amount = amount;
2363
+ }
2364
+ name;
2365
+ description;
2366
+ quantity;
2367
+ unitPrice;
2368
+ amount;
2369
+ static fromRaw(data) {
2370
+ return new _SubscriptionItem(
2371
+ arrString(data, "name"),
2372
+ arrString(data, "description"),
2373
+ arrString(data, "quantity"),
2374
+ arrString(data, "unit_price"),
2375
+ arrString(data, "amount")
2376
+ );
2377
+ }
2378
+ };
2379
+
2380
+ // src/data-objects/subscription-plan.ts
2381
+ var SubscriptionPlan = class _SubscriptionPlan {
2382
+ constructor(id, name, description, recurrenceSchedule, status, subtotal, total, token, publicUrl, allowPublic = false, createdAt, items = []) {
2383
+ this.id = id;
2384
+ this.name = name;
2385
+ this.description = description;
2386
+ this.recurrenceSchedule = recurrenceSchedule;
2387
+ this.status = status;
2388
+ this.subtotal = subtotal;
2389
+ this.total = total;
2390
+ this.token = token;
2391
+ this.publicUrl = publicUrl;
2392
+ this.allowPublic = allowPublic;
2393
+ this.createdAt = createdAt;
2394
+ this.items = items;
2395
+ }
2396
+ id;
2397
+ name;
2398
+ description;
2399
+ recurrenceSchedule;
2400
+ status;
2401
+ subtotal;
2402
+ total;
2403
+ token;
2404
+ publicUrl;
2405
+ allowPublic;
2406
+ createdAt;
2407
+ items;
2408
+ static fromRaw(data) {
2409
+ return new _SubscriptionPlan(
2410
+ arrInt(data, "id"),
2411
+ arrString(data, "name"),
2412
+ arrString(data, "description"),
2413
+ arrString(data, "recurrence_schedule"),
2414
+ arrString(data, "status"),
2415
+ arrString(data, "subtotal"),
2416
+ arrString(data, "total"),
2417
+ arrString(data, "token"),
2418
+ arrString(data, "public_url"),
2419
+ arrBool(data, "allow_public"),
2420
+ arrString(data, "created_at"),
2421
+ arrArrayFrom(data, "items").map(SubscriptionItem.fromRaw)
2422
+ );
2423
+ }
2424
+ };
2425
+
2426
+ // src/resources/subscription-plans.ts
2427
+ var SubscriptionPlans = class extends AbstractResource {
2428
+ /**
2429
+ * List a merchant's plans, newest first.
2430
+ *
2431
+ * @param status `draft`, `active` or `archived`
2432
+ */
2433
+ async list(sid, status) {
2434
+ return this.paginate(
2435
+ "GET",
2436
+ "subscription-plan/list",
2437
+ this.envelope({ sid, status }),
2438
+ SubscriptionPlan.fromRaw
2439
+ );
2440
+ }
2441
+ async show(sid, subscriptionPlanId) {
2442
+ const raw = await this.transport.request(
2443
+ "GET",
2444
+ "subscription-plan/show",
2445
+ this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
2446
+ );
2447
+ return SubscriptionPlan.fromRaw(raw["data"] ?? {});
2448
+ }
2449
+ /**
2450
+ * Create a plan as a draft. Publish it before customers can subscribe.
2451
+ *
2452
+ * @param attributes
2453
+ * `name`, `recurrence_schedule` (`Weekly` | `Biweekly` | `FirstFifteenth` |
2454
+ * `Monthly` | `Yearly`) and `lines` are required. `lines[]` takes
2455
+ * `item_id` (a Merchant item), `name`, `quantity`, `unit_price` and
2456
+ * optional `description`. Optional: `description`, `allow_public` (list
2457
+ * the plan in the public catalog).
2458
+ */
2459
+ async create(sid, attributes) {
2460
+ const raw = await this.transport.request(
2461
+ "POST",
2462
+ "subscription-plan/create",
2463
+ this.envelope({ sid, ...attributes })
2464
+ );
2465
+ return SubscriptionPlan.fromRaw(raw["data"] ?? {});
2466
+ }
2467
+ /**
2468
+ * Replace a plan's fields and line items wholesale — send the full plan, not
2469
+ * just what changed. Existing subscribers are unaffected.
2470
+ *
2471
+ * @param attributes same shape as {@link SubscriptionPlans.create}
2472
+ */
2473
+ async edit(sid, subscriptionPlanId, attributes) {
2474
+ const raw = await this.transport.request(
2475
+ "PATCH",
2476
+ "subscription-plan/edit",
2477
+ this.envelope({ sid, subscription_plan_id: subscriptionPlanId, ...attributes })
2478
+ );
2479
+ return SubscriptionPlan.fromRaw(raw["data"] ?? {});
2480
+ }
2481
+ /** Delete a plan with no subscribers. A plan that has any must be archived instead. */
2482
+ async delete(sid, subscriptionPlanId) {
2483
+ const raw = await this.transport.request(
2484
+ "POST",
2485
+ "subscription-plan/delete",
2486
+ this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
2487
+ );
2488
+ return MessageResult.fromRaw(raw["data"] ?? raw);
2489
+ }
2490
+ /** Move a draft plan with at least one line item to active, so customers can subscribe. */
2491
+ async publish(sid, subscriptionPlanId) {
2492
+ const raw = await this.transport.request(
2493
+ "PATCH",
2494
+ "subscription-plan/publish",
2495
+ this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
2496
+ );
2497
+ return SubscriptionPlan.fromRaw(raw["data"] ?? {});
2498
+ }
2499
+ /** Stop new subscriptions and hide the plan from the public catalog. */
2500
+ async archive(sid, subscriptionPlanId) {
2501
+ const raw = await this.transport.request(
2502
+ "PATCH",
2503
+ "subscription-plan/archive",
2504
+ this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
2505
+ );
2506
+ return SubscriptionPlan.fromRaw(raw["data"] ?? {});
2507
+ }
2508
+ /**
2509
+ * Move an archived plan back to draft, to review and re-publish.
2510
+ * `allowPublic` stays off until the merchant opts back into the catalog.
2511
+ */
2512
+ async unarchive(sid, subscriptionPlanId) {
2513
+ const raw = await this.transport.request(
2514
+ "PATCH",
2515
+ "subscription-plan/unarchive",
2516
+ this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
2517
+ );
2518
+ return SubscriptionPlan.fromRaw(raw["data"] ?? {});
2519
+ }
2520
+ /**
2521
+ * Subscribe a customer to an active plan: charges the first payment to one
2522
+ * of the customer's saved payment methods and enrolls them.
2523
+ */
2524
+ async subscribe(sid, subscriptionPlanId, customerUuid, paymentMethodId) {
2525
+ const raw = await this.transport.request(
2526
+ "POST",
2527
+ "subscription-plan/subscribe",
2528
+ this.envelope({
2529
+ sid,
2530
+ subscription_plan_id: subscriptionPlanId,
2531
+ customer_uuid: customerUuid,
2532
+ payment_method: paymentMethodId
2533
+ })
2534
+ );
2535
+ return SubscribeResult.fromRaw(raw["data"] ?? {});
2536
+ }
2537
+ };
2538
+
2539
+ // src/data-objects/subscription.ts
2540
+ var Subscription = class _Subscription {
2541
+ constructor(id, subscriptionPlanId, planName, amount, recurrenceSchedule, startDate, endDate, lastRunDate, lastRunStatus, lastRunFailedCount, nextRunDate, status, pausedUntilDate, cancelledAt, cancelledBy, customerUuid, error, paymentMethod = new RecurringPaymentMethod(), items = []) {
2542
+ this.id = id;
2543
+ this.subscriptionPlanId = subscriptionPlanId;
2544
+ this.planName = planName;
2545
+ this.amount = amount;
2546
+ this.recurrenceSchedule = recurrenceSchedule;
2547
+ this.startDate = startDate;
2548
+ this.endDate = endDate;
2549
+ this.lastRunDate = lastRunDate;
2550
+ this.lastRunStatus = lastRunStatus;
2551
+ this.lastRunFailedCount = lastRunFailedCount;
2552
+ this.nextRunDate = nextRunDate;
2553
+ this.status = status;
2554
+ this.pausedUntilDate = pausedUntilDate;
2555
+ this.cancelledAt = cancelledAt;
2556
+ this.cancelledBy = cancelledBy;
2557
+ this.customerUuid = customerUuid;
2558
+ this.error = error;
2559
+ this.paymentMethod = paymentMethod;
2560
+ this.items = items;
2561
+ }
2562
+ id;
2563
+ subscriptionPlanId;
2564
+ planName;
2565
+ amount;
2566
+ recurrenceSchedule;
2567
+ startDate;
2568
+ endDate;
2569
+ lastRunDate;
2570
+ lastRunStatus;
2571
+ lastRunFailedCount;
2572
+ nextRunDate;
2573
+ status;
2574
+ pausedUntilDate;
2575
+ cancelledAt;
2576
+ cancelledBy;
2577
+ customerUuid;
2578
+ error;
2579
+ paymentMethod;
2580
+ items;
2581
+ static fromRaw(data) {
2582
+ return new _Subscription(
2583
+ arrInt(data, "id"),
2584
+ arrInt(data, "subscription_plan_id"),
2585
+ arrString(data, "plan_name"),
2586
+ arrString(data, "amount"),
2587
+ arrString(data, "recurrence_schedule"),
2588
+ arrString(data, "start_date"),
2589
+ arrString(data, "end_date"),
2590
+ arrString(data, "last_run_date"),
2591
+ arrString(data, "last_run_status"),
2592
+ arrInt(data, "last_run_failed_count"),
2593
+ arrString(data, "next_run_date"),
2594
+ arrString(data, "status"),
2595
+ arrString(data, "paused_until_date"),
2596
+ arrString(data, "cancelled_at"),
2597
+ arrString(data, "cancelled_by"),
2598
+ arrString(data, "customer_uuid"),
2599
+ arrString(data, "error"),
2600
+ RecurringPaymentMethod.fromRaw(arrObjectFrom(data, ["payment_method"])),
2601
+ arrArrayFrom(data, "items").map(SubscriptionItem.fromRaw)
2602
+ );
2603
+ }
2604
+ };
2605
+
2606
+ // src/resources/subscriptions.ts
2607
+ var Subscriptions = class extends AbstractResource {
2608
+ /**
2609
+ * List a merchant's subscriptions, newest first.
2610
+ *
2611
+ * @param filters `status` — Active | Failed | Paused | Cancelled | Ended;
2612
+ * `customer_uuid`
2613
+ */
2614
+ async list(sid, filters = {}) {
2615
+ return this.paginate(
2616
+ "GET",
2617
+ "subscription/list",
2618
+ this.envelope({ sid }, filters),
2619
+ Subscription.fromRaw
2620
+ );
2621
+ }
2622
+ async show(sid, subscriptionId) {
2623
+ const raw = await this.transport.request(
2624
+ "GET",
2625
+ "subscription/show",
2626
+ this.envelope({ sid, subscription_id: subscriptionId })
2627
+ );
2628
+ return Subscription.fromRaw(raw["data"] ?? {});
2629
+ }
2630
+ /**
2631
+ * Pause a subscription until `pauseUntilDate` (Y-m-d, in the future), or
2632
+ * indefinitely when it is omitted.
2633
+ */
2634
+ async pause(sid, subscriptionId, pauseUntilDate) {
2635
+ const raw = await this.transport.request(
2636
+ "PATCH",
2637
+ "subscription/pause",
2638
+ this.envelope({
2639
+ sid,
2640
+ subscription_id: subscriptionId,
2641
+ pause_until_date: pauseUntilDate
2642
+ })
2643
+ );
2644
+ return Subscription.fromRaw(raw["data"] ?? {});
2645
+ }
2646
+ /** Reactivate a paused subscription and recompute its next charge date. */
2647
+ async resume(sid, subscriptionId) {
2648
+ const raw = await this.transport.request(
2649
+ "PATCH",
2650
+ "subscription/resume",
2651
+ this.envelope({ sid, subscription_id: subscriptionId })
2652
+ );
2653
+ return Subscription.fromRaw(raw["data"] ?? {});
2654
+ }
2655
+ /** Cancel a subscription permanently; no further charges are made. */
2656
+ async cancel(sid, subscriptionId) {
2657
+ const raw = await this.transport.request(
2658
+ "PATCH",
2659
+ "subscription/cancel",
2660
+ this.envelope({ sid, subscription_id: subscriptionId })
2661
+ );
2662
+ return Subscription.fromRaw(raw["data"] ?? {});
2663
+ }
2664
+ };
2665
+
1819
2666
  // src/data-objects/tokenize-result.ts
1820
2667
  var TokenizeResult = class _TokenizeResult {
1821
2668
  constructor(token) {
@@ -1878,6 +2725,40 @@ var Transactions = class extends AbstractResource {
1878
2725
  );
1879
2726
  return TokenizeResult.fromRaw(raw["data"] ?? {});
1880
2727
  }
2728
+ /**
2729
+ * Place a hold on a card without moving money. Pass a `token` or the raw
2730
+ * card fields, as for {@link Transactions.chargeCard}.
2731
+ *
2732
+ * The returned `transactionNumber` is the handle on the authorization:
2733
+ * collect it with {@link Transactions.capture}, or release the hold with
2734
+ * {@link Transactions.void} (type `CC`). Capture promptly — the issuer
2735
+ * releases an uncaptured hold on its own schedule.
2736
+ */
2737
+ async authorize(sid, attributes) {
2738
+ const raw = await this.transport.request(
2739
+ "POST",
2740
+ "transaction/authorize",
2741
+ this.envelope({ sid, ...attributes })
2742
+ );
2743
+ return Transaction.fromRaw(raw["data"] ?? {});
2744
+ }
2745
+ /**
2746
+ * Capture an authorization. Omit `amount` to capture the full authorized
2747
+ * amount, or pass less to capture part of it.
2748
+ *
2749
+ * An authorization is captured once: a partial capture settles that amount
2750
+ * and releases the rest to the cardholder.
2751
+ *
2752
+ * @param transactionId the `transactionNumber` returned by {@link Transactions.authorize}
2753
+ */
2754
+ async capture(sid, transactionId, amount) {
2755
+ const raw = await this.transport.request(
2756
+ "POST",
2757
+ "transaction/capture",
2758
+ this.envelope({ sid, transaction_id: transactionId, amount })
2759
+ );
2760
+ return MessageResult.fromRaw(raw["data"] ?? raw);
2761
+ }
1881
2762
  async refund(sid, attributes) {
1882
2763
  const raw = await this.transport.request(
1883
2764
  "POST",
@@ -1907,6 +2788,11 @@ var Client = class {
1907
2788
  recurringPayments;
1908
2789
  invoices;
1909
2790
  recurringInvoices;
2791
+ chargebacks;
2792
+ documents;
2793
+ funds;
2794
+ subscriptionPlans;
2795
+ subscriptions;
1910
2796
  _config;
1911
2797
  constructor(token, baseUrl = DEFAULT_BASE_URL) {
1912
2798
  this._config = token instanceof Config ? token : new Config(token, baseUrl);
@@ -1920,6 +2806,11 @@ var Client = class {
1920
2806
  this.recurringPayments = new RecurringPayments(transport);
1921
2807
  this.invoices = new Invoices(transport);
1922
2808
  this.recurringInvoices = new RecurringInvoices(transport);
2809
+ this.chargebacks = new Chargebacks(transport);
2810
+ this.documents = new Documents(transport);
2811
+ this.funds = new Funds(transport);
2812
+ this.subscriptionPlans = new SubscriptionPlans(transport);
2813
+ this.subscriptions = new Subscriptions(transport);
1923
2814
  }
1924
2815
  config() {
1925
2816
  return this._config;
@@ -1929,7 +2820,9 @@ var Client = class {
1929
2820
  0 && (module.exports = {
1930
2821
  Address,
1931
2822
  ApiException,
2823
+ ApplicationStatus,
1932
2824
  AuthenticationException,
2825
+ Chargeback,
1933
2826
  Client,
1934
2827
  Config,
1935
2828
  ConnectionException,
@@ -1941,7 +2834,12 @@ var Client = class {
1941
2834
  DepositGroup,
1942
2835
  DepositWithTransactions,
1943
2836
  DimeException,
2837
+ DocumentUploadFailure,
2838
+ DocumentUploadResult,
1944
2839
  FormLink,
2840
+ FundRelease,
2841
+ FundReleaseResult,
2842
+ HeldBalance,
1945
2843
  Invoice,
1946
2844
  InvoiceCustomer,
1947
2845
  InvoiceEvent,
@@ -1950,6 +2848,7 @@ var Client = class {
1950
2848
  InvoiceLink,
1951
2849
  InvoicePayment,
1952
2850
  Merchant,
2851
+ MerchantDocument,
1953
2852
  MessageResult,
1954
2853
  NotFoundException,
1955
2854
  PaymentMethod,
@@ -1958,7 +2857,13 @@ var Client = class {
1958
2857
  RecurringInvoice,
1959
2858
  RecurringPayment,
1960
2859
  RecurringPaymentMethod,
2860
+ ReleasableTransaction,
2861
+ ReleasableTransactions,
1961
2862
  ServerException,
2863
+ SubscribeResult,
2864
+ Subscription,
2865
+ SubscriptionItem,
2866
+ SubscriptionPlan,
1962
2867
  TokenizeResult,
1963
2868
  Transaction,
1964
2869
  TransactionAddress,