Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,74 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { respaidAuth } from '../..';
import { respaidCommon } from '../common';
export const createNewCampaign = createAction({
name: 'create_new_campaign',
displayName: 'Create New Campaign',
description: 'Action for creating a new campaign.',
auth: respaidAuth,
props: {
campaign_name: Property.ShortText({
displayName: 'Campaign Name',
required: true,
}),
is_agency_collection: Property.Checkbox({
displayName: 'Agency collection?',
required: false,
defaultValue: false,
}),
importData: Property.Json({
displayName: 'Import Data (Array of Invoices)',
required: true,
description: `Provide an array of invoice objects with the following example structure:
[{
"unique_identifier": "123",
"company_name": "Company XYZ",
"email": "john@example.com",
"invoice_number": "INV123",
"invoice_date": "01/01/2025",
"description": "Invoice for service"
"due_amount": 1000,
"invoicing_entity_name": "Creditor ABC",
"invoicing_entity_address": "456 Avenue, City",
"full_name": "John Doe",
"phone_number": "1234567890",
"address": "123 Street, City",
}]`,
}),
},
async run({ auth, propsValue }) {
if (!Array.isArray(propsValue.importData)) {
throw new Error('Import Data must be an array of objects.');
}
const requestBody = {
campaign_name: propsValue.campaign_name,
is_agency_collection: propsValue.is_agency_collection,
import: propsValue.importData.map(invoice => ({
unique_identifier: invoice.unique_identifier,
full_name: invoice.full_name,
company_name: invoice.company_name,
email: invoice.email,
phone_number: invoice.phone_number,
address: invoice.address,
due_amount: invoice.due_amount,
invoicing_entity_name: invoice.invoicing_entity_name,
invoicing_entity_address: invoice.invoicing_entity_address,
invoice_number: invoice.invoice_number,
invoice_date: invoice.invoice_date,
description: invoice.description,
})),
};
const res = await httpClient.sendRequest<string[]>({
method: HttpMethod.POST,
url: `${respaidCommon.baseUrl}/actions/import_campaign`,
headers: respaidCommon.getHeadersStructure(auth.secret_text),
body: ({ type: 'active_pieces', import: JSON.stringify(requestBody) }),
});
return res.body;
},
});

View File

@@ -0,0 +1,11 @@
import { createNewCampaign } from "./create_new_campaign";
import { stopCollectionClientPaidDirectly } from "./stop_collection_client_paid_directly";
import { stopCollectionForDirectInstalmentPayment } from "./stop_collection_for_direct_instalment_payment";
import { stopCollectionForDirectPartialPayment } from "./stop_collection_for_direct_partial_payment";
export const respaidActions = [
createNewCampaign,
stopCollectionClientPaidDirectly,
stopCollectionForDirectPartialPayment,
stopCollectionForDirectInstalmentPayment
]

View File

@@ -0,0 +1,37 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { respaidAuth } from '../..';
import { respaidCommon, respaidActionsCommon } from '../common';
export const stopCollectionClientPaidDirectly = createAction({
name: 'stop_collection_client_paid_directly',
displayName: 'Stop Collection for Direct Full Payment',
description: 'Stops the collection process for a case and mark it as paid directly to the creditor.',
auth: respaidAuth,
props: {
unique_identifier: Property.ShortText({
displayName: 'Unique Identifier',
required: false,
}),
email: Property.ShortText({
displayName: 'Email',
required: false,
}),
invoice_number: Property.ShortText({
displayName: 'Invoice Number',
required: false,
}),
},
async run({ auth, propsValue }) {
respaidActionsCommon.validateProps(propsValue);
const res = await httpClient.sendRequest<string[]>({
method: HttpMethod.POST,
url: `${respaidCommon.baseUrl}/actions/stop_collection_client_paid_directly`,
headers: respaidCommon.getHeadersStructure(auth.secret_text),
body: respaidActionsCommon.getPayloadBodyStructure(propsValue),
});
return res.body;
},
});

View File

@@ -0,0 +1,37 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { respaidAuth } from '../..';
import { respaidCommon, respaidActionsCommon } from '../common';
export const stopCollectionForDirectInstalmentPayment = createAction({
name: 'stop_collection_for_direct_instalment_payment',
displayName: 'Stop Collection for Direct Instalment Payment',
description: 'Stops the collection process for a case when an instalment plan is set up with the creditor.',
auth: respaidAuth,
props: {
unique_identifier: Property.ShortText({
displayName: 'Unique Identifier',
required: false,
}),
email: Property.ShortText({
displayName: 'Email',
required: false,
}),
invoice_number: Property.ShortText({
displayName: 'Invoice Number',
required: false,
}),
},
async run({ auth, propsValue }) {
respaidActionsCommon.validateProps(propsValue);
const res = await httpClient.sendRequest<string[]>({
method: HttpMethod.POST,
url: `${respaidCommon.baseUrl}/actions/stop_collection_for_direct_instalment_payment`,
headers: respaidCommon.getHeadersStructure(auth.secret_text),
body: respaidActionsCommon.getPayloadBodyStructure(propsValue),
});
return res.body;
},
});

