n8n-nodes-pilot-status 2.10.0 → 2.11.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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `n8n-nodes-pilot-status`.
|
|
4
4
|
|
|
5
|
+
## 2.11.0 - 2026-10-28
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Credential: Workspace ID** (optional), sent as `x-workspace-id` for an **account key**
|
|
10
|
+
(`ps_account_...`); empty = header not sent, so workspace and number keys are unchanged.
|
|
11
|
+
The credential test calls `GET /v1/workspaces` for an account key without a Workspace ID
|
|
12
|
+
(it would otherwise be `400 WORKSPACE_ID_REQUIRED`), `/v1/templates` otherwise.
|
|
13
|
+
- **Workspace (Account Key)** resource — **Get Many** (`GET /v1/workspaces`) and **Create**
|
|
14
|
+
(`POST /v1/workspaces`, body exactly `{ name }`; the answer carries the new workspace's
|
|
15
|
+
primary key once, or `apiKey: null`).
|
|
16
|
+
- **Workspace API Key (Account Key)** resource — **Get Many**, **Create** (`{ name }`) and
|
|
17
|
+
**Revoke** over `/v1/workspaces/{workspaceId}/api-keys[/{keyId}]`.
|
|
18
|
+
- **Workspace Webhook** resource — the seven operations of Phone Line Webhook over
|
|
19
|
+
`/v1/workspace/webhooks*`, with the event `wallet.topup_paid` (opt-in: `*` stays every
|
|
20
|
+
phone-line event only).
|
|
21
|
+
- **Billing** resource:
|
|
22
|
+
- **Create Checkout** (`POST /v1/billing/checkout`) with **Method** `card` (default) or
|
|
23
|
+
`pix` (BRL only; answers `pix { transactionId, copyPaste, qrCode, expiresAt }`).
|
|
24
|
+
Success/Cancel URL are never sent with Pix, and `method` never with Add Card — the API
|
|
25
|
+
answers `400 FIELD_NOT_APPLICABLE` to either.
|
|
26
|
+
- **Get Top-Up** (`GET /v1/billing/topups/{id}`).
|
|
27
|
+
- **Create / Sync Card Setup Intent** (`POST /v1/billing/card/setup-intent`,
|
|
28
|
+
`.../{id}/sync`) and **Create / Sync Payment Intent** (`POST /v1/billing/payment-intents`
|
|
29
|
+
with `{ purpose: "wallet_topup", amount, saveCard? }` and an optional **Idempotency Key**
|
|
30
|
+
header; `.../{id}/sync`) — Stripe Elements.
|
|
31
|
+
|
|
32
|
+
### Not included
|
|
33
|
+
|
|
34
|
+
- The Pilot Status Trigger does not offer `wallet.topup_paid`: like `phone_line.*`, it is
|
|
35
|
+
delivered by the workspace registry, which the Trigger's Automatic mode does not use.
|
|
36
|
+
Point a Workspace Webhook at a regular Webhook node.
|
|
37
|
+
- Phone lines' new `price` and `amountDue` fields: the node does not list or read phone
|
|
38
|
+
lines (only verification and activation audio), so there is nothing to map.
|
|
39
|
+
|
|
5
40
|
## 2.10.0 - 2026-10-27
|
|
6
41
|
|
|
7
42
|
### Added
|
package/README.md
CHANGED
|
@@ -33,10 +33,11 @@ To use the Pilot Status node, you need an **API Key**.
|
|
|
33
33
|
2. Create a new API Key.
|
|
34
34
|
3. In n8n, add a new **Pilot Status API** credential and paste your API Key.
|
|
35
35
|
|
|
36
|
-
The credential has
|
|
36
|
+
The credential has three optional fields:
|
|
37
37
|
|
|
38
38
|
- **Base URL** — API root without `/v1`. Leave it alone unless you are pointing the workflow at a staging environment. It is used by the node, by the credential test *and* by the dropdowns (templates, groups, newsletters), which used to always hit production.
|
|
39
39
|
- **WhatsApp Number ID** — sent as `x-whatsapp-number-id` on every request. Fill it in when your key is **tenant-scoped** and the operation is per-number; a **number-scoped** key already carries its number, and the header is ignored.
|
|
40
|
+
- **Workspace ID** — only for an **account key** (`ps_account_...`, created in *Profile → API*): sent as `x-workspace-id` to name the workspace the key acts on (an id from **Workspace (Account Key) → Get Many**). Without it, every workspace operation answers `400 WORKSPACE_ID_REQUIRED`; a workspace the key's user is not an active member of answers `403 WORKSPACE_MEMBERSHIP_REQUIRED`. Leave it empty for a workspace or number key. With an account key and no Workspace ID, the credential test calls `GET /v1/workspaces` instead of `/v1/templates`.
|
|
40
41
|
|
|
41
42
|
*Note: TEST keys will only send messages to the WhatsApp number registered in your Pilot Status Profile.*
|
|
42
43
|
|
|
@@ -215,6 +216,30 @@ Events: `phone_line.purchased`, `phone_line.audio_received`, `phone_line.code_re
|
|
|
215
216
|
- **Get Deliveries:** `GET /v1/phone-lines/webhooks/{id}/deliveries?limit=` (**Limit** 1–200, default 50) → `{ deliveries }`, newest first, each `{ id, event, status (PENDING|DELIVERED|FAILED), attempts, responseStatus, lastError, createdAt, deliveredAt }`. Never the payload.
|
|
216
217
|
- **Get Delivery:** `GET /v1/phone-lines/webhooks/{id}/deliveries/{deliveryId}` → `{ delivery }` with `durationMs`, `responseBody` and `payload` — the **exact signed JSON string** that was sent (parse it yourself; it is a string so the signature can be re-checked byte for byte). ⛔ A `phone_line.code_received` payload carries the **activation code** — treat this output as a credential.
|
|
217
218
|
|
|
219
|
+
### 14. Workspace Webhook (workspace events: phone lines + `wallet.topup_paid`)
|
|
220
|
+
|
|
221
|
+
`/v1/workspace/webhooks*` — the **same rows** as Phone Line Webhook (a webhook created on one shows on the other, same `plwh_...` secret and signature), with a wider event set: every `phone_line.*` event plus **`wallet.topup_paid`** (a wallet top-up, Pix or card, was credited: `data` = `{ orderId, amount, currency, method, provider, paidAt, balance }`). ⚠️ `*` (**All Phone Line Events**) means every *phone-line* event — it does **not** include `wallet.topup_paid`, which is opt-in: select it by name. Same seven operations, fields and rules as Phone Line Webhook (Create shows the secret once and is not idempotent; Update sends only the added fields; Get Deliveries `limit` 1–200; Get Delivery returns the exact signed `payload`). Tenant-scoped credential; `phone_lines:webhooks` (**ADMIN** and up).
|
|
222
|
+
|
|
223
|
+
### 15. Billing (`/v1/billing/*`)
|
|
224
|
+
|
|
225
|
+
Tenant-scoped credential. Nothing here charges by itself — a human pays the hosted page or the Pix, and a Stripe intent is confirmed by Stripe.js in a browser.
|
|
226
|
+
|
|
227
|
+
- **Create Checkout:** `POST /v1/billing/checkout`. **Purpose** *Wallet Top-Up* (needs **Amount**, in the workspace currency) or *Add Card*. For a top-up, **Method** *Card* (default) answers `{ url, purpose, method, orderId, amount, currency }` — a hosted Stripe page; *Pix* (BRL workspaces only, else `400 PIX_NOT_ELIGIBLE`) answers `{ purpose, method: "pix", orderId, status: "pending", amount, currency, pix: { transactionId, copyPaste, qrCode, expiresAt } }` — show the copy-and-paste code or the QR to the payer. Success/Cancel URL are card-only and are never sent with Pix (the API would answer `400 FIELD_NOT_APPLICABLE`); `method` is never sent with Add Card.
|
|
228
|
+
- **Get Top-Up:** `GET /v1/billing/topups/{id}` → `{ topup: { id, status (pending|paid|expired|failed), amount, currency, method, provider, createdAt, paidAt, expiresAt } }`. Read-only; poll it after a checkout or payment intent. `404 TOPUP_NOT_FOUND`.
|
|
229
|
+
- **Create Card Setup Intent:** `POST /v1/billing/card/setup-intent` → `{ clientSecret, setupIntentId, publishableKey }` for the Stripe Payment Element (`stripe.confirmSetup`). OWNER (`billing:payment_method:manage`).
|
|
230
|
+
- **Sync Card Setup Intent:** `POST /v1/billing/card/setup-intent/{id}/sync` → `{ setupIntentId, status, saved, card }` — makes the confirmed card the workspace's saved card now. Idempotent.
|
|
231
|
+
- **Create Payment Intent:** `POST /v1/billing/payment-intents` with `{ purpose: "wallet_topup", amount, saveCard? }` → `{ clientSecret, paymentIntentId, orderId, amount, currency, publishableKey }` for `stripe.confirmPayment`. Optional **Idempotency Key** (header `Idempotency-Key`): a retry within 24 h with the same key and body gets the same intent (`Idempotent-Replayed: true`); same key with another body → `409 IDEMPOTENCY_KEY_REUSED`, first call still running → `409 IDEMPOTENCY_KEY_IN_USE`.
|
|
232
|
+
- **Sync Payment Intent:** `POST /v1/billing/payment-intents/{id}/sync` → `{ paymentIntentId, status, orderId, orderStatus, amount, currency, credited, balance, cardSaved }` — credits the wallet exactly once; never charges.
|
|
233
|
+
- ⛔ Never log a `clientSecret`. `503 PAYMENTS_NOT_CONFIGURED` when card payments are unavailable.
|
|
234
|
+
|
|
235
|
+
### 16. Workspace and Workspace API Key (account key only)
|
|
236
|
+
|
|
237
|
+
These need an **account key** (`ps_account_...`); any other key or an OAuth token answers `403 ACCOUNT_KEY_REQUIRED`. The credential's Workspace ID is ignored here.
|
|
238
|
+
|
|
239
|
+
- **Workspace (Account Key) → Get Many:** `GET /v1/workspaces` → `{ data: [{ id, name, role, plan, createdAt }] }` — the workspaces the key's user is an active member of.
|
|
240
|
+
- **Workspace (Account Key) → Create:** `POST /v1/workspaces` with `{ name }` → `201 { id, name, plan, createdAt, role: "OWNER", apiKey }`, `apiKey` being the new workspace's primary `ps_workspace_...` key, **shown only here** — or `null` if minting failed (the workspace exists: mint a key with Workspace API Key → Create, do not create again). `409 WORKSPACE_LIMIT_REACHED`.
|
|
241
|
+
- **Workspace API Key → Get Many / Create / Revoke:** `GET|POST /v1/workspaces/{workspaceId}/api-keys`, `DELETE .../api-keys/{keyId}`, with the user's live role (ADMIN and up). Create mints a named key (`apiKey.key` shown once; `409 WORKSPACE_KEY_LIMIT_REACHED`); Revoke answers `{ id, revokedAt }` (`409 PRIMARY_KEY_NOT_REVOCABLE` for the primary, `404 API_KEY_NOT_FOUND`).
|
|
242
|
+
|
|
218
243
|
---
|
|
219
244
|
|
|
220
245
|
## 💡 Use Case Examples
|
|
@@ -36,6 +36,14 @@ class PilotStatusApi {
|
|
|
36
36
|
required: false,
|
|
37
37
|
description: 'Sent as x-whatsapp-number-id on every request. Required when the key is tenant-scoped and the operation is per-number (Chatwoot, webhook logs); leave empty for a number-scoped key, which already carries its number.',
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Workspace ID',
|
|
41
|
+
name: 'workspaceId',
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: '',
|
|
44
|
+
required: false,
|
|
45
|
+
description: 'Only for an ACCOUNT key (ps_account_…, created in Profile → API): sent as x-workspace-id on every request to name the workspace the key acts on (an id from Workspace → Get Many). Without it, every workspace operation answers 400 WORKSPACE_ID_REQUIRED; a workspace the key\'s user is not an active member of answers 403 WORKSPACE_MEMBERSHIP_REQUIRED. The Workspace and Workspace API Key resources need an account key and ignore this field; any other key there answers 403 ACCOUNT_KEY_REQUIRED. Leave empty for a workspace or number key.',
|
|
46
|
+
},
|
|
39
47
|
];
|
|
40
48
|
this.authenticate = {
|
|
41
49
|
type: 'generic',
|
|
@@ -47,13 +55,18 @@ class PilotStatusApi {
|
|
|
47
55
|
// `x-whatsapp-number-id: `, which the server would read as a header
|
|
48
56
|
// that is present and invalid.
|
|
49
57
|
'x-whatsapp-number-id': '={{$credentials.whatsappNumberId || undefined}}',
|
|
58
|
+
// Same rule: empty = header omitted, so workspace and number keys are unchanged.
|
|
59
|
+
'x-workspace-id': '={{$credentials.workspaceId || undefined}}',
|
|
50
60
|
},
|
|
51
61
|
},
|
|
52
62
|
};
|
|
53
63
|
this.test = {
|
|
54
64
|
request: {
|
|
55
65
|
baseURL: '={{($credentials.baseUrl || "https://pilotstatus.com.br").replace(/\\/+$/, "") + "/v1"}}',
|
|
56
|
-
|
|
66
|
+
// An account key with no Workspace ID names no workspace, so /templates would be
|
|
67
|
+
// 400 WORKSPACE_ID_REQUIRED for a valid key: it is tested on /workspaces instead,
|
|
68
|
+
// the one route it reaches without the header.
|
|
69
|
+
url: '={{String($credentials.apiKey || "").startsWith("ps_account_") && !$credentials.workspaceId ? "/workspaces" : "/templates"}}',
|
|
57
70
|
},
|
|
58
71
|
};
|
|
59
72
|
}
|
|
@@ -66,6 +66,49 @@ export declare function phoneLineWebhookCreatePreSend(this: IExecuteSingleFuncti
|
|
|
66
66
|
* `null` with 400 INVALID_FIELD_TYPE). `active: false` is sent as is: it pauses the webhook.
|
|
67
67
|
*/
|
|
68
68
|
export declare function phoneLineWebhookUpdatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
69
|
+
/**
|
|
70
|
+
* The events a WORKSPACE webhook subscribes to (`/v1/workspace/webhooks`): the phone-line
|
|
71
|
+
* events plus the workspace's own (`wallet.topup_paid`). Same table, secret and signature as
|
|
72
|
+
* the phone-line webhooks — a row made on either surface shows on both.
|
|
73
|
+
*
|
|
74
|
+
* ⚠️ `*` keeps the meaning it always had in this table: every PHONE-LINE event. Wallet
|
|
75
|
+
* events are OPT-IN — a `*` row never receives `wallet.topup_paid`; select it by name.
|
|
76
|
+
*/
|
|
77
|
+
export declare const WORKSPACE_WEBHOOK_EVENT_OPTIONS: INodePropertyOptions[];
|
|
78
|
+
/**
|
|
79
|
+
* Workspace Webhook → Create: the WHOLE `POST /v1/workspace/webhooks` body. Same strictness as
|
|
80
|
+
* the phone-line twin: exactly `url`, `events` and — only when not blank — `name`.
|
|
81
|
+
*/
|
|
82
|
+
export declare function workspaceWebhookCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
83
|
+
/**
|
|
84
|
+
* Workspace Webhook → Update: the `PATCH /v1/workspace/webhooks/{id}` body — only the fields
|
|
85
|
+
* added under "Update Fields", blanks and empty lists left out, `active: false` sent as is.
|
|
86
|
+
*/
|
|
87
|
+
export declare function workspaceWebhookUpdatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
88
|
+
/**
|
|
89
|
+
* Workspace → Create: the body is exactly `{ name }` — `POST /v1/workspaces` refuses any other
|
|
90
|
+
* field with 400 UNKNOWN_FIELDS.
|
|
91
|
+
*/
|
|
92
|
+
export declare function workspaceCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
93
|
+
/** Workspace API Key → Create: the body is exactly `{ name }`. */
|
|
94
|
+
export declare function workspaceApiKeyCreatePreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
95
|
+
/**
|
|
96
|
+
* Billing → Create Checkout: the `POST /v1/billing/checkout` body.
|
|
97
|
+
*
|
|
98
|
+
* - Add Card: `{ purpose, successUrl?, cancelUrl? }` — never `method` (400 FIELD_NOT_APPLICABLE).
|
|
99
|
+
* - Wallet Top-Up: `{ purpose, amount, method }`; with method `card` also the redirect URLs.
|
|
100
|
+
* With `pix` they are NEVER sent, even if a value lingers in the hidden fields: a Pix has no
|
|
101
|
+
* redirect and the API answers 400 FIELD_NOT_APPLICABLE to them.
|
|
102
|
+
*
|
|
103
|
+
* Blank URLs are left out instead of sent empty.
|
|
104
|
+
*/
|
|
105
|
+
export declare function billingCheckoutPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
106
|
+
/**
|
|
107
|
+
* Billing → Create Payment Intent: the body is `{ purpose: "wallet_topup", amount }` plus
|
|
108
|
+
* `saveCard` only when on (the route refuses unknown fields). The optional Idempotency Key goes
|
|
109
|
+
* out as the `Idempotency-Key` HEADER; blank = not sent (every run creates a new intent).
|
|
110
|
+
*/
|
|
111
|
+
export declare function billingPaymentIntentPreSend(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions>;
|
|
69
112
|
/**
|
|
70
113
|
* Lead Form → Update: builds the WHOLE `PUT /v1/lead-pages/{id}/forms/{formId}` body.
|
|
71
114
|
*
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PilotStatus = exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS = exports.DEFAULT_BASE_URL = exports.FLOW_CATEGORY_OPTIONS = exports.GO_TRISTATE = void 0;
|
|
3
|
+
exports.PilotStatus = exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS = exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS = exports.DEFAULT_BASE_URL = exports.FLOW_CATEGORY_OPTIONS = exports.GO_TRISTATE = void 0;
|
|
4
4
|
exports.apiBaseUrl = apiBaseUrl;
|
|
5
5
|
exports.resolvePhoneLineDocument = resolvePhoneLineDocument;
|
|
6
6
|
exports.phoneLineStartVerificationPreSend = phoneLineStartVerificationPreSend;
|
|
7
7
|
exports.phoneLineSubmitDocumentPreSend = phoneLineSubmitDocumentPreSend;
|
|
8
8
|
exports.phoneLineWebhookCreatePreSend = phoneLineWebhookCreatePreSend;
|
|
9
9
|
exports.phoneLineWebhookUpdatePreSend = phoneLineWebhookUpdatePreSend;
|
|
10
|
+
exports.workspaceWebhookCreatePreSend = workspaceWebhookCreatePreSend;
|
|
11
|
+
exports.workspaceWebhookUpdatePreSend = workspaceWebhookUpdatePreSend;
|
|
12
|
+
exports.workspaceCreatePreSend = workspaceCreatePreSend;
|
|
13
|
+
exports.workspaceApiKeyCreatePreSend = workspaceApiKeyCreatePreSend;
|
|
14
|
+
exports.billingCheckoutPreSend = billingCheckoutPreSend;
|
|
15
|
+
exports.billingPaymentIntentPreSend = billingPaymentIntentPreSend;
|
|
10
16
|
exports.leadFormConfigPreSend = leadFormConfigPreSend;
|
|
11
17
|
exports.parseContentDispositionFileName = parseContentDispositionFileName;
|
|
12
18
|
exports.phoneLineAudioToBinary = phoneLineAudioToBinary;
|
|
@@ -195,6 +201,154 @@ async function phoneLineWebhookUpdatePreSend(requestOptions) {
|
|
|
195
201
|
requestOptions.body = body;
|
|
196
202
|
return requestOptions;
|
|
197
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* The events a WORKSPACE webhook subscribes to (`/v1/workspace/webhooks`): the phone-line
|
|
206
|
+
* events plus the workspace's own (`wallet.topup_paid`). Same table, secret and signature as
|
|
207
|
+
* the phone-line webhooks — a row made on either surface shows on both.
|
|
208
|
+
*
|
|
209
|
+
* ⚠️ `*` keeps the meaning it always had in this table: every PHONE-LINE event. Wallet
|
|
210
|
+
* events are OPT-IN — a `*` row never receives `wallet.topup_paid`; select it by name.
|
|
211
|
+
*/
|
|
212
|
+
exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS = [
|
|
213
|
+
{
|
|
214
|
+
name: 'All Phone Line Events',
|
|
215
|
+
value: '*',
|
|
216
|
+
description: 'Every phone_line.* event, including future ones. Does NOT include Wallet Top-Up Paid.',
|
|
217
|
+
},
|
|
218
|
+
...exports.PHONE_LINE_WEBHOOK_EVENT_OPTIONS.filter((o) => o.value !== '*'),
|
|
219
|
+
{
|
|
220
|
+
name: 'Wallet Top-Up Paid',
|
|
221
|
+
value: 'wallet.topup_paid',
|
|
222
|
+
description: 'A wallet top-up (Pix or card) was credited: data has orderId, amount, currency, method, provider, paidAt and balance. Opt-in: "*" does not include it.',
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
/**
|
|
226
|
+
* Workspace Webhook → Create: the WHOLE `POST /v1/workspace/webhooks` body. Same strictness as
|
|
227
|
+
* the phone-line twin: exactly `url`, `events` and — only when not blank — `name`.
|
|
228
|
+
*/
|
|
229
|
+
async function workspaceWebhookCreatePreSend(requestOptions) {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
const url = String((_a = this.getNodeParameter('workspaceWebhookUrl', '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
232
|
+
if (!url)
|
|
233
|
+
throw new Error('Pilot Status: "URL" is required to create a workspace webhook.');
|
|
234
|
+
const events = toEventList(this.getNodeParameter('workspaceWebhookEvents', []));
|
|
235
|
+
if (events.length === 0) {
|
|
236
|
+
throw new Error('Pilot Status: choose at least one event in "Events" to create a workspace webhook.');
|
|
237
|
+
}
|
|
238
|
+
const body = { url, events };
|
|
239
|
+
const name = String((_b = this.getNodeParameter('workspaceWebhookName', '')) !== null && _b !== void 0 ? _b : '').trim();
|
|
240
|
+
if (name)
|
|
241
|
+
body.name = name;
|
|
242
|
+
requestOptions.body = body;
|
|
243
|
+
return requestOptions;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Workspace Webhook → Update: the `PATCH /v1/workspace/webhooks/{id}` body — only the fields
|
|
247
|
+
* added under "Update Fields", blanks and empty lists left out, `active: false` sent as is.
|
|
248
|
+
*/
|
|
249
|
+
async function workspaceWebhookUpdatePreSend(requestOptions) {
|
|
250
|
+
const raw = this.getNodeParameter('workspaceWebhookUpdateFields', {});
|
|
251
|
+
const fields = raw && typeof raw === 'object' ? raw : {};
|
|
252
|
+
const body = {};
|
|
253
|
+
const name = typeof fields.name === 'string' ? fields.name.trim() : '';
|
|
254
|
+
if (name)
|
|
255
|
+
body.name = name;
|
|
256
|
+
const url = typeof fields.url === 'string' ? fields.url.trim() : '';
|
|
257
|
+
if (url)
|
|
258
|
+
body.url = url;
|
|
259
|
+
if (fields.events !== undefined) {
|
|
260
|
+
const events = toEventList(fields.events);
|
|
261
|
+
if (events.length > 0)
|
|
262
|
+
body.events = events;
|
|
263
|
+
}
|
|
264
|
+
if (typeof fields.active === 'boolean')
|
|
265
|
+
body.active = fields.active;
|
|
266
|
+
if (Object.keys(body).length === 0) {
|
|
267
|
+
throw new Error('Pilot Status: add at least one field under "Update Fields" (Name, URL, Events or Active) to update a workspace webhook.');
|
|
268
|
+
}
|
|
269
|
+
requestOptions.body = body;
|
|
270
|
+
return requestOptions;
|
|
271
|
+
}
|
|
272
|
+
/** A required, trimmed `name` for the account-level creates (`{ name }` is the whole body). */
|
|
273
|
+
function requiredName(param, what) {
|
|
274
|
+
var _a;
|
|
275
|
+
const name = String((_a = this.getNodeParameter(param, '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
276
|
+
if (!name)
|
|
277
|
+
throw new Error(`Pilot Status: "Name" is required to create ${what}.`);
|
|
278
|
+
return name;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Workspace → Create: the body is exactly `{ name }` — `POST /v1/workspaces` refuses any other
|
|
282
|
+
* field with 400 UNKNOWN_FIELDS.
|
|
283
|
+
*/
|
|
284
|
+
async function workspaceCreatePreSend(requestOptions) {
|
|
285
|
+
requestOptions.body = { name: requiredName.call(this, 'workspaceName', 'a workspace') };
|
|
286
|
+
return requestOptions;
|
|
287
|
+
}
|
|
288
|
+
/** Workspace API Key → Create: the body is exactly `{ name }`. */
|
|
289
|
+
async function workspaceApiKeyCreatePreSend(requestOptions) {
|
|
290
|
+
requestOptions.body = { name: requiredName.call(this, 'workspaceApiKeyName', 'a workspace API key') };
|
|
291
|
+
return requestOptions;
|
|
292
|
+
}
|
|
293
|
+
/** A positive finite amount, or a clear error before the round trip (the API's INVALID_AMOUNT). */
|
|
294
|
+
function positiveAmount(raw, what) {
|
|
295
|
+
const amount = Number(raw);
|
|
296
|
+
if (!Number.isFinite(amount) || amount <= 0) {
|
|
297
|
+
throw new Error(`Pilot Status: "Amount" must be a positive number to ${what}.`);
|
|
298
|
+
}
|
|
299
|
+
return amount;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Billing → Create Checkout: the `POST /v1/billing/checkout` body.
|
|
303
|
+
*
|
|
304
|
+
* - Add Card: `{ purpose, successUrl?, cancelUrl? }` — never `method` (400 FIELD_NOT_APPLICABLE).
|
|
305
|
+
* - Wallet Top-Up: `{ purpose, amount, method }`; with method `card` also the redirect URLs.
|
|
306
|
+
* With `pix` they are NEVER sent, even if a value lingers in the hidden fields: a Pix has no
|
|
307
|
+
* redirect and the API answers 400 FIELD_NOT_APPLICABLE to them.
|
|
308
|
+
*
|
|
309
|
+
* Blank URLs are left out instead of sent empty.
|
|
310
|
+
*/
|
|
311
|
+
async function billingCheckoutPreSend(requestOptions) {
|
|
312
|
+
var _a, _b;
|
|
313
|
+
const purpose = String(this.getNodeParameter('billingPurpose', 'wallet_topup'));
|
|
314
|
+
const body = { purpose };
|
|
315
|
+
let withUrls = true;
|
|
316
|
+
if (purpose === 'wallet_topup') {
|
|
317
|
+
body.amount = positiveAmount(this.getNodeParameter('billingAmount', 0), 'top up the wallet');
|
|
318
|
+
const method = String(this.getNodeParameter('billingMethod', 'card'));
|
|
319
|
+
body.method = method;
|
|
320
|
+
withUrls = method !== 'pix';
|
|
321
|
+
}
|
|
322
|
+
if (withUrls) {
|
|
323
|
+
const successUrl = String((_a = this.getNodeParameter('billingSuccessUrl', '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
324
|
+
if (successUrl)
|
|
325
|
+
body.successUrl = successUrl;
|
|
326
|
+
const cancelUrl = String((_b = this.getNodeParameter('billingCancelUrl', '')) !== null && _b !== void 0 ? _b : '').trim();
|
|
327
|
+
if (cancelUrl)
|
|
328
|
+
body.cancelUrl = cancelUrl;
|
|
329
|
+
}
|
|
330
|
+
requestOptions.body = body;
|
|
331
|
+
return requestOptions;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Billing → Create Payment Intent: the body is `{ purpose: "wallet_topup", amount }` plus
|
|
335
|
+
* `saveCard` only when on (the route refuses unknown fields). The optional Idempotency Key goes
|
|
336
|
+
* out as the `Idempotency-Key` HEADER; blank = not sent (every run creates a new intent).
|
|
337
|
+
*/
|
|
338
|
+
async function billingPaymentIntentPreSend(requestOptions) {
|
|
339
|
+
var _a, _b;
|
|
340
|
+
const body = {
|
|
341
|
+
purpose: 'wallet_topup',
|
|
342
|
+
amount: positiveAmount(this.getNodeParameter('billingAmount', 0), 'create a payment intent'),
|
|
343
|
+
};
|
|
344
|
+
if (this.getNodeParameter('billingSaveCard', false) === true)
|
|
345
|
+
body.saveCard = true;
|
|
346
|
+
requestOptions.body = body;
|
|
347
|
+
const key = String((_a = this.getNodeParameter('billingIdempotencyKey', '')) !== null && _a !== void 0 ? _a : '').trim();
|
|
348
|
+
if (key)
|
|
349
|
+
requestOptions.headers = { ...((_b = requestOptions.headers) !== null && _b !== void 0 ? _b : {}), 'Idempotency-Key': key };
|
|
350
|
+
return requestOptions;
|
|
351
|
+
}
|
|
198
352
|
/**
|
|
199
353
|
* Lead Form → Update: builds the WHOLE `PUT /v1/lead-pages/{id}/forms/{formId}` body.
|
|
200
354
|
*
|
|
@@ -433,6 +587,10 @@ class PilotStatus {
|
|
|
433
587
|
{ name: 'Call', value: 'call' },
|
|
434
588
|
{ name: 'Phone Line', value: 'phoneLine' },
|
|
435
589
|
{ name: 'Phone Line Webhook', value: 'phoneLineWebhook' },
|
|
590
|
+
{ name: 'Workspace Webhook', value: 'workspaceWebhook' },
|
|
591
|
+
{ name: 'Billing', value: 'billing' },
|
|
592
|
+
{ name: 'Workspace (Account Key)', value: 'workspace' },
|
|
593
|
+
{ name: 'Workspace API Key (Account Key)', value: 'workspaceApiKey' },
|
|
436
594
|
],
|
|
437
595
|
default: 'message',
|
|
438
596
|
},
|
|
@@ -3376,6 +3534,500 @@ class PilotStatus {
|
|
|
3376
3534
|
default: 50,
|
|
3377
3535
|
routing: { send: { type: 'query', property: 'limit' } },
|
|
3378
3536
|
},
|
|
3537
|
+
// ----------------------------------
|
|
3538
|
+
// Workspace Webhook Operations (/v1/workspace/webhooks) — the workspace's events: every
|
|
3539
|
+
// phone_line.* event plus wallet.topup_paid. Same rows as Phone Line Webhook (a webhook made
|
|
3540
|
+
// on one shows on the other). TENANT-SCOPED key only (a workspace key, or an account key with Workspace ID set); permission phone_lines:webhooks (ADMIN and up).
|
|
3541
|
+
// ----------------------------------
|
|
3542
|
+
{
|
|
3543
|
+
displayName: 'Operation',
|
|
3544
|
+
name: 'operation',
|
|
3545
|
+
type: 'options',
|
|
3546
|
+
noDataExpression: true,
|
|
3547
|
+
displayOptions: { show: { resource: ['workspaceWebhook'] } },
|
|
3548
|
+
options: [
|
|
3549
|
+
{
|
|
3550
|
+
name: 'Create',
|
|
3551
|
+
value: 'create',
|
|
3552
|
+
description: 'Register a webhook for workspace events (phone lines and Wallet Top-Up Paid). Answers 201 {webhook} with the plwh_ signing SECRET — shown ONLY in this response, never again: store it now. Not idempotent: running it twice creates two webhooks with two secrets.',
|
|
3553
|
+
action: 'Create a workspace webhook',
|
|
3554
|
+
routing: {
|
|
3555
|
+
request: { method: 'POST', url: '/workspace/webhooks' },
|
|
3556
|
+
send: { preSend: [workspaceWebhookCreatePreSend] },
|
|
3557
|
+
},
|
|
3558
|
+
},
|
|
3559
|
+
{
|
|
3560
|
+
name: 'Delete',
|
|
3561
|
+
value: 'delete',
|
|
3562
|
+
description: 'Delete a workspace webhook AND its delivery history. There is no undo. Answers {ok: true}.',
|
|
3563
|
+
action: 'Delete a workspace webhook',
|
|
3564
|
+
routing: { request: { method: 'DELETE', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}' } },
|
|
3565
|
+
},
|
|
3566
|
+
{
|
|
3567
|
+
name: 'Get',
|
|
3568
|
+
value: 'get',
|
|
3569
|
+
description: 'One workspace webhook: {webhook} with id, name, url, events, active, lastDeliveryAt, lastStatusCode, createdAt. Never the secret. Another workspace\'s webhook is 404 WEBHOOK_NOT_FOUND.',
|
|
3570
|
+
action: 'Get a workspace webhook',
|
|
3571
|
+
routing: { request: { method: 'GET', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}' } },
|
|
3572
|
+
},
|
|
3573
|
+
{
|
|
3574
|
+
name: 'Get Many',
|
|
3575
|
+
value: 'getAll',
|
|
3576
|
+
description: 'Every webhook of the workspace (oldest first, including the ones made as Phone Line Webhook) and the subscribable event catalogue. Answers {webhooks, events}. Never the secrets.',
|
|
3577
|
+
action: 'Get many workspace webhooks',
|
|
3578
|
+
routing: { request: { method: 'GET', url: '/workspace/webhooks' } },
|
|
3579
|
+
},
|
|
3580
|
+
{
|
|
3581
|
+
name: 'Update',
|
|
3582
|
+
value: 'update',
|
|
3583
|
+
description: 'Change only the fields added under Update Fields; the others stay as they are. Active off PAUSES the webhook. Answers {webhook}; the secret does not change.',
|
|
3584
|
+
action: 'Update a workspace webhook',
|
|
3585
|
+
routing: {
|
|
3586
|
+
request: { method: 'PATCH', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}' },
|
|
3587
|
+
send: { preSend: [workspaceWebhookUpdatePreSend] },
|
|
3588
|
+
},
|
|
3589
|
+
},
|
|
3590
|
+
{
|
|
3591
|
+
name: 'Get Deliveries',
|
|
3592
|
+
value: 'getDeliveries',
|
|
3593
|
+
description: 'The webhook\'s latest deliveries, newest first: {deliveries} with event, status (PENDING, DELIVERED, FAILED), attempts, responseStatus, lastError, createdAt, deliveredAt. Never the payload — use Get Delivery for that.',
|
|
3594
|
+
action: 'Get the deliveries of a workspace webhook',
|
|
3595
|
+
routing: { request: { method: 'GET', url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}/deliveries' } },
|
|
3596
|
+
},
|
|
3597
|
+
{
|
|
3598
|
+
name: 'Get Delivery',
|
|
3599
|
+
value: 'getDelivery',
|
|
3600
|
+
description: 'One delivery with durationMs, responseBody and the payload: the EXACT signed JSON string that was sent. A phone_line.code_received payload carries the activation code — treat the output as a credential.',
|
|
3601
|
+
action: 'Get a delivery of a workspace webhook',
|
|
3602
|
+
routing: {
|
|
3603
|
+
request: {
|
|
3604
|
+
method: 'GET',
|
|
3605
|
+
url: '=/workspace/webhooks/{{encodeURIComponent($parameter.workspaceWebhookId)}}/deliveries/{{encodeURIComponent($parameter.workspaceWebhookDeliveryId)}}',
|
|
3606
|
+
},
|
|
3607
|
+
},
|
|
3608
|
+
},
|
|
3609
|
+
],
|
|
3610
|
+
default: 'getAll',
|
|
3611
|
+
},
|
|
3612
|
+
{
|
|
3613
|
+
displayName: 'Webhook ID',
|
|
3614
|
+
name: 'workspaceWebhookId',
|
|
3615
|
+
type: 'string',
|
|
3616
|
+
description: 'Pilot Status id of the workspace webhook — webhooks[].id from Get Many',
|
|
3617
|
+
displayOptions: {
|
|
3618
|
+
show: {
|
|
3619
|
+
resource: ['workspaceWebhook'],
|
|
3620
|
+
operation: ['delete', 'get', 'update', 'getDeliveries', 'getDelivery'],
|
|
3621
|
+
},
|
|
3622
|
+
},
|
|
3623
|
+
default: '',
|
|
3624
|
+
required: true,
|
|
3625
|
+
},
|
|
3626
|
+
{
|
|
3627
|
+
displayName: 'Delivery ID',
|
|
3628
|
+
name: 'workspaceWebhookDeliveryId',
|
|
3629
|
+
type: 'string',
|
|
3630
|
+
description: 'deliveries[].id from Get Deliveries',
|
|
3631
|
+
displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['getDelivery'] } },
|
|
3632
|
+
default: '',
|
|
3633
|
+
required: true,
|
|
3634
|
+
},
|
|
3635
|
+
// Workspace Webhook: Create. The body is built by workspaceWebhookCreatePreSend.
|
|
3636
|
+
{
|
|
3637
|
+
displayName: 'URL',
|
|
3638
|
+
name: 'workspaceWebhookUrl',
|
|
3639
|
+
type: 'string',
|
|
3640
|
+
placeholder: 'https://example.com/workspace-hook',
|
|
3641
|
+
description: 'HTTPS URL that receives the events. Must be public: an internal or private destination is refused (400 WEBHOOK_URL_REFUSED).',
|
|
3642
|
+
displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['create'] } },
|
|
3643
|
+
default: '',
|
|
3644
|
+
required: true,
|
|
3645
|
+
},
|
|
3646
|
+
{
|
|
3647
|
+
displayName: 'Events',
|
|
3648
|
+
name: 'workspaceWebhookEvents',
|
|
3649
|
+
type: 'multiOptions',
|
|
3650
|
+
options: exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS,
|
|
3651
|
+
description: 'Events delivered to the URL. At least one is required. "All Phone Line Events" does NOT include Wallet Top-Up Paid — select it by name.',
|
|
3652
|
+
displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['create'] } },
|
|
3653
|
+
default: [],
|
|
3654
|
+
required: true,
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
displayName: 'Name',
|
|
3658
|
+
name: 'workspaceWebhookName',
|
|
3659
|
+
type: 'string',
|
|
3660
|
+
description: 'Optional label (max 100 characters). Left empty, the URL\'s hostname is used.',
|
|
3661
|
+
displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['create'] } },
|
|
3662
|
+
default: '',
|
|
3663
|
+
},
|
|
3664
|
+
// Workspace Webhook: Update. The body is built by workspaceWebhookUpdatePreSend.
|
|
3665
|
+
{
|
|
3666
|
+
displayName: 'Update Fields',
|
|
3667
|
+
name: 'workspaceWebhookUpdateFields',
|
|
3668
|
+
type: 'collection',
|
|
3669
|
+
placeholder: 'Add Field',
|
|
3670
|
+
displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['update'] } },
|
|
3671
|
+
default: {},
|
|
3672
|
+
options: [
|
|
3673
|
+
{
|
|
3674
|
+
displayName: 'Active',
|
|
3675
|
+
name: 'active',
|
|
3676
|
+
type: 'boolean',
|
|
3677
|
+
default: true,
|
|
3678
|
+
description: 'Whether the webhook receives events. Off pauses it without deleting it.',
|
|
3679
|
+
},
|
|
3680
|
+
{
|
|
3681
|
+
displayName: 'Events',
|
|
3682
|
+
name: 'events',
|
|
3683
|
+
type: 'multiOptions',
|
|
3684
|
+
options: exports.WORKSPACE_WEBHOOK_EVENT_OPTIONS,
|
|
3685
|
+
default: [],
|
|
3686
|
+
description: 'REPLACES the subscribed events. An empty selection is ignored.',
|
|
3687
|
+
},
|
|
3688
|
+
{
|
|
3689
|
+
displayName: 'Name',
|
|
3690
|
+
name: 'name',
|
|
3691
|
+
type: 'string',
|
|
3692
|
+
default: '',
|
|
3693
|
+
description: 'New label (max 100 characters). A blank value is ignored.',
|
|
3694
|
+
},
|
|
3695
|
+
{
|
|
3696
|
+
displayName: 'URL',
|
|
3697
|
+
name: 'url',
|
|
3698
|
+
type: 'string',
|
|
3699
|
+
default: '',
|
|
3700
|
+
placeholder: 'https://example.com/workspace-hook',
|
|
3701
|
+
description: 'New HTTPS public URL. A blank value is ignored.',
|
|
3702
|
+
},
|
|
3703
|
+
],
|
|
3704
|
+
},
|
|
3705
|
+
// Workspace Webhook: Get Deliveries
|
|
3706
|
+
{
|
|
3707
|
+
displayName: 'Limit',
|
|
3708
|
+
name: 'workspaceWebhookDeliveriesLimit',
|
|
3709
|
+
type: 'number',
|
|
3710
|
+
typeOptions: { minValue: 1, maxValue: 200 },
|
|
3711
|
+
description: 'Max number of results to return',
|
|
3712
|
+
displayOptions: { show: { resource: ['workspaceWebhook'], operation: ['getDeliveries'] } },
|
|
3713
|
+
default: 50,
|
|
3714
|
+
routing: { send: { type: 'query', property: 'limit' } },
|
|
3715
|
+
},
|
|
3716
|
+
// ----------------------------------
|
|
3717
|
+
// Billing Operations (/v1/billing/*) — TENANT-SCOPED key only (a workspace key, or an account key with Workspace ID set). Nothing here
|
|
3718
|
+
// charges by itself: a human pays the hosted page or the Pix, and a Stripe intent is
|
|
3719
|
+
// confirmed by Stripe.js in a browser. Checkout/top-up/payment intents need
|
|
3720
|
+
// billing:wallet:topup; Add Card and setup intents billing:payment_method:manage (OWNER);
|
|
3721
|
+
// Get Top-Up billing:read.
|
|
3722
|
+
// ----------------------------------
|
|
3723
|
+
{
|
|
3724
|
+
displayName: 'Operation',
|
|
3725
|
+
name: 'operation',
|
|
3726
|
+
type: 'options',
|
|
3727
|
+
noDataExpression: true,
|
|
3728
|
+
displayOptions: { show: { resource: ['billing'] } },
|
|
3729
|
+
options: [
|
|
3730
|
+
{
|
|
3731
|
+
name: 'Create Checkout',
|
|
3732
|
+
value: 'createCheckout',
|
|
3733
|
+
description: 'Wallet Top-Up: by card, a hosted Stripe page {url, orderId}; by Pix (BRL workspaces only, else 400 PIX_NOT_ELIGIBLE), {orderId, status: pending, pix: {transactionId, copyPaste, qrCode, expiresAt}} — show the copy-and-paste code or the QR to the payer. Add Card: a hosted page {url} that saves a card. Nothing is charged until a human pays. Poll a top-up with Get Top-Up.',
|
|
3734
|
+
action: 'Create a checkout',
|
|
3735
|
+
routing: {
|
|
3736
|
+
request: { method: 'POST', url: '/billing/checkout' },
|
|
3737
|
+
send: { preSend: [billingCheckoutPreSend] },
|
|
3738
|
+
},
|
|
3739
|
+
},
|
|
3740
|
+
{
|
|
3741
|
+
name: 'Get Top-Up',
|
|
3742
|
+
value: 'getTopup',
|
|
3743
|
+
description: 'Status of a wallet top-up order (card or Pix): {topup} with id, status (pending, paid, expired, failed), amount, currency, method, provider, createdAt, paidAt, expiresAt. Read-only — polling it calls no payment provider. Another workspace\'s order is 404 TOPUP_NOT_FOUND.',
|
|
3744
|
+
action: 'Get a wallet top-up',
|
|
3745
|
+
routing: {
|
|
3746
|
+
request: {
|
|
3747
|
+
method: 'GET',
|
|
3748
|
+
url: '=/billing/topups/{{encodeURIComponent($parameter.billingTopupId)}}',
|
|
3749
|
+
},
|
|
3750
|
+
},
|
|
3751
|
+
},
|
|
3752
|
+
{
|
|
3753
|
+
name: 'Create Card Setup Intent',
|
|
3754
|
+
value: 'createCardSetupIntent',
|
|
3755
|
+
description: 'Transparent card save (Stripe Elements): {clientSecret, setupIntentId, publishableKey} for your page to mount the Payment Element and call stripe.confirmSetup — the card goes browser → Stripe. Then run Sync Card Setup Intent. The clientSecret lets anyone holding it confirm the intent: never log it. 503 PAYMENTS_NOT_CONFIGURED when card payments are unavailable.',
|
|
3756
|
+
action: 'Create a card setup intent',
|
|
3757
|
+
routing: { request: { method: 'POST', url: '/billing/card/setup-intent' } },
|
|
3758
|
+
},
|
|
3759
|
+
{
|
|
3760
|
+
name: 'Sync Card Setup Intent',
|
|
3761
|
+
value: 'syncCardSetupIntent',
|
|
3762
|
+
description: 'After stripe.confirmSetup resolves: reads the SetupIntent from Stripe and, if it succeeded, makes the card the workspace\'s saved card now. Answers {setupIntentId, status, saved, card: {brand, last4, expMonth, expYear} | null}; not succeeded yet = saved false. Idempotent. Unknown or another workspace\'s id: 404 SETUP_INTENT_NOT_FOUND.',
|
|
3763
|
+
action: 'Sync a card setup intent',
|
|
3764
|
+
routing: {
|
|
3765
|
+
request: {
|
|
3766
|
+
method: 'POST',
|
|
3767
|
+
url: '=/billing/card/setup-intent/{{encodeURIComponent($parameter.billingSetupIntentId)}}/sync',
|
|
3768
|
+
},
|
|
3769
|
+
},
|
|
3770
|
+
},
|
|
3771
|
+
{
|
|
3772
|
+
name: 'Create Payment Intent',
|
|
3773
|
+
value: 'createPaymentIntent',
|
|
3774
|
+
description: 'Transparent wallet top-up by card (Stripe Elements): creates a pending order and a PaymentIntent, answering {clientSecret, paymentIntentId, orderId, amount, currency, publishableKey} for stripe.confirmPayment in your page. Then run Sync Payment Intent. Never log the clientSecret. 400 AMOUNT_TOO_SMALL below the minimum card charge; 503 PAYMENTS_NOT_CONFIGURED.',
|
|
3775
|
+
action: 'Create a payment intent',
|
|
3776
|
+
routing: {
|
|
3777
|
+
request: { method: 'POST', url: '/billing/payment-intents' },
|
|
3778
|
+
send: { preSend: [billingPaymentIntentPreSend] },
|
|
3779
|
+
},
|
|
3780
|
+
},
|
|
3781
|
+
{
|
|
3782
|
+
name: 'Sync Payment Intent',
|
|
3783
|
+
value: 'syncPaymentIntent',
|
|
3784
|
+
description: 'After stripe.confirmPayment resolves: reads the PaymentIntent from Stripe and, if it succeeded, credits the wallet — exactly once (a replay, or the racing webhook, gets credited false). Answers {paymentIntentId, status, orderId, orderStatus, amount, currency, credited, balance, cardSaved}. It never charges. Unknown or another workspace\'s id: 404 PAYMENT_INTENT_NOT_FOUND.',
|
|
3785
|
+
action: 'Sync a payment intent',
|
|
3786
|
+
routing: {
|
|
3787
|
+
request: {
|
|
3788
|
+
method: 'POST',
|
|
3789
|
+
url: '=/billing/payment-intents/{{encodeURIComponent($parameter.billingPaymentIntentId)}}/sync',
|
|
3790
|
+
},
|
|
3791
|
+
},
|
|
3792
|
+
},
|
|
3793
|
+
],
|
|
3794
|
+
default: 'createCheckout',
|
|
3795
|
+
},
|
|
3796
|
+
// Billing: Create Checkout. The body is built by billingCheckoutPreSend.
|
|
3797
|
+
{
|
|
3798
|
+
displayName: 'Purpose',
|
|
3799
|
+
name: 'billingPurpose',
|
|
3800
|
+
type: 'options',
|
|
3801
|
+
options: [
|
|
3802
|
+
{ name: 'Wallet Top-Up', value: 'wallet_topup', description: 'Add credit to the pre-paid wallet' },
|
|
3803
|
+
{ name: 'Add Card', value: 'add_card', description: 'Save a card on file (hosted Stripe page)' },
|
|
3804
|
+
],
|
|
3805
|
+
displayOptions: { show: { resource: ['billing'], operation: ['createCheckout'] } },
|
|
3806
|
+
default: 'wallet_topup',
|
|
3807
|
+
required: true,
|
|
3808
|
+
},
|
|
3809
|
+
{
|
|
3810
|
+
displayName: 'Method',
|
|
3811
|
+
name: 'billingMethod',
|
|
3812
|
+
type: 'options',
|
|
3813
|
+
options: [
|
|
3814
|
+
{ name: 'Card', value: 'card', description: 'Hosted Stripe Checkout page' },
|
|
3815
|
+
{ name: 'Pix', value: 'pix', description: 'Pix copy-and-paste code and QR (BRL workspaces only)' },
|
|
3816
|
+
],
|
|
3817
|
+
displayOptions: {
|
|
3818
|
+
show: { resource: ['billing'], operation: ['createCheckout'], billingPurpose: ['wallet_topup'] },
|
|
3819
|
+
},
|
|
3820
|
+
default: 'card',
|
|
3821
|
+
},
|
|
3822
|
+
{
|
|
3823
|
+
displayName: 'Amount',
|
|
3824
|
+
name: 'billingAmount',
|
|
3825
|
+
type: 'number',
|
|
3826
|
+
typeOptions: { minValue: 0, numberPrecision: 2 },
|
|
3827
|
+
description: 'Amount to add to the wallet, in the workspace currency (major units, e.g. 50.00)',
|
|
3828
|
+
displayOptions: {
|
|
3829
|
+
show: { resource: ['billing'], operation: ['createCheckout'], billingPurpose: ['wallet_topup'] },
|
|
3830
|
+
},
|
|
3831
|
+
default: 0,
|
|
3832
|
+
required: true,
|
|
3833
|
+
},
|
|
3834
|
+
{
|
|
3835
|
+
displayName: 'Amount',
|
|
3836
|
+
name: 'billingAmount',
|
|
3837
|
+
type: 'number',
|
|
3838
|
+
typeOptions: { minValue: 0, numberPrecision: 2 },
|
|
3839
|
+
description: 'Amount to add to the wallet, in the workspace currency (major units, e.g. 50.00)',
|
|
3840
|
+
displayOptions: { show: { resource: ['billing'], operation: ['createPaymentIntent'] } },
|
|
3841
|
+
default: 0,
|
|
3842
|
+
required: true,
|
|
3843
|
+
},
|
|
3844
|
+
{
|
|
3845
|
+
displayName: 'Success URL',
|
|
3846
|
+
name: 'billingSuccessUrl',
|
|
3847
|
+
type: 'string',
|
|
3848
|
+
description: 'Where the hosted page sends the browser after paying. Card only — a Pix has no redirect.',
|
|
3849
|
+
displayOptions: {
|
|
3850
|
+
show: { resource: ['billing'], operation: ['createCheckout'] },
|
|
3851
|
+
hide: { billingMethod: ['pix'] },
|
|
3852
|
+
},
|
|
3853
|
+
default: '',
|
|
3854
|
+
},
|
|
3855
|
+
{
|
|
3856
|
+
displayName: 'Cancel URL',
|
|
3857
|
+
name: 'billingCancelUrl',
|
|
3858
|
+
type: 'string',
|
|
3859
|
+
description: 'Where the hosted page sends the browser on cancel. Card only — a Pix has no redirect.',
|
|
3860
|
+
displayOptions: {
|
|
3861
|
+
show: { resource: ['billing'], operation: ['createCheckout'] },
|
|
3862
|
+
hide: { billingMethod: ['pix'] },
|
|
3863
|
+
},
|
|
3864
|
+
default: '',
|
|
3865
|
+
},
|
|
3866
|
+
{
|
|
3867
|
+
displayName: 'Top-Up ID',
|
|
3868
|
+
name: 'billingTopupId',
|
|
3869
|
+
type: 'string',
|
|
3870
|
+
description: 'orderId returned by Create Checkout (Wallet Top-Up) or Create Payment Intent',
|
|
3871
|
+
displayOptions: { show: { resource: ['billing'], operation: ['getTopup'] } },
|
|
3872
|
+
default: '',
|
|
3873
|
+
required: true,
|
|
3874
|
+
},
|
|
3875
|
+
{
|
|
3876
|
+
displayName: 'Setup Intent ID',
|
|
3877
|
+
name: 'billingSetupIntentId',
|
|
3878
|
+
type: 'string',
|
|
3879
|
+
placeholder: 'seti_...',
|
|
3880
|
+
description: 'setupIntentId from Create Card Setup Intent (a Stripe seti_… id; anything else is 400 INVALID_SETUP_INTENT_ID)',
|
|
3881
|
+
displayOptions: { show: { resource: ['billing'], operation: ['syncCardSetupIntent'] } },
|
|
3882
|
+
default: '',
|
|
3883
|
+
required: true,
|
|
3884
|
+
},
|
|
3885
|
+
{
|
|
3886
|
+
displayName: 'Payment Intent ID',
|
|
3887
|
+
name: 'billingPaymentIntentId',
|
|
3888
|
+
type: 'string',
|
|
3889
|
+
placeholder: 'pi_...',
|
|
3890
|
+
description: 'paymentIntentId from Create Payment Intent (a Stripe pi_… id; anything else is 400 INVALID_PAYMENT_INTENT_ID)',
|
|
3891
|
+
displayOptions: { show: { resource: ['billing'], operation: ['syncPaymentIntent'] } },
|
|
3892
|
+
default: '',
|
|
3893
|
+
required: true,
|
|
3894
|
+
},
|
|
3895
|
+
{
|
|
3896
|
+
displayName: 'Save Card',
|
|
3897
|
+
name: 'billingSaveCard',
|
|
3898
|
+
type: 'boolean',
|
|
3899
|
+
description: 'Whether the card used also becomes the workspace\'s saved card',
|
|
3900
|
+
displayOptions: { show: { resource: ['billing'], operation: ['createPaymentIntent'] } },
|
|
3901
|
+
default: false,
|
|
3902
|
+
},
|
|
3903
|
+
{
|
|
3904
|
+
displayName: 'Idempotency Key',
|
|
3905
|
+
name: 'billingIdempotencyKey',
|
|
3906
|
+
type: 'string',
|
|
3907
|
+
description: 'Optional. Sent as the Idempotency-Key header (max 255 characters, no control characters). REUSE THE SAME KEY when retrying: within 24 hours the same key and body return the SAME orderId, paymentIntentId and clientSecret (Idempotent-Replayed: true) and create nothing. Same key with a DIFFERENT body → 409 IDEMPOTENCY_KEY_REUSED; first call still running → 409 IDEMPOTENCY_KEY_IN_USE; invalid → 400 IDEMPOTENCY_KEY_INVALID. Empty: every run creates a new order.',
|
|
3908
|
+
displayOptions: { show: { resource: ['billing'], operation: ['createPaymentIntent'] } },
|
|
3909
|
+
default: '',
|
|
3910
|
+
},
|
|
3911
|
+
// ----------------------------------
|
|
3912
|
+
// Workspace Operations (/v1/workspaces) — ACCOUNT KEY ONLY (ps_account_…, Profile → API).
|
|
3913
|
+
// The principal is a USER: any other key or token is 403 ACCOUNT_KEY_REQUIRED. The
|
|
3914
|
+
// credential's Workspace ID is ignored here.
|
|
3915
|
+
// ----------------------------------
|
|
3916
|
+
{
|
|
3917
|
+
displayName: 'Operation',
|
|
3918
|
+
name: 'operation',
|
|
3919
|
+
type: 'options',
|
|
3920
|
+
noDataExpression: true,
|
|
3921
|
+
displayOptions: { show: { resource: ['workspace'] } },
|
|
3922
|
+
options: [
|
|
3923
|
+
{
|
|
3924
|
+
name: 'Create',
|
|
3925
|
+
value: 'create',
|
|
3926
|
+
description: 'Create a workspace owned by the account key\'s user, plus its first (primary) ps_workspace_ key. Answers 201 {id, name, plan, createdAt, role: OWNER, apiKey: {id, name, key, prefix, last4, isPrimary, createdAt} | null} — apiKey.key is shown ONLY here; null means the workspace exists but the key failed (mint one with Workspace API Key → Create, do NOT run Create again). Not idempotent. 409 WORKSPACE_LIMIT_REACHED at the owned-workspace limit.',
|
|
3927
|
+
action: 'Create a workspace',
|
|
3928
|
+
routing: {
|
|
3929
|
+
request: { method: 'POST', url: '/workspaces' },
|
|
3930
|
+
send: { preSend: [workspaceCreatePreSend] },
|
|
3931
|
+
},
|
|
3932
|
+
},
|
|
3933
|
+
{
|
|
3934
|
+
name: 'Get Many',
|
|
3935
|
+
value: 'getAll',
|
|
3936
|
+
description: 'The workspaces the account key\'s user is an active member of: {data: [{id, name, role, plan, createdAt}]}. Use an id as the credential\'s Workspace ID.',
|
|
3937
|
+
action: 'Get many workspaces',
|
|
3938
|
+
routing: { request: { method: 'GET', url: '/workspaces' } },
|
|
3939
|
+
},
|
|
3940
|
+
],
|
|
3941
|
+
default: 'getAll',
|
|
3942
|
+
},
|
|
3943
|
+
{
|
|
3944
|
+
displayName: 'Name',
|
|
3945
|
+
name: 'workspaceName',
|
|
3946
|
+
type: 'string',
|
|
3947
|
+
description: 'Workspace name (required)',
|
|
3948
|
+
displayOptions: { show: { resource: ['workspace'], operation: ['create'] } },
|
|
3949
|
+
default: '',
|
|
3950
|
+
required: true,
|
|
3951
|
+
},
|
|
3952
|
+
// ----------------------------------
|
|
3953
|
+
// Workspace API Key Operations (/v1/workspaces/{id}/api-keys) — ACCOUNT KEY ONLY, acting
|
|
3954
|
+
// with the user's LIVE role in that workspace (ADMIN and up; not a member → 403
|
|
3955
|
+
// WORKSPACE_MEMBERSHIP_REQUIRED).
|
|
3956
|
+
// ----------------------------------
|
|
3957
|
+
{
|
|
3958
|
+
displayName: 'Operation',
|
|
3959
|
+
name: 'operation',
|
|
3960
|
+
type: 'options',
|
|
3961
|
+
noDataExpression: true,
|
|
3962
|
+
displayOptions: { show: { resource: ['workspaceApiKey'] } },
|
|
3963
|
+
options: [
|
|
3964
|
+
{
|
|
3965
|
+
name: 'Create',
|
|
3966
|
+
value: 'create',
|
|
3967
|
+
description: 'Mint a NAMED ps_workspace_ key (never the primary). Answers 201 {apiKey: {id, name, key, prefix, last4, isPrimary: false, createdAt}} — apiKey.key is shown ONLY here. 409 WORKSPACE_KEY_LIMIT_REACHED at the limit.',
|
|
3968
|
+
action: 'Create a workspace API key',
|
|
3969
|
+
routing: {
|
|
3970
|
+
request: {
|
|
3971
|
+
method: 'POST',
|
|
3972
|
+
url: '=/workspaces/{{encodeURIComponent($parameter.workspaceApiKeyWorkspaceId)}}/api-keys',
|
|
3973
|
+
},
|
|
3974
|
+
send: { preSend: [workspaceApiKeyCreatePreSend] },
|
|
3975
|
+
},
|
|
3976
|
+
},
|
|
3977
|
+
{
|
|
3978
|
+
name: 'Get Many',
|
|
3979
|
+
value: 'getAll',
|
|
3980
|
+
description: 'The workspace\'s tenant keys, MASKED: {data: [{id, name, prefix, last4, isPrimary, createdAt, lastUsedAt}]}.',
|
|
3981
|
+
action: 'Get many workspace API keys',
|
|
3982
|
+
routing: {
|
|
3983
|
+
request: {
|
|
3984
|
+
method: 'GET',
|
|
3985
|
+
url: '=/workspaces/{{encodeURIComponent($parameter.workspaceApiKeyWorkspaceId)}}/api-keys',
|
|
3986
|
+
},
|
|
3987
|
+
},
|
|
3988
|
+
},
|
|
3989
|
+
{
|
|
3990
|
+
name: 'Revoke',
|
|
3991
|
+
value: 'revoke',
|
|
3992
|
+
description: 'Revoke a NAMED workspace key, effective on its next request. Answers {id, revokedAt}. The primary key cannot be revoked (409 PRIMARY_KEY_NOT_REVOCABLE — rotate it instead); an unknown id is 404 API_KEY_NOT_FOUND.',
|
|
3993
|
+
action: 'Revoke a workspace API key',
|
|
3994
|
+
routing: {
|
|
3995
|
+
request: {
|
|
3996
|
+
method: 'DELETE',
|
|
3997
|
+
url: '=/workspaces/{{encodeURIComponent($parameter.workspaceApiKeyWorkspaceId)}}/api-keys/{{encodeURIComponent($parameter.workspaceApiKeyId)}}',
|
|
3998
|
+
},
|
|
3999
|
+
},
|
|
4000
|
+
},
|
|
4001
|
+
],
|
|
4002
|
+
default: 'getAll',
|
|
4003
|
+
},
|
|
4004
|
+
{
|
|
4005
|
+
displayName: 'Workspace ID',
|
|
4006
|
+
name: 'workspaceApiKeyWorkspaceId',
|
|
4007
|
+
type: 'string',
|
|
4008
|
+
description: 'data[].id from Workspace (Account Key) → Get Many',
|
|
4009
|
+
displayOptions: { show: { resource: ['workspaceApiKey'] } },
|
|
4010
|
+
default: '',
|
|
4011
|
+
required: true,
|
|
4012
|
+
},
|
|
4013
|
+
{
|
|
4014
|
+
displayName: 'Name',
|
|
4015
|
+
name: 'workspaceApiKeyName',
|
|
4016
|
+
type: 'string',
|
|
4017
|
+
description: 'Key name (required)',
|
|
4018
|
+
displayOptions: { show: { resource: ['workspaceApiKey'], operation: ['create'] } },
|
|
4019
|
+
default: '',
|
|
4020
|
+
required: true,
|
|
4021
|
+
},
|
|
4022
|
+
{
|
|
4023
|
+
displayName: 'API Key ID',
|
|
4024
|
+
name: 'workspaceApiKeyId',
|
|
4025
|
+
type: 'string',
|
|
4026
|
+
description: 'data[].id from Get Many',
|
|
4027
|
+
displayOptions: { show: { resource: ['workspaceApiKey'], operation: ['revoke'] } },
|
|
4028
|
+
default: '',
|
|
4029
|
+
required: true,
|
|
4030
|
+
},
|
|
3379
4031
|
],
|
|
3380
4032
|
};
|
|
3381
4033
|
}
|