﻿# 1 文档说明
本文档适用于厂商智能耳机/无摄像头眼镜接入支付宝AI支付，包括输出产物、API接口说明和交互流程。

**注：**本文档采用的是**纯手机端SDK方案**，无需设备端改动，适用于无摄像头的RTOS**耳机或眼镜**；

## 1.1 产品方案
随着智能家居、智能终端、智能穿戴设备的普及，语音助手已成为用户日常交互的重要入口。其场景化服务能力持续向生活服务纵深拓展。

### 1.1.1 绑定流程交互
耳机需要绑定支付宝账号，录入声纹才能使用支付功能。绑定后默认开通了交话费，瑞幸咖啡的能力。

+ 厂商侧要记录已开未开通支付的状态
+ 厂商测需要有常驻的入口，引导用户去开通耳机端的支付宝
+ 语音助手要增加意图关键词：开通支付宝，绑定支付宝，解绑支付宝，关闭支付宝

![](https://intranetproxy.alipay.com/skylark/lark/0/2026/png/11743/1780020369630-d5f8823d-cebe-4dd9-8ba1-d190d4a77063.png)



#### 停车缴费需要单独开通：
已开通耳机支付宝后，用户在耳机上操作：停车缴费，需要引导用户去录入车牌

![](https://intranetproxy.alipay.com/skylark/lark/0/2026/png/11743/1780020639176-b66c0d07-4940-4811-bbec-8086a93c3669.png)

也可以在支付宝端内单独打开

![](https://intranetproxy.alipay.com/skylark/lark/0/2026/png/11743/1780020543773-d12e5e26-d058-4c45-a862-a1e53d4ab67c.png)



### 1.1.2 交话费用户交互
交话费和停车缴费都是属于支付宝的一方应用（支付宝内自闭环）

![](https://intranetproxy.alipay.com/skylark/lark/0/2026/png/11743/1780021736278-4dfe2f9d-2dae-4010-9059-165be69f8a76.png)

### 1.1.3 厂商关键词配置
| **场景** | **厂商唤醒关键词** | **示例** |
| --- | --- | --- |
| 缴话费 | <font style="color:rgb(15, 17, 21);">交话费、充话费、缴话费、手机充值、电话充值</font><br/><font style="color:#000000;">金额结合型（用户意图明确）</font><br/>+ <font style="color:#000000;">【动词】+【话费/元】：充50话费、交100元、充200块话费</font> | 帮我充值、帮我交话费、帮我手机充值50元、<br/>帮我交50元话费、我要充50元话费、 |
| 停车缴费 | XX 停车缴费、XX停车费、<br/>给【XX车牌号】交下停车费、停车费怎么交？ | 乐奇，停车缴费、帮我停车缴费、启动停车缴费<br/>小爱同学，停车缴费、给我交停车费、<br/>交一下停车费、付停车费、给这辆车交下停车费<br/>浙A28372交停车费 |
| 点咖啡 | 点一杯、来一杯、我要点、点杯、来杯 **+** 咖啡名（奥瑞白、杨枝甘露、鲜萃、美式、拿铁、咖啡）/瑞幸<br/>新增：推荐一杯好喝的、推荐一杯、推荐新品 | 帮我点杯咖啡、帮我点一杯瑞幸咖啡、点一杯瑞幸咖啡、来一杯瑞幸咖啡、来一杯咖啡、我要点咖啡、点杯咖啡、请帮我点⼀杯柠C美式、来一杯 XXXX 咖啡、点一杯XXXX咖啡、<font style="color:rgb(23, 26, 29);">来杯精萃澳瑞白、点一杯生椰杨枝甘露、</font><font style="color:rgb(23, 26, 29);">点杯鲜萃轻轻茉莉</font> |




## 1.2 支付宝输出产物
| **平台** | **产物** | **功能与说明** |
| --- | --- | --- |
| Android | 支付宝安卓SDK | 支付宝智能体业务和支付、核身逻辑处理 |
| IOS | 支付宝IOS SDK | 同安卓 |
| Harmony | 支付宝鸿蒙SDK | 同安卓 |


## 1.3 系统框图
![画板](https://intranetproxy.alipay.com/skylark/lark/0/2026/jpeg/198428/1782118100649-25112811-85be-4b8e-b886-6c7fc67eb429.jpeg)

# 2 接口说明
主要接口类：**<u>AlipayGlassV2Sdk</u>**

## 2.1 initSDK初始化
```java
AlipayGlassV2Sdk.initSDK(context, extParams, new GlassSDKCallback() {
    //开启录音，发起绑定后回调，开启后需要在receiveDenoiseAudio传入降噪音频
    @Override
    public void onStartRecording(String token) {
        //startRecordAudio(true);
    }

    @Override
    public void onStopRecording() {
        //startRecordAudio(false);
    }

    //播放支付过程提示文案
    @Override
    public String onStartPlayback(String ttsData) {
        return null;
    }

    //佩戴状态检测
    @Override
    public boolean onWearDetection() {
        return true;
    }

    @Override
    public void onErrorEvent(String code, String message) {
        //错误回调
        //○ Q1010/1011:sdk调用initCloudEnv失败，或者wss建联失败；收到此错误码仅需播音提示用户。
        //○ Q9990:glassSDK已释放退出
    }

     @Override
    public void onEvent(String eventId, String eventData, Map<String, Object> extInfo) {
        //SDK内的事件回调,updateView、推进状态等
        //Q9991状态机事件回调,SDK_ENTER/SDK_EXIT表示服务进入和退出
        //webSyncDownData：长连接推送消息，如咖啡制作状态等
    }

    @Override
    public void onViIntentResult(String bizType, String dataJson, Map<String, Object> extInfo) {
        //核身和意图回调：厂商按需处理
    }
});
```

<font style="color:rgb(0, 0, 0);">初始化SDK，在手机App和耳机建立连接时调用，支持重复调用；</font>

<font style="color:rgb(0, 0, 0);">入参：（入参key详见GlasspayConfig.java中定义）</font>

| **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">参数key</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">类型</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">含义</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">是否必填</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">备注</font>** |
| :--- | :--- | :--- | :--- | --- |
| <font style="color:rgb(0, 0, 0);">isvName</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">厂商名称</font> | <font style="color:rgb(0, 0, 0);">是</font> | |
| <font style="color:rgb(0, 0, 0);">deviceModel</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">设备机型</font> | <font style="color:rgb(0, 0, 0);">是</font> | |
| <font style="color:rgb(0, 0, 0);">deviceSN</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">设备SN</font> | <font style="color:rgb(0, 0, 0);">是</font> | |
| <font style="color:rgb(0, 0, 0);">productType</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">产品类型</font> | <font style="color:rgb(0, 0, 0);">否</font> | 耳机或无摄像头眼镜时，传"earphones" |


## <font style="color:rgb(0, 0, 0);">2.2 getBindStatus</font>
<font style="color:rgb(0, 0, 0);">获取设备的绑定状态和服务开通状态；</font>

+ <font style="color:rgb(0, 0, 0);">调用时机：在手机端展示服务状态或者每次发起支付前调用；若未开通该服务，提示用户去厂商App中发起开通；</font>
+ <font style="color:rgb(0, 0, 0);">入参说明：</font>
    - <font style="color:rgb(0, 0, 0);">needCloudStatus=true, 查询云端状态，一般填true;</font>
    - <font style="color:rgb(0, 0, 0);">needCloudStatus=false, 查询本地缓存状态；</font>
+ 出参说明：

| **字段** | **类型** | **说明** | **示例** |
| --- | --- | --- | --- |
| isBinded | boolean | 账号绑定状态；（基本废弃，厂商根据featureStatusList判断服务是否开通） | true/false |
| extInfo | Map<String,Object> | 扩展信息 |  |
| \|-featureStatusList | String | 服务开通状态,若已开通则同时返回对应的manageUrl。各服务编码说明：<br/>("PAYMENT", "支付")(包含充话费、点咖啡、电影票等)<br/>("CAR_PARKING", "停车缴费"),<br/>("CAR_PARKING_MESSAGE", "停车缴费消息"),<br/>("CITY_SIGHTSEEING", "城市导览"),<br/> | featureStatusList":["{\"featureId\":\"CAR_PARKING\",\"status\":\"STATUS_BIND\"}","{\"featureId\":\"PAYMENT\",\"status\":\"STATUS_BIND\"}","{\"featureId\":\"QUICK_MODE\",\"status\":\"STATUS_UNBIND\"}","<br/>{\"featureId\":\"PAYMENT\",\"status\":\"STATUS_BIND\", \"manageUrl\":\"`http:xxx`\"}","{\"featureId\":\"PAY_DEMO\",\"status\":\"STATUS_BIND\"}"]}<br/>注：若服务从未开通过，则列表不展示 |
|   \|-verifyMethodStatus | 核身方式录入状态 | VERIFY_VOICE | OPEN，表示已录入 |


## <font style="color:rgb(0, 0, 0);">2.3 startBinding</font>
```java
AlipayGlassV2Sdk.startBinding(map, new BindingCallBack() {
    @Override
    public void onGetBindingSchemeSuccess(String bindingScheme, String token) {
        //收到支付宝绑定页面，跳转scheme
    }

    @Override
    public void onBindingSuccess() {
        //绑定完成
    }

    @Override
    public void onBindingFailed(String errorCode) {
        //绑定失败
    }
});
```

<font style="color:rgb(0, 0, 0);">发起服务开通，当用户点击手机上的【去支付宝开通】按钮时调用；</font>

<font style="color:rgb(0, 0, 0);">入参：(详见GlasspayConfig.java中定义）</font>

| **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">参数key</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">类型</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">含义</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">是否必填</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">备注</font>** |
| :--- | :--- | :--- | :--- | :--- |
| <font style="color:rgb(0, 0, 0);">returnUrl</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">绑定完成后的回跳地址</font> | <font style="color:rgb(0, 0, 0);">否</font> | <font style="color:rgb(0, 0, 0);">优先级高于callback中的getReturnUrl</font> |
| <font style="color:rgb(0, 0, 0);">sourceFrom</font> | <font style="color:rgb(0, 0, 0);">String</font> | 发起开通的服务入口 | <font style="color:rgb(0, 0, 0);">是</font> | ("PAYMENT", "支付")(含充话费、点咖啡等支付业务)，<br/><font style="color:rgb(0, 0, 0);">("CAR_PARKING", "停车缴费"),</font><br/><font style="color:rgb(0, 0, 0);">("CITY_SIGHTSEEING", "城市导览"),</font> |


## <font style="color:rgb(0, 0, 0);">2.4 receiveDenoiseAudio</font>
<font style="color:rgb(0, 0, 0);">接收降噪音频传入，格式要求：pcm，单声道，16000采样率，16位深(AV_SAMPLE_FMT_S16)；</font>

+ <font style="color:rgb(0, 0, 0);">绑定阶段：当进入支付宝小程序读文案界面时，会回调onStartRecording，此时打开麦克风，上传音频；</font>
+ <font style="color:rgb(0, 0, 0);">支付阶段：识别智能体或支付意图时，调用startAlipayService接口，同时将用户这句唤醒语也调用receiveDenoiseAudio传入；</font>

#### <font style="color:rgb(0, 0, 0);">唤起语上传</font>
<font style="color:rgb(0, 0, 0);">唤起语料需厂商先做缓存，当识别到支付意愿调用scanpay/startAlipayService接口时，同时把唤起语音进行上传；同时在扩展字段中填写</font>

<font style="color:rgb(0, 0, 0);">extParams.put("flowNode", "AROUSE");</font>

:::warning
<font style="color:rgb(0, 0, 0);">注意：唤起语音频上传要在startAlipayService/scanpay之后才有效</font>

:::

## <font style="color:rgb(0, 0, 0);">2.5 unbind</font>
+ 解绑支付宝账号，仅清除设备本地缓存uid tid信息(不会清除支付宝小程序里的设备)；
+ 厂商手机App端解绑按钮建议跳转到支付宝小程序设备页面，进行解绑：
    - <font style="color:rgb(0, 0, 0);">可调用getBindStatus或getCustomInfoV2，得到manageUrl后，跳转到支付宝小程序管理页进行解绑；</font>

## <font style="color:rgb(0, 0, 0);">2.6 command</font>
<font style="color:rgb(0, 0, 0);">发送指令，比如用户点击耳机或眼镜的返回按键、摘下耳机/眼镜等时机调用；</font>

<font style="color:rgb(0, 0, 0);">入参：(详见GlasspayConfig.java中定义）</font>

| **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">参数key</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">类型</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">含义</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">是否必填</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">备注</font>** |
| :--- | :--- | :--- | :--- | :--- |
| <font style="color:rgb(0, 0, 0);">commandCode</font> | <font style="color:rgb(0, 0, 0);">int</font> | <font style="color:rgb(0, 0, 0);">指令编码</font> | <font style="color:rgb(0, 0, 0);">是</font> | <font style="color:rgb(0, 0, 0);">0:表示退出</font><br/><font style="color:rgb(0, 0, 0);">1：表示按键命令</font> |
| <font style="color:rgb(0, 0, 0);">keyCode</font> | <font style="color:rgb(0, 0, 0);">int</font> | <font style="color:rgb(0, 0, 0);">具体按键值</font> | <font style="color:rgb(0, 0, 0);">否</font> | |
| <font style="color:rgb(0, 0, 0);">source</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">命令来源</font> | <font style="color:rgb(0, 0, 0);">否</font> | 摘下、双击退出键等 |


<font style="color:rgb(0, 0, 0);">当摘掉耳机或眼镜时，退出支付流程</font>

```java
params.put(GlasspayConfig.KEY_COMMAND_CODE, GlasspayConfig.CommandCode.EXIT);
params.put("source", "wearOff");
AlipayGlassV2Sdk.command(params);
```



## <font style="color:rgb(0, 0, 0);">2.7  getCustomInfoV2</font>
```java
void getCustomInfoV2(final Map<String, Object> params, CustomInfoCallback callback)
```

<font style="color:rgb(0, 0, 0);">获取客制化的自定义信息；</font>

<font style="color:rgb(0, 0, 0);">入参：1)params:表示要获取信息的key, value按需填写;  2)customInfoCallback:返回指定keys的查询信息；</font>

<font style="color:rgb(0, 0, 0);">出参：CustomInfoCallback的onCustomInfo中返回要查询的信息；</font>

<font style="color:rgb(0, 0, 0);">keys取值如下：</font>

| **<font style="background-color:rgb(29, 192, 201);">参数key</font>** | **<font style="background-color:rgb(29, 192, 201);">参数Val</font>** | **<font style="background-color:rgb(29, 192, 201);">含义</font>** | **<font style="background-color:rgb(29, 192, 201);">备注</font>** |
| :--- | :--- | :--- | :--- |
| <font style="color:rgb(0, 0, 0);">AlipayAppDownloadUrl</font> | <font style="color:rgb(0, 0, 0);">""</font> | <font style="color:rgb(0, 0, 0);">支付宝App下载地址</font> | <font style="color:rgb(0, 0, 0);">绑定时，若用户手机未安装支付宝，则提示其下载安装</font> |
| <font style="color:rgb(0, 0, 0);">AlipayManageGlassPage</font> | <font style="color:rgb(0, 0, 0);">填写对应来源,如</font><br/><font style="color:rgb(0, 0, 0);">sourceFrom=PAYMENT/CAR_PARKING....</font> | <font style="color:rgb(0, 0, 0);">支付宝App对应的服务管理的小程序页面</font> | <font style="color:rgb(0, 0, 0);">若未安装支付宝则跳转到下载链接页面；</font><br/><font style="color:rgb(0, 0, 0);">sourceFrom的服务与getBIndStatus返回的featureStatusList中的服务相同；</font> |
| <font style="color:rgb(0, 0, 0);">currentTradeUrl</font> | <font style="color:rgb(0, 0, 0);">""</font> | <font style="color:rgb(0, 0, 0);">当前交易订单的url地址</font> | <font style="color:rgb(0, 0, 0);">可跳转到支付宝订单详情页</font> |
| <font style="color:rgb(0, 0, 0);">currentAlipayUid</font> | <font style="color:rgb(0, 0, 0);">""</font> | <font style="color:rgb(0, 0, 0);">内部用，获取uid</font> | <font style="color:rgb(0, 0, 0);"></font> |


```plain
String customKeys = new HashMap();
customKeys.put("AlipayAppDownloadUrl", "");
customKeys.put("AlipayManageGlassPage", "sourceFrom=CAR_PARKING");
AlipayGlassV2Sdk.getCustomInfoV2(customKeys, new CustomInfoCallback() {
    @Override
    public void onCustomInfo(String data, Map<String, Object> extInfo) {
        //data暂未使用； extInfo中为各个key对应的信息
    }
});
```



## <font style="color:rgb(0, 0, 0);">2.8 setWearingState</font>
接口定义：public void setWearingState(boolean wearing)

入参：wearing=true表示设备戴上，false表示设备摘下；

调用时机：当设备佩戴状态发生变化时调用；



## <font style="color:rgb(0, 0, 0);">2.9 startAlipayService</font>
```java
String startAlipayService(final String appId, final String serviceCode, final Map<String,Object> params, final GAlipayCallback callback);

void stopAlipayService(final String appId, final String serviceCode, final Map<String,Object> params,
                                  final String sessionId, final GAlipayCallback callback)

```

<font style="color:rgb(0, 0, 0);">启动/停止支付宝服务，serviceCode为具体的服务编码；厂商侧调用 startAlipayService 同时需要开启回传音频,通过 receiveDenoise 回传，在收到支付结束回调 onErrorEvent(ErrorCode.Q9990) 时关闭音频回传;</font>

<font style="color:rgb(0, 0, 0);">入参：(详见GlasspayConfig.java中定义）</font>

| **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">参数key</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">类型</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">含义</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">是否必填</font>** | **<font style="color:rgb(0, 0, 0);background-color:rgb(29, 192, 201);">备注</font>** |
| --- | :--- | :--- | :--- | --- |
| <font style="color:rgb(0, 0, 0);">PAY_INIT_ASR </font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">唤起语文本传入</font> | 是 | <font style="color:rgb(0, 0, 0);"></font> |
| <font style="color:rgb(0, 0, 0);">orderStr</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">外部订单号，需码路由</font> | <font style="color:rgb(0, 0, 0);">否</font> | <font style="color:rgb(0, 0, 0);">预下单后调用支付</font> |
| <font style="color:rgb(0, 0, 0);">scene</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">场景码</font> | <font style="color:rgb(0, 0, 0);">否(智能体场景需填写)</font> | <font style="color:rgb(0, 0, 0);">Coffee,         //点咖啡</font><br/><font style="color:rgb(0, 0, 0);">TopUp,          //充话费</font><br/><font style="color:rgb(0, 0, 0);">MovieTicket,    //电影票</font> |
| <font style="color:rgb(0, 0, 0);">locationLat</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">地理位置-纬度</font> | <font style="color:rgb(0, 0, 0);">否（咖啡必填）</font> | 31.564343 |
| <font style="color:rgb(0, 0, 0);">locationLnt</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">地理位置-经度</font> | <font style="color:rgb(0, 0, 0);">否（咖啡必填）</font> | 120.533231 |
| <font style="color:rgb(0, 0, 0);">coordType</font> | <font style="color:rgb(0, 0, 0);">String</font> | <font style="color:rgb(0, 0, 0);">经纬度对应坐标系</font> | <font style="color:rgb(0, 0, 0);">否（咖啡必填）</font> | 高德：GCJ-02<br/>百度：BD-09 |
| <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">codeResultString</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">String</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">外部码值</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">否</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">外部设备端扫码得到支付宝码值</font> |
| <font style="color:#000000;background-color:#FFFFFF;">codeResultNeedDecrypt</font><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;"></font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">String</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">码值是否需要解密</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">否</font> | <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">外置独立扫码启用加密时传true</font> |


#### 调用示例
```c
Map<String, Object> params = new HashMap<>();
params.put("PAY_INIT_ASR", "帮我交50元话费");
params.put("scene", "TopUp");
 AlipayGlassV2Sdk.startAlipayService("appId", "TopUp", params, new GAlipayCallback() {
    @Override
    public void onResponse(GAlipayResponse response) {
        Log.i(TAG, "onResponseresponse=" + response);
    }

    @Override
    public void onEvent(String eventId, String data, Map<String, Object> extra) {
        Log.i(TAG, "onEvent, eventId=" + eventId + ",data=" + data + ",extra=" + extra);
    }
});
```

```c
Map<String, Object> params = new HashMap<>();
params.put("PAY_INIT_ASR", "帮我点一杯咖啡");
params.put(GlasspayConfig.KEY_SCENE, "Coffee");
params.put(GlasspayConfig.KEY_LOCATION_LONGITUDE, "120.104739");
params.put(GlasspayConfig.KEY_LOCATION_LATITUDE, "30.261124000000017");
AlipayGlassV2Sdk.startAlipayService("appId", "Coffee", params, new GAlipayCallback());
```

## <font style="color:rgb(0, 0, 0);">2.10 日志重定向</font>
**<u>接口：setLogger</u>**

**<u>功能：用于将支付SDK的日志重定向到厂商日志中，便于后续客户端问题排查；Log等级跟随厂商设置，一般release包设置为Info，debug包设置为Verbose;</u>**

```json
public class AlipayLogger extends Logger {

    @Override
    public int verbose(String tag, String msg) {
        //重定向输出到厂商log文件
        return 0;
    }
  //。。。其他日志接口实现
}

com.alipay.glass.log.Log.setLogger(new AlipayLogger());
```



# 3 交互流程
## 3.1 用户动线
![](https://intranetproxy.alipay.com/skylark/lark/0/2026/jpeg/198428/1775011543682-ba6bef45-6277-4830-9ae4-acec0e2b26ab.jpeg)

## 3.2 绑定流程
+ 绑定支付宝账号、录入声纹、开通支付

```mermaid
sequenceDiagram
    autonumber
    participant ISVPhone as 厂商手机App
    participant PAYSDK as 支付SDK
    participant ZFBApp as 手机支付宝App
    participant LauncherApp as 厂商耳机
    participant OPENAPI as 支付宝服务端

    activate ISVPhone

    ISVPhone->>PAYSDK: initSDK初始化

    ISVPhone->>PAYSDK: 查询绑定状态getBindStatus
    PAYSDK->>OPENAPI: queryBindStatus
    OPENAPI-->>PAYSDK: 绑定状态应答
    PAYSDK-->>ISVPhone: 返回绑定状态

    alt 已绑定
        ISVPhone->>ISVPhone: 显示"去支付宝管理"
    else 未绑定
        ISVPhone->>PAYSDK: 点击去绑定startBinding
        PAYSDK->>PAYSDK: initCloudEnv初始化<br/>startBindingProcess串联核身
        PAYSDK->>OPENAPI: 请求bindCode
        OPENAPI-->>PAYSDK: 返回bindCode
        PAYSDK-->>ISVPhone: onGetBindingSchemeSuccess返回schema
        ISVPhone->>ZFBApp: 打开绑定小程序
        ZFBApp->>ZFBApp: 用户绑定操作
        PAYSDK-->>ISVPhone: onStartRecording开麦通知
        ISVPhone->>LauncherApp: 打开麦克风
        ISVPhone->>PAYSDK: receiveDenoiseAudio送入音频
        PAYSDK->>OPENAPI: wss上传音频

        loop 轮询绑定状态
            PAYSDK->>OPENAPI: 轮询绑定状态
            OPENAPI-->>PAYSDK: 返回绑定状态
        end

        PAYSDK-->>ISVPhone: 返回绑定结果
        ISVPhone->>LauncherApp: 关闭麦克风
    end
```



## 3.3 唤起智能体业务
+ 通过厂商语音助手唤醒词，唤起智能体业务，如充话费、电影购票等；

```mermaid
sequenceDiagram
    participant App as 厂商手机App
    participant SDK as 支付SDK
    participant BT as 蓝牙通道
    participant Ear as 厂商耳机应用
    participant Server as 支付宝服务端

    App->>Ear: 1 设备建联
    App->>SDK: 2 initSDK初始化
    Ear->>App: 3 业务唤醒词

    alt 支付宝智能体业务
        App->>SDK: 4 startAlipayService
        App->>SDK: 5 receiveDenoiseAudio
        SDK->>SDK: 6 充话费/点咖啡<br/>TTS交互
        SDK->>Server: 7 创建订单，发起支付
        Server-->>SDK: 8 支付结果
    else 三方智能体业务
        App->>App: 9 购物/购票<br/>TTS交互

        alt 未登录
            App->>SDK: 10 授权登录组件
            SDK-->>App: 11 登录结果回调
        end

        App->>Server: 12 厂商skills创建订单
        Server-->>App: 13 预下单号
        App->>SDK: 14 startAlipayService 发起支付
        App->>SDK: 15 receiveDenoiseAudio
        SDK->>SDK: 16 提示并等待用户意图输入

        alt 用户确认支付
            SDK->>Server: 17 发起支付请求
            Server-->>SDK: 18 返回支付结果
        else 用户取消支付
            SDK->>SDK: 19 提示用户
        end
    end

    SDK-->>App: 20 返回支付结果
```


# 4 接入流程
1、填写信息登记，申请支付宝服务端绑定、支付、停车缴费配置

**信息模板：**

| **类别** | **厂商提供值** | **含义** | **备注** |
| --- | --- | --- | --- |
| isvName | | 厂商名称 | |
| deviceModel | | 设备型号 | |
| 语音唤醒词 | | 语音助手唤醒词 | |
| 安卓apk包名 | | 应用包名 | |
| 安卓apk签名 | | 应用签名 | apksigner verify -verbose --print-certs <apk_path>，提供MD5值 |
| IOS包名 | | 应用包名 | IOS应用的Bundle Identifier‌ |
| 鸿蒙包名 | | 应用包名 | |


2、支付宝侧生成蓝盾加密图片**nearx_bs.jpg**， 放到厂商App应用中

+ Android拿到蓝盾签名图片后，放到对应的工程中的app主模块下的assets根目录下即可
+ iOS需要放在mainBundle里，图片名称需要为nearx_bs.jpg
+ Harmony放在主应用的src/main/resources/base/media/nearx_bs.jpg

3、集成支付宝sdk，进行对接开发和功能联调；

```java
dependencies {
  //支付宝耳机sdk依赖
  implementation files('libs/galipay_sakwrapper-1.3.501.aar')
  //三方库依赖
  implementation "com.alibaba:fastjson:1.2.83@jar"
  implementation 'com.squareup.wire:wire-lite-runtime:1.5.3.4@jar'
  implementation 'com.squareup.okio:okio:1.7.0@jar'
}
```

4、绑定和开通入口

+ 独立页面形式：页面上展示“说一下支付”、“停车缴费”入口，点击按钮进入子页面时根据getBindStatus返回的fetatureStatusList判断，若服务未开通，则按钮显示“去支付宝开通”，反之显示“去支付宝管理”；
+ 弹窗引导形式：识别到充话费、点咖啡、停车缴费等支付宝意图时，判断若未开通，则弹出浮窗提示，用户点击后跳转支付宝小程序进行开通；

**建议:** 为避免每次发起服务都getBindStatus导致耗时，可以在设备建联或者进入页面时候查询一次getBindStatus，后续使用缓存状态；


