@paygentic/sdk 0.6.33 → 0.6.34

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/FUNCTIONS.md CHANGED
@@ -20,7 +20,7 @@ specific category of applications.
20
20
 
21
21
  ```typescript
22
22
  import { PaygenticCore } from "@paygentic/sdk/core.js";
23
- import { billableMetricsCreate } from "@paygentic/sdk/funcs/billableMetricsCreate.js";
23
+ import { customersCreate } from "@paygentic/sdk/funcs/customersCreate.js";
24
24
 
25
25
  // Use `PaygenticCore` for best tree-shaking performance.
26
26
  // You can create one instance of it to use across an application.
@@ -29,19 +29,23 @@ const paygentic = new PaygenticCore({
29
29
  });
30
30
 
31
31
  async function run() {
32
- const res = await billableMetricsCreate(paygentic, {
33
- aggregation: "SUM",
34
- description: "other gracefully hold",
35
- merchantId: "<id>",
36
- name: "<value>",
37
- productId: "<id>",
38
- unit: "becquerel",
32
+ const res = await customersCreate(paygentic, {
33
+ consumer: {
34
+ name: "Jane Smith",
35
+ email: "jane@example.com",
36
+ address: {
37
+ city: "San Francisco",
38
+ state: "CA",
39
+ country: "US",
40
+ },
41
+ },
42
+ merchantId: "org_YS8jkP59V71TdUvj",
39
43
  });
40
44
  if (res.ok) {
41
45
  const { value: result } = res;
42
46
  console.log(result);
43
47
  } else {
44
- console.log("billableMetricsCreate failed:", res.error);
48
+ console.log("customersCreate failed:", res.error);
45
49
  }
46
50
  }
47
51
 
package/README.md CHANGED
@@ -14,31 +14,19 @@ Developer-friendly & type-safe Typescript SDK specifically catered to leverage *
14
14
  <!-- Start Summary [summary] -->
15
15
  ## Summary
16
16
 
17
- Paygentic API: The Paygentic API provides a comprehensive platform for building and scaling monetization infrastructure.
17
+ Paygentic API: The Paygentic API provides billing infrastructure for usage-based and subscription monetization — customers, subscriptions, usage metering, invoicing, entitlements, and payments.
18
18
 
19
- ## Authentication
20
- All API requests require authentication using an API key passed in the `Authorization` header:
21
- ```
22
- Authorization: Bearer YOUR_API_KEY
23
- ```
24
-
25
- ## Base URL
26
- All API requests should be made to:
27
- ```
28
- https://api.paygentic.io/v0
29
- ```
19
+ See the [Quickstart](https://docs.paygentic.io/getting-started/quickstart) to go from zero to billing in four steps.
30
20
  <!-- End Summary [summary] -->
31
21
 
32
22
  <!-- Start Table of Contents [toc] -->
33
23
  ## Table of Contents
34
24
  <!-- $toc-max-depth=2 -->
35
25
  * [paygentic](#paygentic)
36
- * [Authentication](#authentication)
37
- * [Base URL](#base-url)
38
26
  * [SDK Installation](#sdk-installation)
39
27
  * [Requirements](#requirements)
40
28
  * [SDK Example Usage](#sdk-example-usage)
41
- * [Authentication](#authentication-1)
29
+ * [Authentication](#authentication)
42
30
  * [Available Resources and Operations](#available-resources-and-operations)
43
31
  * [Standalone functions](#standalone-functions)
44
32
  * [Retries](#retries)
@@ -55,30 +43,34 @@ https://api.paygentic.io/v0
55
43
  <!-- Start SDK Installation [installation] -->
56
44
  ## SDK Installation
57
45
 
46
+ > [!TIP]
47
+ > To finish publishing your SDK to npm and others you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
48
+
49
+
58
50
  The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
59
51
 
60
52
  ### NPM
61
53
 
62
54
  ```bash
63
- npm add @paygentic/sdk
55
+ npm add https://github.com/paygentic/sdk-node
64
56
  ```
65
57
 
66
58
  ### PNPM
67
59
 
68
60
  ```bash
