# Accept Bayarcash payments in WHMCS

> Install the Bayarcash gateway module in WHMCS, add your keys, set up the cron job and optionally add gateway fees to invoices.
>
> Source: https://docs.bayarcash.com/whmcs/

The Bayarcash module for WHMCS lets your clients pay invoices through Bayarcash. It takes MYR invoices only. This guide covers the gateway, the cron job and the optional fees add-on.

## Before you start

You need the following:

- An approved Bayarcash merchant account with the payment channels you want switched on.
- Your **Personal Access Token (PAT)**, **Portal Key** and **API Secret Key**. See [API keys](/api-keys/) and [Portals](/portals/).
- Admin access to WHMCS and to the server files or cron settings.

## Install the module

Download the module from the [WHMCS Marketplace](https://marketplace.whmcs.com/product/7531-bayarcash). Then:

1. Unzip the file. Check that it has a **modules** folder with **addons** and **gateways** inside.
2. Upload the **modules** folder to your WHMCS installation folder, so the files merge with the existing ones.
3. In the WHMCS admin area, go to **System Settings** → **Payment Gateways**.
4. Open the **All Payment Gateways** tab, find **Bayarcash** and activate it.

## Add your keys and choose channels

On the Bayarcash settings, fill in these fields:

| Field | What to enter |
|---|---|
| **Personal Access Token (PAT)** | Your Bayarcash token. |
| **Portal Key** | The portal that should receive the payments. |
| **API Secret Key** | Your secret key. Keep it private. |
| **Sandbox Mode** | Turn on only for testing, with sandbox keys. |
| **Payment Information** | Text shown on the invoice page. |
| **Successful Payment** and **Unsuccessful Payment** | The page the client lands on after paying or failing: **Specific Invoice**, **List Invoice** or **Client Area**. |
| **Payment Channels** | The channel numbers to offer, separated by commas. |

Click **Save Changes** when done. The channel numbers are:

| Number | Channel |
|---|---|
| 1 | FPX Online Banking |
| 4 | FPX Line of Credit (Credit Card Account) |
| 5 | DuitNow Online Banking/Wallets |
| 6 | DuitNow QR |
| 7 | SPayLater |
| 8 | Boost PayFlex |
| 9 | QRIS Indonesia Online Banking |
| 10 | QRIS Indonesia eWallet |
| 11 | NETS Singapore |

Your Bayarcash account must have a channel enabled before clients can use it. See [Payment channels](/payment-channels/).

## Set up the cron job

Bayarcash needs a cron job that checks pending payments every minute. Ask your host to add this, replacing whmcsdomain with your WHMCS domain:

```
* * * * * wget -q -O /dev/null 'https://whmcsdomain/modules/gateways/bayarcash/bayarcash_cron.php?job=requery'
```

## Add gateway fees to invoices (optional)

Use the **Bayarcash Gateway Fees** add-on if you want to pass the payment fee to your client. It adds a fee line to the invoice for the channel the client picks. To set it up:

1. Go to **System Settings** → **Addon Modules**.
2. Find **Bayarcash Gateway Fees** and click **Activate**, then **Configure**.
3. Under **Access Control**, tick **Full Administrator** and save.
4. Open **Addons** → **Bayarcash Gateway Fees**.
5. For each channel, set **Flat Price (RM)** and **Percentage Fee (%)**, then click **Save All Settings**.

Check the amounts against your own Bayarcash agreement before you save, because the add-on starts with sample values.

## Tips

- **Test with Sandbox Mode first.** Use sandbox keys, pay one test invoice, then switch to live keys and turn it off.
- **Keep the cron job running.** If it stops, clients may pay but their invoices stay unpaid until you check.

## Common issues

### My customer sees a message that Bayarcash only accepts payment in MYR.

The invoice is in another currency. Bayarcash accepts MYR only, so issue the invoice in Malaysian Ringgit.

### Payments are made but invoices stay unpaid.

Check that the requery cron job runs every minute, and that your Personal Access Token, Portal Key and API Secret Key are correct. The cron job updates pending payments.

### A customer sees 'An error occurred. Please try again later.' after choosing a channel.

Check your credentials in the Bayarcash gateway settings. Turn on Sandbox Mode only when you use sandbox keys.