View File

@@ -0,0 +1,42 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { respaidAuth } from '../..';
import { respaidCommon, respaidActionsCommon } from '../common';
export const stopCollectionForDirectPartialPayment = createAction({
name: 'stop_collection_for_direct_partial_payment',
displayName: 'Stop Collection for Direct Partial Payment',
description: 'Stops the collection process for a case and mark it as partially paid directly to the creditor.',
auth: respaidAuth,
props: {
unique_identifier: Property.ShortText({
displayName: 'Unique Identifier',
required: false,
}),
amount: Property.ShortText({
displayName: 'Amount',
required: false,
}),
email: Property.ShortText({
displayName: 'Email',
required: false,
}),
invoice_number: Property.ShortText({
displayName: 'Invoice Number',
required: false,
}),
},
async run({ auth, propsValue }) {
respaidActionsCommon.validateProps(propsValue);
const res = await httpClient.sendRequest<string[]>({
method: HttpMethod.POST,
url: `${respaidCommon.baseUrl}/actions/stop_collection_for_direct_partial_payment`,
headers: respaidCommon.getHeadersStructure(auth.secret_text),
body: respaidActionsCommon.getPayloadBodyStructure(propsValue),
});
return res.body;
},
});

View File

@@ -0,0 +1,81 @@
import { TriggerHookContext, TriggerStrategy, SecretTextProperty } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from "@activepieces/pieces-common";
interface ActionPayloadProps {
unique_identifier?: string;
invoice_number?: string;
email?: string;
amount?: string;
}
export const respaidCommon = {
baseUrl: 'https://backend.widr.app/api/workflow',
getHeadersStructure: (auth: string) => ({
'Content-Type': 'application/json',
Accept: 'application/json',
'X-API-KEY': auth
}),
};
export const respaidActionsCommon = {
getPayloadBodyStructure: (propsValue: ActionPayloadProps) => ({
type: 'active_pieces',
payload: JSON.stringify({
...(propsValue.unique_identifier && { unique_identifier: propsValue.unique_identifier }),
...(propsValue.invoice_number && { invoice_number: propsValue.invoice_number }),
...(propsValue.amount && { amount: propsValue.amount }),
...(propsValue.email && { email: propsValue.email }),
})
}),
validateProps: (propsValue: ActionPayloadProps) => {
const { unique_identifier, email } = propsValue;
if (!unique_identifier && !email) {
throw new Error('You must provide either a unique_identifier OR email.');
}
}
}
export const respaidTriggersCommon = {
onEnable: (eventType: string) => async(context: TriggerHookContext<SecretTextProperty<true>, Record<string, never>, TriggerStrategy.WEBHOOK>) => {
try {
console.log('Trigger enabled, subscribing to webhook');
await httpClient.sendRequest({
method: HttpMethod.POST,
url: `${respaidCommon.baseUrl}/webhook/subscribe`,
headers: respaidCommon.getHeadersStructure(context.auth.secret_text as string),
body: {
type: 'active_pieces',
event_type: eventType,
target_url: context.webhookUrl,
},
});
} catch (error) {
console.error('Error subscribing to webhook:', error);
throw new Error('Failed to subscribe to webhook');
}
},
onDisable: (eventType: string) => async(context: TriggerHookContext<SecretTextProperty<true>, Record<string, never>, TriggerStrategy.WEBHOOK>) => {
try {
console.log('Trigger disabled, unsubscribing from webhook');
await httpClient.sendRequest({
method: HttpMethod.DELETE,
url: `${respaidCommon.baseUrl}/webhook/unsubscribe`,
headers: respaidCommon.getHeadersStructure(context.auth.secret_text),
body: {
type: 'active_pieces',
event_type: eventType,
target_url: context.webhookUrl,
},
});
} catch (error) {
console.error('Error unsubscribing from webhook:', error);
throw new Error('Failed to unsubscribe to webhook');
}
},
getPayload: (context: TriggerHookContext<SecretTextProperty<true>, Record<string, never>, TriggerStrategy.WEBHOOK>) => {
return typeof context.payload.body === 'string'
? JSON.parse(context.payload.body)
: context.payload;
}
}

View File

