@commet/node 7.1.0 → 7.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.d.mts +1143 -11
- package/dist/index.d.ts +1143 -11
- package/dist/index.js +70 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -200,6 +200,35 @@ var InvoicesResource = class {
|
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
+
// src/resources/payments.ts
|
|
204
|
+
var PaymentsResource = class {
|
|
205
|
+
constructor(httpClient) {
|
|
206
|
+
this.httpClient = httpClient;
|
|
207
|
+
}
|
|
208
|
+
/** List payments with cursor-based pagination. Filter by customer. */
|
|
209
|
+
async list(params, options) {
|
|
210
|
+
return this.httpClient.get("/payments", params, options);
|
|
211
|
+
}
|
|
212
|
+
/** Create a hosted payment link. Returns a url the customer opens to pay with any card. Calculates tax, generates an invoice, and vaults the payment method on confirmation. No subscription or plan required. */
|
|
213
|
+
async create(params, options) {
|
|
214
|
+
return this.httpClient.post("/payments", params, options);
|
|
215
|
+
}
|
|
216
|
+
/** Charge a customer's vaulted payment method off-session. Calculates tax, generates an invoice, and sends a receipt. No subscription or plan required. */
|
|
217
|
+
async charge(params, options) {
|
|
218
|
+
return this.httpClient.post("/payments/charge", params, options);
|
|
219
|
+
}
|
|
220
|
+
/** Retrieve a payment by its public ID. */
|
|
221
|
+
async get(params, options) {
|
|
222
|
+
const { id } = params;
|
|
223
|
+
return this.httpClient.get(`/payments/${id}`, void 0, options);
|
|
224
|
+
}
|
|
225
|
+
/** Cancel a pending payment link so it can no longer be paid. Only a link that has not been paid or started processing can be canceled; canceling an already canceled link is a no-op. Charges cannot be canceled. */
|
|
226
|
+
async cancel(params, options) {
|
|
227
|
+
const { id } = params;
|
|
228
|
+
return this.httpClient.post(`/payments/${id}/cancel`, {}, options);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
203
232
|
// src/resources/payouts.ts
|
|
204
233
|
var PayoutsResource = class {
|
|
205
234
|
constructor(httpClient) {
|
|
@@ -507,6 +536,29 @@ var SubscriptionsResource = class {
|
|
|
507
536
|
const { id } = params;
|
|
508
537
|
return this.httpClient.post(`/subscriptions/${id}/uncancel`, {}, options);
|
|
509
538
|
}
|
|
539
|
+
/** Retries the outstanding renewal charge for a past_due subscription. On a successful charge the subscription recovers to active and a payment.recovered webhook is delivered; a declined charge returns an error and the subscription stays past_due. */
|
|
540
|
+
async reactivate(params, options) {
|
|
541
|
+
const { id } = params;
|
|
542
|
+
return this.httpClient.post(`/subscriptions/${id}/reactivate`, {}, options);
|
|
543
|
+
}
|
|
544
|
+
/** Generates a hosted, signed recovery link that lets the customer pay the outstanding renewal charge for a past_due subscription. Unlike reactivate, which charges server-to-server, this returns a link the merchant can deliver through their own email, SMS, or dashboard. The link carries a self-contained signed token and stays valid until the charge is paid or the subscription is no longer past due. */
|
|
545
|
+
async createRecoveryLink(params, options) {
|
|
546
|
+
const { id } = params;
|
|
547
|
+
return this.httpClient.post(
|
|
548
|
+
`/subscriptions/${id}/recovery-link`,
|
|
549
|
+
{},
|
|
550
|
+
options
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
/** Creates a hosted checkout session for the customer to update the subscription's default payment method. */
|
|
554
|
+
async updatePaymentMethod(params, options) {
|
|
555
|
+
const { id, ...rest } = params;
|
|
556
|
+
return this.httpClient.post(
|
|
557
|
+
`/subscriptions/${id}/payment-method/update`,
|
|
558
|
+
rest,
|
|
559
|
+
options
|
|
560
|
+
);
|
|
561
|
+
}
|
|
510
562
|
/** Upgrade, downgrade, or change billing interval. */
|
|
511
563
|
async changePlan(params, options) {
|
|
512
564
|
const { id, ...rest } = params;
|
|
@@ -602,7 +654,7 @@ var TransactionsResource = class {
|
|
|
602
654
|
const { id } = params;
|
|
603
655
|
return this.httpClient.post(`/transactions/${id}/refund`, {}, options);
|
|
604
656
|
}
|
|
605
|
-
/** Retry a failed
|
|
657
|
+
/** Retry a failed subscription renewal. Re-charges the outstanding renewal invoice through the recovery engine. */
|
|
606
658
|
async retry(params, options) {
|
|
607
659
|
const { id } = params;
|
|
608
660
|
return this.httpClient.post(`/transactions/${id}/retry`, {}, options);
|
|
@@ -619,6 +671,7 @@ var GeneratedResources = class {
|
|
|
619
671
|
this.featureAccess = new FeatureAccessResource(http);
|
|
620
672
|
this.features = new FeaturesResource(http);
|
|
621
673
|
this.invoices = new InvoicesResource(http);
|
|
674
|
+
this.payments = new PaymentsResource(http);
|
|
622
675
|
this.payouts = new PayoutsResource(http);
|
|
623
676
|
this.planGroups = new PlanGroupsResource(http);
|
|
624
677
|
this.plans = new PlansResource(http);
|
|
@@ -675,8 +728,8 @@ import crypto2 from "crypto";
|
|
|
675
728
|
var Webhooks = class {
|
|
676
729
|
constructor(httpClient) {
|
|
677
730
|
this.httpClient = httpClient;
|
|
731
|
+
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
678
732
|
}
|
|
679
|
-
/** HMAC-SHA256 verification. Payload must be the raw request body string, not parsed JSON. */
|
|
680
733
|
verify(params) {
|
|
681
734
|
const { payload, signature, secret } = params;
|
|
682
735
|
if (!signature || !secret || !payload) {
|
|
@@ -696,7 +749,6 @@ var Webhooks = class {
|
|
|
696
749
|
const { payload, secret } = params;
|
|
697
750
|
return crypto2.createHmac("sha256", secret).update(payload).digest("hex");
|
|
698
751
|
}
|
|
699
|
-
/** Verifies signature and parses JSON in one step. Returns null if invalid. */
|
|
700
752
|
verifyAndParse(params) {
|
|
701
753
|
const { rawBody, signature, secret } = params;
|
|
702
754
|
if (!this.verify({ payload: rawBody, signature, secret })) {
|
|
@@ -708,6 +760,20 @@ var Webhooks = class {
|
|
|
708
760
|
return null;
|
|
709
761
|
}
|
|
710
762
|
}
|
|
763
|
+
on(event, handler) {
|
|
764
|
+
this.eventHandlers.set(
|
|
765
|
+
event,
|
|
766
|
+
handler
|
|
767
|
+
);
|
|
768
|
+
return this;
|
|
769
|
+
}
|
|
770
|
+
async process(params) {
|
|
771
|
+
const payload = this.verifyAndParse(params);
|
|
772
|
+
if (!payload) return null;
|
|
773
|
+
const handler = this.eventHandlers.get(payload.event);
|
|
774
|
+
if (handler) await handler(payload.data, payload);
|
|
775
|
+
return payload;
|
|
776
|
+
}
|
|
711
777
|
async list(params, options) {
|
|
712
778
|
return this.httpClient.get("/webhooks", params, options);
|
|
713
779
|
}
|
|
@@ -764,7 +830,7 @@ var CommetValidationError = class extends CommetError {
|
|
|
764
830
|
|
|
765
831
|
// src/version.ts
|
|
766
832
|
var API_VERSION = "2026-06-10";
|
|
767
|
-
var SDK_VERSION = "7.
|
|
833
|
+
var SDK_VERSION = "7.3.0";
|
|
768
834
|
|
|
769
835
|
// src/utils/telemetry.ts
|
|
770
836
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|