Skip to content

[Components] xendit #16278 #16385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions components/xendit/.gitignore

This file was deleted.

214 changes: 214 additions & 0 deletions components/xendit/actions/create-invoice/create-invoice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
import {
INVOICE_NOTIFICATION_OPTIONS,
LOCALE_OPTIONS,
PAYMENT_METHODS_OPTIONS,
} from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import xendit from "../../xendit.app.mjs";

export default {
key: "xendit-create-invoice",
name: "Create Invoice",
version: "0.0.1",
description: "Create a new invoice on Xendit platform [See the documentation](https://developers.xendit.co/api-reference/#create-invoice)",
type: "action",
props: {
xendit,
externalId: {
type: "string",
label: "External ID",
description: "ID of your choice (typically the unique identifier of an invoice in your system).",
},
amount: {
type: "string",
label: "Amount",
description: "Amount on the invoice. Min and max amounts are stated [here](https://docs.xendit.co/xeninvoice/payment-channels). The amount should be inclusive of any fees and or items that you may choose to include. If there is a difference between this amount and the sum of the price in the `items` parameters and or `fees` parameter, Xendit will refer to this amount parameter to create invoice. Do take note: if the currency or default currency is IDR and the amount includes decimals (e.g IDR 4550.50), the amount will be truncated to IDR 4550.",
},
description: {
type: "string",
label: "Description",
description: "Description of invoice - you can use this field to list what items are being paid for, or anything else of your choice that describes the function of the invoice.",
optional: true,
},
givenNames: {
type: "string",
label: "Given Names",
description: "Given name of the customer",
optional: true,
},
surname: {
type: "string",
label: "Surname",
description: "Surname of the customer",
optional: true,
},
email: {
type: "string",
label: "Email",
description: "Email address of the customer",
optional: true,
},
mobileNumber: {
type: "string",
label: "Mobile Number",
description: "Mobile phone number of the customer in E164 format",
optional: true,
},
addressCity: {
type: "string",
label: "City",
description: "The city of the customer",
optional: true,
},
addressCountry: {
type: "string",
label: "Country",
description: "The country of the customer",
optional: true,
},
addressPostalCode: {
type: "string",
label: "Postal Code",
description: "The postal code of the customer",
optional: true,
},
addressstate: {
type: "string",
label: "State",
description: "The state of the customer",
optional: true,
},
addressLine1: {
type: "string",
label: "Address Line 1",
description: "The address line 1 of the customer",
optional: true,
},
addressLine2: {
type: "string",
label: "Address Line 2",
description: "The address line 2 of the customer",
optional: true,
},
invoiceCreatedNotification: {
type: "string[]",
label: "Invoice Created Notification",
description: "Specify which channel you want to notify your end customer through when you create a payment/invoice. If you do not specify values for this object, your end user will not be notified for this notification type.",
options: INVOICE_NOTIFICATION_OPTIONS,
optional: true,
},
invoiceReminderNotification: {
type: "string[]",
label: "Invoice Reminder Notification",
description: "Specify which channel you want to notify your end customer through when you want to remind your customer to complete their payment. If you do not specify values for this object, your end user will not be notified for this notification type.",
options: INVOICE_NOTIFICATION_OPTIONS,
optional: true,
},
invoicePaidNotification: {
type: "string[]",
label: "Invoice Paid Notification",
description: "Specify which channel you want to notify your end customer through when they have successfully completed payment. If you do not specify values for this object, your end user will not be notified for this notification type.",
options: INVOICE_NOTIFICATION_OPTIONS,
optional: true,
},
invoiceDuration: {
type: "integer",
label: "Invoice Duration",
description: "Duration of time that the end customer is given to pay the invoice before expiration (in seconds, since creation). Default is 24 hours (86,400 seconds).",
optional: true,
},
successRedirectUrl: {
type: "string",
label: "Success Redirect URL",
description: "URL to redirect the customer to after successful payment.",
optional: true,
},
failureRedirectUrl: {
type: "string",
label: "Failure Redirect URL",
description: "URL to redirect the customer to after failed payment.",
optional: true,
},
paymentMethods: {
type: "string[]",
label: "Payment Methods",
description: "Specify the payment channels that you wish to be available on your Invoice.",
options: PAYMENT_METHODS_OPTIONS,
optional: true,
},
currency: {
type: "string",
label: "Currency",
description: "Currency of the amount that you created.",
optional: true,
},
locale: {
type: "string",
label: "Locale",
description: "The default language to display",
options: LOCALE_OPTIONS,
optional: true,
},
items: {
type: "string[]",
label: "Items",
description: "Array of items JSON objects describing the item(s) purchased. Max array size: 75. Mandatory for PayLater payment method. [See the documentation](https://developers.xendit.co/api-reference/#create-invoice) for further details.",
optional: true,
},
fees: {
type: "string[]",
label: "Fees",
description: "Array of items JSON objects describing the fee(s) that you charge to your end customer. This can be an admin fee, logistics fee, etc. This amount will be included in the total invoice amount and will be transferred to your balance when the transaction settles. Max array size: 10. [See the documentation](https://developers.xendit.co/api-reference/#create-invoice) for further details.",
optional: true,
},
metadata: {
type: "object",
label: "Metadata",
description: "An object containing any additional information you want to include with the invoice. This will be returned in the response and can be used for tracking or reporting purposes.",
optional: true,
},
},
async run({ $ }) {
const response = await this.xendit.createInvoice({
$,
data: {
external_id: this.externalId,
amount: this.amount,
description: this.description,
customer: {
given_names: this.givenNames,
surname: this.surname,
email: this.email,
mobile_number: this.mobileNumber,
addresses: [
{
city: this.addressCity,
country: this.addressCountry,
postal_code: this.addressPostalCode,
state: this.addressstate,
street_line1: this.addressLine1,
street_line2: this.addressLine2,
},
],
},
customer_notification_preference: {
invoice_created: parseObject(this.invoiceCreatedNotification),
invoice_reminder: parseObject(this.invoiceReminderNotification),
invoice_paid: parseObject(this.invoicePaidNotification),
},
invoice_duration: this.invoiceDuration,
success_redirect_url: this.successRedirectUrl,
failure_redirect_url: this.failureRedirectUrl,
payment_methods: parseObject(this.paymentMethods),
locale: this.locale,
items: parseObject(this.items),
fees: parseObject(this.fees),
currency: this.currency,
metadata: this.metadata,
},
});

$.export("$summary", `A new invoice with ID: ${response.id} was successfully created!`);
return response;
},
};
110 changes: 110 additions & 0 deletions components/xendit/actions/create-payout/create-payout.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { v7 as uuidV7 } from "uuid";
import { parseObject } from "../../common/utils.mjs";
import xendit from "../../xendit.app.mjs";

