Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions components/chargebee/actions/create-customer/create-customer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import chargebee from "../../chargebee.app.mjs";
import { clearObject } from "../../common/utils.mjs";

export default {
key: "chargebee-create-customer",
name: "Create Customer",
description: "Create a customer in Chargebee. [See the documentation](https://apidocs.chargebee.com/docs/api/customers?lang=node-v3#create_a_customer)",
version: "0.0.1",
type: "action",
props: {
chargebee,
id: {
type: "string",
label: "ID",
description: "ID for the new customer. If not given, this will be auto-generated.",
optional: true,
},
firstName: {
type: "string",
label: "First Name",
description: "First name of the customer.",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "Last name of the customer.",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "Email of the customer.",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "Phone number of the customer.",
optional: true,
},
company: {
type: "string",
label: "Company",
description: "Company name of the customer.",
optional: true,
},
additionalFields: {
type: "object",
label: "Additional Fields",
description: "Additional fields and values to set for the customer. [See the documentation](https://apidocs.chargebee.com/docs/api/customers?lang=curl#create_a_customer) for all available fields.",
optional: true,
},
},
async run({ $ }) {
const response = await this.chargebee.createCustomer(clearObject({
id: this.id,
first_name: this.firstName,
last_name: this.lastName,
email: this.email,
phone: this.phone,
company: this.company,
...this.additionalFields,
}));

$.export("$summary", `Successfully created customer (ID: ${response?.customer?.id})`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import chargebee from "../../chargebee.app.mjs";
import { clearObject } from "../../common/utils.mjs";

export default {
key: "chargebee-create-subscription",
name: "Create Subscription",
description: "Create a new subscription for an existing customer. [See the documentation](https://apidocs.chargebee.com/docs/api/subscriptions?lang=curl#create_subscription_for_items)",
version: "0.0.1",
type: "action",
props: {
chargebee,
customerId: {
propDefinition: [
chargebee,
"customerId",
],
},
id: {
type: "string",
label: "ID",
description: "A unique and immutable identifier for the subscription. If not provided, it is autogenerated.",
optional: true,
},
netTermDays: {
type: "integer",
label: "Net Term Days",
description: "Defines [Net D](https://www.chargebee.com/docs/net_d.html?_gl=1*1w075xz*_gcl_au*MTU4NzU2NDYzOC4xNzMzODA0OTYw) for the subscription. Net D is the number of days within which any invoice raised for the subscription must be paid.",
optional: true,
},
startDate: {
type: "string",
label: "Start Date",
description: "The date/time at which the subscription is to start, e.g. `2024-08-15T09:30:00Z`. If not provided, the subscription starts immediately.",
optional: true,
},
additionalFields: {
type: "object",
label: "Additional Fields",
description: "Additional fields and values to set for the subscription. [See the documentation](https://apidocs.chargebee.com/docs/api/subscriptions?lang=curl#create_subscription_for_items) for all available fields.",
optional: true,
},
},
async run({ $ }) {
const response = await this.chargebee.createCustomer(this.customerId, clearObject({
id: this.id,
net_term_days: this.netTermDays,
start_date: this.startDate && (Date.parse(this.startDate) / 1000),
...this.additionalFields,
}));

$.export("$summary", `Successfully created subscription (ID: ${response?.subscription?.id})`);
return response;
},
};
20 changes: 20 additions & 0 deletions components/chargebee/chargebee.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ import chargebee from "chargebee";
export default {
type: "app",
app: "chargebee",
propDefinitions: {
customerId: {
type: "string",
label: "Customer ID",
description: "The ID of the customer to create the subscription for.",
async options() {
const customers = await this.getCustomers();
return customers.list.map((customer) => ({
label: `${customer.first_name ?? ""} ${customer.last_name ?? ""} (${customer.email ?? customer.id})`,
value: customer.id,
}));
},
},
},
methods: {
instance() {
chargebee.configure({
Expand All @@ -29,5 +43,11 @@ export default {
getEvents(args = {}) {
return this.instance().event.list(args).request();
},
createCustomer(args = {}) {
return this.instance().customer.create(args).request();
},
createSubscription(customerId, args = {}) {
return this.instance().subscription.create_for_customer(customerId, args).request();
},
},
};
6 changes: 6 additions & 0 deletions components/chargebee/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function clearObject(obj) {
return Object.fromEntries(Object.entries(obj).filter(([
,
v,
]) => v !== undefined));
}
4 changes: 2 additions & 2 deletions components/chargebee/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/chargebee",
"version": "0.0.2",
"version": "0.1.0",
"description": "Pipedream Chargebee Components",
"main": "chargebee.app.mjs",
"keywords": [
Expand All @@ -11,7 +11,7 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"license": "MIT",
"dependencies": {
"@pipedream/platform": "^1.4.1",
"@pipedream/platform": "^3.0.3",
"chargebee": "^2.22.3"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-customer-card-expired-instant",
name: "Customer Card Expired (Instant)",

Check warning on line 8 in components/chargebee/sources/customer-card-expired-instant/customer-card-expired-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a customer card has expired. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#card_expired). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-customer-changed-instant",
name: "Customer Changed (Instant)",

Check warning on line 8 in components/chargebee/sources/customer-changed-instant/customer-changed-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a customer is changed. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#customer_changed). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Customer Created (Instant)",
description: "Emit new event when a new customer is created. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#customer_created). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
2 changes: 1 addition & 1 deletion components/chargebee/sources/new-event/new-event.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Event",
description: "Emit new event when the selected event is triggered. [See the Documentation](https://apidocs.chargebee.com/docs/api/events). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Invoice Created (Instant)",
description: "Emit new event when a new invoice is created. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#invoice_generated). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Invoice Updated (Instant)",
description: "Emit new event when a new invoice is updated. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#invoice_updated). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Payment Source Added (Instant)",
description: "Emit new event when a new payment source is added. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#payment_source_added). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-payment-failed-instant",
name: "Payment Failed (Instant)",

Check warning on line 8 in components/chargebee/sources/payment-failed-instant/payment-failed-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a payment is failed. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#payment_failed). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Payment Refunded (Instant)",
description: "Emit new event when a payment is refunded. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#payment_refunded). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-payment-source-updated-instant",
name: "Payment Source Updated (Instant)",

Check warning on line 8 in components/chargebee/sources/payment-source-updated-instant/payment-source-updated-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a payment source is updated. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#payment_source_updated). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-payment-succeeded-instant",
name: "Payment Succeeded (Instant)",

Check warning on line 8 in components/chargebee/sources/payment-succeeded-instant/payment-succeeded-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a payment is successful. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#payment_succeeded). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Subscription Activated (Instant)",
description: "Emit new event when a subscription is activated. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_activated). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
export default {
...common,
key: "chargebee-subscription-cancellation-scheduled-instant",
name: "Subscription Cancellation Scheduled (Instant)",

Check warning on line 7 in components/chargebee/sources/subscription-cancellation-scheduled-instant/subscription-cancellation-scheduled-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a subscription cancellation is scheduled. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_cancellation_scheduled). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-subscription-cancelled-instant",
name: "Subscription Cancelled (Instant)",

Check warning on line 8 in components/chargebee/sources/subscription-cancelled-instant/subscription-cancelled-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a subscription is cancelled. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_cancelled). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-subscription-changed-instant",
name: "Subscription Changed (Instant)",

Check warning on line 8 in components/chargebee/sources/subscription-changed-instant/subscription-changed-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a subscription is changed. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_changed). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Subscription Created (Instant)",
description: "Emit new event when a new subscription is created. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_created). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-subscription-paused-instant",
name: "Subscription Paused (Instant)",

Check warning on line 8 in components/chargebee/sources/subscription-paused-instant/subscription-paused-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a subscription is paused. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_paused). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
export default {
...common,
key: "chargebee-subscription-reactivated-instant",
name: "Subscription Reactivated (Instant)",

Check warning on line 8 in components/chargebee/sources/subscription-reactivated-instant/subscription-reactivated-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a subscription is reactivated. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_reactivated). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Subscription Renewed (Instant)",
description: "Emit new event when a subscription is renewed. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_renewed). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
name: "Subscription Resumed (Instant)",
description: "Emit new event when a subscription is resumed. [See the Documentation](https://apidocs.chargebee.com/docs/api/events#subscription_resumed). Please make sure once you deploy this source, you copy/paste the webhook URL to create it in your [Chargebee Webhook settings](https://www.chargebee.com/docs/2.0/webhook_settings.html#configure-webhooks).",
type: "source",
version: "0.0.2",
version: "0.0.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading