PHP code example of ssh / smct-sdk-php

1. Go to this page and download the library: Download ssh/smct-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ssh / smct-sdk-php example snippets




use Smct\Config;
use Smct\SmctClient;

$config = new Config([
    'appId'          => 'SYSTEM002',
    'channelCode'    => 'F1001',
    'appChannelCode' => 'JKWB',
    'baseUrl'        => 'https://smct-test.fintechabchina.com', // 测试环境
    'deviceNum'      => 'YOUR_DEVICE_NUM',
    'sm2PublicKey'   => 'YOUR_SM2_PUBLIC_KEY_HEX',
]);

$smct = new SmctClient($config);

// 获取食堂基础信息
$result = $smct->getCanteenId();

// 刷脸支付
$result = $smct->flexiblePay(
    amtTrans: '10.50',
    idCanteen: 'CANTEEN_ID',
    transId: 'UNIQUE_TRANS_ID',
    payType: 'FPAY',
    personId: 'USER_ID'
);

// 获取饭卡余额
$result = $smct->getCardBalance('FTYPE', 'CANTEEN_ID', personId: 'USER_ID');

// 交易退款
$result = $smct->refund('ORDER_NO', 'CANTEEN_ID');

use Smct\Config;
use Smct\FaceClient;

$config = new Config([
    'faceBaseUrl' => 'https://face-api.example.com',
    'faceAppId'   => 'SYSTEM002',
    'faceAesKey'  => 'YOUR_AES_KEY',
]);

$face = new FaceClient($config);

// 查询绑定状态
$result = $face->queryBindStatus('userId', 'companyId', '张三');

// 提交人脸绑定
$result = $face->submitFaceBind('userId', 'companyId', '张三', $base64Image);

// 后台查询采集情况(AES 加密)
$result = $face->queryFaceBindInfo('2025-01-01 00:00:00', '2025-12-31 23:59:59', 'companyId');
bash
composer