@@ -0,0 +1,23 @@
import { newCampaignCreation } from "./new_campaign_creation";
import { newCancelledCase } from "./new_cancelled_case";
import { newDisputedCase } from "./new_disputed_case";
import { newPayout } from "./new_payout";
import { newSuccessfulCollectionPaidToCreditor } from "./new_successful_collection_paid_to_creditor";
import { newSuccessfulInstallmentPaymentViaRespaid } from "./new_successful_installment_payment_via_respaid";
import { newSuccessfulCollectionViaLegalOfficer } from "./new_successful_collection_via_legal_officer";
import { newSuccessfulPartialPaymentToCreditor } from "./new_successful_partial_payment_to_creditor";
import { newSuccessfulPartialPaymentViaRespaid } from "./new_successful_partial_payment_via_respaid";
import { newSuccessfulCollectionViaRespaid } from "./new_successful_collection_via_respaid";
export const respaidTriggers = [
newCampaignCreation,
newCancelledCase,
newDisputedCase,
newPayout,
newSuccessfulCollectionPaidToCreditor,
newSuccessfulInstallmentPaymentViaRespaid,
newSuccessfulCollectionViaLegalOfficer,
newSuccessfulPartialPaymentToCreditor,
newSuccessfulPartialPaymentViaRespaid,
newSuccessfulCollectionViaRespaid
]

View File

@@ -0,0 +1,50 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewCampaignTriggerPayload {
request_id?: string;
is_campaign_created?: boolean;
valid_files?: {
unique_identifier: string;
sequence_code: string;
}[];
invalid_files?: {
invalid_email: Record<string, string>;
}[];
file_processing_report?: string;
}
export const newCampaignCreation = createTrigger({
name: 'new_campaign_creation',
displayName: 'New Campaign Creation Result',
description: "Triggers when the campaign is created.",
auth: respaidAuth,
props: {},
sampleData: {
"request_id": "1234",
"is_campaign_created": true,
"valid_files": [{
"unique_identifier": "1",
"sequence_code": 'SQ###1'
}, {
"unique_identifier": "2",
"sequence_code": 'SQ###2'
}],
"invalid_files": [{
"invalid_email": {
"unique_identifier_3": "3",
"unique_identifier_4": "4"
}
}],
"file_processing_report": 'https://link_excel.com'
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_campaign_creation'),
onDisable: respaidTriggersCommon.onDisable('new_campaign_creation'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewCampaignTriggerPayload];
},
})

View File

@@ -0,0 +1,43 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewCancelledCaseTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
currency?: string;
reason?: string;
}
export const newCancelledCase = createTrigger({
name: 'new_cancelled_case',
displayName: 'New Cancelled Case',
description: "Triggers when a collection process for a given sequence (case) was cancelled.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"currency": "usd",
"reason": "Issue with invoice"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_cancelled_case'),
onDisable: respaidTriggersCommon.onDisable('new_cancelled_case'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewCancelledCaseTriggerPayload];
},
})

View File

@@ -0,0 +1,48 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewDisputedCaseTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
currency?: string;
context?: string;
attachment?: string;
}
export const newDisputedCase = createTrigger({
name: 'new_disputed_case',
displayName: 'New Disputed Case',
description: "Triggers when a collection process was disputed by the debtor.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"currency": "usd",
"context": "Q: In order to stop the proceedings against you and not increase the amount of the debt, we can offer you\n" +
"A: Payment in instalments of up to 5 months (activation of instalments within 1 working day).\n" +
"Q: Do you agree to sign the following mandate?\n" +
"A: I agree",
"attachment": "https://link_excel.com/"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_disputed_case'),
onDisable: respaidTriggersCommon.onDisable('new_disputed_case'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewDisputedCaseTriggerPayload];
},
})

View File

@@ -0,0 +1,56 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
type Payment = Partial<{
reference: string;
unique_identifier: string;
name: string;
company_name: string;
email: string;
phone_number: string;
invoice_number: string;
amount: number;
fees: number;
currency: string;
paid_at: string;
}>
type PayoutTriggerPayload = Partial<{
date: string;
payout_id: string;
payments: Payment[];
}>
export const newPayout = createTrigger({
name: 'new_payout',
displayName: 'New Payout',
description: "Triggers when a payout is successfully sent to your bank account.",
auth: respaidAuth,
props: {},
sampleData: {
"payout_id": "1234",
"date": "2025-03-02T00:00:00+0000",
"payments": [{
"reference": "XXX123",
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"fees": 2.5,
"currency": "usd",
"paid_at": "2025-03-02T00:00:00+0000"
}]
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_payout'),
onDisable: respaidTriggersCommon.onDisable('new_payout'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as PayoutTriggerPayload];
},
})

View File

