chargefy-js 1.1.10 → 1.1.11
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/dist/chargefy.d.ts +3 -0
- package/dist/chargefy.d.ts.map +1 -1
- package/dist/chargefy.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/models/checkout.d.ts +4 -0
- package/dist/models/checkout.d.ts.map +1 -1
- package/dist/models/discount.d.ts +108 -0
- package/dist/models/discount.d.ts.map +1 -0
- package/dist/models/discount.js +1 -0
- package/dist/namespaces/checkouts.d.ts.map +1 -1
- package/dist/namespaces/checkouts.js +4 -0
- package/dist/namespaces/discounts.d.ts +22 -0
- package/dist/namespaces/discounts.d.ts.map +1 -0
- package/dist/namespaces/discounts.js +119 -0
- package/dist/namespaces/sub-organizations.d.ts +26 -0
- package/dist/namespaces/sub-organizations.d.ts.map +1 -1
- package/dist/namespaces/sub-organizations.js +92 -0
- package/package.json +1 -1
- package/src/chargefy.ts +4 -0
- package/src/index.ts +13 -0
- package/src/models/checkout.ts +4 -0
- package/src/models/discount.ts +119 -0
- package/src/namespaces/checkouts.ts +2 -0
- package/src/namespaces/discounts.ts +119 -0
- package/src/namespaces/sub-organizations.ts +100 -0
package/dist/chargefy.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { Webhooks } from './namespaces/webhooks.js';
|
|
|
11
11
|
import { EmbedOnboarding } from './namespaces/embed-onboarding.js';
|
|
12
12
|
import { OnboardingLinks } from './namespaces/onboarding-links.js';
|
|
13
13
|
import { Kyc } from './namespaces/kyc.js';
|
|
14
|
+
import { Discounts } from './namespaces/discounts.js';
|
|
14
15
|
export type { ChargefyCoreOptions };
|
|
15
16
|
/**
|
|
16
17
|
* Chargefy SDK
|
|
@@ -52,6 +53,8 @@ export declare class Chargefy {
|
|
|
52
53
|
readonly onboardingLinks: OnboardingLinks;
|
|
53
54
|
/** KYC document status and upload (OAT or user session). */
|
|
54
55
|
readonly kyc: Kyc;
|
|
56
|
+
/** Discount management: create, list, validate, stats. */
|
|
57
|
+
readonly discounts: Discounts;
|
|
55
58
|
constructor(options?: ChargefyCoreOptions);
|
|
56
59
|
}
|
|
57
60
|
//# 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,WAAW,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"chargefy.d.ts","sourceRoot":"","sources":["../src/chargefy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE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zC,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAA;IACzC,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;IACjB,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;gBAEjB,OAAO,GAAE,mBAAwB;CAgB9C"}
|
package/dist/chargefy.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Webhooks } from './namespaces/webhooks.js';
|
|
|
11
11
|
import { EmbedOnboarding } from './namespaces/embed-onboarding.js';
|
|
12
12
|
import { OnboardingLinks } from './namespaces/onboarding-links.js';
|
|
13
13
|
import { Kyc } from './namespaces/kyc.js';
|
|
14
|
+
import { Discounts } from './namespaces/discounts.js';
|
|
14
15
|
/**
|
|
15
16
|
* Chargefy SDK
|
|
16
17
|
*
|
|
@@ -51,6 +52,8 @@ export class Chargefy {
|
|
|
51
52
|
onboardingLinks;
|
|
52
53
|
/** KYC document status and upload (OAT or user session). */
|
|
53
54
|
kyc;
|
|
55
|
+
/** Discount management: create, list, validate, stats. */
|
|
56
|
+
discounts;
|
|
54
57
|
constructor(options = {}) {
|
|
55
58
|
const core = new ChargefyCore(options);
|
|
56
59
|
this.organizations = new Organizations(core);
|
|
@@ -65,5 +68,6 @@ export class Chargefy {
|
|
|
65
68
|
this.embedOnboarding = new EmbedOnboarding(core);
|
|
66
69
|
this.onboardingLinks = new OnboardingLinks(core);
|
|
67
70
|
this.kyc = new Kyc(core);
|
|
71
|
+
this.discounts = new Discounts(core);
|
|
68
72
|
}
|
|
69
73
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type { WebhookEndpoint, WebhookEventType, WebhookFormat, CreateWebhookEnd
|
|
|
18
18
|
export { SUBORGANIZATION_EVENTS } from './models/webhook.js';
|
|
19
19
|
export type { CreateOnboardingLinkRequest, CreateOnboardingLinkResponse, } from './models/onboarding-link.js';
|
|
20
20
|
export type { KycDocumentType, KycDocumentsResponse, UploadDocumentResponse, } from './models/kyc.js';
|
|
21
|
+
export type { Discount, DiscountCreate, DiscountCreateFixed, DiscountCreatePercentage, DiscountUpdate, ValidateDiscountParams, ValidateDiscountResponse, DiscountStats, DiscountListParams, DiscountListResponse, CreateDiscountForChildRequest, } from './models/discount.js';
|
|
21
22
|
export { SDKError, SDKValidationError, UnexpectedClientError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, ConnectionError, } from './models/errors/httpclienterrors.js';
|
|
22
23
|
export { HTTPValidationError, type ValidationErrorDetail } from './models/errors/httpvalidationerror.js';
|
|
23
24
|
export { ResourceNotFound } from './models/errors/resourcenotfound.js';
|
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,eAAe,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGzC,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,YAAY,EACV,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,KAAK,EACL,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,QAAQ,EACR,cAAc,GACf,MAAM,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E,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,YAAY,EACV,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,6BAA6B,CAAA;AACpC,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AACxG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAA;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA"}
|
|
@@ -111,6 +111,8 @@ export interface ConfirmCheckoutRequest {
|
|
|
111
111
|
/** CPF or CNPJ. */
|
|
112
112
|
customerTaxId?: string;
|
|
113
113
|
card: CardData;
|
|
114
|
+
/** Discount code to apply at payment time. */
|
|
115
|
+
discountCode?: string;
|
|
114
116
|
}
|
|
115
117
|
/** Generate a PIX QR code for a checkout. */
|
|
116
118
|
export interface GeneratePixRequest {
|
|
@@ -120,5 +122,7 @@ export interface GeneratePixRequest {
|
|
|
120
122
|
/** Omit for anonymous / totem checkouts. */
|
|
121
123
|
customerName?: string;
|
|
122
124
|
customerTaxId?: string;
|
|
125
|
+
/** Discount code to apply at payment time. */
|
|
126
|
+
discountCode?: string;
|
|
123
127
|
}
|
|
124
128
|
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/models/checkout.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,cAAc,EAAE,MAAM,CAAA;IACtB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,EAAE,OAAO,CAAA;IACpB,iBAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE;QACb,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAC1B,CAAA;CACF;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;IACjE,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC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MAAM,CAAA;IACpB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export interface Discount {
|
|
2
|
+
id: string;
|
|
3
|
+
organizationId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: 'fixed' | 'percentage';
|
|
6
|
+
code: string | null;
|
|
7
|
+
startsAt: string | null;
|
|
8
|
+
endsAt: string | null;
|
|
9
|
+
maxRedemptions: number | null;
|
|
10
|
+
redemptionsCount: number;
|
|
11
|
+
duration: 'once' | 'forever' | 'repeating';
|
|
12
|
+
durationInMonths: number | null;
|
|
13
|
+
/** For fixed type: amount in cents. */
|
|
14
|
+
amount?: number | null;
|
|
15
|
+
currency?: string | null;
|
|
16
|
+
/** For percentage type: basis points (1000 = 10%). */
|
|
17
|
+
basisPoints?: number | null;
|
|
18
|
+
userMetadata?: Record<string, unknown>;
|
|
19
|
+
internalReference?: string | null;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
modifiedAt: string | null;
|
|
22
|
+
deletedAt: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface DiscountCreateFixed {
|
|
25
|
+
organizationId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: 'fixed';
|
|
28
|
+
amount: number;
|
|
29
|
+
currency: string;
|
|
30
|
+
code?: string | null;
|
|
31
|
+
startsAt?: string | null;
|
|
32
|
+
endsAt?: string | null;
|
|
33
|
+
maxRedemptions?: number | null;
|
|
34
|
+
duration: 'once' | 'forever' | 'repeating';
|
|
35
|
+
durationInMonths?: number | null;
|
|
36
|
+
products?: string[];
|
|
37
|
+
userMetadata?: Record<string, unknown>;
|
|
38
|
+
internalReference?: string | null;
|
|
39
|
+
}
|
|
40
|
+
export interface DiscountCreatePercentage {
|
|
41
|
+
organizationId: string;
|
|
42
|
+
name: string;
|
|
43
|
+
type: 'percentage';
|
|
44
|
+
basisPoints: number;
|
|
45
|
+
code?: string | null;
|
|
46
|
+
startsAt?: string | null;
|
|
47
|
+
endsAt?: string | null;
|
|
48
|
+
maxRedemptions?: number | null;
|
|
49
|
+
duration: 'once' | 'forever' | 'repeating';
|
|
50
|
+
durationInMonths?: number | null;
|
|
51
|
+
products?: string[];
|
|
52
|
+
userMetadata?: Record<string, unknown>;
|
|
53
|
+
internalReference?: string | null;
|
|
54
|
+
}
|
|
55
|
+
export type DiscountCreate = DiscountCreateFixed | DiscountCreatePercentage;
|
|
56
|
+
/** Create discount for child org (organizationId comes from orgId param). */
|
|
57
|
+
export type CreateDiscountForChildRequest = Omit<DiscountCreateFixed, 'organizationId'> | Omit<DiscountCreatePercentage, 'organizationId'>;
|
|
58
|
+
export interface DiscountUpdate {
|
|
59
|
+
name?: string;
|
|
60
|
+
code?: string | null;
|
|
61
|
+
startsAt?: string | null;
|
|
62
|
+
endsAt?: string | null;
|
|
63
|
+
maxRedemptions?: number | null;
|
|
64
|
+
durationInMonths?: number | null;
|
|
65
|
+
products?: string[];
|
|
66
|
+
userMetadata?: Record<string, unknown>;
|
|
67
|
+
internalReference?: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface ValidateDiscountParams {
|
|
70
|
+
code: string;
|
|
71
|
+
organizationId: string;
|
|
72
|
+
amount?: number;
|
|
73
|
+
productId?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ValidateDiscountResponse {
|
|
76
|
+
valid: boolean;
|
|
77
|
+
discount?: Discount;
|
|
78
|
+
error?: string;
|
|
79
|
+
calculatedDiscount?: {
|
|
80
|
+
originalAmount: number;
|
|
81
|
+
discountAmount: number;
|
|
82
|
+
finalAmount: number;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface DiscountStats {
|
|
86
|
+
totalRedemptions: number;
|
|
87
|
+
totalDiscountAmount: number;
|
|
88
|
+
totalOriginalAmount: number;
|
|
89
|
+
totalFinalAmount: number;
|
|
90
|
+
}
|
|
91
|
+
export interface DiscountListParams {
|
|
92
|
+
organizationId?: string;
|
|
93
|
+
query?: string;
|
|
94
|
+
isArchived?: boolean;
|
|
95
|
+
limit?: number;
|
|
96
|
+
offset?: number;
|
|
97
|
+
sortBy?: 'created_at' | 'name' | 'redemptions_count';
|
|
98
|
+
sortOrder?: 'asc' | 'desc';
|
|
99
|
+
}
|
|
100
|
+
export interface DiscountListResponse {
|
|
101
|
+
items: Discount[];
|
|
102
|
+
pagination: {
|
|
103
|
+
total: number;
|
|
104
|
+
limit: number;
|
|
105
|
+
offset: number;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=discount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discount.d.ts","sourceRoot":"","sources":["../../src/models/discount.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,GAAG,YAAY,CAAA;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAA;IAC1C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA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C,CAAA;AAGxF,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;IAwBnF;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;CAepF"}
|
|
@@ -97,6 +97,8 @@ export class Checkouts {
|
|
|
97
97
|
payload.customer_name = body.customerName;
|
|
98
98
|
if (body.customerTaxId !== undefined)
|
|
99
99
|
payload.customer_tax_id = body.customerTaxId;
|
|
100
|
+
if (body.discountCode !== undefined)
|
|
101
|
+
payload.discount_code = body.discountCode;
|
|
100
102
|
return this.core.request({
|
|
101
103
|
method: 'POST',
|
|
102
104
|
path: `/v1/checkouts/client/${body.clientSecret}/confirm-sdk`,
|
|
@@ -119,6 +121,8 @@ export class Checkouts {
|
|
|
119
121
|
payload.customer_name = body.customerName;
|
|
120
122
|
if (body.customerTaxId !== undefined)
|
|
121
123
|
payload.customer_tax_id = body.customerTaxId;
|
|
124
|
+
if (body.discountCode !== undefined)
|
|
125
|
+
payload.discount_code = body.discountCode;
|
|
122
126
|
return this.core.request({
|
|
123
127
|
method: 'POST',
|
|
124
128
|
path: `/v1/checkouts/client/${body.clientSecret}/confirm-sdk`,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChargefyCore, APIError } from '../core.js';
|
|
2
|
+
import type { Result } from '../types/fp.js';
|
|
3
|
+
import type { Discount, DiscountCreate, DiscountUpdate, ValidateDiscountParams, ValidateDiscountResponse, DiscountStats, DiscountListParams, DiscountListResponse } from '../models/discount.js';
|
|
4
|
+
export declare class Discounts {
|
|
5
|
+
private readonly core;
|
|
6
|
+
constructor(core: ChargefyCore);
|
|
7
|
+
/** List discounts for your organization. OAT uses token's org; pass organizationId for user auth. */
|
|
8
|
+
list(params?: DiscountListParams): Promise<Result<DiscountListResponse, APIError>>;
|
|
9
|
+
/** Get a discount by ID. */
|
|
10
|
+
get(id: string): Promise<Result<Discount, APIError>>;
|
|
11
|
+
/** Create a new discount. */
|
|
12
|
+
create(data: DiscountCreate): Promise<Result<Discount, APIError>>;
|
|
13
|
+
/** Update an existing discount. */
|
|
14
|
+
update(id: string, data: DiscountUpdate): Promise<Result<Discount, APIError>>;
|
|
15
|
+
/** Soft delete a discount. */
|
|
16
|
+
delete(id: string): Promise<Result<void, APIError>>;
|
|
17
|
+
/** Validate a discount code (authenticated). Params: code, organizationId, amount?, productId? */
|
|
18
|
+
validate(params: ValidateDiscountParams): Promise<Result<ValidateDiscountResponse, APIError>>;
|
|
19
|
+
/** Get redemption statistics for a discount. */
|
|
20
|
+
getStats(id: string): Promise<Result<DiscountStats, APIError>>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=discounts.d.ts.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AE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;CAM/D"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export class Discounts {
|
|
2
|
+
core;
|
|
3
|
+
constructor(core) {
|
|
4
|
+
this.core = core;
|
|
5
|
+
}
|
|
6
|
+
/** List discounts for your organization. OAT uses token's org; pass organizationId for user auth. */
|
|
7
|
+
list(params) {
|
|
8
|
+
const query = {};
|
|
9
|
+
if (params?.organizationId)
|
|
10
|
+
query.organization_id = params.organizationId;
|
|
11
|
+
if (params?.query)
|
|
12
|
+
query.query = params.query;
|
|
13
|
+
if (params?.isArchived !== undefined)
|
|
14
|
+
query.is_archived = params.isArchived;
|
|
15
|
+
if (params?.limit !== undefined)
|
|
16
|
+
query.limit = params.limit;
|
|
17
|
+
if (params?.offset !== undefined)
|
|
18
|
+
query.offset = params.offset;
|
|
19
|
+
if (params?.sortBy)
|
|
20
|
+
query.sort_by = params.sortBy;
|
|
21
|
+
if (params?.sortOrder)
|
|
22
|
+
query.sort_order = params.sortOrder;
|
|
23
|
+
return this.core.request({
|
|
24
|
+
method: 'GET',
|
|
25
|
+
path: '/v1/discounts',
|
|
26
|
+
query,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Get a discount by ID. */
|
|
30
|
+
get(id) {
|
|
31
|
+
return this.core.request({
|
|
32
|
+
method: 'GET',
|
|
33
|
+
path: `/v1/discounts/${id}`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Create a new discount. */
|
|
37
|
+
create(data) {
|
|
38
|
+
const payload = {
|
|
39
|
+
organization_id: data.organizationId,
|
|
40
|
+
name: data.name,
|
|
41
|
+
type: data.type,
|
|
42
|
+
duration: data.duration,
|
|
43
|
+
code: data.code ?? null,
|
|
44
|
+
starts_at: data.startsAt ?? null,
|
|
45
|
+
ends_at: data.endsAt ?? null,
|
|
46
|
+
max_redemptions: data.maxRedemptions ?? null,
|
|
47
|
+
duration_in_months: data.durationInMonths ?? null,
|
|
48
|
+
products: data.products ?? [],
|
|
49
|
+
user_metadata: data.userMetadata ?? {},
|
|
50
|
+
internal_reference: data.internalReference ?? null,
|
|
51
|
+
};
|
|
52
|
+
if (data.type === 'fixed') {
|
|
53
|
+
payload.amount = data.amount;
|
|
54
|
+
payload.currency = data.currency;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
payload.basis_points = data.basisPoints;
|
|
58
|
+
}
|
|
59
|
+
return this.core.request({
|
|
60
|
+
method: 'POST',
|
|
61
|
+
path: '/v1/discounts',
|
|
62
|
+
body: payload,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Update an existing discount. */
|
|
66
|
+
update(id, data) {
|
|
67
|
+
const payload = {};
|
|
68
|
+
if (data.name !== undefined)
|
|
69
|
+
payload.name = data.name;
|
|
70
|
+
if (data.code !== undefined)
|
|
71
|
+
payload.code = data.code;
|
|
72
|
+
if (data.startsAt !== undefined)
|
|
73
|
+
payload.starts_at = data.startsAt;
|
|
74
|
+
if (data.endsAt !== undefined)
|
|
75
|
+
payload.ends_at = data.endsAt;
|
|
76
|
+
if (data.maxRedemptions !== undefined)
|
|
77
|
+
payload.max_redemptions = data.maxRedemptions;
|
|
78
|
+
if (data.durationInMonths !== undefined)
|
|
79
|
+
payload.duration_in_months = data.durationInMonths;
|
|
80
|
+
if (data.products !== undefined)
|
|
81
|
+
payload.products = data.products;
|
|
82
|
+
if (data.userMetadata !== undefined)
|
|
83
|
+
payload.user_metadata = data.userMetadata;
|
|
84
|
+
if (data.internalReference !== undefined)
|
|
85
|
+
payload.internal_reference = data.internalReference;
|
|
86
|
+
return this.core.request({
|
|
87
|
+
method: 'PATCH',
|
|
88
|
+
path: `/v1/discounts/${id}`,
|
|
89
|
+
body: payload,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Soft delete a discount. */
|
|
93
|
+
delete(id) {
|
|
94
|
+
return this.core.request({
|
|
95
|
+
method: 'DELETE',
|
|
96
|
+
path: `/v1/discounts/${id}`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** Validate a discount code (authenticated). Params: code, organizationId, amount?, productId? */
|
|
100
|
+
validate(params) {
|
|
101
|
+
return this.core.request({
|
|
102
|
+
method: 'POST',
|
|
103
|
+
path: '/v1/discounts/validate',
|
|
104
|
+
body: {
|
|
105
|
+
code: params.code,
|
|
106
|
+
organization_id: params.organizationId,
|
|
107
|
+
amount: params.amount,
|
|
108
|
+
product_id: params.productId,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** Get redemption statistics for a discount. */
|
|
113
|
+
getStats(id) {
|
|
114
|
+
return this.core.request({
|
|
115
|
+
method: 'GET',
|
|
116
|
+
path: `/v1/discounts/${id}/stats`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { ChargefyCore, APIError } from '../core.js';
|
|
|
2
2
|
import type { Result } from '../types/fp.js';
|
|
3
3
|
import type { SubOrganizationListItem, CreateSubOrganizationRequest, CreateSubOrganizationResponse, OrgAccessToken, CreateOrgAccessTokenRequest, CreateOrgAccessTokenResponse, CheckExistingResponse } from '../models/sub-organization.js';
|
|
4
4
|
import type { CreateWebhookEndpointRequest } from '../models/webhook.js';
|
|
5
|
+
import type { Discount, DiscountListResponse, CreateDiscountForChildRequest, DiscountUpdate } from '../models/discount.js';
|
|
5
6
|
export declare class SubOrganizations {
|
|
6
7
|
private readonly core;
|
|
7
8
|
constructor(core: ChargefyCore);
|
|
@@ -71,5 +72,30 @@ export declare class SubOrganizations {
|
|
|
71
72
|
* })
|
|
72
73
|
*/
|
|
73
74
|
createWebhook(data: Omit<CreateWebhookEndpointRequest, 'organizationId'>): Promise<Result<import('../models/webhook.js').WebhookEndpoint, APIError>>;
|
|
75
|
+
/**
|
|
76
|
+
* List discounts of a child organization.
|
|
77
|
+
* Your organization must be the direct parent of the specified child org.
|
|
78
|
+
*/
|
|
79
|
+
listDiscounts(orgId: string): Promise<Result<DiscountListResponse, APIError>>;
|
|
80
|
+
/**
|
|
81
|
+
* Create a discount for a child organization.
|
|
82
|
+
* Your organization must be the direct parent of the specified child org.
|
|
83
|
+
*/
|
|
84
|
+
createDiscount(orgId: string, data: CreateDiscountForChildRequest): Promise<Result<Discount, APIError>>;
|
|
85
|
+
/**
|
|
86
|
+
* Get a discount of a child organization.
|
|
87
|
+
* Your organization must be the direct parent of the specified child org.
|
|
88
|
+
*/
|
|
89
|
+
getDiscount(orgId: string, discountId: string): Promise<Result<Discount, APIError>>;
|
|
90
|
+
/**
|
|
91
|
+
* Update a discount of a child organization.
|
|
92
|
+
* Your organization must be the direct parent of the specified child org.
|
|
93
|
+
*/
|
|
94
|
+
updateDiscount(orgId: string, discountId: string, data: DiscountUpdate): Promise<Result<Discount, APIError>>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete a discount of a child organization.
|
|
97
|
+
* Your organization must be the direct parent of the specified child org.
|
|
98
|
+
*/
|
|
99
|
+
deleteDiscount(orgId: string, discountId: string): Promise<Result<void, APIError>>;
|
|
74
100
|
}
|
|
75
101
|
//# sourceMappingURL=sub-organizations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-organizations.d.ts","sourceRoot":"","sources":["../../src/namespaces/sub-organizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,EAC7B,cAAc,EACd,2BAA2B,EAC3B,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"sub-organiz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EAAE,MAAM,EAClB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAkBtC;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;CAMnF"}
|
|
@@ -150,4 +150,96 @@ export class SubOrganizations {
|
|
|
150
150
|
},
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* List discounts of a child organization.
|
|
155
|
+
* Your organization must be the direct parent of the specified child org.
|
|
156
|
+
*/
|
|
157
|
+
listDiscounts(orgId) {
|
|
158
|
+
return this.core.request({
|
|
159
|
+
method: 'GET',
|
|
160
|
+
path: `/v1/sdk/organizations/${orgId}/discounts`,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Create a discount for a child organization.
|
|
165
|
+
* Your organization must be the direct parent of the specified child org.
|
|
166
|
+
*/
|
|
167
|
+
createDiscount(orgId, data) {
|
|
168
|
+
const payload = {
|
|
169
|
+
organization_id: orgId,
|
|
170
|
+
name: data.name,
|
|
171
|
+
type: data.type,
|
|
172
|
+
duration: data.duration,
|
|
173
|
+
code: data.code ?? null,
|
|
174
|
+
starts_at: data.startsAt ?? null,
|
|
175
|
+
ends_at: data.endsAt ?? null,
|
|
176
|
+
max_redemptions: data.maxRedemptions ?? null,
|
|
177
|
+
duration_in_months: data.durationInMonths ?? null,
|
|
178
|
+
products: data.products ?? [],
|
|
179
|
+
user_metadata: data.userMetadata ?? {},
|
|
180
|
+
internal_reference: data.internalReference ?? null,
|
|
181
|
+
};
|
|
182
|
+
if (data.type === 'fixed') {
|
|
183
|
+
payload.amount = data.amount;
|
|
184
|
+
payload.currency = data.currency;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
payload.basis_points = data.basisPoints;
|
|
188
|
+
}
|
|
189
|
+
return this.core.request({
|
|
190
|
+
method: 'POST',
|
|
191
|
+
path: `/v1/sdk/organizations/${orgId}/discounts`,
|
|
192
|
+
body: payload,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get a discount of a child organization.
|
|
197
|
+
* Your organization must be the direct parent of the specified child org.
|
|
198
|
+
*/
|
|
199
|
+
getDiscount(orgId, discountId) {
|
|
200
|
+
return this.core.request({
|
|
201
|
+
method: 'GET',
|
|
202
|
+
path: `/v1/sdk/organizations/${orgId}/discounts/${discountId}`,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Update a discount of a child organization.
|
|
207
|
+
* Your organization must be the direct parent of the specified child org.
|
|
208
|
+
*/
|
|
209
|
+
updateDiscount(orgId, discountId, data) {
|
|
210
|
+
const payload = {};
|
|
211
|
+
if (data.name !== undefined)
|
|
212
|
+
payload.name = data.name;
|
|
213
|
+
if (data.code !== undefined)
|
|
214
|
+
payload.code = data.code;
|
|
215
|
+
if (data.startsAt !== undefined)
|
|
216
|
+
payload.starts_at = data.startsAt;
|
|
217
|
+
if (data.endsAt !== undefined)
|
|
218
|
+
payload.ends_at = data.endsAt;
|
|
219
|
+
if (data.maxRedemptions !== undefined)
|
|
220
|
+
payload.max_redemptions = data.maxRedemptions;
|
|
221
|
+
if (data.durationInMonths !== undefined)
|
|
222
|
+
payload.duration_in_months = data.durationInMonths;
|
|
223
|
+
if (data.products !== undefined)
|
|
224
|
+
payload.products = data.products;
|
|
225
|
+
if (data.userMetadata !== undefined)
|
|
226
|
+
payload.user_metadata = data.userMetadata;
|
|
227
|
+
if (data.internalReference !== undefined)
|
|
228
|
+
payload.internal_reference = data.internalReference;
|
|
229
|
+
return this.core.request({
|
|
230
|
+
method: 'PATCH',
|
|
231
|
+
path: `/v1/sdk/organizations/${orgId}/discounts/${discountId}`,
|
|
232
|
+
body: payload,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Delete a discount of a child organization.
|
|
237
|
+
* Your organization must be the direct parent of the specified child org.
|
|
238
|
+
*/
|
|
239
|
+
deleteDiscount(orgId, discountId) {
|
|
240
|
+
return this.core.request({
|
|
241
|
+
method: 'DELETE',
|
|
242
|
+
path: `/v1/sdk/organizations/${orgId}/discounts/${discountId}`,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
153
245
|
}
|
package/package.json
CHANGED
package/src/chargefy.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { Webhooks } from './namespaces/webhooks.js'
|
|
|
11
11
|
import { EmbedOnboarding } from './namespaces/embed-onboarding.js'
|
|
12
12
|
import { OnboardingLinks } from './namespaces/onboarding-links.js'
|
|
13
13
|
import { Kyc } from './namespaces/kyc.js'
|
|
14
|
+
import { Discounts } from './namespaces/discounts.js'
|
|
14
15
|
|
|
15
16
|
export type { ChargefyCoreOptions }
|
|
16
17
|
|
|
@@ -54,6 +55,8 @@ export class Chargefy {
|
|
|
54
55
|
readonly onboardingLinks: OnboardingLinks
|
|
55
56
|
/** KYC document status and upload (OAT or user session). */
|
|
56
57
|
readonly kyc: Kyc
|
|
58
|
+
/** Discount management: create, list, validate, stats. */
|
|
59
|
+
readonly discounts: Discounts
|
|
57
60
|
|
|
58
61
|
constructor(options: ChargefyCoreOptions = {}) {
|
|
59
62
|
const core = new ChargefyCore(options)
|
|
@@ -69,5 +72,6 @@ export class Chargefy {
|
|
|
69
72
|
this.embedOnboarding = new EmbedOnboarding(core)
|
|
70
73
|
this.onboardingLinks = new OnboardingLinks(core)
|
|
71
74
|
this.kyc = new Kyc(core)
|
|
75
|
+
this.discounts = new Discounts(core)
|
|
72
76
|
}
|
|
73
77
|
}
|
package/src/index.ts
CHANGED
|
@@ -99,6 +99,19 @@ export type {
|
|
|
99
99
|
KycDocumentsResponse,
|
|
100
100
|
UploadDocumentResponse,
|
|
101
101
|
} from './models/kyc.js'
|
|
102
|
+
export type {
|
|
103
|
+
Discount,
|
|
104
|
+
DiscountCreate,
|
|
105
|
+
DiscountCreateFixed,
|
|
106
|
+
DiscountCreatePercentage,
|
|
107
|
+
DiscountUpdate,
|
|
108
|
+
ValidateDiscountParams,
|
|
109
|
+
ValidateDiscountResponse,
|
|
110
|
+
DiscountStats,
|
|
111
|
+
DiscountListParams,
|
|
112
|
+
DiscountListResponse,
|
|
113
|
+
CreateDiscountForChildRequest,
|
|
114
|
+
} from './models/discount.js'
|
|
102
115
|
|
|
103
116
|
// Errors
|
|
104
117
|
export {
|
package/src/models/checkout.ts
CHANGED
|
@@ -119,6 +119,8 @@ export interface ConfirmCheckoutRequest {
|
|
|
119
119
|
/** CPF or CNPJ. */
|
|
120
120
|
customerTaxId?: string
|
|
121
121
|
card: CardData
|
|
122
|
+
/** Discount code to apply at payment time. */
|
|
123
|
+
discountCode?: string
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/** Generate a PIX QR code for a checkout. */
|
|
@@ -129,4 +131,6 @@ export interface GeneratePixRequest {
|
|
|
129
131
|
/** Omit for anonymous / totem checkouts. */
|
|
130
132
|
customerName?: string
|
|
131
133
|
customerTaxId?: string
|
|
134
|
+
/** Discount code to apply at payment time. */
|
|
135
|
+
discountCode?: string
|
|
132
136
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface Discount {
|
|
2
|
+
id: string
|
|
3
|
+
organizationId: string
|
|
4
|
+
name: string
|
|
5
|
+
type: 'fixed' | 'percentage'
|
|
6
|
+
code: string | null
|
|
7
|
+
startsAt: string | null
|
|
8
|
+
endsAt: string | null
|
|
9
|
+
maxRedemptions: number | null
|
|
10
|
+
redemptionsCount: number
|
|
11
|
+
duration: 'once' | 'forever' | 'repeating'
|
|
12
|
+
durationInMonths: number | null
|
|
13
|
+
/** For fixed type: amount in cents. */
|
|
14
|
+
amount?: number | null
|
|
15
|
+
currency?: string | null
|
|
16
|
+
/** For percentage type: basis points (1000 = 10%). */
|
|
17
|
+
basisPoints?: number | null
|
|
18
|
+
userMetadata?: Record<string, unknown>
|
|
19
|
+
internalReference?: string | null
|
|
20
|
+
createdAt: string
|
|
21
|
+
modifiedAt: string | null
|
|
22
|
+
deletedAt: string | null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface DiscountCreateFixed {
|
|
26
|
+
organizationId: string
|
|
27
|
+
name: string
|
|
28
|
+
type: 'fixed'
|
|
29
|
+
amount: number
|
|
30
|
+
currency: string
|
|
31
|
+
code?: string | null
|
|
32
|
+
startsAt?: string | null
|
|
33
|
+
endsAt?: string | null
|
|
34
|
+
maxRedemptions?: number | null
|
|
35
|
+
duration: 'once' | 'forever' | 'repeating'
|
|
36
|
+
durationInMonths?: number | null
|
|
37
|
+
products?: string[]
|
|
38
|
+
userMetadata?: Record<string, unknown>
|
|
39
|
+
internalReference?: string | null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface DiscountCreatePercentage {
|
|
43
|
+
organizationId: string
|
|
44
|
+
name: string
|
|
45
|
+
type: 'percentage'
|
|
46
|
+
basisPoints: number
|
|
47
|
+
code?: string | null
|
|
48
|
+
startsAt?: string | null
|
|
49
|
+
endsAt?: string | null
|
|
50
|
+
maxRedemptions?: number | null
|
|
51
|
+
duration: 'once' | 'forever' | 'repeating'
|
|
52
|
+
durationInMonths?: number | null
|
|
53
|
+
products?: string[]
|
|
54
|
+
userMetadata?: Record<string, unknown>
|
|
55
|
+
internalReference?: string | null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type DiscountCreate = DiscountCreateFixed | DiscountCreatePercentage
|
|
59
|
+
|
|
60
|
+
/** Create discount for child org (organizationId comes from orgId param). */
|
|
61
|
+
export type CreateDiscountForChildRequest =
|
|
62
|
+
| Omit<DiscountCreateFixed, 'organizationId'>
|
|
63
|
+
| Omit<DiscountCreatePercentage, 'organizationId'>
|
|
64
|
+
|
|
65
|
+
export interface DiscountUpdate {
|
|
66
|
+
name?: string
|
|
67
|
+
code?: string | null
|
|
68
|
+
startsAt?: string | null
|
|
69
|
+
endsAt?: string | null
|
|
70
|
+
maxRedemptions?: number | null
|
|
71
|
+
durationInMonths?: number | null
|
|
72
|
+
products?: string[]
|
|
73
|
+
userMetadata?: Record<string, unknown>
|
|
74
|
+
internalReference?: string | null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ValidateDiscountParams {
|
|
78
|
+
code: string
|
|
79
|
+
organizationId: string
|
|
80
|
+
amount?: number
|
|
81
|
+
productId?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ValidateDiscountResponse {
|
|
85
|
+
valid: boolean
|
|
86
|
+
discount?: Discount
|
|
87
|
+
error?: string
|
|
88
|
+
calculatedDiscount?: {
|
|
89
|
+
originalAmount: number
|
|
90
|
+
discountAmount: number
|
|
91
|
+
finalAmount: number
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface DiscountStats {
|
|
96
|
+
totalRedemptions: number
|
|
97
|
+
totalDiscountAmount: number
|
|
98
|
+
totalOriginalAmount: number
|
|
99
|
+
totalFinalAmount: number
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface DiscountListParams {
|
|
103
|
+
organizationId?: string
|
|
104
|
+
query?: string
|
|
105
|
+
isArchived?: boolean
|
|
106
|
+
limit?: number
|
|
107
|
+
offset?: number
|
|
108
|
+
sortBy?: 'created_at' | 'name' | 'redemptions_count'
|
|
109
|
+
sortOrder?: 'asc' | 'desc'
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface DiscountListResponse {
|
|
113
|
+
items: Discount[]
|
|
114
|
+
pagination: {
|
|
115
|
+
total: number
|
|
116
|
+
limit: number
|
|
117
|
+
offset: number
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -100,6 +100,7 @@ export class Checkouts {
|
|
|
100
100
|
if (body.customerEmail !== undefined) payload.customer_email = body.customerEmail
|
|
101
101
|
if (body.customerName !== undefined) payload.customer_name = body.customerName
|
|
102
102
|
if (body.customerTaxId !== undefined) payload.customer_tax_id = body.customerTaxId
|
|
103
|
+
if (body.discountCode !== undefined) payload.discount_code = body.discountCode
|
|
103
104
|
return this.core.request<CheckoutConfirmed>({
|
|
104
105
|
method: 'POST',
|
|
105
106
|
path: `/v1/checkouts/client/${body.clientSecret}/confirm-sdk`,
|
|
@@ -120,6 +121,7 @@ export class Checkouts {
|
|
|
120
121
|
if (body.customerEmail !== undefined) payload.customer_email = body.customerEmail
|
|
121
122
|
if (body.customerName !== undefined) payload.customer_name = body.customerName
|
|
122
123
|
if (body.customerTaxId !== undefined) payload.customer_tax_id = body.customerTaxId
|
|
124
|
+
if (body.discountCode !== undefined) payload.discount_code = body.discountCode
|
|
123
125
|
return this.core.request<CheckoutConfirmed>({
|
|
124
126
|
method: 'POST',
|
|
125
127
|
path: `/v1/checkouts/client/${body.clientSecret}/confirm-sdk`,
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ChargefyCore, APIError } from '../core.js'
|
|
2
|
+
import type { Result } from '../types/fp.js'
|
|
3
|
+
import type {
|
|
4
|
+
Discount,
|
|
5
|
+
DiscountCreate,
|
|
6
|
+
DiscountUpdate,
|
|
7
|
+
ValidateDiscountParams,
|
|
8
|
+
ValidateDiscountResponse,
|
|
9
|
+
DiscountStats,
|
|
10
|
+
DiscountListParams,
|
|
11
|
+
DiscountListResponse,
|
|
12
|
+
} from '../models/discount.js'
|
|
13
|
+
|
|
14
|
+
export class Discounts {
|
|
15
|
+
constructor(private readonly core: ChargefyCore) {}
|
|
16
|
+
|
|
17
|
+
/** List discounts for your organization. OAT uses token's org; pass organizationId for user auth. */
|
|
18
|
+
list(params?: DiscountListParams): Promise<Result<DiscountListResponse, APIError>> {
|
|
19
|
+
const query: Record<string, string | number | boolean | undefined | null> = {}
|
|
20
|
+
if (params?.organizationId) query.organization_id = params.organizationId
|
|
21
|
+
if (params?.query) query.query = params.query
|
|
22
|
+
if (params?.isArchived !== undefined) query.is_archived = params.isArchived
|
|
23
|
+
if (params?.limit !== undefined) query.limit = params.limit
|
|
24
|
+
if (params?.offset !== undefined) query.offset = params.offset
|
|
25
|
+
if (params?.sortBy) query.sort_by = params.sortBy
|
|
26
|
+
if (params?.sortOrder) query.sort_order = params.sortOrder
|
|
27
|
+
return this.core.request<DiscountListResponse>({
|
|
28
|
+
method: 'GET',
|
|
29
|
+
path: '/v1/discounts',
|
|
30
|
+
query,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Get a discount by ID. */
|
|
35
|
+
get(id: string): Promise<Result<Discount, APIError>> {
|
|
36
|
+
return this.core.request<Discount>({
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: `/v1/discounts/${id}`,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Create a new discount. */
|
|
43
|
+
create(data: DiscountCreate): Promise<Result<Discount, APIError>> {
|
|
44
|
+
const payload: Record<string, unknown> = {
|
|
45
|
+
organization_id: data.organizationId,
|
|
46
|
+
name: data.name,
|
|
47
|
+
type: data.type,
|
|
48
|
+
duration: data.duration,
|
|
49
|
+
code: data.code ?? null,
|
|
50
|
+
starts_at: data.startsAt ?? null,
|
|
51
|
+
ends_at: data.endsAt ?? null,
|
|
52
|
+
max_redemptions: data.maxRedemptions ?? null,
|
|
53
|
+
duration_in_months: data.durationInMonths ?? null,
|
|
54
|
+
products: data.products ?? [],
|
|
55
|
+
user_metadata: data.userMetadata ?? {},
|
|
56
|
+
internal_reference: data.internalReference ?? null,
|
|
57
|
+
}
|
|
58
|
+
if (data.type === 'fixed') {
|
|
59
|
+
payload.amount = data.amount
|
|
60
|
+
payload.currency = data.currency
|
|
61
|
+
} else {
|
|
62
|
+
payload.basis_points = data.basisPoints
|
|
63
|
+
}
|
|
64
|
+
return this.core.request<Discount>({
|
|
65
|
+
method: 'POST',
|
|
66
|
+
path: '/v1/discounts',
|
|
67
|
+
body: payload,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Update an existing discount. */
|
|
72
|
+
update(id: string, data: DiscountUpdate): Promise<Result<Discount, APIError>> {
|
|
73
|
+
const payload: Record<string, unknown> = {}
|
|
74
|
+
if (data.name !== undefined) payload.name = data.name
|
|
75
|
+
if (data.code !== undefined) payload.code = data.code
|
|
76
|
+
if (data.startsAt !== undefined) payload.starts_at = data.startsAt
|
|
77
|
+
if (data.endsAt !== undefined) payload.ends_at = data.endsAt
|
|
78
|
+
if (data.maxRedemptions !== undefined) payload.max_redemptions = data.maxRedemptions
|
|
79
|
+
if (data.durationInMonths !== undefined) payload.duration_in_months = data.durationInMonths
|
|
80
|
+
if (data.products !== undefined) payload.products = data.products
|
|
81
|
+
if (data.userMetadata !== undefined) payload.user_metadata = data.userMetadata
|
|
82
|
+
if (data.internalReference !== undefined) payload.internal_reference = data.internalReference
|
|
83
|
+
return this.core.request<Discount>({
|
|
84
|
+
method: 'PATCH',
|
|
85
|
+
path: `/v1/discounts/${id}`,
|
|
86
|
+
body: payload,
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Soft delete a discount. */
|
|
91
|
+
delete(id: string): Promise<Result<void, APIError>> {
|
|
92
|
+
return this.core.request<void>({
|
|
93
|
+
method: 'DELETE',
|
|
94
|
+
path: `/v1/discounts/${id}`,
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Validate a discount code (authenticated). Params: code, organizationId, amount?, productId? */
|
|
99
|
+
validate(params: ValidateDiscountParams): Promise<Result<ValidateDiscountResponse, APIError>> {
|
|
100
|
+
return this.core.request<ValidateDiscountResponse>({
|
|
101
|
+
method: 'POST',
|
|
102
|
+
path: '/v1/discounts/validate',
|
|
103
|
+
body: {
|
|
104
|
+
code: params.code,
|
|
105
|
+
organization_id: params.organizationId,
|
|
106
|
+
amount: params.amount,
|
|
107
|
+
product_id: params.productId,
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Get redemption statistics for a discount. */
|
|
113
|
+
getStats(id: string): Promise<Result<DiscountStats, APIError>> {
|
|
114
|
+
return this.core.request<DiscountStats>({
|
|
115
|
+
method: 'GET',
|
|
116
|
+
path: `/v1/discounts/${id}/stats`,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -10,6 +10,12 @@ import type {
|
|
|
10
10
|
CheckExistingResponse,
|
|
11
11
|
} from '../models/sub-organization.js'
|
|
12
12
|
import type { CreateWebhookEndpointRequest } from '../models/webhook.js'
|
|
13
|
+
import type {
|
|
14
|
+
Discount,
|
|
15
|
+
DiscountListResponse,
|
|
16
|
+
CreateDiscountForChildRequest,
|
|
17
|
+
DiscountUpdate,
|
|
18
|
+
} from '../models/discount.js'
|
|
13
19
|
|
|
14
20
|
export class SubOrganizations {
|
|
15
21
|
constructor(private readonly core: ChargefyCore) {}
|
|
@@ -181,4 +187,98 @@ export class SubOrganizations {
|
|
|
181
187
|
},
|
|
182
188
|
})
|
|
183
189
|
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* List discounts of a child organization.
|
|
193
|
+
* Your organization must be the direct parent of the specified child org.
|
|
194
|
+
*/
|
|
195
|
+
listDiscounts(orgId: string): Promise<Result<DiscountListResponse, APIError>> {
|
|
196
|
+
return this.core.request<DiscountListResponse>({
|
|
197
|
+
method: 'GET',
|
|
198
|
+
path: `/v1/sdk/organizations/${orgId}/discounts`,
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Create a discount for a child organization.
|
|
204
|
+
* Your organization must be the direct parent of the specified child org.
|
|
205
|
+
*/
|
|
206
|
+
createDiscount(
|
|
207
|
+
orgId: string,
|
|
208
|
+
data: CreateDiscountForChildRequest
|
|
209
|
+
): Promise<Result<Discount, APIError>> {
|
|
210
|
+
const payload: Record<string, unknown> = {
|
|
211
|
+
organization_id: orgId,
|
|
212
|
+
name: data.name,
|
|
213
|
+
type: data.type,
|
|
214
|
+
duration: data.duration,
|
|
215
|
+
code: data.code ?? null,
|
|
216
|
+
starts_at: data.startsAt ?? null,
|
|
217
|
+
ends_at: data.endsAt ?? null,
|
|
218
|
+
max_redemptions: data.maxRedemptions ?? null,
|
|
219
|
+
duration_in_months: data.durationInMonths ?? null,
|
|
220
|
+
products: data.products ?? [],
|
|
221
|
+
user_metadata: data.userMetadata ?? {},
|
|
222
|
+
internal_reference: data.internalReference ?? null,
|
|
223
|
+
}
|
|
224
|
+
if (data.type === 'fixed') {
|
|
225
|
+
payload.amount = data.amount
|
|
226
|
+
payload.currency = data.currency
|
|
227
|
+
} else {
|
|
228
|
+
payload.basis_points = data.basisPoints
|
|
229
|
+
}
|
|
230
|
+
return this.core.request<Discount>({
|
|
231
|
+
method: 'POST',
|
|
232
|
+
path: `/v1/sdk/organizations/${orgId}/discounts`,
|
|
233
|
+
body: payload,
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Get a discount of a child organization.
|
|
239
|
+
* Your organization must be the direct parent of the specified child org.
|
|
240
|
+
*/
|
|
241
|
+
getDiscount(orgId: string, discountId: string): Promise<Result<Discount, APIError>> {
|
|
242
|
+
return this.core.request<Discount>({
|
|
243
|
+
method: 'GET',
|
|
244
|
+
path: `/v1/sdk/organizations/${orgId}/discounts/${discountId}`,
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Update a discount of a child organization.
|
|
250
|
+
* Your organization must be the direct parent of the specified child org.
|
|
251
|
+
*/
|
|
252
|
+
updateDiscount(
|
|
253
|
+
orgId: string,
|
|
254
|
+
discountId: string,
|
|
255
|
+
data: DiscountUpdate
|
|
256
|
+
): Promise<Result<Discount, APIError>> {
|
|
257
|
+
const payload: Record<string, unknown> = {}
|
|
258
|
+
if (data.name !== undefined) payload.name = data.name
|
|
259
|
+
if (data.code !== undefined) payload.code = data.code
|
|
260
|
+
if (data.startsAt !== undefined) payload.starts_at = data.startsAt
|
|
261
|
+
if (data.endsAt !== undefined) payload.ends_at = data.endsAt
|
|
262
|
+
if (data.maxRedemptions !== undefined) payload.max_redemptions = data.maxRedemptions
|
|
263
|
+
if (data.durationInMonths !== undefined) payload.duration_in_months = data.durationInMonths
|
|
264
|
+
if (data.products !== undefined) payload.products = data.products
|
|
265
|
+
if (data.userMetadata !== undefined) payload.user_metadata = data.userMetadata
|
|
266
|
+
if (data.internalReference !== undefined) payload.internal_reference = data.internalReference
|
|
267
|
+
return this.core.request<Discount>({
|
|
268
|
+
method: 'PATCH',
|
|
269
|
+
path: `/v1/sdk/organizations/${orgId}/discounts/${discountId}`,
|
|
270
|
+
body: payload,
|
|
271
|
+
})
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Delete a discount of a child organization.
|
|
276
|
+
* Your organization must be the direct parent of the specified child org.
|
|
277
|
+
*/
|
|
278
|
+
deleteDiscount(orgId: string, discountId: string): Promise<Result<void, APIError>> {
|
|
279
|
+
return this.core.request<void>({
|
|
280
|
+
method: 'DELETE',
|
|
281
|
+
path: `/v1/sdk/organizations/${orgId}/discounts/${discountId}`,
|
|
282
|
+
})
|
|
283
|
+
}
|
|
184
284
|
}
|