@activepieces/piece-chargebee 0.0.1
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/package.json +17 -0
- package/src/index.d.ts +5 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +57 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/cancel-subscription.d.ts +21 -0
- package/src/lib/actions/cancel-subscription.d.ts.map +1 -0
- package/src/lib/actions/cancel-subscription.js +168 -0
- package/src/lib/actions/cancel-subscription.js.map +1 -0
- package/src/lib/actions/create-customer.d.ts +29 -0
- package/src/lib/actions/create-customer.d.ts.map +1 -0
- package/src/lib/actions/create-customer.js +169 -0
- package/src/lib/actions/create-customer.js.map +1 -0
- package/src/lib/actions/create-subscription.d.ts +20 -0
- package/src/lib/actions/create-subscription.d.ts.map +1 -0
- package/src/lib/actions/create-subscription.js +119 -0
- package/src/lib/actions/create-subscription.js.map +1 -0
- package/src/lib/actions/get-customer.d.ts +7 -0
- package/src/lib/actions/get-customer.d.ts.map +1 -0
- package/src/lib/actions/get-customer.js +32 -0
- package/src/lib/actions/get-customer.js.map +1 -0
- package/src/lib/auth.d.ts +5 -0
- package/src/lib/auth.d.ts.map +1 -0
- package/src/lib/auth.js +46 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +15 -0
- package/src/lib/common/client.d.ts.map +1 -0
- package/src/lib/common/client.js +64 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/webhook.d.ts +4 -0
- package/src/lib/common/webhook.d.ts.map +1 -0
- package/src/lib/common/webhook.js +48 -0
- package/src/lib/common/webhook.js.map +1 -0
- package/src/lib/triggers/customer-created.d.ts +15 -0
- package/src/lib/triggers/customer-created.d.ts.map +1 -0
- package/src/lib/triggers/customer-created.js +68 -0
- package/src/lib/triggers/customer-created.js.map +1 -0
- package/src/lib/triggers/invoice-generated.d.ts +15 -0
- package/src/lib/triggers/invoice-generated.d.ts.map +1 -0
- package/src/lib/triggers/invoice-generated.js +61 -0
- package/src/lib/triggers/invoice-generated.js.map +1 -0
- package/src/lib/triggers/payment-failed.d.ts +15 -0
- package/src/lib/triggers/payment-failed.d.ts.map +1 -0
- package/src/lib/triggers/payment-failed.js +92 -0
- package/src/lib/triggers/payment-failed.js.map +1 -0
- package/src/lib/triggers/payment-succeeded.d.ts +15 -0
- package/src/lib/triggers/payment-succeeded.d.ts.map +1 -0
- package/src/lib/triggers/payment-succeeded.js +92 -0
- package/src/lib/triggers/payment-succeeded.js.map +1 -0
- package/src/lib/triggers/subscription-cancelled.d.ts +15 -0
- package/src/lib/triggers/subscription-cancelled.d.ts.map +1 -0
- package/src/lib/triggers/subscription-cancelled.js +84 -0
- package/src/lib/triggers/subscription-cancelled.js.map +1 -0
- package/src/lib/triggers/subscription-changed.d.ts +15 -0
- package/src/lib/triggers/subscription-changed.d.ts.map +1 -0
- package/src/lib/triggers/subscription-changed.js +84 -0
- package/src/lib/triggers/subscription-changed.js.map +1 -0
- package/src/lib/triggers/subscription-created.d.ts +15 -0
- package/src/lib/triggers/subscription-created.d.ts.map +1 -0
- package/src/lib/triggers/subscription-created.js +84 -0
- package/src/lib/triggers/subscription-created.js.map +1 -0
- package/src/lib/triggers/subscription-renewed.d.ts +15 -0
- package/src/lib/triggers/subscription-renewed.d.ts.map +1 -0
- package/src/lib/triggers/subscription-renewed.js +84 -0
- package/src/lib/triggers/subscription-renewed.js.map +1 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSubscription = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.createSubscription = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'create_subscription',
|
|
11
|
+
auth: auth_1.chargebeeAuth,
|
|
12
|
+
displayName: 'Create Subscription',
|
|
13
|
+
description: 'Create a subscription for an existing customer using a Chargebee item price.',
|
|
14
|
+
props: {
|
|
15
|
+
customer_id: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Customer ID',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
item_price_id: pieces_framework_1.Property.ShortText({
|
|
20
|
+
displayName: 'Item Price ID',
|
|
21
|
+
description: 'The Chargebee item price ID to subscribe the customer to.',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
quantity: pieces_framework_1.Property.Number({
|
|
25
|
+
displayName: 'Quantity',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
auto_collection: pieces_framework_1.Property.StaticDropdown({
|
|
29
|
+
displayName: 'Auto Collection',
|
|
30
|
+
description: 'Whether to automatically charge the customer. Defaults to the customer setting.',
|
|
31
|
+
required: false,
|
|
32
|
+
options: {
|
|
33
|
+
options: [
|
|
34
|
+
{ label: 'On', value: 'on' },
|
|
35
|
+
{ label: 'Off', value: 'off' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
billing_cycles: pieces_framework_1.Property.Number({
|
|
40
|
+
displayName: 'Billing Cycles',
|
|
41
|
+
description: 'Number of billing cycles before the subscription ends. Defaults to the item price setting.',
|
|
42
|
+
required: false,
|
|
43
|
+
}),
|
|
44
|
+
trial_end: pieces_framework_1.Property.Number({
|
|
45
|
+
displayName: 'Trial End (Unix Seconds)',
|
|
46
|
+
description: 'UTC timestamp in seconds when the trial period ends. Set to 0 for no trial.',
|
|
47
|
+
required: false,
|
|
48
|
+
}),
|
|
49
|
+
start_date: pieces_framework_1.Property.Number({
|
|
50
|
+
displayName: 'Start Date (Unix Seconds)',
|
|
51
|
+
description: 'UTC timestamp in seconds when the subscription starts. Defaults to now. Provide a past value to backdate.',
|
|
52
|
+
required: false,
|
|
53
|
+
}),
|
|
54
|
+
coupon_ids: pieces_framework_1.Property.ShortText({
|
|
55
|
+
displayName: 'Coupon ID',
|
|
56
|
+
description: 'A coupon ID or code to apply to this subscription.',
|
|
57
|
+
required: false,
|
|
58
|
+
}),
|
|
59
|
+
po_number: pieces_framework_1.Property.ShortText({
|
|
60
|
+
displayName: 'PO Number',
|
|
61
|
+
description: 'Purchase order number to associate with this subscription.',
|
|
62
|
+
required: false,
|
|
63
|
+
}),
|
|
64
|
+
invoice_notes: pieces_framework_1.Property.LongText({
|
|
65
|
+
displayName: 'Invoice Notes',
|
|
66
|
+
description: 'Customer-facing note added to all invoices for this subscription.',
|
|
67
|
+
required: false,
|
|
68
|
+
}),
|
|
69
|
+
payment_source_id: pieces_framework_1.Property.ShortText({
|
|
70
|
+
displayName: 'Payment Source ID',
|
|
71
|
+
description: 'ID of the payment source to attach to this subscription.',
|
|
72
|
+
required: false,
|
|
73
|
+
}),
|
|
74
|
+
invoice_immediately: pieces_framework_1.Property.Checkbox({
|
|
75
|
+
displayName: 'Invoice Immediately',
|
|
76
|
+
description: 'Invoice any charges raised at creation time immediately rather than adding them to unbilled charges.',
|
|
77
|
+
required: false,
|
|
78
|
+
}),
|
|
79
|
+
net_term_days: pieces_framework_1.Property.Number({
|
|
80
|
+
displayName: 'Net Term Days',
|
|
81
|
+
description: 'Number of days within which invoices for this subscription must be paid (Net D). Must match a value configured in Chargebee.',
|
|
82
|
+
required: false,
|
|
83
|
+
}),
|
|
84
|
+
meta_data: pieces_framework_1.Property.Object({
|
|
85
|
+
displayName: 'Metadata',
|
|
86
|
+
description: 'Key-value pairs to store extra information on the subscription.',
|
|
87
|
+
required: false,
|
|
88
|
+
}),
|
|
89
|
+
},
|
|
90
|
+
run(context) {
|
|
91
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const { customer_id, item_price_id, quantity, auto_collection, billing_cycles, trial_end, start_date, coupon_ids, po_number, invoice_notes, payment_source_id, invoice_immediately, net_term_days, meta_data, } = context.propsValue;
|
|
93
|
+
const body = (0, client_1.cleanObject)({
|
|
94
|
+
auto_collection,
|
|
95
|
+
billing_cycles,
|
|
96
|
+
trial_end,
|
|
97
|
+
start_date,
|
|
98
|
+
'coupon_ids[0]': coupon_ids,
|
|
99
|
+
po_number,
|
|
100
|
+
invoice_notes,
|
|
101
|
+
payment_source_id,
|
|
102
|
+
invoice_immediately,
|
|
103
|
+
net_term_days,
|
|
104
|
+
meta_data: meta_data ? JSON.stringify(meta_data) : undefined,
|
|
105
|
+
'subscription_items[item_price_id][0]': item_price_id,
|
|
106
|
+
'subscription_items[quantity][0]': quantity,
|
|
107
|
+
});
|
|
108
|
+
return yield (0, client_1.chargebeeRequest)({
|
|
109
|
+
site: context.auth.props.site,
|
|
110
|
+
apiKey: context.auth.props.api_key,
|
|
111
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
112
|
+
path: `/customers/${customer_id}/subscription_for_items`,
|
|
113
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
114
|
+
body,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=create-subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-subscription.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-subscription.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AAExE,kCAAwC;AACxC,6CAAiE;AAEpD,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,oBAAa;IACnB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EACT,8EAA8E;IAChF,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,S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,IAAA,yBAAgB,EAAC;gBAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI;gBAC7B,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;gBAClC,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,IAAI,EAAE,cAAc,WAAW,yBAAyB;gBACxD,WAAW,EAAE,mCAAmC;gBAChD,IAAI;aACL,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getCustomer: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
}>, {
|
|
5
|
+
customer_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=get-customer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-customer.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-customer.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW;;;;;EAqBtB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.getCustomer = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'get_customer',
|
|
11
|
+
auth: auth_1.chargebeeAuth,
|
|
12
|
+
displayName: 'Get Customer',
|
|
13
|
+
description: 'Retrieve a customer from Chargebee by ID.',
|
|
14
|
+
props: {
|
|
15
|
+
customer_id: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'Customer ID',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { customer_id } = context.propsValue;
|
|
23
|
+
return yield (0, client_1.chargebeeRequest)({
|
|
24
|
+
site: context.auth.props.site,
|
|
25
|
+
apiKey: context.auth.props.api_key,
|
|
26
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
27
|
+
path: `/customers/${encodeURIComponent(customer_id)}`,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=get-customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-customer.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-customer.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AAExE,kCAAwC;AACxC,6CAAoD;AAEvC,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,oBAAa;IACnB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,2CAA2C;IACxD,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAE3C,OAAO,MAAM,IAAA,yBAAgB,EAAC;gBAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI;gBAC7B,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;gBAClC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,cAAc,kBAAkB,CAAC,WAAW,CAAC,EAAE;aACtD,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const chargebeeAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
}>;
|
|
5
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;EAwCxB,CAAC"}
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chargebeeAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const client_1 = require("./common/client");
|
|
8
|
+
exports.chargebeeAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
9
|
+
displayName: 'Chargebee',
|
|
10
|
+
description: 'Go to Settings > Configure Chargebee > API Keys and Webhooks > API Keys tab. Click Add an API Key, select Full-Access Key, and copy the generated key.',
|
|
11
|
+
required: true,
|
|
12
|
+
props: {
|
|
13
|
+
site: pieces_framework_1.Property.ShortText({
|
|
14
|
+
displayName: 'Site',
|
|
15
|
+
description: 'Your Chargebee site subdomain. For acme.chargebee.com, enter acme.',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
api_key: pieces_framework_1.PieceAuth.SecretText({
|
|
19
|
+
displayName: 'API Key',
|
|
20
|
+
description: 'Go to Settings > Configure Chargebee > API Keys and Webhooks > API Keys tab. Click Add an API Key, select Full-Access Key, and copy the generated key.',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
25
|
+
try {
|
|
26
|
+
yield (0, client_1.chargebeeRequest)({
|
|
27
|
+
site: auth.site,
|
|
28
|
+
apiKey: auth.api_key,
|
|
29
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
30
|
+
path: '/customers?limit=1',
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
valid: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
valid: false,
|
|
39
|
+
error: error instanceof Error
|
|
40
|
+
? error.message
|
|
41
|
+
: 'Failed to validate Chargebee credentials.',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAqE;AAErE,4CAAmD;AAEtC,QAAA,aAAa,GAAG,4BAAS,CAAC,UAAU,CAAC;IAChD,WAAW,EAAE,WAAW;IACxB,WAAW,EACT,wJAAwJ;IAC1J,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EACT,oEAAoE;YACtE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC5B,WAAW,EAAE,SAAS;YACtB,WAAW,EACT,wJAAwJ;YAC1J,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAA,yBAAgB,EAAC;gBACrB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,oBAAoB;aAC3B,CAAC,CAAC;YACH,OAAO;gBACL,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EACH,KAAK,YAAY,KAAK;oBACpB,CAAC,CAAC,KAAK,CAAC,OAAO;oBACf,CAAC,CAAC,2CAA2C;aAClD,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpMethod } from '@activepieces/pieces-common';
|
|
2
|
+
type ChargebeeRequestParams = {
|
|
3
|
+
site: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
path: string;
|
|
7
|
+
body?: Record<string, unknown>;
|
|
8
|
+
contentType?: 'application/json' | 'application/x-www-form-urlencoded';
|
|
9
|
+
};
|
|
10
|
+
export declare function getChargebeeBaseUrl(site: string): string;
|
|
11
|
+
export declare function getChargebeeAuthHeader(apiKey: string): string;
|
|
12
|
+
export declare function cleanObject(value: Record<string, unknown>): Record<string, unknown>;
|
|
13
|
+
export declare function chargebeeRequest<TResponse>({ site, apiKey, method, path, body, contentType, }: ChargebeeRequestParams): Promise<TResponse>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,6BAA6B,CAAC;AAWrE,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,kBAAkB,GAAG,mCAAmC,CAAC;CACxE,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAgBD,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,EAChD,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,WAAiD,GAClD,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CAiC7C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChargebeeBaseUrl = getChargebeeBaseUrl;
|
|
4
|
+
exports.getChargebeeAuthHeader = getChargebeeAuthHeader;
|
|
5
|
+
exports.cleanObject = cleanObject;
|
|
6
|
+
exports.chargebeeRequest = chargebeeRequest;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
const CHARGEBEE_API_SUFFIX = '/api/v2';
|
|
10
|
+
function getChargebeeBaseUrl(site) {
|
|
11
|
+
return `https://${site.trim()}.chargebee.com${CHARGEBEE_API_SUFFIX}`;
|
|
12
|
+
}
|
|
13
|
+
function getChargebeeAuthHeader(apiKey) {
|
|
14
|
+
return `Basic ${Buffer.from(`${apiKey}:`).toString('base64')}`;
|
|
15
|
+
}
|
|
16
|
+
function cleanObject(value) {
|
|
17
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => {
|
|
18
|
+
if (entry === undefined || entry === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (typeof entry === 'string') {
|
|
22
|
+
return entry.trim().length > 0;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Serialize a plain object to an application/x-www-form-urlencoded string.
|
|
29
|
+
* Keys are passed through as-is (so bracket notation like
|
|
30
|
+
* `subscription_items[item_price_id][0]` is preserved), while values are
|
|
31
|
+
* percent-encoded manually with encodeURIComponent.
|
|
32
|
+
*/
|
|
33
|
+
function toFormEncoded(body) {
|
|
34
|
+
return Object.entries(body)
|
|
35
|
+
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
|
|
36
|
+
.join('&');
|
|
37
|
+
}
|
|
38
|
+
function chargebeeRequest(_a) {
|
|
39
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ site, apiKey, method, path, body, contentType = 'application/x-www-form-urlencoded', }) {
|
|
40
|
+
var _b, _c, _d, _e, _f;
|
|
41
|
+
try {
|
|
42
|
+
const isFormEncoded = contentType === 'application/x-www-form-urlencoded';
|
|
43
|
+
const serializedBody = body && isFormEncoded ? toFormEncoded(body) : body;
|
|
44
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
45
|
+
method,
|
|
46
|
+
url: `${getChargebeeBaseUrl(site)}${path}`,
|
|
47
|
+
headers: {
|
|
48
|
+
Accept: 'application/json',
|
|
49
|
+
Authorization: getChargebeeAuthHeader(apiKey),
|
|
50
|
+
'Content-Type': contentType,
|
|
51
|
+
},
|
|
52
|
+
body: serializedBody,
|
|
53
|
+
});
|
|
54
|
+
return response.body;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const chargebeeError = error;
|
|
58
|
+
const status = (_b = chargebeeError.response) === null || _b === void 0 ? void 0 : _b.status;
|
|
59
|
+
const message = (_f = (_e = (_d = (_c = chargebeeError.response) === null || _c === void 0 ? void 0 : _c.body) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : chargebeeError.message) !== null && _f !== void 0 ? _f : 'Chargebee API request failed.';
|
|
60
|
+
throw new Error(status ? `${message} (status ${status})` : message);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;AAoBA,kDAEC;AAED,wDAEC;AAED,kCAcC;AAgBD,4CAwCC;;AAlGD,+DAAqE;AAErE,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAkBvC,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,WAAW,IAAI,CAAC,IAAI,EAAE,iBAAiB,oBAAoB,EAAE,CAAC;AACvE,CAAC;AAED,SAAgB,sBAAsB,CAAC,MAAc;IACnD,OAAO,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,SAAgB,WAAW,CACzB,KAA8B;IAE9B,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE;QACzC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1C,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,IAAI,E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MAAA,cAAc,CAAC,QAAQ,0CAAE,IAAI,0CAAE,OAAO,mCACtC,cAAc,CAAC,OAAO,mCACtB,+BAA+B,CAAC;YAElC,MAAM,IAAI,KAAK,CACb,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,YAAY,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CACnD,CAAC;QACJ,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function subscribeChargebeeWebhook(site: string, apiKey: string, webhookUrl: string, eventType: string): Promise<string>;
|
|
2
|
+
export declare function unsubscribeChargebeeWebhook(site: string, apiKey: string, webhookId: string): Promise<void>;
|
|
3
|
+
export declare function fetchRecentEvents(site: string, apiKey: string, eventType: string): Promise<unknown[]>;
|
|
4
|
+
//# sourceMappingURL=webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/webhook.ts"],"names":[],"mappings":"AAQA,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,EAAE,CAAC,CAUpB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribeChargebeeWebhook = subscribeChargebeeWebhook;
|
|
4
|
+
exports.unsubscribeChargebeeWebhook = unsubscribeChargebeeWebhook;
|
|
5
|
+
exports.fetchRecentEvents = fetchRecentEvents;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
function subscribeChargebeeWebhook(site, apiKey, webhookUrl, eventType) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const response = yield (0, client_1.chargebeeRequest)({
|
|
12
|
+
site,
|
|
13
|
+
apiKey,
|
|
14
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
15
|
+
path: '/webhook_endpoints',
|
|
16
|
+
contentType: 'application/x-www-form-urlencoded',
|
|
17
|
+
body: {
|
|
18
|
+
webhook_url: webhookUrl,
|
|
19
|
+
'subscribed_events[0]': eventType,
|
|
20
|
+
is_active: true,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
return response.webhook.id;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function unsubscribeChargebeeWebhook(site, apiKey, webhookId) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
yield (0, client_1.chargebeeRequest)({
|
|
29
|
+
site,
|
|
30
|
+
apiKey,
|
|
31
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
32
|
+
path: `/webhook_endpoints/${webhookId}/delete`,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function fetchRecentEvents(site, apiKey, eventType) {
|
|
37
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var _a;
|
|
39
|
+
const response = yield (0, client_1.chargebeeRequest)({
|
|
40
|
+
site,
|
|
41
|
+
apiKey,
|
|
42
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
43
|
+
path: `/events?limit=5&event_type[is]=${eventType}`,
|
|
44
|
+
});
|
|
45
|
+
return ((_a = response.list) !== null && _a !== void 0 ? _a : []).map((item) => item.event);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=webhook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../src/lib/common/webhook.ts"],"names":[],"mappings":";;AAQA,8DAmBC;AAED,kEAWC;AAED,8CAcC;;AAxDD,+DAAyD;AAEzD,qCAA4C;AAM5C,SAAsB,yBAAyB,CAC7C,IAAY,EACZ,MAAc,EACd,UAAkB,EAClB,SAAiB;;QAEjB,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EAAkB;YACvD,IAAI;YACJ,MAAM;YACN,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,mCAAmC;YAChD,IAAI,EAAE;gBACJ,WAAW,EAAE,UAAU;gBACvB,sBAAsB,EAAE,SAAS;gBACjC,SAAS,EAAE,IAAI;aAChB;SACF,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7B,CAAC;CAAA;AAED,SAAsB,2BAA2B,CAC/C,IAAY,EACZ,MAAc,EACd,SAAiB;;QAEjB,MAAM,IAAA,yBAAgB,EAAC;YACrB,IAAI;YACJ,MAAM;YACN,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,IAAI,EAAE,sBAAsB,SAAS,SAAS;SAC/C,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAsB,iBAAiB,CACrC,IAAY,EACZ,MAAc,EACd,SAAiB;;;QAEjB,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EAEpC;YACD,IAAI;YACJ,MAAM;YACN,MAAM,EAAE,0BAAU,CAAC,GAAG;YACtB,IAAI,EAAE,kCAAkC,SAAS,EAAE;SACpD,CAAC,CAAC;QACH,OAAO,CAAC,MAAA,QAAQ,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const customerCreated: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
8
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
9
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
13
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
14
|
+
}>, {}>;
|
|
15
|
+
//# sourceMappingURL=customer-created.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-created.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/customer-created.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAYhF,eAAO,MAAM,eAAe;;;;;;;;;;;;OA8D1B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customerCreated = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const webhook_1 = require("../common/webhook");
|
|
8
|
+
const EVENT_TYPE = 'customer_created';
|
|
9
|
+
const STORE_KEY = '_chargebee_customer_created_webhook_id';
|
|
10
|
+
exports.customerCreated = (0, pieces_framework_1.createTrigger)({
|
|
11
|
+
auth: auth_1.chargebeeAuth,
|
|
12
|
+
name: 'customer_created',
|
|
13
|
+
displayName: 'Customer Created',
|
|
14
|
+
description: 'Triggers when a new customer is created in Chargebee.',
|
|
15
|
+
props: {},
|
|
16
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
17
|
+
sampleData: {
|
|
18
|
+
id: 'ev_customercwwy6nq',
|
|
19
|
+
occurred_at: 1776067864,
|
|
20
|
+
source: 'admin_console',
|
|
21
|
+
object: 'event',
|
|
22
|
+
api_version: 'v2',
|
|
23
|
+
event_type: 'customer_created',
|
|
24
|
+
webhook_status: 'not_applicable',
|
|
25
|
+
content: {
|
|
26
|
+
customer: {
|
|
27
|
+
allow_direct_debit: false,
|
|
28
|
+
auto_collection: 'on',
|
|
29
|
+
billing_address: {
|
|
30
|
+
city: 'Walnut',
|
|
31
|
+
country: 'US',
|
|
32
|
+
first_name: 'John',
|
|
33
|
+
last_name: 'Doe',
|
|
34
|
+
line1: 'PO Box 9999',
|
|
35
|
+
'...': '...',
|
|
36
|
+
},
|
|
37
|
+
card_status: 'no_card',
|
|
38
|
+
created_at: 1517505731,
|
|
39
|
+
'...': '...',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
onEnable(context) {
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const webhookId = yield (0, webhook_1.subscribeChargebeeWebhook)(context.auth.props.site, context.auth.props.api_key, context.webhookUrl, EVENT_TYPE);
|
|
46
|
+
yield context.store.put(STORE_KEY, webhookId);
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
onDisable(context) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const webhookId = yield context.store.get(STORE_KEY);
|
|
52
|
+
if (webhookId) {
|
|
53
|
+
yield (0, webhook_1.unsubscribeChargebeeWebhook)(context.auth.props.site, context.auth.props.api_key, webhookId);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
test(context) {
|
|
58
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return (0, webhook_1.fetchRecentEvents)(context.auth.props.site, context.auth.props.api_key, EVENT_TYPE);
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
run(context) {
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
return [context.payload.body];
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=customer-created.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-created.js","sourceRoot":"","sources":["../../../../src/lib/triggers/customer-created.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAEhF,kCAAwC;AACxC,+CAI2B;AAE3B,MAAM,UAAU,GAAG,kBAAkB,CAAC;AACtC,MAAM,SAAS,GAAG,wCAAwC,CAAC;AAE9C,QAAA,eAAe,GAAG,IAAA,gCAAa,EAAC;IAC3C,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,uDAAuD;IACpE,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,UAAU,EAAE;QACV,EAAE,EAAE,oBAAoB;QACxB,WAAW,EAAE,U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AAC,KAAK,CAAC,OAAO,EAC1B,UAAU,CACX,CAAC;QACJ,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const invoiceGenerated: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
8
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
9
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
13
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
14
|
+
}>, {}>;
|
|
15
|
+
//# sourceMappingURL=invoice-generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-generated.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/invoice-generated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAYhF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;OAuD3B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invoiceGenerated = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const webhook_1 = require("../common/webhook");
|
|
8
|
+
const EVENT_TYPE = 'invoice_generated';
|
|
9
|
+
const STORE_KEY = '_chargebee_invoice_generated_webhook_id';
|
|
10
|
+
exports.invoiceGenerated = (0, pieces_framework_1.createTrigger)({
|
|
11
|
+
auth: auth_1.chargebeeAuth,
|
|
12
|
+
name: 'invoice_generated',
|
|
13
|
+
displayName: 'Invoice Generated',
|
|
14
|
+
description: 'Triggers when a new invoice is generated for a subscription.',
|
|
15
|
+
props: {},
|
|
16
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
17
|
+
sampleData: {
|
|
18
|
+
id: 'ev_invoicegewwy4m2',
|
|
19
|
+
occurred_at: 1776067861,
|
|
20
|
+
source: 'admin_console',
|
|
21
|
+
object: 'event',
|
|
22
|
+
api_version: 'v2',
|
|
23
|
+
event_type: 'invoice_generated',
|
|
24
|
+
webhook_status: 'not_applicable',
|
|
25
|
+
content: {
|
|
26
|
+
invoice: {
|
|
27
|
+
adjustment_credit_notes: {},
|
|
28
|
+
amount_adjusted: 0,
|
|
29
|
+
amount_due: 0,
|
|
30
|
+
amount_paid: 1000,
|
|
31
|
+
amount_to_collect: 0,
|
|
32
|
+
'...': '...',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
onEnable(context) {
|
|
37
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const webhookId = yield (0, webhook_1.subscribeChargebeeWebhook)(context.auth.props.site, context.auth.props.api_key, context.webhookUrl, EVENT_TYPE);
|
|
39
|
+
yield context.store.put(STORE_KEY, webhookId);
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
onDisable(context) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const webhookId = yield context.store.get(STORE_KEY);
|
|
45
|
+
if (webhookId) {
|
|
46
|
+
yield (0, webhook_1.unsubscribeChargebeeWebhook)(context.auth.props.site, context.auth.props.api_key, webhookId);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
test(context) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return (0, webhook_1.fetchRecentEvents)(context.auth.props.site, context.auth.props.api_key, EVENT_TYPE);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
run(context) {
|
|
56
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return [context.payload.body];
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=invoice-generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-generated.js","sourceRoot":"","sources":["../../../../src/lib/triggers/invoice-generated.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAEhF,kCAAwC;AACxC,+CAI2B;AAE3B,MAAM,UAAU,GAAG,mBAAmB,CAAC;AACvC,MAAM,SAAS,GAAG,yCAAyC,CAAC;AAE/C,QAAA,gBAAgB,GAAG,IAAA,gCAAa,EAAC;IAC5C,IAAI,EAAE,oBAAa;IACnB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,8DAA8D;IAC3E,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,kCAAe,CAAC,OAAO;IAC7B,UAAU,EAAE;QACV,EAAE,EAAE,oBA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,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const paymentFailed: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
8
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
9
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
}>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
site: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
13
|
+
api_key: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
14
|
+
}>, {}>;
|
|
15
|
+
//# sourceMappingURL=payment-failed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-failed.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/payment-failed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAYhF,eAAO,MAAM,aAAa;;;;;;;;;;;;OAuFxB,CAAC"}
|