
流逸穿风
V1
2022/05/18阅读:34主题:橙心
支付apk接口文档
AIDL声明、请求、回调
方案规范
1. AIDL文件(main/aidl/com/fpyn/dishrecognition)
// IAIDLRequst.aidl
package com.fpyn.dishrecognition;
interface IRequst {
void createOrder(String msg);
void requestPay(String msg );//支付
void requestHistory();
void connect();
void disconnect();
void registerCallBack(IResponse response);//注册回调接口
void unregisterCallBack();//取消注册
}
// IAIDLResponse.aidl
interface IResponse {
void notifyPayResult(String datas);
void notifyConnectionStatus(int status);
}
2.Client 端示例
private IRequst iRequest;
private IResponse iResponse;
private ServiceConnection conn = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
iRequest = IRequest.Stub.asInterface(iBinder);
Integer.parseInt("");
if (iRequest == null) {
return;
}
if (iResponse == null) {
iResponse = new NotifyCallLister();
}
try {
iRequest.registerCallBack(iResponse);
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
if (iRequest != null) {
try {
iRequest.unregisterCallBack();
} catch (RemoteException e) {
e.printStackTrace();
}
iRequest = null;
}
}
};
//请求响应监听
class NotifyCallLister extends IResponse.Stub {
@Override
public void notifyPayResult(String datas) {
//do something
});
}
@Override
public void notifyConnectionStatus(int success) {
//do something
}
}
Intent intent=newIntent();
intent.setAction("com.fpyn.dishrecognition.FpynPayService");
intent.setPackage("com.fpyn.dishrecognition");
bindService(intent,connection, Context.BIND_AUTO_CREATE);
创建订单
-
iRequest.createOrder(Orderjson)
-
请求JSON
{
"action":"createOrder"
"deviceId":"xxxx",
"restaurantId":"xxxx",
"orderFoodList": [{
"count": 1,
"id": 838,
"name": "红烧肉",
"price": 1
}, {
"count": 1,
"id": 873,
"name": "大片冬瓜",
"price": 1
}, {
"count": 2,
"id": 899,
"name": "苹果",
"price": 2
}],
"totalPrice": 4,
"extFee":0,
"preferentialAmount":0
}
-
请求参数说明
参数名 | 类型 | 说明 |
---|---|---|
action | String | 操作 |
deviceId | String | 设备 |
restaurantId | String | 店铺ID |
totalPrice | int | 总价格;单位:分 |
extFee | int | 附加费;单位:分 |
preferentialAmount | int | 打折优惠;单位:分 |
orderFoodList | List | 菜品信息 |
orderFoodList-->count | int | 菜品份数 |
orderFoodList-->id | String | 菜品ID |
orderFoodList-->name | String | 菜品名称 |
orderFoodList-->price | int | 菜品单价;单位:分 |
-
返回JSON
{
"action":"createOrder",
"code":1,
"msg":"xxx",
"orderNum":"xxxxx"
}
-
返回参数说明
参数名 | 类型 | 说明 |
---|---|---|
action | String | 操作 |
code | int | 返回值;1:成功,-1:失败 |
msg | String | 返回内容 |
orderNum | String | 订单号 |
作者介绍

流逸穿风
V1