export default {
key: "xendit-create-payout",
name: "Create Payout",
version: "0.0.1",
description: "Create a new payout on Xendit platform [See the documentation](https://developers.xendit.co/api-reference/#create-payout)",
type: "action",
props: {
xendit,
referenceId: {
type: "string",
label: "Reference ID",
description: "A client defined payout identifier. This is the ID assigned to the payout on your system, such as a transaction or order ID. Does not need to be unique.",
},
channelCode: {
type: "string",
label: "Channel Code",
description: "Channel code of destination bank, e-wallet or OTC channel. List of supported channels can be found [here](https://docs.xendit.co/xendisburse/channel-codes)",
},
accountHolderName: {
type: "string",
label: "Account Holder Name",
description: "Name of account holder as per the bank or e-wallet's records. Needs to match the registered account name exactly.",
},
accountNumber: {
type: "string",
label: "Account Number",
description: "Account number of destination. Mobile numbers for e-wallet accounts.",
},
accountType: {
type: "string",
label: "Account Type",
description: "Account type of the destination for currencies and channels that supports proxy transfers (ie: Using mobile number as account number)",
optional: true,
},
amount: {
type: "string",
label: "Amount",
description: "Amount to be sent to the destination account. Should be a multiple of the minimum increment for the selected channel.",
},
description: {
type: "string",
label: "Description",
description: "Description to send with the payout. The recipient may see this e.g., in their bank statement (if supported) or in email receipts we send on your behalf.",
optional: true,
},
currency: {
type: "string",
label: "Currency",
description: "ISO 4217 Currency Code.",
optional: true,
},
emailTo: {
type: "string[]",
label: "Email To",
description: "A list of email addresses to receive the payout details upon successful payout. **Maximum of three email addresses**.",
optional: true,
},
emailCc: {
type: "string[]",
label: "Email Cc",
description: "A list of email addresses to receive the payout details upon successful payout. **Maximum of three email addresses**.",
optional: true,
},
emailBcc: {
type: "string[]",
label: "Email Bcc",
description: "A list of email addresses to receive a hidden copy of the payout details upon successful payout. **Maximum of three email addresses**.",
optional: true,
},
metadata: {
type: "object",
label: "Metadata",
description: "A list of objects of metadata key-value pairs. The key must be a string and the value can be a string or number.",
optional: true,
},
},
async run({ $ }) {
const response = await this.xendit.createPayout({
$,
headers: {
"idempotency-key": uuidV7(),
},
data: {
reference_id: this.referenceId,
channel_code: this.channelCode,
channel_properties: {
account_holder_name: this.accountHolderName,
account_number: this.accountNumber,
account_type: this.accountType,
},
amount: parseFloat(this.amount),
description: this.description,
currency: this.currency,
receipt_notification: {
email_to: this.emailTo,
email_cc: this.emailCc,
email_bcc: this.emailBcc,
},
metadata: parseObject(this.metadata),
},
});

$.export("$summary", `A new payout with ID: ${response.id} was successfully created!`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import xendit from "../../xendit.app.mjs";

export default {
key: "xendit-get-payment-status",
name: "Get Payment Status",
description: "Get the status of a payment request. [See the documentation](https://developers.xendit.co/api-reference/payments-api/#get-payment-request-by-id)",
version: "0.0.1",
type: "action",
props: {
xendit,
paymentRequestId: {
propDefinition: [
xendit,
"paymentRequestId",
],
},
},
async run({ $ }) {
const response = await this.xendit.getPaymentRequest({
$,
paymentRequestId: this.paymentRequestId,
});

$.export("$summary", `Payment status: ${response.status}`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/xendit/app/xendit.app.ts

This file was deleted.

Loading
Loading