@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/README.md +164 -4
- package/dist/index.cjs +911 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +587 -88
- package/dist/index.d.ts +587 -88
- package/dist/index.js +897 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
3
|
+
var VERSION = "1.4.0";
|
|
4
4
|
var Config = class {
|
|
5
5
|
token;
|
|
6
6
|
baseUrl;
|
|
@@ -184,11 +184,7 @@ var Transport = class {
|
|
|
184
184
|
url += "?" + new URLSearchParams(params).toString();
|
|
185
185
|
}
|
|
186
186
|
const sendBody = !bodyless && Object.keys(body).length > 0;
|
|
187
|
-
const headers =
|
|
188
|
-
Authorization: `Bearer ${this.config.token}`,
|
|
189
|
-
Accept: "application/json",
|
|
190
|
-
"X-Dime-Sdk": `dime-js-sdk/${VERSION}`
|
|
191
|
-
};
|
|
187
|
+
const headers = this.headers();
|
|
192
188
|
if (sendBody) headers["Content-Type"] = "application/json";
|
|
193
189
|
const init = {
|
|
194
190
|
method,
|
|
@@ -197,6 +193,32 @@ var Transport = class {
|
|
|
197
193
|
};
|
|
198
194
|
return this.attempt(url, init, 0);
|
|
199
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Execute a `multipart/form-data` request and return the decoded JSON body.
|
|
198
|
+
*
|
|
199
|
+
* Multipart has no JSON parsing, so the envelope is sent as bracketed form
|
|
200
|
+
* fields (`data[sid]=…`) — a single `data` field holding JSON would be read
|
|
201
|
+
* as a plain string. No Content-Type is set here: fetch derives it, boundary
|
|
202
|
+
* included, from the FormData body.
|
|
203
|
+
*/
|
|
204
|
+
async requestMultipart(method, path, body, files) {
|
|
205
|
+
const url = `${this.config.baseUri()}${path.replace(/^\//, "")}`;
|
|
206
|
+
const form = new FormData();
|
|
207
|
+
for (const [name, value] of Object.entries(flattenParams(body))) {
|
|
208
|
+
form.append(name, value);
|
|
209
|
+
}
|
|
210
|
+
for (const file of files) {
|
|
211
|
+
form.append(file.field, file.content, file.filename);
|
|
212
|
+
}
|
|
213
|
+
return this.attempt(url, { method, headers: this.headers(), body: form }, 0);
|
|
214
|
+
}
|
|
215
|
+
headers() {
|
|
216
|
+
return {
|
|
217
|
+
Authorization: `Bearer ${this.config.token}`,
|
|
218
|
+
Accept: "application/json",
|
|
219
|
+
"X-Dime-Sdk": `dime-js-sdk/${VERSION}`
|
|
220
|
+
};
|
|
221
|
+
}
|
|
200
222
|
async attempt(url, init, attempt) {
|
|
201
223
|
let response;
|
|
202
224
|
try {
|
|
@@ -471,6 +493,103 @@ var Addresses = class extends AbstractResource {
|
|
|
471
493
|
}
|
|
472
494
|
};
|
|
473
495
|
|
|
496
|
+
// src/data-objects/chargeback.ts
|
|
497
|
+
var Chargeback = class _Chargeback {
|
|
498
|
+
constructor(transactionInfoId, parentTransactionInfoId, gatewayTransactionId, transactionNumber, invoiceNumber, chargebackDate, merchantChargebackDate, transactionAmount, chargebackAmount, cardBrand, ccLastFour, payeeName, daysToRepresent, representmentDate, merchantRepresentmentDate, representmentStatus, result, chargebackCode, chargebackResponseCode, resolved = false) {
|
|
499
|
+
this.transactionInfoId = transactionInfoId;
|
|
500
|
+
this.parentTransactionInfoId = parentTransactionInfoId;
|
|
501
|
+
this.gatewayTransactionId = gatewayTransactionId;
|
|
502
|
+
this.transactionNumber = transactionNumber;
|
|
503
|
+
this.invoiceNumber = invoiceNumber;
|
|
504
|
+
this.chargebackDate = chargebackDate;
|
|
505
|
+
this.merchantChargebackDate = merchantChargebackDate;
|
|
506
|
+
this.transactionAmount = transactionAmount;
|
|
507
|
+
this.chargebackAmount = chargebackAmount;
|
|
508
|
+
this.cardBrand = cardBrand;
|
|
509
|
+
this.ccLastFour = ccLastFour;
|
|
510
|
+
this.payeeName = payeeName;
|
|
511
|
+
this.daysToRepresent = daysToRepresent;
|
|
512
|
+
this.representmentDate = representmentDate;
|
|
513
|
+
this.merchantRepresentmentDate = merchantRepresentmentDate;
|
|
514
|
+
this.representmentStatus = representmentStatus;
|
|
515
|
+
this.result = result;
|
|
516
|
+
this.chargebackCode = chargebackCode;
|
|
517
|
+
this.chargebackResponseCode = chargebackResponseCode;
|
|
518
|
+
this.resolved = resolved;
|
|
519
|
+
}
|
|
520
|
+
transactionInfoId;
|
|
521
|
+
parentTransactionInfoId;
|
|
522
|
+
gatewayTransactionId;
|
|
523
|
+
transactionNumber;
|
|
524
|
+
invoiceNumber;
|
|
525
|
+
chargebackDate;
|
|
526
|
+
merchantChargebackDate;
|
|
527
|
+
transactionAmount;
|
|
528
|
+
chargebackAmount;
|
|
529
|
+
cardBrand;
|
|
530
|
+
ccLastFour;
|
|
531
|
+
payeeName;
|
|
532
|
+
daysToRepresent;
|
|
533
|
+
representmentDate;
|
|
534
|
+
merchantRepresentmentDate;
|
|
535
|
+
representmentStatus;
|
|
536
|
+
result;
|
|
537
|
+
chargebackCode;
|
|
538
|
+
chargebackResponseCode;
|
|
539
|
+
resolved;
|
|
540
|
+
static fromRaw(data) {
|
|
541
|
+
return new _Chargeback(
|
|
542
|
+
arrString(data, "transaction_info_id"),
|
|
543
|
+
arrString(data, "parent_transaction_info_id"),
|
|
544
|
+
arrString(data, "gateway_transaction_id"),
|
|
545
|
+
arrString(data, "transaction_number"),
|
|
546
|
+
arrString(data, "invoice_number"),
|
|
547
|
+
arrString(data, "chargeback_date"),
|
|
548
|
+
arrString(data, "merchant_chargeback_date"),
|
|
549
|
+
arrString(data, "transaction_amount"),
|
|
550
|
+
arrString(data, "chargeback_amount"),
|
|
551
|
+
arrString(data, "card_brand"),
|
|
552
|
+
arrString(data, "cc_last_four"),
|
|
553
|
+
arrString(data, "payee_name"),
|
|
554
|
+
arrInt(data, "days_to_represent"),
|
|
555
|
+
arrString(data, "representment_date"),
|
|
556
|
+
arrString(data, "merchant_representment_date"),
|
|
557
|
+
arrString(data, "representment_status"),
|
|
558
|
+
arrString(data, "result"),
|
|
559
|
+
arrString(data, "chargeback_code"),
|
|
560
|
+
arrString(data, "chargeback_response_code"),
|
|
561
|
+
arrBool(data, "resolved")
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/resources/chargebacks.ts
|
|
567
|
+
var Chargebacks = class extends AbstractResource {
|
|
568
|
+
/**
|
|
569
|
+
* List a merchant's chargebacks.
|
|
570
|
+
*
|
|
571
|
+
* @param filters `start_date` and `end_date` (UTC, `Y-m-d H:i:s`, sent
|
|
572
|
+
* together), `representment_status` (free text from the processor, e.g.
|
|
573
|
+
* `New` or `Resolved`)
|
|
574
|
+
*/
|
|
575
|
+
async list(sid, filters = {}) {
|
|
576
|
+
return this.paginate(
|
|
577
|
+
"GET",
|
|
578
|
+
"chargeback/list",
|
|
579
|
+
this.envelope({ sid }, filters),
|
|
580
|
+
Chargeback.fromRaw
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
async show(sid, transactionInfoId) {
|
|
584
|
+
const raw = await this.transport.request(
|
|
585
|
+
"GET",
|
|
586
|
+
"chargeback/show",
|
|
587
|
+
this.envelope({ sid, transaction_info_id: transactionInfoId })
|
|
588
|
+
);
|
|
589
|
+
return Chargeback.fromRaw(raw["data"] ?? {});
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
474
593
|
// src/data-objects/customer.ts
|
|
475
594
|
var Customer = class _Customer {
|
|
476
595
|
constructor(uuid, firstName, lastName, phone, email, addr1, addr2, addr3, city, state, zip, country) {
|
|
@@ -777,6 +896,343 @@ var Deposits = class extends AbstractResource {
|
|
|
777
896
|
}
|
|
778
897
|
};
|
|
779
898
|
|
|
899
|
+
// src/data-objects/document-upload-failure.ts
|
|
900
|
+
var DocumentUploadFailure = class _DocumentUploadFailure {
|
|
901
|
+
constructor(fileName, reason) {
|
|
902
|
+
this.fileName = fileName;
|
|
903
|
+
this.reason = reason;
|
|
904
|
+
}
|
|
905
|
+
fileName;
|
|
906
|
+
reason;
|
|
907
|
+
static fromRaw(data) {
|
|
908
|
+
return new _DocumentUploadFailure(arrString(data, "file_name"), arrString(data, "reason"));
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
// src/data-objects/merchant-document.ts
|
|
913
|
+
var MerchantDocument = class _MerchantDocument {
|
|
914
|
+
constructor(uuid, fileName, docType, chargebackTransactionInfoId, size, uploadedAt, uploadedVia, sentToProcessorAt, processorResponse) {
|
|
915
|
+
this.uuid = uuid;
|
|
916
|
+
this.fileName = fileName;
|
|
917
|
+
this.docType = docType;
|
|
918
|
+
this.chargebackTransactionInfoId = chargebackTransactionInfoId;
|
|
919
|
+
this.size = size;
|
|
920
|
+
this.uploadedAt = uploadedAt;
|
|
921
|
+
this.uploadedVia = uploadedVia;
|
|
922
|
+
this.sentToProcessorAt = sentToProcessorAt;
|
|
923
|
+
this.processorResponse = processorResponse;
|
|
924
|
+
}
|
|
925
|
+
uuid;
|
|
926
|
+
fileName;
|
|
927
|
+
docType;
|
|
928
|
+
chargebackTransactionInfoId;
|
|
929
|
+
size;
|
|
930
|
+
uploadedAt;
|
|
931
|
+
uploadedVia;
|
|
932
|
+
sentToProcessorAt;
|
|
933
|
+
processorResponse;
|
|
934
|
+
static fromRaw(data) {
|
|
935
|
+
const sent = Array.isArray(data["sent_to_processor"]) ? data["sent_to_processor"] : [];
|
|
936
|
+
const [sentAt, processorResponse] = sent.map(
|
|
937
|
+
(value) => value === null || value === void 0 ? void 0 : String(value)
|
|
938
|
+
);
|
|
939
|
+
return new _MerchantDocument(
|
|
940
|
+
arrString(data, "uuid"),
|
|
941
|
+
arrString(data, "file_name"),
|
|
942
|
+
arrString(data, "doc_type"),
|
|
943
|
+
arrString(data, "chargeback_transaction_info_id"),
|
|
944
|
+
arrInt(data, "size"),
|
|
945
|
+
arrString(data, "uploaded_at"),
|
|
946
|
+
arrString(data, "uploaded_via"),
|
|
947
|
+
sentAt,
|
|
948
|
+
processorResponse
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// src/data-objects/document-upload-result.ts
|
|
954
|
+
var DocumentUploadResult = class _DocumentUploadResult {
|
|
955
|
+
constructor(message, documents = [], failed = []) {
|
|
956
|
+
this.message = message;
|
|
957
|
+
this.documents = documents;
|
|
958
|
+
this.failed = failed;
|
|
959
|
+
}
|
|
960
|
+
message;
|
|
961
|
+
documents;
|
|
962
|
+
failed;
|
|
963
|
+
static fromRaw(data) {
|
|
964
|
+
return new _DocumentUploadResult(
|
|
965
|
+
arrString(data, "message"),
|
|
966
|
+
arrArrayFrom(data, "documents").map(MerchantDocument.fromRaw),
|
|
967
|
+
arrArrayFrom(data, "failed").map(DocumentUploadFailure.fromRaw)
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// src/resources/documents.ts
|
|
973
|
+
var Documents = class extends AbstractResource {
|
|
974
|
+
/**
|
|
975
|
+
* Upload up to 10 documents for a merchant (PDF, JPG, PNG, DOC, DOCX or RTF,
|
|
976
|
+
* each 9 MB or smaller). Sent as `multipart/form-data`.
|
|
977
|
+
*
|
|
978
|
+
* Files are stored independently: check `failed` on the result and re-send
|
|
979
|
+
* only those. A 413 means the request as a whole was too large — send fewer
|
|
980
|
+
* files per request.
|
|
981
|
+
*
|
|
982
|
+
* Uploading does not forward the document to the processor; our team
|
|
983
|
+
* reviews it and does that.
|
|
984
|
+
*
|
|
985
|
+
* @param docType `Verification`, `FraudHolds`, `Underwriting` or
|
|
986
|
+
* `RetrievalRequest` (evidence for a chargeback or retrieval request)
|
|
987
|
+
* @param chargebackTransactionInfoId attach the files as evidence to this
|
|
988
|
+
* chargeback (its `transactionInfoId`)
|
|
989
|
+
*/
|
|
990
|
+
async upload(sid, docType, files, chargebackTransactionInfoId) {
|
|
991
|
+
const raw = await this.transport.requestMultipart(
|
|
992
|
+
"POST",
|
|
993
|
+
"document/upload",
|
|
994
|
+
this.envelope({
|
|
995
|
+
sid,
|
|
996
|
+
doc_type: docType,
|
|
997
|
+
chargeback_transaction_info_id: chargebackTransactionInfoId
|
|
998
|
+
}),
|
|
999
|
+
files.map((file) => ({ field: "files[]", ...toBlob(file) }))
|
|
1000
|
+
);
|
|
1001
|
+
return DocumentUploadResult.fromRaw(raw["data"] ?? {});
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* List the documents held for a merchant, whether uploaded through the API,
|
|
1005
|
+
* by our team, or through the merchant application.
|
|
1006
|
+
*
|
|
1007
|
+
* @param filters `doc_type`, `chargeback_transaction_info_id`
|
|
1008
|
+
*/
|
|
1009
|
+
async list(sid, filters = {}) {
|
|
1010
|
+
const raw = await this.transport.request(
|
|
1011
|
+
"GET",
|
|
1012
|
+
"document/list",
|
|
1013
|
+
this.envelope({ sid }, filters)
|
|
1014
|
+
);
|
|
1015
|
+
const documents = Array.isArray(raw["data"]) ? raw["data"] : [];
|
|
1016
|
+
return documents.map(MerchantDocument.fromRaw);
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
function toBlob(file) {
|
|
1020
|
+
if (file instanceof Blob) {
|
|
1021
|
+
const name = file.name;
|
|
1022
|
+
return { content: file, filename: typeof name === "string" && name !== "" ? name : "document" };
|
|
1023
|
+
}
|
|
1024
|
+
const content = file.content instanceof Blob ? file.content : new Blob([file.content], file.contentType ? { type: file.contentType } : {});
|
|
1025
|
+
return { content, filename: file.filename };
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/data-objects/fund-release.ts
|
|
1029
|
+
var FundRelease = class _FundRelease {
|
|
1030
|
+
constructor(id, amount, fee, status, statusLabel, idempotencyKey, transactionInfoIds = [], failureReason, requestedAt, completedAt) {
|
|
1031
|
+
this.id = id;
|
|
1032
|
+
this.amount = amount;
|
|
1033
|
+
this.fee = fee;
|
|
1034
|
+
this.status = status;
|
|
1035
|
+
this.statusLabel = statusLabel;
|
|
1036
|
+
this.idempotencyKey = idempotencyKey;
|
|
1037
|
+
this.transactionInfoIds = transactionInfoIds;
|
|
1038
|
+
this.failureReason = failureReason;
|
|
1039
|
+
this.requestedAt = requestedAt;
|
|
1040
|
+
this.completedAt = completedAt;
|
|
1041
|
+
}
|
|
1042
|
+
id;
|
|
1043
|
+
amount;
|
|
1044
|
+
fee;
|
|
1045
|
+
status;
|
|
1046
|
+
statusLabel;
|
|
1047
|
+
idempotencyKey;
|
|
1048
|
+
transactionInfoIds;
|
|
1049
|
+
failureReason;
|
|
1050
|
+
requestedAt;
|
|
1051
|
+
completedAt;
|
|
1052
|
+
static fromRaw(data) {
|
|
1053
|
+
const ids = Array.isArray(data["transaction_info_ids"]) ? data["transaction_info_ids"].map(String) : [];
|
|
1054
|
+
return new _FundRelease(
|
|
1055
|
+
arrInt(data, "id"),
|
|
1056
|
+
arrString(data, "amount"),
|
|
1057
|
+
arrString(data, "fee"),
|
|
1058
|
+
arrString(data, "status"),
|
|
1059
|
+
arrString(data, "status_label"),
|
|
1060
|
+
arrString(data, "idempotency_key"),
|
|
1061
|
+
ids,
|
|
1062
|
+
arrString(data, "failure_reason"),
|
|
1063
|
+
arrString(data, "requested_at"),
|
|
1064
|
+
arrString(data, "completed_at")
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
// src/data-objects/fund-release-result.ts
|
|
1070
|
+
var FundReleaseResult = class _FundReleaseResult {
|
|
1071
|
+
constructor(sid, replayed = false, release = new FundRelease()) {
|
|
1072
|
+
this.sid = sid;
|
|
1073
|
+
this.replayed = replayed;
|
|
1074
|
+
this.release = release;
|
|
1075
|
+
}
|
|
1076
|
+
sid;
|
|
1077
|
+
replayed;
|
|
1078
|
+
release;
|
|
1079
|
+
static fromRaw(data) {
|
|
1080
|
+
return new _FundReleaseResult(
|
|
1081
|
+
arrString(data, "sid"),
|
|
1082
|
+
arrBool(data, "replayed"),
|
|
1083
|
+
FundRelease.fromRaw(arrObjectFrom(data, ["release"]))
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// src/data-objects/held-balance.ts
|
|
1089
|
+
var HeldBalance = class _HeldBalance {
|
|
1090
|
+
constructor(sid, available, pending, reserve, atRisk, owedToSplit, unresolved, releaseFee, releasable, achSettlementDays, achOutEnabled = false, achOutLimitRemaining) {
|
|
1091
|
+
this.sid = sid;
|
|
1092
|
+
this.available = available;
|
|
1093
|
+
this.pending = pending;
|
|
1094
|
+
this.reserve = reserve;
|
|
1095
|
+
this.atRisk = atRisk;
|
|
1096
|
+
this.owedToSplit = owedToSplit;
|
|
1097
|
+
this.unresolved = unresolved;
|
|
1098
|
+
this.releaseFee = releaseFee;
|
|
1099
|
+
this.releasable = releasable;
|
|
1100
|
+
this.achSettlementDays = achSettlementDays;
|
|
1101
|
+
this.achOutEnabled = achOutEnabled;
|
|
1102
|
+
this.achOutLimitRemaining = achOutLimitRemaining;
|
|
1103
|
+
}
|
|
1104
|
+
sid;
|
|
1105
|
+
available;
|
|
1106
|
+
pending;
|
|
1107
|
+
reserve;
|
|
1108
|
+
atRisk;
|
|
1109
|
+
owedToSplit;
|
|
1110
|
+
unresolved;
|
|
1111
|
+
releaseFee;
|
|
1112
|
+
releasable;
|
|
1113
|
+
achSettlementDays;
|
|
1114
|
+
achOutEnabled;
|
|
1115
|
+
achOutLimitRemaining;
|
|
1116
|
+
static fromRaw(data) {
|
|
1117
|
+
return new _HeldBalance(
|
|
1118
|
+
arrString(data, "sid"),
|
|
1119
|
+
arrString(data, "available"),
|
|
1120
|
+
arrString(data, "pending"),
|
|
1121
|
+
arrString(data, "reserve"),
|
|
1122
|
+
arrString(data, "at_risk"),
|
|
1123
|
+
arrString(data, "owed_to_split"),
|
|
1124
|
+
arrString(data, "unresolved"),
|
|
1125
|
+
arrString(data, "release_fee"),
|
|
1126
|
+
arrString(data, "releasable"),
|
|
1127
|
+
arrInt(data, "ach_settlement_days"),
|
|
1128
|
+
arrBool(data, "ach_out_enabled"),
|
|
1129
|
+
arrString(data, "ach_out_limit_remaining")
|
|
1130
|
+
);
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
// src/data-objects/releasable-transaction.ts
|
|
1135
|
+
var ReleasableTransaction = class _ReleasableTransaction {
|
|
1136
|
+
constructor(transactionInfoId, type, transactionDate, grossAmount, netAmount, splitAmount, amount) {
|
|
1137
|
+
this.transactionInfoId = transactionInfoId;
|
|
1138
|
+
this.type = type;
|
|
1139
|
+
this.transactionDate = transactionDate;
|
|
1140
|
+
this.grossAmount = grossAmount;
|
|
1141
|
+
this.netAmount = netAmount;
|
|
1142
|
+
this.splitAmount = splitAmount;
|
|
1143
|
+
this.amount = amount;
|
|
1144
|
+
}
|
|
1145
|
+
transactionInfoId;
|
|
1146
|
+
type;
|
|
1147
|
+
transactionDate;
|
|
1148
|
+
grossAmount;
|
|
1149
|
+
netAmount;
|
|
1150
|
+
splitAmount;
|
|
1151
|
+
amount;
|
|
1152
|
+
static fromRaw(data) {
|
|
1153
|
+
return new _ReleasableTransaction(
|
|
1154
|
+
arrString(data, "transaction_info_id"),
|
|
1155
|
+
arrString(data, "type"),
|
|
1156
|
+
arrString(data, "transaction_date"),
|
|
1157
|
+
arrString(data, "gross_amount"),
|
|
1158
|
+
arrString(data, "net_amount"),
|
|
1159
|
+
arrString(data, "split_amount"),
|
|
1160
|
+
arrString(data, "amount")
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
// src/data-objects/releasable-transactions.ts
|
|
1166
|
+
var ReleasableTransactions = class _ReleasableTransactions {
|
|
1167
|
+
constructor(sid, transactions = [], total, truncated = false) {
|
|
1168
|
+
this.sid = sid;
|
|
1169
|
+
this.transactions = transactions;
|
|
1170
|
+
this.total = total;
|
|
1171
|
+
this.truncated = truncated;
|
|
1172
|
+
}
|
|
1173
|
+
sid;
|
|
1174
|
+
transactions;
|
|
1175
|
+
total;
|
|
1176
|
+
truncated;
|
|
1177
|
+
static fromRaw(data) {
|
|
1178
|
+
return new _ReleasableTransactions(
|
|
1179
|
+
arrString(data, "sid"),
|
|
1180
|
+
arrArrayFrom(data, "transactions").map(ReleasableTransaction.fromRaw),
|
|
1181
|
+
arrString(data, "total"),
|
|
1182
|
+
arrBool(data, "truncated")
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
// src/resources/funds.ts
|
|
1188
|
+
var Funds = class extends AbstractResource {
|
|
1189
|
+
/** The merchant's balance at the processor, and how much is releasable today. */
|
|
1190
|
+
async balance(sid) {
|
|
1191
|
+
const raw = await this.transport.request("GET", "funds/balance", this.envelope({ sid }));
|
|
1192
|
+
return HeldBalance.fromRaw(raw["data"] ?? {});
|
|
1193
|
+
}
|
|
1194
|
+
/** The payments that can be released right now — the list to release by `transaction_info_ids`. */
|
|
1195
|
+
async transactions(sid) {
|
|
1196
|
+
const raw = await this.transport.request("GET", "funds/transactions", this.envelope({ sid }));
|
|
1197
|
+
return ReleasableTransactions.fromRaw(raw["data"] ?? {});
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Send part of a merchant's held balance to the bank account on file.
|
|
1201
|
+
*
|
|
1202
|
+
* Use a fresh `idempotencyKey` per intended release and reuse it when
|
|
1203
|
+
* retrying: a retry with the same key and request returns the original
|
|
1204
|
+
* release instead of sending the money again. The SDK's own retries of
|
|
1205
|
+
* timeouts and 5xx responses resend the same key, so they are safe.
|
|
1206
|
+
*
|
|
1207
|
+
* Check `release.status`, not only whether this resolved. A declined release
|
|
1208
|
+
* (`failed`) is returned rather than thrown, alongside `released` and
|
|
1209
|
+
* `unknown`. Refusals that create no release — a transaction that does not
|
|
1210
|
+
* qualify, more than is releasable, a key reused for a different request, a
|
|
1211
|
+
* release already in flight — throw an {@link ApiException} whose response
|
|
1212
|
+
* body carries the detail (`data.ineligible`, `data.releasable`).
|
|
1213
|
+
*
|
|
1214
|
+
* @param attributes exactly one of `amount` (dollars, at most two decimal
|
|
1215
|
+
* places) or `transaction_info_ids` (up to 100, all or nothing)
|
|
1216
|
+
*/
|
|
1217
|
+
async release(sid, idempotencyKey, attributes) {
|
|
1218
|
+
let raw;
|
|
1219
|
+
try {
|
|
1220
|
+
raw = await this.transport.request(
|
|
1221
|
+
"POST",
|
|
1222
|
+
"funds/release",
|
|
1223
|
+
this.envelope({ sid, idempotency_key: idempotencyKey, ...attributes })
|
|
1224
|
+
);
|
|
1225
|
+
} catch (e) {
|
|
1226
|
+
const data = e instanceof ApiException ? e.getResponseBody()["data"] : void 0;
|
|
1227
|
+
if (data !== null && typeof data === "object" && "release" in data) {
|
|
1228
|
+
return FundReleaseResult.fromRaw(data);
|
|
1229
|
+
}
|
|
1230
|
+
throw e;
|
|
1231
|
+
}
|
|
1232
|
+
return FundReleaseResult.fromRaw(raw["data"] ?? {});
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
|
|
780
1236
|
// src/data-objects/cover-fee-quote.ts
|
|
781
1237
|
var CoverFeeQuote = class _CoverFeeQuote {
|
|
782
1238
|
constructor(basis, base, ccFee, ccTotal, achFee, achTotal) {
|
|
@@ -1219,6 +1675,34 @@ var Invoices = class extends AbstractResource {
|
|
|
1219
1675
|
}
|
|
1220
1676
|
};
|
|
1221
1677
|
|
|
1678
|
+
// src/data-objects/application-status.ts
|
|
1679
|
+
var ApplicationStatus = class _ApplicationStatus {
|
|
1680
|
+
constructor(sid, name, status, applicationStatus, boarded = false, applicationSubmittedAt) {
|
|
1681
|
+
this.sid = sid;
|
|
1682
|
+
this.name = name;
|
|
1683
|
+
this.status = status;
|
|
1684
|
+
this.applicationStatus = applicationStatus;
|
|
1685
|
+
this.boarded = boarded;
|
|
1686
|
+
this.applicationSubmittedAt = applicationSubmittedAt;
|
|
1687
|
+
}
|
|
1688
|
+
sid;
|
|
1689
|
+
name;
|
|
1690
|
+
status;
|
|
1691
|
+
applicationStatus;
|
|
1692
|
+
boarded;
|
|
1693
|
+
applicationSubmittedAt;
|
|
1694
|
+
static fromRaw(data) {
|
|
1695
|
+
return new _ApplicationStatus(
|
|
1696
|
+
arrString(data, "sid"),
|
|
1697
|
+
arrString(data, "name"),
|
|
1698
|
+
arrString(data, "status"),
|
|
1699
|
+
arrString(data, "application_status"),
|
|
1700
|
+
arrBool(data, "boarded"),
|
|
1701
|
+
arrString(data, "application_submitted_at")
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
|
|
1222
1706
|
// src/data-objects/form-link.ts
|
|
1223
1707
|
var FormLink = class _FormLink {
|
|
1224
1708
|
constructor(link) {
|
|
@@ -1332,6 +1816,19 @@ var Merchants = class extends AbstractResource {
|
|
|
1332
1816
|
);
|
|
1333
1817
|
return FormLink.fromRaw(raw["data"] ?? {});
|
|
1334
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Where the merchant sits in onboarding — follow up an application sent with
|
|
1821
|
+
* {@link Merchants.getFormLink}. Prefer the `application_status_changed`
|
|
1822
|
+
* webhook to polling; poll only to reconcile after an outage.
|
|
1823
|
+
*/
|
|
1824
|
+
async applicationStatus(sid) {
|
|
1825
|
+
const raw = await this.transport.request(
|
|
1826
|
+
"GET",
|
|
1827
|
+
"merchant/application-status",
|
|
1828
|
+
this.envelope({ sid })
|
|
1829
|
+
);
|
|
1830
|
+
return ApplicationStatus.fromRaw(raw["data"] ?? {});
|
|
1831
|
+
}
|
|
1335
1832
|
};
|
|
1336
1833
|
|
|
1337
1834
|
// src/data-objects/payment-method.ts
|
|
@@ -1754,6 +2251,342 @@ var RecurringPayments = class extends AbstractResource {
|
|
|
1754
2251
|
}
|
|
1755
2252
|
};
|
|
1756
2253
|
|
|
2254
|
+
// src/data-objects/subscribe-result.ts
|
|
2255
|
+
var SubscribeResult = class _SubscribeResult {
|
|
2256
|
+
constructor(subscriptionId, status, nextRunDate, transactionNumber, amount) {
|
|
2257
|
+
this.subscriptionId = subscriptionId;
|
|
2258
|
+
this.status = status;
|
|
2259
|
+
this.nextRunDate = nextRunDate;
|
|
2260
|
+
this.transactionNumber = transactionNumber;
|
|
2261
|
+
this.amount = amount;
|
|
2262
|
+
}
|
|
2263
|
+
subscriptionId;
|
|
2264
|
+
status;
|
|
2265
|
+
nextRunDate;
|
|
2266
|
+
transactionNumber;
|
|
2267
|
+
amount;
|
|
2268
|
+
static fromRaw(data) {
|
|
2269
|
+
return new _SubscribeResult(
|
|
2270
|
+
arrInt(data, "subscription_id"),
|
|
2271
|
+
arrString(data, "status"),
|
|
2272
|
+
arrString(data, "next_run_date"),
|
|
2273
|
+
arrString(data, "transaction_number"),
|
|
2274
|
+
arrString(data, "amount")
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
|
|
2279
|
+
// src/data-objects/subscription-item.ts
|
|
2280
|
+
var SubscriptionItem = class _SubscriptionItem {
|
|
2281
|
+
constructor(name, description, quantity, unitPrice, amount) {
|
|
2282
|
+
this.name = name;
|
|
2283
|
+
this.description = description;
|
|
2284
|
+
this.quantity = quantity;
|
|
2285
|
+
this.unitPrice = unitPrice;
|
|
2286
|
+
this.amount = amount;
|
|
2287
|
+
}
|
|
2288
|
+
name;
|
|
2289
|
+
description;
|
|
2290
|
+
quantity;
|
|
2291
|
+
unitPrice;
|
|
2292
|
+
amount;
|
|
2293
|
+
static fromRaw(data) {
|
|
2294
|
+
return new _SubscriptionItem(
|
|
2295
|
+
arrString(data, "name"),
|
|
2296
|
+
arrString(data, "description"),
|
|
2297
|
+
arrString(data, "quantity"),
|
|
2298
|
+
arrString(data, "unit_price"),
|
|
2299
|
+
arrString(data, "amount")
|
|
2300
|
+
);
|
|
2301
|
+
}
|
|
2302
|
+
};
|
|
2303
|
+
|
|
2304
|
+
// src/data-objects/subscription-plan.ts
|
|
2305
|
+
var SubscriptionPlan = class _SubscriptionPlan {
|
|
2306
|
+
constructor(id, name, description, recurrenceSchedule, status, subtotal, total, token, publicUrl, allowPublic = false, createdAt, items = []) {
|
|
2307
|
+
this.id = id;
|
|
2308
|
+
this.name = name;
|
|
2309
|
+
this.description = description;
|
|
2310
|
+
this.recurrenceSchedule = recurrenceSchedule;
|
|
2311
|
+
this.status = status;
|
|
2312
|
+
this.subtotal = subtotal;
|
|
2313
|
+
this.total = total;
|
|
2314
|
+
this.token = token;
|
|
2315
|
+
this.publicUrl = publicUrl;
|
|
2316
|
+
this.allowPublic = allowPublic;
|
|
2317
|
+
this.createdAt = createdAt;
|
|
2318
|
+
this.items = items;
|
|
2319
|
+
}
|
|
2320
|
+
id;
|
|
2321
|
+
name;
|
|
2322
|
+
description;
|
|
2323
|
+
recurrenceSchedule;
|
|
2324
|
+
status;
|
|
2325
|
+
subtotal;
|
|
2326
|
+
total;
|
|
2327
|
+
token;
|
|
2328
|
+
publicUrl;
|
|
2329
|
+
allowPublic;
|
|
2330
|
+
createdAt;
|
|
2331
|
+
items;
|
|
2332
|
+
static fromRaw(data) {
|
|
2333
|
+
return new _SubscriptionPlan(
|
|
2334
|
+
arrInt(data, "id"),
|
|
2335
|
+
arrString(data, "name"),
|
|
2336
|
+
arrString(data, "description"),
|
|
2337
|
+
arrString(data, "recurrence_schedule"),
|
|
2338
|
+
arrString(data, "status"),
|
|
2339
|
+
arrString(data, "subtotal"),
|
|
2340
|
+
arrString(data, "total"),
|
|
2341
|
+
arrString(data, "token"),
|
|
2342
|
+
arrString(data, "public_url"),
|
|
2343
|
+
arrBool(data, "allow_public"),
|
|
2344
|
+
arrString(data, "created_at"),
|
|
2345
|
+
arrArrayFrom(data, "items").map(SubscriptionItem.fromRaw)
|
|
2346
|
+
);
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2350
|
+
// src/resources/subscription-plans.ts
|
|
2351
|
+
var SubscriptionPlans = class extends AbstractResource {
|
|
2352
|
+
/**
|
|
2353
|
+
* List a merchant's plans, newest first.
|
|
2354
|
+
*
|
|
2355
|
+
* @param status `draft`, `active` or `archived`
|
|
2356
|
+
*/
|
|
2357
|
+
async list(sid, status) {
|
|
2358
|
+
return this.paginate(
|
|
2359
|
+
"GET",
|
|
2360
|
+
"subscription-plan/list",
|
|
2361
|
+
this.envelope({ sid, status }),
|
|
2362
|
+
SubscriptionPlan.fromRaw
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2365
|
+
async show(sid, subscriptionPlanId) {
|
|
2366
|
+
const raw = await this.transport.request(
|
|
2367
|
+
"GET",
|
|
2368
|
+
"subscription-plan/show",
|
|
2369
|
+
this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
|
|
2370
|
+
);
|
|
2371
|
+
return SubscriptionPlan.fromRaw(raw["data"] ?? {});
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Create a plan as a draft. Publish it before customers can subscribe.
|
|
2375
|
+
*
|
|
2376
|
+
* @param attributes
|
|
2377
|
+
* `name`, `recurrence_schedule` (`Weekly` | `Biweekly` | `FirstFifteenth` |
|
|
2378
|
+
* `Monthly` | `Yearly`) and `lines` are required. `lines[]` takes
|
|
2379
|
+
* `item_id` (a Merchant item), `name`, `quantity`, `unit_price` and
|
|
2380
|
+
* optional `description`. Optional: `description`, `allow_public` (list
|
|
2381
|
+
* the plan in the public catalog).
|
|
2382
|
+
*/
|
|
2383
|
+
async create(sid, attributes) {
|
|
2384
|
+
const raw = await this.transport.request(
|
|
2385
|
+
"POST",
|
|
2386
|
+
"subscription-plan/create",
|
|
2387
|
+
this.envelope({ sid, ...attributes })
|
|
2388
|
+
);
|
|
2389
|
+
return SubscriptionPlan.fromRaw(raw["data"] ?? {});
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Replace a plan's fields and line items wholesale — send the full plan, not
|
|
2393
|
+
* just what changed. Existing subscribers are unaffected.
|
|
2394
|
+
*
|
|
2395
|
+
* @param attributes same shape as {@link SubscriptionPlans.create}
|
|
2396
|
+
*/
|
|
2397
|
+
async edit(sid, subscriptionPlanId, attributes) {
|
|
2398
|
+
const raw = await this.transport.request(
|
|
2399
|
+
"PATCH",
|
|
2400
|
+
"subscription-plan/edit",
|
|
2401
|
+
this.envelope({ sid, subscription_plan_id: subscriptionPlanId, ...attributes })
|
|
2402
|
+
);
|
|
2403
|
+
return SubscriptionPlan.fromRaw(raw["data"] ?? {});
|
|
2404
|
+
}
|
|
2405
|
+
/** Delete a plan with no subscribers. A plan that has any must be archived instead. */
|
|
2406
|
+
async delete(sid, subscriptionPlanId) {
|
|
2407
|
+
const raw = await this.transport.request(
|
|
2408
|
+
"POST",
|
|
2409
|
+
"subscription-plan/delete",
|
|
2410
|
+
this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
|
|
2411
|
+
);
|
|
2412
|
+
return MessageResult.fromRaw(raw["data"] ?? raw);
|
|
2413
|
+
}
|
|
2414
|
+
/** Move a draft plan with at least one line item to active, so customers can subscribe. */
|
|
2415
|
+
async publish(sid, subscriptionPlanId) {
|
|
2416
|
+
const raw = await this.transport.request(
|
|
2417
|
+
"PATCH",
|
|
2418
|
+
"subscription-plan/publish",
|
|
2419
|
+
this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
|
|
2420
|
+
);
|
|
2421
|
+
return SubscriptionPlan.fromRaw(raw["data"] ?? {});
|
|
2422
|
+
}
|
|
2423
|
+
/** Stop new subscriptions and hide the plan from the public catalog. */
|
|
2424
|
+
async archive(sid, subscriptionPlanId) {
|
|
2425
|
+
const raw = await this.transport.request(
|
|
2426
|
+
"PATCH",
|
|
2427
|
+
"subscription-plan/archive",
|
|
2428
|
+
this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
|
|
2429
|
+
);
|
|
2430
|
+
return SubscriptionPlan.fromRaw(raw["data"] ?? {});
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Move an archived plan back to draft, to review and re-publish.
|
|
2434
|
+
* `allowPublic` stays off until the merchant opts back into the catalog.
|
|
2435
|
+
*/
|
|
2436
|
+
async unarchive(sid, subscriptionPlanId) {
|
|
2437
|
+
const raw = await this.transport.request(
|
|
2438
|
+
"PATCH",
|
|
2439
|
+
"subscription-plan/unarchive",
|
|
2440
|
+
this.envelope({ sid, subscription_plan_id: subscriptionPlanId })
|
|
2441
|
+
);
|
|
2442
|
+
return SubscriptionPlan.fromRaw(raw["data"] ?? {});
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* Subscribe a customer to an active plan: charges the first payment to one
|
|
2446
|
+
* of the customer's saved payment methods and enrolls them.
|
|
2447
|
+
*/
|
|
2448
|
+
async subscribe(sid, subscriptionPlanId, customerUuid, paymentMethodId) {
|
|
2449
|
+
const raw = await this.transport.request(
|
|
2450
|
+
"POST",
|
|
2451
|
+
"subscription-plan/subscribe",
|
|
2452
|
+
this.envelope({
|
|
2453
|
+
sid,
|
|
2454
|
+
subscription_plan_id: subscriptionPlanId,
|
|
2455
|
+
customer_uuid: customerUuid,
|
|
2456
|
+
payment_method: paymentMethodId
|
|
2457
|
+
})
|
|
2458
|
+
);
|
|
2459
|
+
return SubscribeResult.fromRaw(raw["data"] ?? {});
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
|
|
2463
|
+
// src/data-objects/subscription.ts
|
|
2464
|
+
var Subscription = class _Subscription {
|
|
2465
|
+
constructor(id, subscriptionPlanId, planName, amount, recurrenceSchedule, startDate, endDate, lastRunDate, lastRunStatus, lastRunFailedCount, nextRunDate, status, pausedUntilDate, cancelledAt, cancelledBy, customerUuid, error, paymentMethod = new RecurringPaymentMethod(), items = []) {
|
|
2466
|
+
this.id = id;
|
|
2467
|
+
this.subscriptionPlanId = subscriptionPlanId;
|
|
2468
|
+
this.planName = planName;
|
|
2469
|
+
this.amount = amount;
|
|
2470
|
+
this.recurrenceSchedule = recurrenceSchedule;
|
|
2471
|
+
this.startDate = startDate;
|
|
2472
|
+
this.endDate = endDate;
|
|
2473
|
+
this.lastRunDate = lastRunDate;
|
|
2474
|
+
this.lastRunStatus = lastRunStatus;
|
|
2475
|
+
this.lastRunFailedCount = lastRunFailedCount;
|
|
2476
|
+
this.nextRunDate = nextRunDate;
|
|
2477
|
+
this.status = status;
|
|
2478
|
+
this.pausedUntilDate = pausedUntilDate;
|
|
2479
|
+
this.cancelledAt = cancelledAt;
|
|
2480
|
+
this.cancelledBy = cancelledBy;
|
|
2481
|
+
this.customerUuid = customerUuid;
|
|
2482
|
+
this.error = error;
|
|
2483
|
+
this.paymentMethod = paymentMethod;
|
|
2484
|
+
this.items = items;
|
|
2485
|
+
}
|
|
2486
|
+
id;
|
|
2487
|
+
subscriptionPlanId;
|
|
2488
|
+
planName;
|
|
2489
|
+
amount;
|
|
2490
|
+
recurrenceSchedule;
|
|
2491
|
+
startDate;
|
|
2492
|
+
endDate;
|
|
2493
|
+
lastRunDate;
|
|
2494
|
+
lastRunStatus;
|
|
2495
|
+
lastRunFailedCount;
|
|
2496
|
+
nextRunDate;
|
|
2497
|
+
status;
|
|
2498
|
+
pausedUntilDate;
|
|
2499
|
+
cancelledAt;
|
|
2500
|
+
cancelledBy;
|
|
2501
|
+
customerUuid;
|
|
2502
|
+
error;
|
|
2503
|
+
paymentMethod;
|
|
2504
|
+
items;
|
|
2505
|
+
static fromRaw(data) {
|
|
2506
|
+
return new _Subscription(
|
|
2507
|
+
arrInt(data, "id"),
|
|
2508
|
+
arrInt(data, "subscription_plan_id"),
|
|
2509
|
+
arrString(data, "plan_name"),
|
|
2510
|
+
arrString(data, "amount"),
|
|
2511
|
+
arrString(data, "recurrence_schedule"),
|
|
2512
|
+
arrString(data, "start_date"),
|
|
2513
|
+
arrString(data, "end_date"),
|
|
2514
|
+
arrString(data, "last_run_date"),
|
|
2515
|
+
arrString(data, "last_run_status"),
|
|
2516
|
+
arrInt(data, "last_run_failed_count"),
|
|
2517
|
+
arrString(data, "next_run_date"),
|
|
2518
|
+
arrString(data, "status"),
|
|
2519
|
+
arrString(data, "paused_until_date"),
|
|
2520
|
+
arrString(data, "cancelled_at"),
|
|
2521
|
+
arrString(data, "cancelled_by"),
|
|
2522
|
+
arrString(data, "customer_uuid"),
|
|
2523
|
+
arrString(data, "error"),
|
|
2524
|
+
RecurringPaymentMethod.fromRaw(arrObjectFrom(data, ["payment_method"])),
|
|
2525
|
+
arrArrayFrom(data, "items").map(SubscriptionItem.fromRaw)
|
|
2526
|
+
);
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
// src/resources/subscriptions.ts
|
|
2531
|
+
var Subscriptions = class extends AbstractResource {
|
|
2532
|
+
/**
|
|
2533
|
+
* List a merchant's subscriptions, newest first.
|
|
2534
|
+
*
|
|
2535
|
+
* @param filters `status` — Active | Failed | Paused | Cancelled | Ended;
|
|
2536
|
+
* `customer_uuid`
|
|
2537
|
+
*/
|
|
2538
|
+
async list(sid, filters = {}) {
|
|
2539
|
+
return this.paginate(
|
|
2540
|
+
"GET",
|
|
2541
|
+
"subscription/list",
|
|
2542
|
+
this.envelope({ sid }, filters),
|
|
2543
|
+
Subscription.fromRaw
|
|
2544
|
+
);
|
|
2545
|
+
}
|
|
2546
|
+
async show(sid, subscriptionId) {
|
|
2547
|
+
const raw = await this.transport.request(
|
|
2548
|
+
"GET",
|
|
2549
|
+
"subscription/show",
|
|
2550
|
+
this.envelope({ sid, subscription_id: subscriptionId })
|
|
2551
|
+
);
|
|
2552
|
+
return Subscription.fromRaw(raw["data"] ?? {});
|
|
2553
|
+
}
|
|
2554
|
+
/**
|
|
2555
|
+
* Pause a subscription until `pauseUntilDate` (Y-m-d, in the future), or
|
|
2556
|
+
* indefinitely when it is omitted.
|
|
2557
|
+
*/
|
|
2558
|
+
async pause(sid, subscriptionId, pauseUntilDate) {
|
|
2559
|
+
const raw = await this.transport.request(
|
|
2560
|
+
"PATCH",
|
|
2561
|
+
"subscription/pause",
|
|
2562
|
+
this.envelope({
|
|
2563
|
+
sid,
|
|
2564
|
+
subscription_id: subscriptionId,
|
|
2565
|
+
pause_until_date: pauseUntilDate
|
|
2566
|
+
})
|
|
2567
|
+
);
|
|
2568
|
+
return Subscription.fromRaw(raw["data"] ?? {});
|
|
2569
|
+
}
|
|
2570
|
+
/** Reactivate a paused subscription and recompute its next charge date. */
|
|
2571
|
+
async resume(sid, subscriptionId) {
|
|
2572
|
+
const raw = await this.transport.request(
|
|
2573
|
+
"PATCH",
|
|
2574
|
+
"subscription/resume",
|
|
2575
|
+
this.envelope({ sid, subscription_id: subscriptionId })
|
|
2576
|
+
);
|
|
2577
|
+
return Subscription.fromRaw(raw["data"] ?? {});
|
|
2578
|
+
}
|
|
2579
|
+
/** Cancel a subscription permanently; no further charges are made. */
|
|
2580
|
+
async cancel(sid, subscriptionId) {
|
|
2581
|
+
const raw = await this.transport.request(
|
|
2582
|
+
"PATCH",
|
|
2583
|
+
"subscription/cancel",
|
|
2584
|
+
this.envelope({ sid, subscription_id: subscriptionId })
|
|
2585
|
+
);
|
|
2586
|
+
return Subscription.fromRaw(raw["data"] ?? {});
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
|
|
1757
2590
|
// src/data-objects/tokenize-result.ts
|
|
1758
2591
|
var TokenizeResult = class _TokenizeResult {
|
|
1759
2592
|
constructor(token) {
|
|
@@ -1816,6 +2649,40 @@ var Transactions = class extends AbstractResource {
|
|
|
1816
2649
|
);
|
|
1817
2650
|
return TokenizeResult.fromRaw(raw["data"] ?? {});
|
|
1818
2651
|
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Place a hold on a card without moving money. Pass a `token` or the raw
|
|
2654
|
+
* card fields, as for {@link Transactions.chargeCard}.
|
|
2655
|
+
*
|
|
2656
|
+
* The returned `transactionNumber` is the handle on the authorization:
|
|
2657
|
+
* collect it with {@link Transactions.capture}, or release the hold with
|
|
2658
|
+
* {@link Transactions.void} (type `CC`). Capture promptly — the issuer
|
|
2659
|
+
* releases an uncaptured hold on its own schedule.
|
|
2660
|
+
*/
|
|
2661
|
+
async authorize(sid, attributes) {
|
|
2662
|
+
const raw = await this.transport.request(
|
|
2663
|
+
"POST",
|
|
2664
|
+
"transaction/authorize",
|
|
2665
|
+
this.envelope({ sid, ...attributes })
|
|
2666
|
+
);
|
|
2667
|
+
return Transaction.fromRaw(raw["data"] ?? {});
|
|
2668
|
+
}
|
|
2669
|
+
/**
|
|
2670
|
+
* Capture an authorization. Omit `amount` to capture the full authorized
|
|
2671
|
+
* amount, or pass less to capture part of it.
|
|
2672
|
+
*
|
|
2673
|
+
* An authorization is captured once: a partial capture settles that amount
|
|
2674
|
+
* and releases the rest to the cardholder.
|
|
2675
|
+
*
|
|
2676
|
+
* @param transactionId the `transactionNumber` returned by {@link Transactions.authorize}
|
|
2677
|
+
*/
|
|
2678
|
+
async capture(sid, transactionId, amount) {
|
|
2679
|
+
const raw = await this.transport.request(
|
|
2680
|
+
"POST",
|
|
2681
|
+
"transaction/capture",
|
|
2682
|
+
this.envelope({ sid, transaction_id: transactionId, amount })
|
|
2683
|
+
);
|
|
2684
|
+
return MessageResult.fromRaw(raw["data"] ?? raw);
|
|
2685
|
+
}
|
|
1819
2686
|
async refund(sid, attributes) {
|
|
1820
2687
|
const raw = await this.transport.request(
|
|
1821
2688
|
"POST",
|
|
@@ -1845,6 +2712,11 @@ var Client = class {
|
|
|
1845
2712
|
recurringPayments;
|
|
1846
2713
|
invoices;
|
|
1847
2714
|
recurringInvoices;
|
|
2715
|
+
chargebacks;
|
|
2716
|
+
documents;
|
|
2717
|
+
funds;
|
|
2718
|
+
subscriptionPlans;
|
|
2719
|
+
subscriptions;
|
|
1848
2720
|
_config;
|
|
1849
2721
|
constructor(token, baseUrl = DEFAULT_BASE_URL) {
|
|
1850
2722
|
this._config = token instanceof Config ? token : new Config(token, baseUrl);
|
|
@@ -1858,6 +2730,11 @@ var Client = class {
|
|
|
1858
2730
|
this.recurringPayments = new RecurringPayments(transport);
|
|
1859
2731
|
this.invoices = new Invoices(transport);
|
|
1860
2732
|
this.recurringInvoices = new RecurringInvoices(transport);
|
|
2733
|
+
this.chargebacks = new Chargebacks(transport);
|
|
2734
|
+
this.documents = new Documents(transport);
|
|
2735
|
+
this.funds = new Funds(transport);
|
|
2736
|
+
this.subscriptionPlans = new SubscriptionPlans(transport);
|
|
2737
|
+
this.subscriptions = new Subscriptions(transport);
|
|
1861
2738
|
}
|
|
1862
2739
|
config() {
|
|
1863
2740
|
return this._config;
|
|
@@ -1866,7 +2743,9 @@ var Client = class {
|
|
|
1866
2743
|
export {
|
|
1867
2744
|
Address,
|
|
1868
2745
|
ApiException,
|
|
2746
|
+
ApplicationStatus,
|
|
1869
2747
|
AuthenticationException,
|
|
2748
|
+
Chargeback,
|
|
1870
2749
|
Client,
|
|
1871
2750
|
Config,
|
|
1872
2751
|
ConnectionException,
|
|
@@ -1878,7 +2757,12 @@ export {
|
|
|
1878
2757
|
DepositGroup,
|
|
1879
2758
|
DepositWithTransactions,
|
|
1880
2759
|
DimeException,
|
|
2760
|
+
DocumentUploadFailure,
|
|
2761
|
+
DocumentUploadResult,
|
|
1881
2762
|
FormLink,
|
|
2763
|
+
FundRelease,
|
|
2764
|
+
FundReleaseResult,
|
|
2765
|
+
HeldBalance,
|
|
1882
2766
|
Invoice,
|
|
1883
2767
|
InvoiceCustomer,
|
|
1884
2768
|
InvoiceEvent,
|
|
@@ -1887,6 +2771,7 @@ export {
|
|
|
1887
2771
|
InvoiceLink,
|
|
1888
2772
|
InvoicePayment,
|
|
1889
2773
|
Merchant,
|
|
2774
|
+
MerchantDocument,
|
|
1890
2775
|
MessageResult,
|
|
1891
2776
|
NotFoundException,
|
|
1892
2777
|
PaymentMethod,
|
|
@@ -1895,7 +2780,13 @@ export {
|
|
|
1895
2780
|
RecurringInvoice,
|
|
1896
2781
|
RecurringPayment,
|
|
1897
2782
|
RecurringPaymentMethod,
|
|
2783
|
+
ReleasableTransaction,
|
|
2784
|
+
ReleasableTransactions,
|
|
1898
2785
|
ServerException,
|
|
2786
|
+
SubscribeResult,
|
|
2787
|
+
Subscription,
|
|
2788
|
+
SubscriptionItem,
|
|
2789
|
+
SubscriptionPlan,
|
|
1899
2790
|
TokenizeResult,
|
|
1900
2791
|
Transaction,
|
|
1901
2792
|
TransactionAddress,
|