Bahari KYC for Clientexec
=========================

Requirements: Clientexec 6.x, PHP 7.4 or newer (tested on 7.4 and 8.2) with curl.

Install
1. Upload the contents of this zip to the Clientexec root folder. It creates
   plugins/snapin/baharikyc/ and plugins/services/baharikycsync/.
2. In Clientexec admin open Settings > Plugins > Snapins, choose Bahari KYC and set Enabled to Yes.
3. Paste a secret API key from the Bahari KYC dashboard (API keys). Keys start with sk_live_.
4. In the Bahari KYC dashboard open Webhooks and add an endpoint with the Webhook URL shown in the
   snapin settings (<your Clientexec URL>/plugins/snapin/baharikyc/webhook.php). Copy the signing
   secret (whsec_...) into the snapin settings.
5. Open Settings > Plugins > Services, enable Bahari KYC re-check (runs every 10 minutes by default).
6. Open Clients > Identity verification. Connection should say OK.

Client area
  Clients verify from the Identity verification link in the account menu. Direct link:
  index.php?fuse=admin&view=snapin&controller=snapins&plugin=baharikyc&v=verify

Admin
  Clients > Identity verification shows the connection check, webhook URL, a client lookup with
  Re-check status and Get verification link, recent verifications, held packages and a short log.
  Each client profile has an Identity verification tab with the status and a link to the session
  in the Bahari KYC dashboard.

Settings
  Hold setup for unverified clients   New packages ordered by clients who are not verified are not set
                                      up by the Order Processor until the client is approved.
  Hold only these product groups      Comma separated product group ids. Empty means all groups.
  Run held setup after approval       Held packages are released when the client is approved and the
                                      Order Processor sets them up on its next run.
  Declined clients can try again      Otherwise they need to contact support.

Limits
  Clientexec has no hook to stop an order at checkout, so orders can always be placed and paid.
  Use Hold setup for unverified clients to keep services from being set up until the client is verified.
  The hold works with automatic setup by the Order Processor service. An admin can still activate a
  held package by hand at any time.

Data
  Only the session id, status and reason codes are stored, in the table baharikyc_status. Held
  packages are listed in baharikyc_held and the plugin log in baharikyc_log. Photos and document data
  stay in Bahari KYC. Disabling the snapin keeps the tables.

Help and documentation: https://kyc.baharione.com/docs#clientexec
Support: support@baharione.com
