﻿# 1 文档说明
本文档适用于具身智能机器狗/机器人接入支付宝AI支付，包括输出产物、API接口说明和交互流程。

## 1.1 支付宝输出产物
| **平台** | **产物** | **功能与说明** |
| --- | --- | --- |
| Android | 支付宝安卓SDK | 支付宝智能体业务和支付、核身逻辑处理 |
| IOS | 支付宝IOS SDK | 同安卓 |
| Linux | 支付宝Linux SDK | 扫码算法封装，支持一二维码扫描;音频和意图处理； |


## 1.2 功能列表
+ 看一下支付：具身智能设备扫码，用户语音支付；
+ 一方智能体业务：充话费、点咖啡等;

## 1.3 系统框图
若设备支持联网，则直接集成支付宝SDK即可使用，无需连接手机；若不支持联网，则需手机App集成支付宝SDK；此处以搭配手机使用为例：

![画板](https://intranetproxy.alipay.com/skylark/lark/0/2026/jpeg/198428/1790418910348-f9da4908-bd9e-404e-a7da-1c14734a59c0.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 void onErrorEvent(String code, String message) {
        //错误回调
        //○ Q1010/1011:sdk调用initCloudEnv失败，或者wss建联失败；收到此错误码仅需播音提示用户。
    }

    @Override
    public void onEvent(String eventId, String eventData, Map<String, Object> extInfo) {
        //○ Q9991:SDK内状态机回调
        //○ updateViewV2：页面驱动事件
    }

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

<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" |


:::warning
支付过程中部分音频数据需要录制成音频，部分语音需要在线合成TTS，需要注意语音播报需要互斥，新的语音指令需要打断前序的播报，以避免在线TTS慢导致的语音排队问题

:::

#### <font style="color:rgb(0, 0, 0);">2.2 getBindStatus</font>
<font style="color:rgb(0, 0, 0);">获取设备的绑定/服务开通状态；在手机端展示绑定状态 或者每次发起支付前调用；若未开通，提示用户去厂商App中进行服务开通；</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接口时，同时把唤起语音进行上传；在扩展字段中填写</font>

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

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

:::

#### 2.5 unbind
解绑支付宝账号，仅清除设备本地缓存uid tid信息； 

厂商手机App端解绑按钮建议跳转到支付宝小程序设备页面，进行解绑。

#### <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 </font><font style="color:rgb(0, 0, 0);"> 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> |


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



#### 2.8 setWearingState
机器狗、机器人无佩戴状态检测，未用该接口；


#### 2.9 startAlipayService
```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);">参数key</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);">备注</font>** |
| --- | :--- | :--- | :--- | --- |
| <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">PAY_INIT_ASR </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:rgb(0, 0, 0);background-color:#FFFFFF;">orderStr</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:rgb(0, 0, 0);background-color:#FFFFFF;">scene</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;">Coffee,         //点咖啡</font><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">TopUp,          //充话费</font><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">MovieTicket,    //电影票</font> |
| <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">locationLat</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;">31.564343</font> |
| <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">locationLnt</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;">120.533231</font> |
| <font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">coordType</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;">高德：GCJ-02</font><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">百度：BD-09</font> |
| <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><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;"></font><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">高德机器狗接入此项必传：</font><br/><font style="color:rgb(0, 0, 0);background-color:#FFFFFF;">扫码sdk返回的加密二进制数据转成base64字符串后传入</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> |


#### **<u>2.10 日志重定向</u>**
**<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/png/198428/1782183022842-641794d7-c979-40f3-8105-449b0bf94734.png)

## 3.2 绑定流程
+ 绑定支付宝账号、录入声纹、开通支付；
+ 这里以手机App+无网设备接入为例；当具身智能设备支持独立联网时，将厂商手机App换成厂商具身智能App；

```mermaid
sequenceDiagram
    autonumber
    participant ISVPhone as 厂商手机App
    participant PAYSDK as 支付SDK
    participant ZFBApp as 手机支付宝App
    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->>ISVPhone: 打开麦克风
        ISVPhone->>PAYSDK: receiveDenoiseAudio送入音频

        PAYSDK->>OPENAPI: wss上传音频

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

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

**注：实际用户使用时，可能有两种形式**：

