@openaisdk/billing-sdk-node 1.11.5 → 1.13.2

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 CHANGED
@@ -72,6 +72,64 @@ const customer = await billing.customers.create(
72
72
  );
73
73
  ```
74
74
 
75
+ ### 3.1. Обновить профиль плательщика
76
+
77
+ Форма в ЛК вендора (имя / компания, email, телефон) сохраняется через `customers.update`. Отдельного поля `company` нет: передайте компанию в `name`. Login-email пользователя — зона вашего identity, не Billing.
78
+
79
+ - Пропущенное поле не меняется; `null` очищает.
80
+ - `externalType` / `externalId` иммутабельны.
81
+ - `idempotencyKey` опционален (как у cancel): last-write-wins, безопасный retry.
82
+ - Уже финализированные счета не переписываются; следующий invoice возьмёт актуальный контакт в snapshot.
83
+ - `invoice.finalized` — webhook на ваш URL, не письмо на `customer.email`.
84
+
85
+ ```ts
86
+ const updated = await billing.customers.update(
87
+ customer.id,
88
+ {
89
+ name: 'Acme LLC',
90
+ email: 'billing@acme.example',
91
+ phone: null,
92
+ },
93
+ { idempotencyKey: `customer-update:${customer.id}:v1` }
94
+ );
95
+
96
+ console.log(updated.name, updated.email, updated.phone);
97
+ ```
98
+
99
+ Пример через curl (sandbox):
100
+
101
+ ```bash
102
+ # GET
103
+ curl -sS "$BILLING_API_URL/v1/customers/cus_123" \
104
+ -H "Authorization: Bearer $BILLING_API_KEY"
105
+
106
+ # PATCH
107
+ curl -sS -X PATCH "$BILLING_API_URL/v1/customers/cus_123" \
108
+ -H "Authorization: Bearer $BILLING_API_KEY" \
109
+ -H "Content-Type: application/json" \
110
+ -H "Idempotency-Key: customer-update:cus_123:v1" \
111
+ -d '{"name":"Acme LLC","email":"billing@acme.example","phone":null}'
112
+ ```
113
+
114
+ Ожидаемый ответ `200`:
115
+
116
+ ```json
117
+ {
118
+ "id": "cus_123",
119
+ "object": "customer",
120
+ "livemode": false,
121
+ "externalType": "workspace",
122
+ "externalId": "ws_123",
123
+ "email": "billing@acme.example",
124
+ "name": "Acme LLC",
125
+ "phone": null,
126
+ "status": "active",
127
+ "createdAt": "2026-08-10T00:00:00.000Z"
128
+ }
129
+ ```
130
+
131
+ Пустой body `{}` → `400 bad_request`. Невалидный email → `400`. Клиент другого проекта → `404 customer_account_not_found`.
132
+
75
133
  ### 4. Открыть оплату
76
134
 
77
135
  `checkout.sessions.create` → отправьте человека на `confirmationUrl`. Для create/checkout передавайте `idempotencyKey`. Если у клиента уже есть живая подписка (`active` / `trialing` / `past_due`), create вернёт 409 `active_subscription_exists` — смену тарифа делайте через `subscriptions.previewChange` / `subscriptions.change`. Незавершённую оплату читайте из `access.incompleteCheckout` и продолжайте через `checkout.sessions.resume(id)` (id = pending `sub_...`).
@@ -281,6 +339,12 @@ try {
281
339
 
282
340
  ## Changelog
283
341
 
342
+ ### 1.13.1
343
+
344
+ - Документирован `billing.customers.update` (профиль плательщика: `name` / `email` / `phone`).
345
+ - README: семантика omit/`null`, optional `idempotencyKey`, curl GET/PATCH 200, email vs login, invoice `customer_snapshot` не переписывается.
346
+ - Версия пакета выровнена с `SDK_VERSION`.
347
+
284
348
  ### 1.13.0
285
349
 
286
350
  - `billing.featureGroups.list()` / `.retrieve(code)` — публичные разделы прайса.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { toUiProjection } from './diagnostics/index.js';
2
2
  import type { CheckResult, CheckStatus, DiagnosticsContext, DiagnosticsOptions, DiagnosticsReport, DiagnosticsUiProjection } from './diagnostics/index.js';
3
- declare const SDK_VERSION = "1.13.0";
3
+ declare const SDK_VERSION = "1.13.1";
4
4
  declare const SDK_PACKAGE_NAME = "@openaisdk/billing-sdk-node";
5
5
  declare const DEFAULT_BASE_URL = "https://billing.example.com";
6
6
  declare const DEFAULT_TIMEOUT_MS = 30000;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHmac, timingSafeEqual } from 'crypto';
2
2
  import { createDiagnostics, toUiProjection } from './diagnostics/index.js';
3
- const SDK_VERSION = '1.13.0';
3
+ const SDK_VERSION = '1.13.1';
4
4
  const SDK_PACKAGE_NAME = '@openaisdk/billing-sdk-node';
5
5
  const DEFAULT_BASE_URL = 'https://billing.example.com';
6
6
  const DEFAULT_TIMEOUT_MS = 30_000;
@@ -47,9 +47,20 @@ const customer = await billing.customers.create(
47
47
  }
48
48
  );
49
49
 
50
+ const updatedCustomer = await billing.customers.update(
51
+ customer.id,
52
+ {
53
+ name: `${workspaceName} (billing)`,
54
+ email: workspaceEmail,
55
+ },
56
+ {
57
+ idempotencyKey: `customer-update:${workspaceId}:v1`,
58
+ }
59
+ );
60
+
50
61
  const checkout = await billing.checkout.sessions.create(
51
62
  {
52
- customer: customer.id,
63
+ customer: updatedCustomer.id,
53
64
  price: resolvedPriceId,
54
65
  successUrl: `${appUrl}/billing/success`,
55
66
  cancelUrl: `${appUrl}/billing`,
@@ -89,8 +100,9 @@ console.log(
89
100
  priceId: resolvedPriceId,
90
101
  featureCount: features.data.length,
91
102
  productFeatureCount: productFeatures.data.length,
92
- customerId: customer.id,
93
- customerLivemode: customer.livemode,
103
+ customerId: updatedCustomer.id,
104
+ customerName: updatedCustomer.name,
105
+ customerLivemode: updatedCustomer.livemode,
94
106
  confirmationUrl: checkout.confirmationUrl,
95
107
  subscriptionId: checkout.subscription,
96
108
  accessStatus: access.status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openaisdk/billing-sdk-node",
3
- "version": "1.11.5",
3
+ "version": "1.13.2",
4
4
  "description": "Handwritten public Node SDK for Mega-Billing Wave 1 API",
5
5
  "license": "MIT",
6
6
  "author": "Anatoliy Tukov <openaisdk@gmail.com>",
@@ -52,7 +52,7 @@
52
52
  "build": "tsc -p tsconfig.json",
53
53
  "clean": "rm -rf dist",
54
54
  "lint": "eslint .",
55
- "test": "pnpm run build && node --test ./test/**/*.test.mjs",
55
+ "test": "pnpm run build && node --test ./test/*.test.mjs",
56
56
  "quickstart": "tsx ./examples/quickstart.ts",
57
57
  "webhook-forward": "node ./bin/billing-sdk-webhook-forward.mjs",
58
58
  "prepack": "pnpm run test"