# 把FluentCart连接到Bayarcash

> 安装Bayarcash for FluentCart，输入你的key，并选择顾客在结账时可以选用的Bayarcash付款渠道。
>
> Source: https://docs.bayarcash.com/zh/fluentcart/

**Bayarcash for FluentCart**把Bayarcash加入你的FluentCart结账页面。顾客选择付款渠道，在Bayarcash页面付款，然后回到你的收据页面。

想在安装前先看看插件怎样运作，可以试试[在线演示](https://fluentcart.bayarcash-demo.com/)。

## 支持的渠道

你可以选择顾客在结账时看到哪些渠道。**Payment Channels**里的选项如下：

| 渠道 | 顾客用什么付款 |
|---|---|
| **FPX (Online Banking)** | FPX网上银行 |
| **FPX Line of Credit** | 通过FPX使用信用卡账户 |
| **DuitNow Online Banking/Wallets** | DuitNow网上银行或电子钱包 |
| **DuitNow QR** | 任何支持DuitNow QR的银行App或电子钱包App |
| **Credit Card** | Visa或Mastercard |
| **Boost PayFlex** | Boost PayFlex |
| **QRIS (Online Banking)** | 印尼网上银行 |
| **QRIS (E-Wallet)** | 印尼电子钱包 |
| **NETS** | NETS（新加坡） |
| **Alipay** | Alipay |
| **WeChat Pay** | WeChat Pay |
| **PromptPay** | PromptPay（泰国） |

列表里也会显示**FPX Direct Debit**。渠道必须同时在你的Bayarcash portal开启，才能使用。请参阅[付款渠道](/zh/payment-channels/)。

## 开始之前

设置插件之前，你需要准备好：

- 已获批准的Bayarcash商家账号。
- 你的**Personal Access Token (PAT)**、**API Secret Key**和**Portal Key**。请参阅[找到你的API key](/zh/api-keys/)。
- 已安装并启用的FluentCart，商店货币设为马币（MYR）。

## 安装插件

这个插件在WordPress.org免费提供，名称是[Bayarcash for FluentCart](https://wordpress.org/plugins/bayarcash-for-fluentcart/)。安装步骤：

1. 在WordPress，前往**Plugins** → **Add New**。
2. 搜索**Bayarcash for FluentCart**，然后点击**Install**。
3. 点击**Activate**。

## 设置Bayarcash

所有设置都在同一个页面：

1. 前往**FluentCart** → **Settings** → **Payments**，然后打开**Bayarcash**。
   
2. 把你的token粘贴到**Personal Access Token (PAT)**。
3. 把你的key粘贴到**API Secret Key**。
4. 把你的portal key粘贴到**Portal Key**。
5. 在**Payment Channels**，勾选顾客可以选择的渠道。<strong>FPX (Online Banking)</strong>和**DuitNow QR**默认已勾选。
6. 开启Bayarcash，然后保存。

商店处于live mode时，保存后会显示“Bayarcash gateway credentials verified successfully!”。这只确认栏位都填了，所以请做一笔小额测试付款，确定key可以用。

## 更改结账外观

同一个页面也可以设置Bayarcash按钮在结账时的外观：

| 设置 | 它更改什么 |
|---|---|
| **Bayarcash Checkout Theme** | **Light**或**Dark** |
| **Bayarcash Checkout Button Text** | 按钮文字。默认是“Pay with Bayarcash”。 |
| **Bayarcash Checkout Button Color**和**Bayarcash Checkout Button Hover Color** | 按钮颜色 |
| **Bayarcash Checkout Button Text Color** | 按钮文字的颜色 |
| **Bayarcash Checkout Button Font Size** | 文字大小，例如`16px` |

## 在sandbox测试

插件本身没有sandbox开关，它跟随你的FluentCart商店模式：

- **Test mode**：付款会转到Bayarcash sandbox，使用插件内置的测试key。你输入的key不会被使用，保存时会显示“Bayarcash test mode is enabled with your credentials.”。
- **Live mode**：付款会转到Bayarcash，使用你输入的key。

把商店切换到test mode，下一个订单，然后在sandbox页面付款。测试成功后，把商店切换回live mode，再做一笔小额真实付款，检查你自己的key。

## 付款结果怎样传到你的商店

你不需要把callback URL粘贴到商家后台（merchant dashboard）。插件每次付款时都会发送它自己的地址：Bayarcash把付款结果报告到你网站的`/?fluent-cart=fct_payment_listener_ipn&method=bayarcash`，顾客则回到你的FluentCart收据页面。插件随后把订单标为已付款或失败。已付款或已退款的订单，插件不会更改。

如果付款成功后订单还是待处理，请确认你的网站是公开的、使用HTTPS，而且没有防火墙或安全插件拦截这个地址。请参阅[Callback和checksum](/zh/callbacks-and-checksum/)。

## 小贴士

使用FluentCart时，这两个习惯对你有帮助：

- **只勾选你的portal可以接受的渠道**。顾客如果选了没有为你的portal开启的渠道，就无法付款。
- **一定要用你的正式key测试一次**。Test mode使用插件自己的key，所以不能证明你的key是正确的。

## 常见问题

### 保存设置时显示“Portal Key is required to activate the gateway.”，为什么？

FluentCart要三个key都填好，才会开启Bayarcash：Personal Access Token (PAT)、API Secret Key和Portal Key。另外两个key缺少时，也会显示同样的信息。请参阅找到你的API key (/zh/api-keys/)。

### 结账页面显示“Bayarcash payment gateway is not properly configured”，为什么？

你的商店处于live mode，但三个key中少了一个。打开FluentCart → Settings → Payments，打开Bayarcash，填好每个key，然后保存。

### 保存时显示“Bayarcash gateway credentials verified successfully!”，但付款还是失败，为什么？

这个信息只表示三个栏位都填了，它不会向Bayarcash核对这些key。从商家后台（merchant dashboard）重新复制每个key，并确认你的portal可以接受你勾选的渠道。请参阅为什么我的付款失败？ (/zh/payment-failed/)。

### 结账页面显示“Failed to create payment intent”，为什么？

Bayarcash拒绝了这个付款request，通常是因为key错误，或你勾选的渠道没有为你的portal开启。检查你的key和你勾选的Payment Channels。
