# Use BCL in n8n

> Install the BCL community node in n8n, connect it with a BCL API token, and create payment links or manage forms and coupons in a workflow.
>
> Source: https://docs.bayarcash.com/n8n-bcl/

The BCL node for [n8n](https://n8n.io) lets a workflow create BCL payment links and find transactions. It can also change your BCL forms and coupons, without code. It is a community node, published on npm as [`n8n-nodes-bcl`](https://www.npmjs.com/package/n8n-nodes-bcl).

BCL takes its payments through Bayarcash. See [What is Bayarcash](/what-is-bayarcash/). To call Bayarcash API v3 directly from n8n, use the [Bayarcash node](/n8n/) instead.

## Install the node

You can install community nodes on self-hosted n8n. To install it:

1. In n8n, open **Settings** → **Community Nodes**.
2. Install the npm package `n8n-nodes-bcl`.
3. Search for **BCL** when you add a node to a workflow.

The [n8n guide to community nodes](https://docs.n8n.io/integrations/community-nodes/installation/) has the full steps and other ways to install.

## Connect your BCL account

The node signs in with a credential called **BCL API**. To create it:

1. In BCL, create an API token. Tick **API Read**, and also **API Write** to create payment links or change forms and coupons. See [Create an API token](https://docs.bcl.my/api-tokens/).
2. In n8n, add a **BCL** node and create a new credential.
3. Paste the token into **API Token**.
4. Save. n8n tests the credential with BCL.

The node always works with your live BCL account. It has no sandbox setting.

## What the node can do

Choose a **Resource**, then an **Operation**:

| Resource | Operation | What it does |
|---|---|---|
| Payment Link | **Create** | Creates a payment link. |
| Payment Link | **Get Transaction** | Gets a transaction by its **Order Number**. |
| Form | **List**, **Get** | Lists your forms, or gets one by **Form ID**. |
| Form | **Duplicate** | Copies a form with a new title and slug. |
| Form | **Update Title**, **Update Slug**, **Update Content**, **Update Status**, **Update Homepage Display** | Changes one part of a form. |
| Form | **Update Stock** | Sets the stock quantity of form items. |
| Form | **Update Redirect URLs** | Sets the **Success URL** and **Failed URL**. |
| Form | **Update Webhook Settings** | Turns the form webhook on or off, and sets its URL and events. |
| Form | **Update Affiliate Settings**, **Update Facebook Pixel**, **Update TikTok Pixel** | Changes the affiliate and tracking settings of a form. |
| Coupon | **List**, **Get** | Lists your coupons, or gets one by **Coupon ID**. |
| Coupon | **Update**, **Update Status** | Changes a coupon, or turns it on or off. |

## Create a payment link

To create a payment link from a workflow:

1. Add a **BCL** node and choose **Payment Link** → **Create**.
2. Fill in **Amount** (in MYR), **Payer Name**, **Payer Email**, **Payer Telephone Number** and **Portal Key**. These are required. **Portal Key** is your Bayarcash portal key. See [Find your API keys](/api-keys/).
3. Optionally, open **Additional Fields** and add these:

   | Field | What it does |
   |---|---|
   | **Order Number** | Your own reference for the payment. BCL makes one if you leave it empty. |
   | **Payment Channel** | **FPX Online Banking**, **FPX Line of Credit**, **DuitNow Online Banking**, **DuitNow QR**, **SPaylater**, **Boost PayFlex**, **QRIS OB**, **QRIS Wallet** or **NETS**. |
   | **Let User Choose Payment** | Lets your customer choose the payment method on the payment page. |
   | **Remarks** | A note for the order. |

4. Run the node. Send the payment link from its output to your customer, for example by email or WhatsApp.

## Receive payments in n8n

To act when a customer pays on a BCL form, let BCL call an n8n webhook:

1. Start a second workflow with the n8n **Webhook** node, and copy its URL.
2. In the BCL node, choose **Form** → **Update Webhook Settings** and enter the **Form ID**.
3. Turn on **Enabled**, paste the URL into **Webhook URL**, and choose the **Events**: **Form Submit**, **Payment Success** or **Direct Debit**.

You can also set the form webhook in BCL itself. See [Payment form webhook payload](https://docs.bcl.my/webhook-payment-form/) in the BCL help centre. It also lists the fields that BCL sends.

## Tips

- **Give each payment link your own order number.** Then **Get Transaction** can find the payment again.
- **Use a separate token for n8n.** If you delete that token later, only n8n stops. Your other apps keep their own tokens.

## Common issues

### The node fails with "Authentication failed: Invalid or expired API token. Please check your credentials." What do I check?

Check that you pasted the whole BCL API token into the BCL API credential, and that the token is not expired or deleted in BCL. See Create an API token (https://docs.bcl.my/api-tokens/) in the BCL help centre.

### Creating a payment link fails, and the message ends with "Token does not have the 'api:write' ability". Why?

The token can only read. Create a new BCL API token with API Write and put it in the credential. You cannot change the permissions of a token that exists.

### The node fails with "Validation error: The API could not process your request."

BCL refused one of the values. The rest of the message lists the fields. Check the payer email and the phone number format, for example 012-3456789.
