chargefy-js 1.1.6 → 1.1.9

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
@@ -112,6 +112,17 @@ const result = await chargefy.products.create({
112
112
  prices: [{ amount: 4900 }], // R$ 49,00/month
113
113
  })
114
114
 
115
+ // Create product with referenceId (upsert: update if exists for org)
116
+ const result = await chargefy.products.create({
117
+ organizationId: 'org_xxx',
118
+ name: 'My Product',
119
+ referenceId: 'my-product-123', // Your internal ID
120
+ prices: [{ amount: 9900 }],
121
+ })
122
+
123
+ // Get product by reference_id (OAT uses token's org)
124
+ const result = await chargefy.products.getByReferenceId('my-product-123')
125
+
115
126
  // Update product
116
127
  const result = await chargefy.products.update({
117
128
  id: 'prod_xxx',
@@ -120,6 +131,10 @@ const result = await chargefy.products.update({
120
131
  })
121
132
  ```
122
133
 
134
+ | Create/Update field | Type | Description |
135
+ |---------------------|------|-------------|
136
+ | `referenceId` | `string \| null` | Optional. Your internal product ID. When set on create, upserts: if a product with this `referenceId` exists for the org, it updates; else creates. Unique per org. |
137
+
123
138
  ---
124
139
 
125
140
  ## Checkout Links
@@ -143,14 +158,36 @@ const result = await chargefy.checkoutLinks.create({
143
158
  })
144
159
  // result.value.url → share this URL with buyers
145
160
 
161
+ // Create checkout link with custom price (override product's default)
162
+ const result = await chargefy.checkoutLinks.create({
163
+ organizationId: 'org_xxx',
164
+ productId: 'prod_xxx',
165
+ successUrl: 'https://mysite.com/thank-you',
166
+ customPriceAmount: 7900, // R$ 79,00 in cents — buyers pay this instead of product price
167
+ })
168
+
146
169
  // Update checkout link
147
170
  const result = await chargefy.checkoutLinks.update({
148
171
  id: 'cl_xxx',
149
172
  successUrl: 'https://mysite.com/new-success-page',
150
173
  allowDiscountCodes: true,
151
174
  })
175
+
176
+ // Update checkout link price (or clear with null)
177
+ const result = await chargefy.checkoutLinks.update({
178
+ id: 'cl_xxx',
179
+ customPriceAmount: 9900, // R$ 99,00 — override for this link only
180
+ })
181
+
182
+ // Get shareable URL (convenience)
183
+ const urlResult = await chargefy.checkoutLinks.getLink('cl_xxx')
184
+ // urlResult.value → full redirect URL to share with buyers
152
185
  ```
153
186
 
187
+ | Create/Update field | Type | Description |
188
+ |---------------------|------|-------------|
189
+ | `customPriceAmount` | `number \| null` | Optional. Price override in cents. When set, buyers pay this amount instead of the product's default. Pass `null` on update to clear. |
190
+
154
191
  ---
155
192
 
156
193
  ## Sub-Organizations
@@ -187,6 +224,14 @@ const result = await chargefy.subOrganizations.createProduct('org_child_xxx', {
187
224
  prices: [{ amountType: 'fixed', priceAmount: 9900, priceCurrency: 'brl' }],
188
225
  })
189
226
 
227
+ // Create product with referenceId (upsert for child org)
228
+ const result = await chargefy.subOrganizations.createProduct('org_child_xxx', {
229
+ feePercent: 5,
230
+ name: 'Child Product',
231
+ referenceId: 'child-prod-123',
232
+ prices: [{ amountType: 'fixed', priceAmount: 9900, priceCurrency: 'brl' }],
233
+ })
234
+
190
235
  // List/create/revoke child's API keys
191
236
  const tokens = await chargefy.subOrganizations.listApiKeys('org_child_xxx')
192
237
  const newToken = await chargefy.subOrganizations.createApiKey('org_child_xxx', { comment: 'Marketing' })
@@ -195,6 +240,40 @@ await chargefy.subOrganizations.revokeApiKey('org_child_xxx', 'token_id')
195
240
 
196
241
  ---
197
242
 
243
+ ## Sub-Organization Administration
244
+
245
+ Child organizations can manage their own products and checkout links using their **OAT** (Organization Access Token). Use the same `products` and `checkoutLinks` namespaces with the child's token:
246
+
247
+ ```ts
248
+ // Initialize with child org's OAT (from createApiKey or parent's dashboard)
249
+ const childChargefy = new Chargefy({
250
+ accessToken: 'chargefy_oat_CHILD_TOKEN',
251
+ server: 'production',
252
+ })
253
+
254
+ // Child creates products (org inferred from token)
255
+ const product = await childChargefy.products.create({
256
+ organizationId: 'org_child_xxx', // Same as token's org
257
+ name: 'My Product',
258
+ referenceId: 'my-internal-id',
259
+ prices: [{ amount: 9900 }],
260
+ })
261
+
262
+ // Child creates checkout link with custom price
263
+ const link = await childChargefy.checkoutLinks.create({
264
+ organizationId: 'org_child_xxx',
265
+ productId: product.value.id,
266
+ successUrl: 'https://child-site.com/thanks',
267
+ customPriceAmount: 7900,
268
+ })
269
+
270
+ // Get shareable URL
271
+ const urlResult = await childChargefy.checkoutLinks.getLink(link.value.id)
272
+ console.log('Share:', urlResult.value)
273
+ ```
274
+
275
+ ---
276
+
198
277
  ## Onboarding Links
199
278
 
200
279
  Create reusable embed onboarding links. **OAT required.**
package/dist/core.d.ts CHANGED
@@ -20,6 +20,8 @@ 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 {
@@ -36,6 +38,7 @@ export declare class ChargefyCore {
36
38
  readonly serverURL: string;
37
39
  readonly accessToken: string | undefined;
38
40
  readonly timeout: number;
41
+ readonly headers: Record<string, string>;
39
42
  constructor(options?: ChargefyCoreOptions);
40
43
  request<T>(options: RequestOptions): Promise<Result<T, APIError>>;
41
44
  }
@@ -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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AAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED,MAAM,MAAM,QAAQ,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,mBAAmB,GACnB,YAAY,GACZ,eAAe,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,6 +27,7 @@ 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
33
  const { method, path, body, bodyIsFormData, query, auth = true } = options;
@@ -48,6 +50,7 @@ export class ChargefyCore {
48
50
  if (auth && this.accessToken) {
49
51
  headers['Authorization'] = `Bearer ${this.accessToken}`;
50
52
  }
53
+ Object.assign(headers, this.headers);
51
54
  const controller = new AbortController();
52
55
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
53
56
  try {
@@ -9,6 +9,8 @@ export interface CheckoutLink {
9
9
  allowDiscountCodes: boolean;
10
10
  isArchived: boolean;
11
11
  metadata?: Record<string, unknown>;
12
+ /** Optional price override in cents. When set, used instead of product price when buyer opens the link. */
13
+ customPriceAmount?: number | null;
12
14
  createdAt: string;
13
15
  }
14
16
  export interface CreateCheckoutLinkRequest {
@@ -19,11 +21,15 @@ export interface CreateCheckoutLinkRequest {
19
21
  successUrl?: string;
20
22
  allowDiscountCodes?: boolean;
21
23
  metadata?: Record<string, unknown>;
24
+ /** Optional price override in cents. When set, buyers pay this amount instead of the product's default price. */
25
+ customPriceAmount?: number | null;
22
26
  }
23
27
  export interface UpdateCheckoutLinkRequest {
24
28
  id: string;
25
29
  successUrl?: string;
26
30
  allowDiscountCodes?: boolean;
27
31
  metadata?: Record<string, unknown>;
32
+ /** Optional price override in cents. When set, buyers pay this amount instead of the product's default price. Pass null to clear. */
33
+ customPriceAmount?: number | null;
28
34
  }
29
35
  //# sourceMappingURL=checkoutLink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkoutLink.d.ts","sourceRoot":"","sources":["../../src/models/checkoutLink.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,CAAC,EAAE,MAAM,CAAA;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C,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,iHAAiH;IACjH,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,qIAAqI;IACrI,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC"}
@@ -18,6 +18,8 @@ export interface Product {
18
18
  prices: ProductPrice[];
19
19
  createdAt: string;
20
20
  metadata?: Record<string, unknown>;
21
+ /** Customer-side product ID; unique per org; enables upsert and lookup */
22
+ referenceId?: string | null;
21
23
  }
22
24
  export interface CreateProductRequest {
23
25
  organizationId: string;
@@ -33,6 +35,8 @@ export interface CreateProductRequest {
33
35
  currency?: string;
34
36
  }>;
35
37
  metadata?: Record<string, unknown>;
38
+ /** Customer-side product ID. When set, upserts: if exists for org, updates; else creates. */
39
+ referenceId?: string | null;
36
40
  }
37
41
  export interface UpdateProductRequest {
38
42
  id: string;
@@ -40,5 +44,6 @@ export interface UpdateProductRequest {
40
44
  description?: string;
41
45
  isArchived?: boolean;
42
46
  metadata?: Record<string, unknown>;
47
+ referenceId?: string | null;
43
48
  }
44
49
  //# sourceMappingURL=product.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"product.d.ts","sourceRoot":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,GAAG,IAAI,CAAA;IAC3C,sCAAsC;IACtC,MAAM,EAAE,KAAK,CAAC;QACZ,oDAAoD;QACpD,MAAM,EAAE,MAAM,CAAA;QACd,8CAA8C;QAC9C,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAC,CAAA;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B"}
@@ -108,6 +108,8 @@ export interface CreateProductForChildRequest {
108
108
  }>;
109
109
  metadata?: Record<string, unknown>;
110
110
  medias?: string[];
111
+ /** Customer-side product ID. When set, upserts: if exists for child org, updates; else creates. */
112
+ referenceId?: string | null;
111
113
  }
112
114
  export interface CreateSubOrganizationResponse {
113
115
  organization: {
@@ -1 +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,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB;AAID,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,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ponse<CheckoutLink>, APIError>>;
10
10
  /** Get a single checkout link by ID. */
11
11
  get(id: string): Promise<Result<CheckoutLink, APIError>>;
12
+ /** Get the shareable checkout URL for a checkout link. Convenience wrapper around get(). */
13
+ getLink(id: string): Promise<Result<string, APIError>>;
12
14
  /** Create a new checkout link. */
13
15
  create(body: CreateCheckoutLinkRequest): Promise<Result<CheckoutLink, APIError>>;
14
16
  /** Update an existing checkout link. */
@@ -1 +1 @@
1
- {"version":3,"file":"checkoutLinks.d.ts","sourceRoot":"","sources":["../../src/namespaces/checkoutLinks.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,EAAE,YAAY,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEpE,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C,iDAAiD;IACjD,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAQhF,wCAAwC;IACxC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAOxD,kCAAkC;IAClC,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAgBhF,wCAAwC;IACxC,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;CAYjF"}
1
+ {"version":3,"file":"checkoutLinks.d.ts","sourceRoot":"","sources":["../../src/namespaces/checkoutLinks.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,EAAE,YAAY,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEpE,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C,iDAAiD;IACjD,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAQhF,wCAAwC;IACxC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAOxD,4FAA4F;IACtF,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAM5D,kCAAkC;IAClC,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAiBhF,wCAAwC;IACxC,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;CAajF"}
@@ -18,6 +18,13 @@ export class CheckoutLinks {
18
18
  path: `/v1/checkout-links/${id}`,
19
19
  });
20
20
  }
21
+ /** Get the shareable checkout URL for a checkout link. Convenience wrapper around get(). */
22
+ async getLink(id) {
23
+ const result = await this.get(id);
24
+ if (!result.ok)
25
+ return result;
26
+ return { ok: true, value: result.value.url };
27
+ }
21
28
  /** Create a new checkout link. */
22
29
  create(body) {
23
30
  const payload = {
@@ -32,6 +39,8 @@ export class CheckoutLinks {
32
39
  payload.allow_discount_codes = body.allowDiscountCodes;
33
40
  if (body.metadata !== undefined)
34
41
  payload.metadata = body.metadata;
42
+ if (body.customPriceAmount !== undefined)
43
+ payload.custom_price_amount = body.customPriceAmount;
35
44
  return this.core.request({
36
45
  method: 'POST',
37
46
  path: '/v1/checkout-links',
@@ -48,6 +57,8 @@ export class CheckoutLinks {
48
57
  payload.allow_discount_codes = rest.allowDiscountCodes;
49
58
  if (rest.metadata !== undefined)
50
59
  payload.metadata = rest.metadata;
60
+ if (rest.customPriceAmount !== undefined)
61
+ payload.custom_price_amount = rest.customPriceAmount;
51
62
  return this.core.request({
52
63
  method: 'PATCH',
53
64
  path: `/v1/checkout-links/${id}`,
@@ -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":[],"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
  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;
@@ -9,9 +9,11 @@ export declare class Products {
9
9
  list(params?: ListParams): Promise<Result<ListResponse<Product>, APIError>>;
10
10
  /** Get a single product by ID. */
11
11
  get(id: string): Promise<Result<Product, APIError>>;
12
- /** Create a new product. */
12
+ /** Create a new product. With referenceId, upserts if product exists for org. */
13
13
  create(body: CreateProductRequest): Promise<Result<Product, APIError>>;
14
14
  /** Update an existing product. */
15
15
  update(body: UpdateProductRequest): Promise<Result<Product, APIError>>;
16
+ /** Get product by reference_id. OAT uses token's org; pass organizationId when using user auth. */
17
+ getByReferenceId(referenceId: string, organizationId?: string): Promise<Result<Product, APIError>>;
16
18
  }
17
19
  //# sourceMappingURL=products.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../src/namespaces/products.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,EAAE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEpE,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,YAAY;IAE/C,+CAA+C;IAC/C,IAAI,CAAC,M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O,EAAE,QAAQ,CAAC,CAAC;IAqBtE,kCAAkC;IAClC,MAAM,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAetE,mGAAmG;IACnG,gBAAgB,CACd,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;CAOtC"}
@@ -18,7 +18,7 @@ export class Products {
18
18
  path: `/v1/products/${id}`,
19
19
  });
20
20
  }
21
- /** Create a new product. */
21
+ /** Create a new product. With referenceId, upserts if product exists for org. */
22
22
  create(body) {
23
23
  const payload = {
24
24
  organization_id: body.organizationId,
@@ -26,11 +26,14 @@ export class Products {
26
26
  description: body.description,
27
27
  recurring_interval: body.recurringInterval,
28
28
  prices: body.prices.map((p) => ({
29
- amount: p.amount,
30
- currency: p.currency ?? 'BRL',
29
+ amount_type: 'fixed',
30
+ price_amount: p.amount,
31
+ price_currency: (p.currency ?? 'BRL').toLowerCase(),
31
32
  })),
32
33
  metadata: body.metadata,
33
34
  };
35
+ if (body.referenceId !== undefined)
36
+ payload.reference_id = body.referenceId;
34
37
  return this.core.request({
35
38
  method: 'POST',
36
39
  path: '/v1/products',
@@ -49,10 +52,20 @@ export class Products {
49
52
  payload.is_archived = rest.isArchived;
50
53
  if (rest.metadata !== undefined)
51
54
  payload.metadata = rest.metadata;
55
+ if (rest.referenceId !== undefined)
56
+ payload.reference_id = rest.referenceId;
52
57
  return this.core.request({
53
58
  method: 'PATCH',
54
59
  path: `/v1/products/${id}`,
55
60
  body: payload,
56
61
  });
57
62
  }
63
+ /** Get product by reference_id. OAT uses token's org; pass organizationId when using user auth. */
64
+ getByReferenceId(referenceId, organizationId) {
65
+ return this.core.request({
66
+ method: 'GET',
67
+ path: `/v1/products/by-reference/${encodeURIComponent(referenceId)}`,
68
+ query: organizationId ? { organization_id: organizationId } : undefined,
69
+ });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MG;IACH,MAAM,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;IAQpG;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAAE,KAAK,EAAE,cAAc,EAAE,CAAA;KAAE,EAAE,QAAQ,CAAC,CAAC;IAOlF;;;;OAIG;IACH,YAAY,CACV,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,2BAA2B,GACjC,OAAO,CAAC,MAAM,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;IAQ1D;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAO7E;;;OAGG;IACH,YAAY,CACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAC9B,OAAO,CAAC,MAAM,CAAC;QAAE,oBAAoB,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,QAAQ,CAAC,CAAC;IAQ/G;;;OAGG;IACH,aAAa,CACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,4BAA4B,EAAE,4BAA4B,GACtE,OAAO,CAAC,MAAM,CAAC,OAAO,mBAAmB,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;CAwClE"}
@@ -119,6 +119,8 @@ export class SubOrganizations {
119
119
  };
120
120
  if (data.medias)
121
121
  payload.medias = data.medias;
122
+ if (data.referenceId !== undefined)
123
+ payload.reference_id = data.referenceId;
122
124
  return this.core.request({
123
125
  method: 'POST',
124
126
  path: `/v1/sdk/organizations/${orgId}/products`,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.1.6",
7
+ "version": "1.1.9",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",
10
10
  "module": "./dist/index.js",
package/src/core.ts CHANGED
@@ -31,6 +31,8 @@ export interface ChargefyCoreOptions {
31
31
  serverURL?: string
32
32
  /** Request timeout in milliseconds. Default: 30000. */
33
33
  timeout?: number
34
+ /** Extra headers sent with every request (e.g. X-Chargefy-Source: embed). */
35
+ headers?: Record<string, string>
34
36
  }
35
37
 
36
38
  export type APIError =
@@ -63,6 +65,7 @@ export class ChargefyCore {
63
65
  readonly serverURL: string
64
66
  readonly accessToken: string | undefined
65
67
  readonly timeout: number
68
+ readonly headers: Record<string, string>
66
69
 
67
70
  constructor(options: ChargefyCoreOptions = {}) {
68
71
  if (options.serverURL) {
@@ -78,6 +81,7 @@ export class ChargefyCore {
78
81
  }
79
82
  this.accessToken = options.accessToken
80
83
  this.timeout = options.timeout ?? 30000
84
+ this.headers = options.headers ?? {}
81
85
  }
82
86
 
83
87
  async request<T>(options: RequestOptions): Promise<Result<T, APIError>> {
@@ -103,6 +107,7 @@ export class ChargefyCore {
103
107
  if (auth && this.accessToken) {
104
108
  headers['Authorization'] = `Bearer ${this.accessToken}`
105
109
  }
110
+ Object.assign(headers, this.headers)
106
111
 
107
112
  const controller = new AbortController()
108
113
  const timeoutId = setTimeout(() => controller.abort(), this.timeout)
@@ -9,6 +9,8 @@ export interface CheckoutLink {
9
9
  allowDiscountCodes: boolean
10
10
  isArchived: boolean
11
11
  metadata?: Record<string, unknown>
12
+ /** Optional price override in cents. When set, used instead of product price when buyer opens the link. */
13
+ customPriceAmount?: number | null
12
14
  createdAt: string
13
15
  }
14
16
 
@@ -20,6 +22,8 @@ export interface CreateCheckoutLinkRequest {
20
22
  successUrl?: string
21
23
  allowDiscountCodes?: boolean
22
24
  metadata?: Record<string, unknown>
25
+ /** Optional price override in cents. When set, buyers pay this amount instead of the product's default price. */
26
+ customPriceAmount?: number | null
23
27
  }
24
28
 
25
29
  export interface UpdateCheckoutLinkRequest {
@@ -27,4 +31,6 @@ export interface UpdateCheckoutLinkRequest {
27
31
  successUrl?: string
28
32
  allowDiscountCodes?: boolean
29
33
  metadata?: Record<string, unknown>
34
+ /** Optional price override in cents. When set, buyers pay this amount instead of the product's default price. Pass null to clear. */
35
+ customPriceAmount?: number | null
30
36
  }
@@ -19,6 +19,8 @@ export interface Product {
19
19
  prices: ProductPrice[]
20
20
  createdAt: string
21
21
  metadata?: Record<string, unknown>
22
+ /** Customer-side product ID; unique per org; enables upsert and lookup */
23
+ referenceId?: string | null
22
24
  }
23
25
 
24
26
  export interface CreateProductRequest {
@@ -35,6 +37,8 @@ export interface CreateProductRequest {
35
37
  currency?: string
36
38
  }>
37
39
  metadata?: Record<string, unknown>
40
+ /** Customer-side product ID. When set, upserts: if exists for org, updates; else creates. */
41
+ referenceId?: string | null
38
42
  }
39
43
 
40
44
  export interface UpdateProductRequest {
@@ -43,4 +47,5 @@ export interface UpdateProductRequest {
43
47
  description?: string
44
48
  isArchived?: boolean
45
49
  metadata?: Record<string, unknown>
50
+ referenceId?: string | null
46
51
  }
@@ -113,6 +113,8 @@ export interface CreateProductForChildRequest {
113
113
  >
114
114
  metadata?: Record<string, unknown>
115
115
  medias?: string[]
116
+ /** Customer-side product ID. When set, upserts: if exists for child org, updates; else creates. */
117
+ referenceId?: string | null
116
118
  }
117
119
 
118
120
  // ── Response ──────────────────────────────────────────────────────────────────
@@ -23,6 +23,13 @@ export class CheckoutLinks {
23
23
  })
24
24
  }
25
25
 
26
+ /** Get the shareable checkout URL for a checkout link. Convenience wrapper around get(). */
27
+ async getLink(id: string): Promise<Result<string, APIError>> {
28
+ const result = await this.get(id)
29
+ if (!result.ok) return result
30
+ return { ok: true, value: result.value.url }
31
+ }
32
+
26
33
  /** Create a new checkout link. */
27
34
  create(body: CreateCheckoutLinkRequest): Promise<Result<CheckoutLink, APIError>> {
28
35
  const payload: Record<string, unknown> = {
@@ -33,6 +40,7 @@ export class CheckoutLinks {
33
40
  if (body.successUrl !== undefined) payload.success_url = body.successUrl
34
41
  if (body.allowDiscountCodes !== undefined) payload.allow_discount_codes = body.allowDiscountCodes
35
42
  if (body.metadata !== undefined) payload.metadata = body.metadata
43
+ if (body.customPriceAmount !== undefined) payload.custom_price_amount = body.customPriceAmount
36
44
  return this.core.request<CheckoutLink>({
37
45
  method: 'POST',
38
46
  path: '/v1/checkout-links',
@@ -47,6 +55,7 @@ export class CheckoutLinks {
47
55
  if (rest.successUrl !== undefined) payload.success_url = rest.successUrl
48
56
  if (rest.allowDiscountCodes !== undefined) payload.allow_discount_codes = rest.allowDiscountCodes
49
57
  if (rest.metadata !== undefined) payload.metadata = rest.metadata
58
+ if (rest.customPriceAmount !== undefined) payload.custom_price_amount = rest.customPriceAmount
50
59
  return this.core.request<CheckoutLink>({
51
60
  method: 'PATCH',
52
61
  path: `/v1/checkout-links/${id}`,
@@ -8,6 +8,8 @@ import type {
8
8
  ConfirmCheckoutRequest,
9
9
  GeneratePixRequest,
10
10
  } from '../models/checkout'
11
+ import type { CheckoutUpdatePublic } from '../models/components/checkoutupdatepublic'
12
+ import { transformToSnakeCase } from '../utils/transformers'
11
13
 
12
14
  export class Checkouts {
13
15
  constructor(private readonly core: ChargefyCore) {}
@@ -50,6 +52,20 @@ export class Checkouts {
50
52
  })
51
53
  }
52
54
 
55
+ /** Update customer info on an open checkout by client secret (public, no auth). */
56
+ updateByClientSecret(
57
+ clientSecret: string,
58
+ data: CheckoutUpdatePublic
59
+ ): Promise<Result<Checkout, APIError>> {
60
+ const payload = transformToSnakeCase(data) as Record<string, unknown>
61
+ return this.core.request<Checkout>({
62
+ method: 'PATCH',
63
+ path: `/v1/checkouts/client/${clientSecret}`,
64
+ body: payload,
65
+ auth: false,
66
+ })
67
+ }
68
+
53
69
  /** Update customer info on an open checkout. */
54
70
  update(body: UpdateCheckoutRequest): Promise<Result<Checkout, APIError>> {
55
71
  const { id, ...rest } = body
@@ -23,19 +23,21 @@ export class Products {
23
23
  })
24
24
  }
25
25
 
26
- /** Create a new product. */
26
+ /** Create a new product. With referenceId, upserts if product exists for org. */
27
27
  create(body: CreateProductRequest): Promise<Result<Product, APIError>> {
28
- const payload = {
28
+ const payload: Record<string, unknown> = {
29
29
  organization_id: body.organizationId,
30
30
  name: body.name,
31
31
  description: body.description,
32
32
  recurring_interval: body.recurringInterval,
33
33
  prices: body.prices.map((p) => ({
34
- amount: p.amount,
35
- currency: p.currency ?? 'BRL',
34
+ amount_type: 'fixed',
35
+ price_amount: p.amount,
36
+ price_currency: (p.currency ?? 'BRL').toLowerCase(),
36
37
  })),
37
38
  metadata: body.metadata,
38
39
  }
40
+ if (body.referenceId !== undefined) payload.reference_id = body.referenceId
39
41
  return this.core.request<Product>({
40
42
  method: 'POST',
41
43
  path: '/v1/products',
@@ -51,10 +53,23 @@ export class Products {
51
53
  if (rest.description !== undefined) payload.description = rest.description
52
54
  if (rest.isArchived !== undefined) payload.is_archived = rest.isArchived
53
55
  if (rest.metadata !== undefined) payload.metadata = rest.metadata
56
+ if (rest.referenceId !== undefined) payload.reference_id = rest.referenceId
54
57
  return this.core.request<Product>({
55
58
  method: 'PATCH',
56
59
  path: `/v1/products/${id}`,
57
60
  body: payload,
58
61
  })
59
62
  }
63
+
64
+ /** Get product by reference_id. OAT uses token's org; pass organizationId when using user auth. */
65
+ getByReferenceId(
66
+ referenceId: string,
67
+ organizationId?: string
68
+ ): Promise<Result<Product, APIError>> {
69
+ return this.core.request<Product>({
70
+ method: 'GET',
71
+ path: `/v1/products/by-reference/${encodeURIComponent(referenceId)}`,
72
+ query: organizationId ? { organization_id: organizationId } : undefined,
73
+ })
74
+ }
60
75
  }
@@ -147,6 +147,7 @@ export class SubOrganizations {
147
147
  metadata: data.metadata ?? {},
148
148
  }
149
149
  if (data.medias) payload.medias = data.medias
150
+ if (data.referenceId !== undefined) payload.reference_id = data.referenceId
150
151
  return this.core.request({
151
152
  method: 'POST',
152
153
  path: `/v1/sdk/organizations/${orgId}/products`,