+ 用户佩戴耳机进行语音交互，全程不用掏手机；
+ 用户拿着手机，对语音助手摁住录音键说话并发送；

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

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

    activate ISVPhone

    ISVPhone->>LauncherApp: 设备建联
    ISVPhone->>PAYSDK: initSDK初始化

    ISVPhone->>ISVPhone: 业务唤醒词

    alt 扫码支付
        ISVPhone->>ISVPhone: 帮我扫码支付
        ISVPhone->>LauncherApp: 发送扫码指令
        LauncherApp->>LauncherApp: 打开相机扫码
        LauncherApp->>LauncherApp: 遮挡、远近等提示
        LauncherApp-->>ISVPhone: 返回码值
        ISVPhone->>PAYSDK: startAlipayService(codeStr)
        PAYSDK->>OPENAPI: parseCode解码
        OPENAPI-->>PAYSDK: 返回商户名称、logo、金额
        PAYSDK->>PAYSDK: tts: 要付多少钱/即将支付x元
        ISVPhone->>PAYSDK: 用户"确认支付"
        PAYSDK->>OPENAPI: 发起支付
        OPENAPI-->>PAYSDK: 返回支付结果
        PAYSDK->>PAYSDK: tts: 支付成功/失败(原因)
        PAYSDK-->>ISVPhone: 返回支付结果

    else 支付宝智能体业务
        ISVPhone->>ISVPhone: 帮我点杯咖啡
        ISVPhone->>PAYSDK: startAlipayService(scene=Coffee)
        ISVPhone->>PAYSDK: receiveDenoiseAudio
        PAYSDK->>PAYSDK: 手机号授权(仅首次)
        PAYSDK->>PAYSDK: 点咖啡<br/>TTS交互
        PAYSDK->>OPENAPI: 创建订单，发起支付
        OPENAPI-->>PAYSDK: 支付结果(门店地址+取单号)
        PAYSDK-->>ISVPhone: 门店地址+取单号
        ISVPhone->>LauncherApp: 发送取咖啡指令<br/>门店地址+取单号
        LauncherApp->>LauncherApp: 前往门店取咖啡

    else GPass业务
        ISVPhone->>ISVPhone: 打开导览<br/>TTS交互
        ISVPhone->>PAYSDK: recognize(scene=city_guide)
        PAYSDK-->>ISVPhone: 导览TTS交互
        ISVPhone->>LauncherApp: 导航位置和内容
        LauncherApp->>LauncherApp: 领航和讲解
    end
```


### 3.3.1 机器狗领取咖啡
+ 发起点咖啡服务调用

```plain
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", selectedScene, 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);
    }
});
```

+ 返回下单结果(地址、门店、取单号)
    - onResponse返回结果信息：

```json
{
  "code": 1000,
  "subCode": "Q100000",
  "subMsg": "OK_SUCCESS",
  "mResult": "{eventData={\"notificationUrl\":\"https://ur.alipay.com/_7qlgugFbslIgI7pFz7Imcq\",\"notificationTitle\":\"瑞幸下单成功，取餐号：468\",\"code\":\"468\",\"address\":\"北京市西城区西单北大街131号\",\"notificationMessage\":\"下单成功\",\"shopName\":\"瑞幸咖啡（丰潭路站店）\"}, resultCode=9000, memo=订单支付完成, eventType=onPayResult}",
  "extInfo": {}
}
```

    - initSDK#onEvent接口返回咖啡制作状态信息：

![](https://intranetproxy.alipay.com/skylark/lark/0/2026/png/198428/1790420368256-13635850-cf25-4bce-91a4-c6609778c43d.png)

```json
//dataJson数据示例：
{
    "topic": "PAY_LUCKIN_COFFEE",
    "bizId": "server-event-id",
    "payload":{
      "intentType": "coffee",
      "content": {
        "deliveryScope": "PROCESS",
        "type": "OrderStatus",
        "data": {
          "device_sn": "1901092548008087",
          "order_id": "7674558732730630153",
          "dept_name": "春申景城店",
          "dept_address": "闵行区兴梅路1181号底商",
          "order_ready_time": "17:31",
          "order_status_name": 40,
          "order_status_desc": "制作完成,等待取餐",
          "update_timestamp": "2026-08-16 17:29:08",
          "note_msg": 154
        }
  }
}
}
```

# 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，后续使用缓存状态；

