chargefy-js 1.1.4 → 1.1.7
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 +127 -0
- package/dist/chargefy.d.ts +12 -0
- package/dist/chargefy.d.ts.map +1 -1
- package/dist/chargefy.js +16 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +13 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/models/kyc.d.ts +17 -0
- package/dist/models/kyc.d.ts.map +1 -0
- package/dist/models/kyc.js +1 -0
- package/dist/models/onboarding-link.d.ts +12 -0
- package/dist/models/onboarding-link.d.ts.map +1 -0
- package/dist/models/onboarding-link.js +1 -0
- package/dist/models/sub-organization.d.ts +160 -0
- package/dist/models/sub-organization.d.ts.map +1 -0
- package/dist/models/sub-organization.js +2 -0
- package/dist/namespaces/checkouts.d.ts +3 -0
- package/dist/namespaces/checkouts.d.ts.map +1 -1
- package/dist/namespaces/checkouts.js +11 -0
- package/dist/namespaces/embed-onboarding.d.ts +29 -0
- package/dist/namespaces/embed-onboarding.d.ts.map +1 -0
- package/dist/namespaces/embed-onboarding.js +53 -0
- package/dist/namespaces/kyc.d.ts +23 -0
- package/dist/namespaces/kyc.d.ts.map +1 -0
- package/dist/namespaces/kyc.js +40 -0
- package/dist/namespaces/onboarding-links.d.ts +19 -0
- package/dist/namespaces/onboarding-links.d.ts.map +1 -0
- package/dist/namespaces/onboarding-links.js +28 -0
- package/dist/namespaces/sub-organizations.d.ts +61 -0
- package/dist/namespaces/sub-organizations.d.ts.map +1 -0
- package/dist/namespaces/sub-organizations.js +128 -0
- package/package.json +1 -1
- package/src/chargefy.ts +16 -0
- package/src/core.ts +19 -3
- package/src/index.ts +25 -0
- package/src/models/kyc.ts +24 -0
- package/src/models/onboarding-link.ts +12 -0
- package/src/models/sub-organization.ts +173 -0
- package/src/namespaces/checkouts.ts +16 -0
- package/src/namespaces/embed-onboarding.ts +73 -0
- package/src/namespaces/kyc.ts +49 -0
- package/src/namespaces/onboarding-links.ts +31 -0
- package/src/namespaces/sub-organizations.ts +156 -0
package/README.md
CHANGED
|
@@ -153,6 +153,120 @@ const result = await chargefy.checkoutLinks.update({
|
|
|
153
153
|
|
|
154
154
|
---
|
|
155
155
|
|
|
156
|
+
## Sub-Organizations
|
|
157
|
+
|
|
158
|
+
Create and manage child organizations. **Requires an Organization Access Token (OAT)** from the parent org.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
// Check if taxpayer already has orgs (before showing create form)
|
|
162
|
+
const check = await chargefy.subOrganizations.checkExisting('12345678900', 'individual')
|
|
163
|
+
// check.value → { exists: boolean, organizations: [{ id, name, avatarUrl }] }
|
|
164
|
+
|
|
165
|
+
// List child organizations
|
|
166
|
+
const result = await chargefy.subOrganizations.list()
|
|
167
|
+
// result.value → { items: SubOrganizationListItem[] }
|
|
168
|
+
|
|
169
|
+
// Create a new child organization (full onboarding)
|
|
170
|
+
const result = await chargefy.subOrganizations.create({
|
|
171
|
+
organization: { name: 'Child Co', slug: 'child-co', email: 'child@example.com' },
|
|
172
|
+
invite_email: 'admin@child.com',
|
|
173
|
+
seller_type: 'individual',
|
|
174
|
+
individual: { full_name: 'João', email: 'joao@example.com', ... },
|
|
175
|
+
bank_account: { holder_name: 'João', ... },
|
|
176
|
+
fee_percent: 5,
|
|
177
|
+
})
|
|
178
|
+
// result.value → CreateSubOrganizationResponse (includes api_key)
|
|
179
|
+
|
|
180
|
+
// Link an existing org as your child (vinculation)
|
|
181
|
+
const result = await chargefy.subOrganizations.linkAsParent('org_child_xxx', { feePercent: 5 })
|
|
182
|
+
|
|
183
|
+
// Create a product for a child (your org earns the fee)
|
|
184
|
+
const result = await chargefy.subOrganizations.createProduct('org_child_xxx', {
|
|
185
|
+
feePercent: 5,
|
|
186
|
+
name: 'Child Product',
|
|
187
|
+
prices: [{ amountType: 'fixed', priceAmount: 9900, priceCurrency: 'brl' }],
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
// List/create/revoke child's API keys
|
|
191
|
+
const tokens = await chargefy.subOrganizations.listApiKeys('org_child_xxx')
|
|
192
|
+
const newToken = await chargefy.subOrganizations.createApiKey('org_child_xxx', { comment: 'Marketing' })
|
|
193
|
+
await chargefy.subOrganizations.revokeApiKey('org_child_xxx', 'token_id')
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Onboarding Links
|
|
199
|
+
|
|
200
|
+
Create reusable embed onboarding links. **OAT required.**
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
// Create onboarding link (fee 0–50% parent earns on child transactions)
|
|
204
|
+
const result = await chargefy.onboardingLinks.create({ feePercent: 5 })
|
|
205
|
+
// result.value → { token, url, feePercent }
|
|
206
|
+
// Share result.value.url — OrgB, OrgC, etc. onboard through the same link
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Embed Onboarding
|
|
212
|
+
|
|
213
|
+
**No auth required** — uses `link_token` from the onboarding link URL.
|
|
214
|
+
Use when OrgB/C/T onboard through OrgA's embed.
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
// Initialize without accessToken for embed flow
|
|
218
|
+
const chargefy = new Chargefy({ serverURL: 'https://app.chargefy.io/api' })
|
|
219
|
+
|
|
220
|
+
// 1. Check if taxpayer already has an org (before showing form)
|
|
221
|
+
const check = await chargefy.embedOnboarding.checkExisting(
|
|
222
|
+
linkToken,
|
|
223
|
+
'12345678900', // CPF (individual) or CNPJ (business)
|
|
224
|
+
'individual'
|
|
225
|
+
)
|
|
226
|
+
// check.value → { exists: boolean, organizations: [{ id, name, avatarUrl }] }
|
|
227
|
+
|
|
228
|
+
// 2a. If exists: link existing org to parent
|
|
229
|
+
if (check.value.exists && check.value.organizations.length > 0) {
|
|
230
|
+
const link = await chargefy.embedOnboarding.linkExisting(
|
|
231
|
+
linkToken,
|
|
232
|
+
check.value.organizations[0].id
|
|
233
|
+
)
|
|
234
|
+
// link.value → { organizationId, apiKey }
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// 2b. If not exists: submit full onboarding form
|
|
238
|
+
const submit = await chargefy.embedOnboarding.submit(linkToken, {
|
|
239
|
+
organization: { name, slug, email },
|
|
240
|
+
invite_email,
|
|
241
|
+
seller_type: 'individual',
|
|
242
|
+
individual: { ... },
|
|
243
|
+
bank_account: { ... },
|
|
244
|
+
})
|
|
245
|
+
// submit.value → CreateSubOrganizationResponse (includes api_key)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## KYC
|
|
251
|
+
|
|
252
|
+
KYC document status and upload for your organization's seller. **OAT or user session required.**
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
// Get KYC document status
|
|
256
|
+
const result = await chargefy.kyc.getDocuments('org_xxx')
|
|
257
|
+
// result.value → { documents: { uploaded, pendingUpload }, kycComplete }
|
|
258
|
+
|
|
259
|
+
// Upload a KYC document
|
|
260
|
+
const result = await chargefy.kyc.uploadDocument(
|
|
261
|
+
'org_xxx',
|
|
262
|
+
'SELFIE', // SELFIE | CNH_FULL | CNH_FRONT | CNH_BACK | RG_FRONT | RG_BACK
|
|
263
|
+
file // Blob, File, or ArrayBuffer
|
|
264
|
+
)
|
|
265
|
+
// result.value → { success, documentType }
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
156
270
|
## Buyers
|
|
157
271
|
|
|
158
272
|
Create or retrieve a buyer (customer) record. Required for card payments.
|
|
@@ -310,6 +424,19 @@ import type {
|
|
|
310
424
|
CardData,
|
|
311
425
|
ListResponse,
|
|
312
426
|
Result,
|
|
427
|
+
// Sub-organizations & onboarding
|
|
428
|
+
CreateSubOrganizationRequest,
|
|
429
|
+
CreateSubOrganizationResponse,
|
|
430
|
+
EmbedSubmitRequest,
|
|
431
|
+
CheckExistingResponse,
|
|
432
|
+
LinkExistingResponse,
|
|
433
|
+
CreateProductForChildRequest,
|
|
434
|
+
CreateOnboardingLinkRequest,
|
|
435
|
+
CreateOnboardingLinkResponse,
|
|
436
|
+
// KYC
|
|
437
|
+
KycDocumentType,
|
|
438
|
+
KycDocumentsResponse,
|
|
439
|
+
UploadDocumentResponse,
|
|
313
440
|
} from '@chargefy/sdk'
|
|
314
441
|
```
|
|
315
442
|
|
package/dist/chargefy.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import { Buyers } from './namespaces/buyers';
|
|
|
6
6
|
import { Checkouts } from './namespaces/checkouts';
|
|
7
7
|
import { Sales } from './namespaces/sales';
|
|
8
8
|
import { Subscriptions } from './namespaces/subscriptions';
|
|
9
|
+
import { SubOrganizations } from './namespaces/sub-organizations';
|
|
10
|
+
import { EmbedOnboarding } from './namespaces/embed-onboarding';
|
|
11
|
+
import { OnboardingLinks } from './namespaces/onboarding-links';
|
|
12
|
+
import { Kyc } from './namespaces/kyc';
|
|
9
13
|
export type { ChargefyCoreOptions };
|
|
10
14
|
/**
|
|
11
15
|
* Chargefy SDK
|
|
@@ -37,6 +41,14 @@ export declare class Chargefy {
|
|
|
37
41
|
readonly sales: Sales;
|
|
38
42
|
/** Subscription endpoints. */
|
|
39
43
|
readonly subscriptions: Subscriptions;
|
|
44
|
+
/** Sub-organization onboarding and API key management (parent OAT required). */
|
|
45
|
+
readonly subOrganizations: SubOrganizations;
|
|
46
|
+
/** Embed onboarding flow — no auth, uses link_token. */
|
|
47
|
+
readonly embedOnboarding: EmbedOnboarding;
|
|
48
|
+
/** Create onboarding links (OAT required). */
|
|
49
|
+
readonly onboardingLinks: OnboardingLinks;
|
|
50
|
+
/** KYC document status and upload (OAT or user session). */
|
|
51
|
+
readonly kyc: Kyc;
|
|
40
52
|
constructor(options?: ChargefyCoreOptions);
|
|
41
53
|
}
|
|
42
54
|
//# sourceMappingURL=chargefy.d.ts.map
|
package/dist/chargefy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chargefy.d.ts","sourceRoot":"","sources":["../src/chargefy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"chargefy.d.ts","sourceRoot":"","sources":["../src/chargefy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,YAAY,EAAE,mBAAmB,EAAE,CAAA;AAEnC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;IACnB,mCAAmC;IACnC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;IACrC,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;IACrC,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;IACrC,gFAAgF;IAChF,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;IAC3C,wDAAwD;IACxD,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;gBAEL,OAAO,GAAE,mBAAwB;CAc9C"}
|
package/dist/chargefy.js
CHANGED
|
@@ -6,6 +6,10 @@ import { Buyers } from './namespaces/buyers';
|
|
|
6
6
|
import { Checkouts } from './namespaces/checkouts';
|
|
7
7
|
import { Sales } from './namespaces/sales';
|
|
8
8
|
import { Subscriptions } from './namespaces/subscriptions';
|
|
9
|
+
import { SubOrganizations } from './namespaces/sub-organizations';
|
|
10
|
+
import { EmbedOnboarding } from './namespaces/embed-onboarding';
|
|
11
|
+
import { OnboardingLinks } from './namespaces/onboarding-links';
|
|
12
|
+
import { Kyc } from './namespaces/kyc';
|
|
9
13
|
/**
|
|
10
14
|
* Chargefy SDK
|
|
11
15
|
*
|
|
@@ -36,6 +40,14 @@ export class Chargefy {
|
|
|
36
40
|
sales;
|
|
37
41
|
/** Subscription endpoints. */
|
|
38
42
|
subscriptions;
|
|
43
|
+
/** Sub-organization onboarding and API key management (parent OAT required). */
|
|
44
|
+
subOrganizations;
|
|
45
|
+
/** Embed onboarding flow — no auth, uses link_token. */
|
|
46
|
+
embedOnboarding;
|
|
47
|
+
/** Create onboarding links (OAT required). */
|
|
48
|
+
onboardingLinks;
|
|
49
|
+
/** KYC document status and upload (OAT or user session). */
|
|
50
|
+
kyc;
|
|
39
51
|
constructor(options = {}) {
|
|
40
52
|
const core = new ChargefyCore(options);
|
|
41
53
|
this.organizations = new Organizations(core);
|
|
@@ -45,5 +57,9 @@ export class Chargefy {
|
|
|
45
57
|
this.checkouts = new Checkouts(core);
|
|
46
58
|
this.sales = new Sales(core);
|
|
47
59
|
this.subscriptions = new Subscriptions(core);
|
|
60
|
+
this.subOrganizations = new SubOrganizations(core);
|
|
61
|
+
this.embedOnboarding = new EmbedOnboarding(core);
|
|
62
|
+
this.onboardingLinks = new OnboardingLinks(core);
|
|
63
|
+
this.kyc = new Kyc(core);
|
|
48
64
|
}
|
|
49
65
|
}
|
package/dist/core.d.ts
CHANGED
|
@@ -20,12 +20,16 @@ export interface ChargefyCoreOptions {
|
|
|
20
20
|
serverURL?: string;
|
|
21
21
|
/** Request timeout in milliseconds. Default: 30000. */
|
|
22
22
|
timeout?: number;
|
|
23
|
+
/** Extra headers sent with every request (e.g. X-Chargefy-Source: embed). */
|
|
24
|
+
headers?: Record<string, string>;
|
|
23
25
|
}
|
|
24
26
|
export type APIError = ResourceNotFound | ExpiredCheckoutError | HTTPValidationError | PaymentError | NotOpenCheckout | AlreadyActiveSubscriptionError | PaymentNotReady | SDKError | UnexpectedClientError | InvalidRequestError | RequestAbortedError | RequestTimeoutError | ConnectionError;
|
|
25
27
|
interface RequestOptions {
|
|
26
28
|
method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
27
29
|
path: string;
|
|
28
30
|
body?: unknown;
|
|
31
|
+
/** When true, body is sent as-is (FormData); no Content-Type, no JSON.stringify. */
|
|
32
|
+
bodyIsFormData?: boolean;
|
|
29
33
|
query?: Record<string, string | number | boolean | undefined | null>;
|
|
30
34
|
/** Send Authorization header. Default: true. */
|
|
31
35
|
auth?: boolean;
|
|
@@ -34,6 +38,7 @@ export declare class ChargefyCore {
|
|
|
34
38
|
readonly serverURL: string;
|
|
35
39
|
readonly accessToken: string | undefined;
|
|
36
40
|
readonly timeout: number;
|
|
41
|
+
readonly headers: Record<string, string>;
|
|
37
42
|
constructor(options?: ChargefyCoreOptions);
|
|
38
43
|
request<T>(options: RequestOptions): Promise<Result<T, APIError>>;
|
|
39
44
|
}
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,QAAQ,EACR,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAA;AACpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,MAAM,WAAW,mBAAmB;IAClC,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,YAA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GACf,8BAA8B,GAC9B,eAAe,GACf,QAAQ,GACR,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,CAAA;AAEnB,UAAU,cAAc;IACtB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,oFAAoF;IACpF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;IACpE,gDAAgD;IAChD,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,qBAAa,YAAY;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;gBAE5B,OAAO,GAAE,mBAAwB;IAiBvC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;CAgExE"}
|
package/dist/core.js
CHANGED
|
@@ -9,6 +9,7 @@ export class ChargefyCore {
|
|
|
9
9
|
serverURL;
|
|
10
10
|
accessToken;
|
|
11
11
|
timeout;
|
|
12
|
+
headers;
|
|
12
13
|
constructor(options = {}) {
|
|
13
14
|
if (options.serverURL) {
|
|
14
15
|
this.serverURL = options.serverURL.replace(/\/$/, '');
|
|
@@ -26,9 +27,10 @@ export class ChargefyCore {
|
|
|
26
27
|
}
|
|
27
28
|
this.accessToken = options.accessToken;
|
|
28
29
|
this.timeout = options.timeout ?? 30000;
|
|
30
|
+
this.headers = options.headers ?? {};
|
|
29
31
|
}
|
|
30
32
|
async request(options) {
|
|
31
|
-
const { method, path, body, query, auth = true } = options;
|
|
33
|
+
const { method, path, body, bodyIsFormData, query, auth = true } = options;
|
|
32
34
|
// Build URL + query string
|
|
33
35
|
const url = new URL(`${this.serverURL}${path}`);
|
|
34
36
|
if (query) {
|
|
@@ -40,19 +42,27 @@ export class ChargefyCore {
|
|
|
40
42
|
}
|
|
41
43
|
// Build headers
|
|
42
44
|
const headers = {
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
45
|
Accept: 'application/json',
|
|
45
46
|
};
|
|
47
|
+
if (!bodyIsFormData) {
|
|
48
|
+
headers['Content-Type'] = 'application/json';
|
|
49
|
+
}
|
|
46
50
|
if (auth && this.accessToken) {
|
|
47
51
|
headers['Authorization'] = `Bearer ${this.accessToken}`;
|
|
48
52
|
}
|
|
53
|
+
Object.assign(headers, this.headers);
|
|
49
54
|
const controller = new AbortController();
|
|
50
55
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
51
56
|
try {
|
|
57
|
+
const requestBody = body !== undefined
|
|
58
|
+
? bodyIsFormData
|
|
59
|
+
? body
|
|
60
|
+
: JSON.stringify(body)
|
|
61
|
+
: undefined;
|
|
52
62
|
const response = await fetch(url.toString(), {
|
|
53
63
|
method,
|
|
54
64
|
headers,
|
|
55
|
-
body:
|
|
65
|
+
body: requestBody,
|
|
56
66
|
signal: controller.signal,
|
|
57
67
|
});
|
|
58
68
|
clearTimeout(timeoutId);
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export type { Checkout, CheckoutConfirmed, CheckoutProduct, InstallmentOption, C
|
|
|
13
13
|
export type { ListResponse, ListParams } from './models/pagination';
|
|
14
14
|
export type { Sale, SaleListParams, SaleStatus, PaymentType, SaleCardData, SaleBoletoData, SalePixData, SaleCustomer, SaleProduct, } from './models/sale';
|
|
15
15
|
export type { Subscription, SubscriptionListParams, SubscriptionStatus, SubscriptionRecurringInterval, CustomerCancellationReason, SubscriptionProduct, SubscriptionCustomer, } from './models/subscription';
|
|
16
|
+
export type { SubOrganizationListItem, SubOrgAddress, SubOrgIndividual, SubOrgBusiness, SubOrgBankAccount, CreateSubOrganizationRequest, CreateSubOrganizationResponse, EmbedSubmitRequest, CheckExistingResponse, LinkExistingResponse, CreateProductForChildRequest, OrgAccessToken, CreateOrgAccessTokenRequest, CreateOrgAccessTokenResponse, } from './models/sub-organization';
|
|
17
|
+
export type { CreateOnboardingLinkRequest, CreateOnboardingLinkResponse, } from './models/onboarding-link';
|
|
18
|
+
export type { KycDocumentType, KycDocumentsResponse, UploadDocumentResponse, } from './models/kyc';
|
|
16
19
|
export { SDKError, SDKValidationError, UnexpectedClientError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, ConnectionError, } from './models/errors/httpclienterrors';
|
|
17
20
|
export { HTTPValidationError, type ValidationErrorDetail } from './models/errors/httpvalidationerror';
|
|
18
21
|
export { ResourceNotFound } from './models/errors/resourcenotfound';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGtC,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGxC,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,YAAY,EACV,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACV,KAAK,EACL,aAAa,EACb,eAA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A8B,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,gDAAgD,CAAA;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** KYC document types supported by Zoop. */
|
|
2
|
+
export type KycDocumentType = 'SELFIE' | 'CNH_FULL' | 'CNH_FRONT' | 'CNH_BACK' | 'RG_FRONT' | 'RG_BACK';
|
|
3
|
+
export interface KycDocumentsResponse {
|
|
4
|
+
marketplaceId: string;
|
|
5
|
+
sellerId: string;
|
|
6
|
+
documents: {
|
|
7
|
+
uploaded: KycDocumentType[];
|
|
8
|
+
pendingUpload: KycDocumentType[];
|
|
9
|
+
};
|
|
10
|
+
kycComplete: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface UploadDocumentResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
documentType: KycDocumentType;
|
|
15
|
+
result?: unknown;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=kyc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kyc.d.ts","sourceRoot":"","sources":["../../src/models/kyc.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,UAAU,GACV,WAAW,GACX,UAAU,GACV,UAAU,GACV,SAAS,CAAA;AAEb,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE;QACT,QAAQ,EAAE,eAAe,EAAE,CAAA;QAC3B,aAAa,EAAE,eAAe,EAAE,CAAA;KACjC,CAAA;IACD,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,eAAe,CAAA;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CreateOnboardingLinkRequest {
|
|
2
|
+
/** Fee percentage (0–50) the parent earns on child transactions. Default: 0. */
|
|
3
|
+
feePercent?: number;
|
|
4
|
+
/** Required when using user session; omitted when using OAT. */
|
|
5
|
+
organizationId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateOnboardingLinkResponse {
|
|
8
|
+
token: string;
|
|
9
|
+
url: string;
|
|
10
|
+
feePercent: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=onboarding-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding-link.d.ts","sourceRoot":"","sources":["../../src/models/onboarding-link.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,2BAA2B;IAC1C,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export interface SubOrgAddress {
|
|
2
|
+
street: string;
|
|
3
|
+
number: string;
|
|
4
|
+
complement?: string;
|
|
5
|
+
neighborhood: string;
|
|
6
|
+
city: string;
|
|
7
|
+
state: string;
|
|
8
|
+
postal_code: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SubOrgIndividual {
|
|
11
|
+
full_name: string;
|
|
12
|
+
email: string;
|
|
13
|
+
phone: string;
|
|
14
|
+
cpf: string;
|
|
15
|
+
birth_date: string;
|
|
16
|
+
mcc?: string;
|
|
17
|
+
statement_descriptor?: string;
|
|
18
|
+
address: SubOrgAddress;
|
|
19
|
+
}
|
|
20
|
+
export interface SubOrgBusiness {
|
|
21
|
+
cnpj: string;
|
|
22
|
+
business_name: string;
|
|
23
|
+
trading_name?: string;
|
|
24
|
+
business_email: string;
|
|
25
|
+
business_phone: string;
|
|
26
|
+
business_opening_date?: string;
|
|
27
|
+
mcc?: string;
|
|
28
|
+
statement_descriptor?: string;
|
|
29
|
+
business_address: SubOrgAddress;
|
|
30
|
+
owner: {
|
|
31
|
+
full_name: string;
|
|
32
|
+
email: string;
|
|
33
|
+
phone: string;
|
|
34
|
+
cpf: string;
|
|
35
|
+
birth_date: string;
|
|
36
|
+
address: SubOrgAddress;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface SubOrgBankAccount {
|
|
40
|
+
holder_name: string;
|
|
41
|
+
taxpayer_id: string;
|
|
42
|
+
bank_code: string;
|
|
43
|
+
routing_number: string;
|
|
44
|
+
account_number: string;
|
|
45
|
+
account_type: 'checking' | 'savings';
|
|
46
|
+
}
|
|
47
|
+
export interface CreateSubOrganizationRequest {
|
|
48
|
+
organization: {
|
|
49
|
+
name: string;
|
|
50
|
+
slug: string;
|
|
51
|
+
email: string;
|
|
52
|
+
website?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
avatar_url?: string;
|
|
55
|
+
};
|
|
56
|
+
/** Email of the person who will become admin of the new organization. */
|
|
57
|
+
invite_email: string;
|
|
58
|
+
seller_type: 'individual' | 'business';
|
|
59
|
+
individual?: SubOrgIndividual;
|
|
60
|
+
business?: SubOrgBusiness;
|
|
61
|
+
bank_account: SubOrgBankAccount;
|
|
62
|
+
/**
|
|
63
|
+
* Percentage fee the parent organization earns on each transaction.
|
|
64
|
+
* Must be between 0 and 50. Chargefy 4.99% is always applied; parent fee is additive.
|
|
65
|
+
*/
|
|
66
|
+
fee_percent: number;
|
|
67
|
+
}
|
|
68
|
+
/** Same as CreateSubOrganizationRequest but without fee_percent (provided by link in embed flow). */
|
|
69
|
+
export type EmbedSubmitRequest = Omit<CreateSubOrganizationRequest, 'fee_percent'>;
|
|
70
|
+
export interface CheckExistingResponse {
|
|
71
|
+
exists: boolean;
|
|
72
|
+
organizations: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
avatarUrl: string | null;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
export interface LinkExistingResponse {
|
|
79
|
+
organizationId: string;
|
|
80
|
+
apiKey: string;
|
|
81
|
+
}
|
|
82
|
+
/** Request to create a product for a child org (parent sets fee). */
|
|
83
|
+
export interface CreateProductForChildRequest {
|
|
84
|
+
/** Fee percentage (0–50) the parent earns on this product's transactions. */
|
|
85
|
+
feePercent: number;
|
|
86
|
+
name: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
recurringInterval?: 'month' | 'year' | 'week' | 'day' | null;
|
|
89
|
+
/** At least one price required. */
|
|
90
|
+
prices: Array<{
|
|
91
|
+
amountType: 'fixed';
|
|
92
|
+
priceAmount: number;
|
|
93
|
+
priceCurrency: 'brl' | 'usd';
|
|
94
|
+
} | {
|
|
95
|
+
amountType: 'free';
|
|
96
|
+
priceCurrency: 'brl' | 'usd';
|
|
97
|
+
} | {
|
|
98
|
+
amountType: 'custom';
|
|
99
|
+
priceCurrency: 'brl' | 'usd';
|
|
100
|
+
minimumAmount?: number;
|
|
101
|
+
maximumAmount?: number;
|
|
102
|
+
presetAmount?: number;
|
|
103
|
+
} | {
|
|
104
|
+
amountType: 'metered_unit';
|
|
105
|
+
meterId: string;
|
|
106
|
+
priceAmount: number;
|
|
107
|
+
priceCurrency: 'brl' | 'usd';
|
|
108
|
+
}>;
|
|
109
|
+
metadata?: Record<string, unknown>;
|
|
110
|
+
medias?: string[];
|
|
111
|
+
}
|
|
112
|
+
export interface CreateSubOrganizationResponse {
|
|
113
|
+
organization: {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
slug: string;
|
|
117
|
+
status: string;
|
|
118
|
+
};
|
|
119
|
+
seller: {
|
|
120
|
+
id: string;
|
|
121
|
+
zoop_seller_id: string;
|
|
122
|
+
status: string;
|
|
123
|
+
seller_type: string;
|
|
124
|
+
reused_existing_seller: boolean;
|
|
125
|
+
};
|
|
126
|
+
bank_account: {
|
|
127
|
+
id: string;
|
|
128
|
+
zoop_bank_account_id: string;
|
|
129
|
+
bank_code: string;
|
|
130
|
+
account_number_last4: string;
|
|
131
|
+
account_type: string;
|
|
132
|
+
is_verified: boolean;
|
|
133
|
+
} | null;
|
|
134
|
+
/** The API key for the new organization. Shown once — store it securely. */
|
|
135
|
+
api_key: string;
|
|
136
|
+
status: string;
|
|
137
|
+
}
|
|
138
|
+
export interface SubOrganizationListItem {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
status: string;
|
|
142
|
+
}
|
|
143
|
+
export interface OrgAccessToken {
|
|
144
|
+
id: string;
|
|
145
|
+
organization_id: string;
|
|
146
|
+
scope: string;
|
|
147
|
+
comment?: string;
|
|
148
|
+
expires_at?: string | null;
|
|
149
|
+
last_used_at?: string | null;
|
|
150
|
+
created_at: string;
|
|
151
|
+
modified_at: string;
|
|
152
|
+
}
|
|
153
|
+
export interface CreateOrgAccessTokenRequest {
|
|
154
|
+
comment?: string;
|
|
155
|
+
}
|
|
156
|
+
export interface CreateOrgAccessTokenResponse extends OrgAccessToken {
|
|
157
|
+
/** The plain-text token. Shown once — store it securely. */
|
|
158
|
+
token: string;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=sub-organization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-organization.d.ts","sourceRoot":"","sources":["../../src/models/sub-organization.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MA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A;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ChargefyCore, APIError } from '../core';
|
|
2
2
|
import type { Result } from '../types/fp';
|
|
3
3
|
import type { Checkout, CheckoutConfirmed, CreateCheckoutRequest, UpdateCheckoutRequest, ConfirmCheckoutRequest, GeneratePixRequest } from '../models/checkout';
|
|
4
|
+
import type { CheckoutUpdatePublic } from '../models/components/checkoutupdatepublic';
|
|
4
5
|
export declare class Checkouts {
|
|
5
6
|
private readonly core;
|
|
6
7
|
constructor(core: ChargefyCore);
|
|
@@ -10,6 +11,8 @@ export declare class Checkouts {
|
|
|
10
11
|
get(id: string): Promise<Result<Checkout, APIError>>;
|
|
11
12
|
/** Get a checkout by its client secret. */
|
|
12
13
|
getByClientSecret(clientSecret: string): Promise<Result<Checkout, APIError>>;
|
|
14
|
+
/** Update customer info on an open checkout by client secret (public, no auth). */
|
|
15
|
+
updateByClientSecret(clientSecret: string, data: CheckoutUpdatePublic): Promise<Result<Checkout, APIError>>;
|
|
13
16
|
/** Update customer info on an open checkout. */
|
|
14
17
|
update(body: UpdateCheckoutRequest): Promise<Result<Checkout, APIError>>;
|
|
15
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkouts.d.ts","sourceRoot":"","sources":["../../src/namespaces/checkouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EACV,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"checkouts.d.ts","sourceRoot":"","sources":["../../src/namespaces/checkouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EACV,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAGrF,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C,qCAAqC;IACrC,MAAM,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAoBxE,4BAA4B;IAC5B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAOpD,2CAA2C;IAC3C,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAQ5E,mFAAmF;IACnF,oBAAoB,CAClB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAUtC,gDAAgD;IAChD,MAAM,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAcxE;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAuBnF;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;CAcpF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { transformToSnakeCase } from '../utils/transformers';
|
|
1
2
|
export class Checkouts {
|
|
2
3
|
core;
|
|
3
4
|
constructor(core) {
|
|
@@ -46,6 +47,16 @@ export class Checkouts {
|
|
|
46
47
|
auth: false,
|
|
47
48
|
});
|
|
48
49
|
}
|
|
50
|
+
/** Update customer info on an open checkout by client secret (public, no auth). */
|
|
51
|
+
updateByClientSecret(clientSecret, data) {
|
|
52
|
+
const payload = transformToSnakeCase(data);
|
|
53
|
+
return this.core.request({
|
|
54
|
+
method: 'PATCH',
|
|
55
|
+
path: `/v1/checkouts/client/${clientSecret}`,
|
|
56
|
+
body: payload,
|
|
57
|
+
auth: false,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
49
60
|
/** Update customer info on an open checkout. */
|
|
50
61
|
update(body) {
|
|
51
62
|
const { id, ...rest } = body;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embed Onboarding Namespace
|
|
3
|
+
*
|
|
4
|
+
* Public endpoints for the embed onboarding flow. No auth required — uses link_token.
|
|
5
|
+
* Used when OrgB/C/T onboard through OrgA's embed link.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChargefyCore, APIError } from '../core';
|
|
8
|
+
import type { Result } from '../types/fp';
|
|
9
|
+
import type { CreateSubOrganizationResponse, EmbedSubmitRequest, CheckExistingResponse, LinkExistingResponse } from '../models/sub-organization';
|
|
10
|
+
export declare class EmbedOnboarding {
|
|
11
|
+
private readonly core;
|
|
12
|
+
constructor(core: ChargefyCore);
|
|
13
|
+
/**
|
|
14
|
+
* Check if taxpayer_id (individual) or ein (business) already exists in zoop_sellers.
|
|
15
|
+
* If exists, the user can choose to link an existing organization instead of creating a new one.
|
|
16
|
+
*/
|
|
17
|
+
checkExisting(linkToken: string, taxpayerId: string, sellerType: 'individual' | 'business'): Promise<Result<CheckExistingResponse, APIError>>;
|
|
18
|
+
/**
|
|
19
|
+
* Link an existing organization to the parent (vinculation).
|
|
20
|
+
* Use when checkExisting returns exists: true and the user selects their org.
|
|
21
|
+
*/
|
|
22
|
+
linkExisting(linkToken: string, organizationId: string): Promise<Result<LinkExistingResponse, APIError>>;
|
|
23
|
+
/**
|
|
24
|
+
* Submit full onboarding form — creates new sub-organization.
|
|
25
|
+
* fee_percent is provided by the link; omit it from data.
|
|
26
|
+
*/
|
|
27
|
+
submit(linkToken: string, data: EmbedSubmitRequest): Promise<Result<CreateSubOrganizationResponse, APIError>>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=embed-onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-onboarding.d.ts","sourceRoot":"","sources":["../../src/namespaces/embed-onboarding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EACV,6BAA6B,EAC7B,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,4BAA4B,CAAA;AAEnC,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C;;;OAGG;IACH,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,YAAY,GAAG,UAAU,GACpC,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;IAcnD;;;OAGG;IACH,YAAY,CACV,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IASlD;;;OAGG;IACH,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;CAQ5D"}
|