@@ -0,0 +1,42 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewPaidTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
currency?: string;
paid_at?: string;
}
export const newSuccessfulCollectionPaidToCreditor = createTrigger({
name: 'new_successful_collection_paid_to_creditor',
displayName: 'New Successful Collection Paid to Creditor',
description: "Triggers when a debt is paid directly to the creditor.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"currency": "usd",
"paid_at": "2025-03-02T00:00:00+0000"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_successful_collection_paid_to_creditor'),
onDisable: respaidTriggersCommon.onDisable('new_successful_collection_paid_to_creditor'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewPaidTriggerPayload];
},
})

View File

@@ -0,0 +1,42 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewPaidTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
currency?: string;
paid_at?: string;
}
export const newSuccessfulCollectionViaLegalOfficer = createTrigger({
name: 'new_successful_collection_via_legal_officer',
displayName: 'New Successful Collection via Legal Officer',
description: "Triggers when a debt is paid to the Legal Officer responsible for the collection campaign.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"currency": "usd",
"paid_at": "2025-03-02T00:00:00+0000"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_successful_collection_via_legal_officer'),
onDisable: respaidTriggersCommon.onDisable('new_successful_collection_via_legal_officer'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewPaidTriggerPayload];
},
})

View File

@@ -0,0 +1,45 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewPaidTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
currency?: string;
payment_mode?: string | null;
paid_at?: string;
}
export const newSuccessfulCollectionViaRespaid = createTrigger({
name: 'new_successful_collection_via_respaid',
displayName: 'New Successful Collection via Respaid',
description: "Triggers when a debt is paid online via Respaid's payment link.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"currency": "usd",
"payment_mode": "one-shot",
"paid_at": "2025-03-02T00:00:00+0000"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_successful_collection_via_respaid'),
onDisable: respaidTriggersCommon.onDisable('new_successful_collection_via_respaid'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewPaidTriggerPayload];
},
})

View File

@@ -0,0 +1,50 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewPaidTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
paid_amount?: number;
installments_number?: number;
current_installment_step?: number;
balance?: number;
currency?: string;
paid_at?: string;
}
export const newSuccessfulInstallmentPaymentViaRespaid = createTrigger({
name: 'new_successful_installment_payment_via_respaid',
displayName: 'New Successful Installment Payment via Respaid',
description: "Triggers when one of the installment payments is made for a given case within a collection's payment plan.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"paid_amount": 250,
"installments_number": 4,
"current_installment_step": 1,
"balance": 750,
"currency": "usd",
"paid_at": "2025-03-02T00:00:00+0000"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_successful_installment_payment_via_respaid'),
onDisable: respaidTriggersCommon.onDisable('new_successful_installment_payment_via_respaid'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewPaidTriggerPayload];
},
})

View File

@@ -0,0 +1,46 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewPaidTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
paid_amount?: number;
balance?: number;
currency?: string;
paid_at?: string;
}
export const newSuccessfulPartialPaymentToCreditor = createTrigger({
name: 'new_successful_partial_payment_to_creditor',
displayName: 'New Successful Partial Payment to Creditor',
description: "Triggers when the debt is partially paid directly to the creditor.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"paid_amount": 250,
"balance": 750,
"currency": "usd",
"paid_at": "2025-03-02T00:00:00+0000"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_successful_partial_payment_to_creditor'),
onDisable: respaidTriggersCommon.onDisable('new_successful_partial_payment_to_creditor'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewPaidTriggerPayload];
},
})

View File

@@ -0,0 +1,46 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { respaidAuth } from '../../index';
import { respaidTriggersCommon } from '../common';
interface NewPaidTriggerPayload {
unique_identifier?: string;
name?: string;
company_name?: string;
email?: string;
phone_number?: string;
invoice_number?: string;
amount?: number;
paid_amount?: number;
balance?: number;
currency?: string;
paid_at?: string;
}
export const newSuccessfulPartialPaymentViaRespaid = createTrigger({
name: 'new_successful_partial_payment_via_respaid',
displayName: 'New Successful Partial Payment via Respaid',
description: "Triggers when the debt is partially paid via Respaid's payment link.",
auth: respaidAuth,
props: {},
sampleData: {
"unique_identifier": "123",
"name": "John Doe",
"company_name": "Company XYZ",
"email": "john@example.com",
"phone_number": "1234567890",
"invoice_number": "INV123",
"amount": 1000,
"paid_amount": 250,
"balance": 750,
"currency": "usd",
"paid_at": "2025-03-02T00:00:00+0000"
},
type: TriggerStrategy.WEBHOOK,
onEnable: respaidTriggersCommon.onEnable('new_successful_partial_payment_via_respaid'),
onDisable: respaidTriggersCommon.onDisable('new_successful_partial_payment_via_respaid'),
async run(context) {
const payload = respaidTriggersCommon.getPayload(context);
return [payload as NewPaidTriggerPayload];
},
})