69
- pnpm add @paygentic/sdk
61
+ pnpm add https://github.com/paygentic/sdk-node
70
62
  ```
71
63
 
72
64
  ### Bun
73
65
 
74
66
  ```bash
75
- bun add @paygentic/sdk
67
+ bun add https://github.com/paygentic/sdk-node
76
68
  ```
77
69
 
78
70
  ### Yarn
79
71
 
80
72
  ```bash
81
- yarn add @paygentic/sdk
73
+ yarn add https://github.com/paygentic/sdk-node
82
74
  ```
83
75
 
84
76
  > [!NOTE]
@@ -94,7 +86,9 @@ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
94
86
  <!-- Start SDK Example Usage [usage] -->
95
87
  ## SDK Example Usage
96
88
 
97
- ### Example
89
+ ### Create a customer
90
+
91
+ Create a customer for each organization you bill. This is the first step in the billing setup — see the [Quickstart](https://docs.paygentic.io/getting-started/quickstart) for the full flow.
98
92
 
99
93
  ```typescript
100
94
  import { Paygentic } from "@paygentic/sdk";
@@ -104,13 +98,72 @@ const paygentic = new Paygentic({
104
98
  });
105
99
 
106
100
  async function run() {
107
- const result = await paygentic.billableMetrics.create({
108
- aggregation: "SUM",
109
- description: "other gracefully hold",
110
- merchantId: "<id>",
111
- name: "<value>",
112
- productId: "<id>",
113
- unit: "becquerel",
101
+ const result = await paygentic.customers.create({
102
+ consumer: {
103
+ name: "Jane Smith",
104
+ email: "jane@example.com",
105
+ address: {
106
+ city: "San Francisco",
107
+ state: "CA",
108
+ country: "US",
109
+ },
110
+ },
111
+ merchantId: "org_YS8jkP59V71TdUvj",
112
+ });
113
+
114
+ console.log(result);
115
+ }
116
+
117
+ run();
118
+
119
+ ```
120
+
121
+ ### Create a subscription
122
+
123
+ Subscribe a customer to a plan. If the plan includes in-advance charges, Paygentic generates an initial invoice and the subscription activates once paid.
124
+
125
+ ```typescript
126
+ import { Paygentic } from "@paygentic/sdk";
127
+
128
+ const paygentic = new Paygentic({
129
+ bearerAuth: process.env["PAYGENTIC_BEARER_AUTH"] ?? "",
130
+ });
131
+
132
+ async function run() {
133
+ const result = await paygentic.subscriptions.create({
134
+ customerId: "cus_abc123",
135
+ name: "Monthly API Service",
136
+ planId: "plan_abc123",
137
+ startedAt: new Date("2024-01-15T00:00:00Z"),
138
+ });
139
+
140
+ console.log(result);
141
+ }
142
+
143
+ run();
144
+
145
+ ```
146
+
147
+ ### Report usage
148
+
149
+ Send meter events to record consumption once a subscription is active. The endpoint is fire-and-forget — it always returns `202 Accepted`.
150
+
151
+ ```typescript
152
+ import { Paygentic } from "@paygentic/sdk";
153
+
154
+ const paygentic = new Paygentic({
155
+ bearerAuth: process.env["PAYGENTIC_BEARER_AUTH"] ?? "",
156
+ });
157
+
158
+ async function run() {
159
+ const result = await paygentic.events.ingest({
160
+ type: "ai.inference",
161
+ source: "https://api.myapp.com",
162
+ subject: "cus_abc123",
163
+ data: {
164
+ "tokens": 1500,
165
+ "model": "gpt-4o",
166
+ },
114
167
  });
115
168
 
116
169
  console.log(result);
@@ -143,11 +196,11 @@ const paygentic = new Paygentic({
143
196
  async function run() {
144
197
  const result = await paygentic.billableMetrics.create({
145
198
  aggregation: "SUM",
146
- description: "other gracefully hold",
147
- merchantId: "<id>",
148
- name: "<value>",
149
- productId: "<id>",
150
- unit: "becquerel",
199
+ description: "Tracks total tokens consumed per API call",
200
+ merchantId: "org_YS8jkP59V71TdUvj",
201
+ name: "Token Counter",
202
+ productId: "prod_abc123",
203
+ unit: "tokens",
151
204
  });
152
205
 
153
206
  console.log(result);
@@ -461,11 +514,11 @@ const paygentic = new Paygentic({
461
514
  async function run() {
462
515
  const result = await paygentic.billableMetrics.create({
463
516
  aggregation: "SUM",
464
- description: "other gracefully hold",
465
- merchantId: "<id>",
466
- name: "<value>",
467
- productId: "<id>",
468
- unit: "becquerel",
517
+ description: "Tracks total tokens consumed per API call",
518
+ merchantId: "org_YS8jkP59V71TdUvj",
519
+ name: "Token Counter",
520
+ productId: "prod_abc123",
521
+ unit: "tokens",
469
522
  }, {
470
523
  retries: {
471
524
  strategy: "backoff",
@@ -507,11 +560,11 @@ const paygentic = new Paygentic({
507
560
  async function run() {
508
561
  const result = await paygentic.billableMetrics.create({
509
562
  aggregation: "SUM",
510
- description: "other gracefully hold",
511
- merchantId: "<id>",
512
- name: "<value>",
513
- productId: "<id>",
514
- unit: "becquerel",
563
+ description: "Tracks total tokens consumed per API call",
564
+ merchantId: "org_YS8jkP59V71TdUvj",
565
+ name: "Token Counter",
566
+ productId: "prod_abc123",
567
+ unit: "tokens",
515
568
  });
516
569
 
517
570
  console.log(result);
@@ -549,11 +602,11 @@ async function run() {
549
602
  try {
550
603
  const result = await paygentic.billableMetrics.create({
551
604
  aggregation: "SUM",
552
- description: "other gracefully hold",
553
- merchantId: "<id>",
554
- name: "<value>",
555
- productId: "<id>",
556
- unit: "becquerel",
605
+ description: "Tracks total tokens consumed per API call",
606
+ merchantId: "org_YS8jkP59V71TdUvj",
607
+ name: "Token Counter",
608
+ productId: "prod_abc123",
609
+ unit: "tokens",
557
610
  });
558
611
 
559
612
  console.log(result);
@@ -624,11 +677,11 @@ const paygentic = new Paygentic({
624
677
  async function run() {
625
678
  const result = await paygentic.billableMetrics.create({
626
679
  aggregation: "SUM",
627
- description: "other gracefully hold",
628
- merchantId: "<id>",
629
- name: "<value>",
630
- productId: "<id>",
631
- unit: "becquerel",
680
+ description: "Tracks total tokens consumed per API call",
681
+ merchantId: "org_YS8jkP59V71TdUvj",
682
+ name: "Token Counter",
683
+ productId: "prod_abc123",
684
+ unit: "tokens",
632
685
  });
633
686
 
634
687
  console.log(result);
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
31
31
  export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "0.1.0";
34
- readonly sdkVersion: "0.6.32";
34
+ readonly sdkVersion: "0.6.34";
35
35
  readonly genVersion: "2.879.13";
36
- readonly userAgent: "speakeasy-sdk/typescript 0.6.32 2.879.13 0.1.0 @paygentic/sdk";
36
+ readonly userAgent: "speakeasy-sdk/typescript 0.6.34 2.879.13 0.1.0 @paygentic/sdk";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -31,8 +31,8 @@ function serverURLFromOptions(options) {
31
31
  exports.SDK_METADATA = {
32
32
  language: "typescript",
33
33
  openapiDocVersion: "0.1.0",
34
- sdkVersion: "0.6.32",
34
+ sdkVersion: "0.6.34",
35
35
  genVersion: "2.879.13",
36
- userAgent: "speakeasy-sdk/typescript 0.6.32 2.879.13 0.1.0 @paygentic/sdk",
36
+ userAgent: "speakeasy-sdk/typescript 0.6.34 2.879.13 0.1.0 @paygentic/sdk",
37
37
  };
38
38
  //# sourceMappingURL=config.js.map
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
31
31
  export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "0.1.0";
34
- readonly sdkVersion: "0.6.32";
34
+ readonly sdkVersion: "0.6.34";
35
35
  readonly genVersion: "2.879.13";
36
- readonly userAgent: "speakeasy-sdk/typescript 0.6.32 2.879.13 0.1.0 @paygentic/sdk";
36
+ readonly userAgent: "speakeasy-sdk/typescript 0.6.34 2.879.13 0.1.0 @paygentic/sdk";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -27,8 +27,8 @@ export function serverURLFromOptions(options) {
27
27
  export const SDK_METADATA = {
28
28
  language: "typescript",
29
29
  openapiDocVersion: "0.1.0",
30
- sdkVersion: "0.6.32",
30
+ sdkVersion: "0.6.34",
31
31
  genVersion: "2.879.13",
32
- userAgent: "speakeasy-sdk/typescript 0.6.32 2.879.13 0.1.0 @paygentic/sdk",
32
+ userAgent: "speakeasy-sdk/typescript 0.6.34 2.879.13 0.1.0 @paygentic/sdk",
33
33
  };
34
34
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import dotenv from "dotenv";
6
+ dotenv.config();
7
+ /**
8
+ * Example usage of the @paygentic/sdk SDK
9
+ *
10
+ * To run this example from the examples directory:
11
+ * npm run build && npx tsx customersCreate.example.ts
12
+ */
13
+
14
+ import { Paygentic } from "@paygentic/sdk";
15
+
16
+ const paygentic = new Paygentic({
17
+ bearerAuth: process.env["PAYGENTIC_BEARER_AUTH"] ?? "",
18
+ });
19
+
20
+ async function main() {
21
+ const result = await paygentic.customers.create({
22
+ consumer: {
23
+ name: "Jane Smith",
24
+ email: "jane@example.com",
25
+ address: {
26
+ city: "San Francisco",
27
+ state: "CA",
28
+ country: "US",
29
+ },
30
+ },
31
+ merchantId: "org_YS8jkP59V71TdUvj",
32
+ });
33
+
34
+ console.log(result);
35
+ }
36
+
37
+ main().catch(console.error);
package/jsr.json CHANGED
@@ -1,10 +1,12 @@
1
+
2
+
1
3
  {
2
4
  "name": "@paygentic/sdk",
3
- "version": "0.6.33",
5
+ "version": "0.6.34",
4
6
  "exports": {
5
- ".": "./src/index.ts",
6
- "./models/errors": "./src/models/errors/index.ts",
7
- "./models": "./src/models/index.ts",
7
+ ".": "./src/index.ts",
8
+ "./models/errors": "./src/models/errors/index.ts",
9
+ "./models": "./src/models/index.ts",
8
10
  "./models/operations": "./src/models/operations/index.ts",
9
11
  "./lib/config": "./src/lib/config.ts",
10
12
  "./lib/http": "./src/lib/http.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paygentic/sdk",
3
- "version": "0.6.33",
3
+ "version": "0.6.34",
4
4
  "author": "Speakeasy",
5
5
  "repository": {
6
6
  "type": "git",
package/src/lib/config.ts CHANGED
@@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
61
61
  export const SDK_METADATA = {
62
62
  language: "typescript",
63
63
  openapiDocVersion: "0.1.0",
64
- sdkVersion: "0.6.32",
64
+ sdkVersion: "0.6.34",
65
65
  genVersion: "2.879.13",
66
- userAgent: "speakeasy-sdk/typescript 0.6.32 2.879.13 0.1.0 @paygentic/sdk",
66
+ userAgent: "speakeasy-sdk/typescript 0.6.34 2.879.13 0.1.0 @paygentic/sdk",
67
67
  } as const;