友朋运营商开放平台
    友朋运营商开放平台
    • 友朋运营商平台第三方开放平台接口文档
    • 业务场景
      • 场景:自取柜第三方支付业务逻辑
      • 场景:异步通知第三方业务回调地址
      • 场景:自取柜售货机订单同步给第三方
    • API 列表
      • api.test
        POST
      • cabinet.list
        POST
      • cabinet.product.stock
        POST
      • cabinet.open.door
        POST
      • cabinet.order.refund.apply
        POST
      • cabinet.order.user.appeal
        POST
      • cabinet.order.list
        POST
      • cabinet.order.get
        POST
      • consumer.order.list
        POST
      • consumer.order.get
        POST

    友朋运营商平台第三方开放平台接口文档

    01. 概述#

    友朋运营商第三方开放平台提供接口能力,运营商可以通过开放平台接口扩展自身的业务能力,支付能力,数据采集能力等。
    接口类型费用说明
    普通业务接口免费在运营商后台自行勾选配置开发者的接口权限,1个运营商可同时创建多个开发者账号进行调用使用。
    支付类接口收费在支付配置选付费购买第三方支付接口,1个运营商仅可配置一个第三方支付回调URL。即一个运营商下的所有机器仅可接入一个唯一的支付渠道(例如银行聚合支付通道)。

    02. 开发者接入流程#

    1.
    注册一个运营商,如已有账号请登陆 点此;
    2.
    在"营销中心"->"开放平台"->新增一个第三方开发者;
    3.
    设置第三方开发者对应的接口权限;
    4.
    记录开发者的 AppID 和 AppSecret,用于调用开发平台的免费接口;
    5.
    完整阅读本文档,并根据业务场景调用你需要的接口

    03. 如何调用接口#

    提示
    同步服务器时间 ntp1.aliyun.com , ntp2.aliyun.com .. ntp7.aliyun.com
    所有接口统一采用 https post 方式调用

    0x01 接口请求地址#

    https://api.yopoint.com/api/gateway/index

    0x02 请求方式#

    Method: POST
    Content-Type: application/x-www-form-urlencoded
    或者
    Content-Type: application/json

    0x03 公共请求参数#

    参数名称类型是否必须描述示例值
    appidstringY运营商后台创建的 AppID930859529955
    methodstringY接口名称 (字母小写)activity.voucher.exchange
    biz_contentstringY业务参数 json 字符串
    versionstringY接口版本:1.0.0,目前固定此版本1.0.0
    timestampintYunix 时间戳到秒1556943285
    sign_typestringY签名方式,md5 (小写)md5
    signstringY签名(小写)签名方式见下文

    0x04 返回结果结构#

    参数名称类型是否必须说明示例值
    error_codeint是错误代码 =0 正常(操作成功,接口调用成功) !=0 异常错误0
    error_msgstring是错误描述ERR_SYSTEM
    dataobject是返回业务内容

    0x05 签名#

    签名注意点:
    1.
    除 sign 参数外所有参数必须参与签名,参数以文本方式字典排序,排序后使用 key=value&key=value 方式拼接字符串
    2.
    得到字符串 tmpString
    3.
    签名:md5(tmpString+"&"+appSecret) 得出的结果转换为小写字母
    4.
    appSecret 在运营商后台获取
    示例
    appid = 930859529955
    appSecret = xxxxxx
    
    //待签名字符串
    
    appid=930859529955&biz_content={"ReceiptNo":"OD190425164650841431"}&method=consumer.order.get&sign_type=md5&timestamp=1556943545748&version=1.0.0&xxxxxx【←这里xxxxxx是AppSecrt换成你自己的】
    
    // md5以上字符串
    sign=b156660e474668f63876c799870acdf8

    04. Apifox 示例#

    第一步设置前置脚本#

    第二步设置环境参数#

    全局参数
    
    Header: Content-Type:application/x-www-form-urlencoded
    
    开发环境
    
    前置URL: https://api.yopoint.com/api/gateway/index
    appid: 你的appid
    appSecret: 你的密钥,注意不要有空格
    如下图:
    image.png

    第三步测试签名#

    通过 api.test接口进行测试签名是否成功

    5. Postman 示例#

    Postman 是一款功能强大的网页调试与发送网页 HTTP 请求,并能运行测试用例的 Chrome 插件,可以用来很方便的模拟 GET 或者 POST 或者其他方式的请求来调试接口。

    安装 Postman#

    您可以在 Chrome 网上应用店安装 Postman 扩展程序
    也可以在 Postman 官网下载并安装桌面版 Postman

    设置 pre-script 脚本#

    var appid="xxxx" // appID
    var appSecret="xxx" // 秘钥
    var method="xx.xx" // 需要调用的接口方法
    var version="1.0.0"
    var timestamp=Math.round((new Date()).getTime());
    var sign_type="md5"
    var sign=""
    
    // 业务参数,根据不同的接口需要传入不同的业务参数
    var biz_content={
    
    }
    
    var params = {
     appid:appid,
     biz_content:JSON.stringify(biz_content),
     method:method,
     sign_type:sign_type,
     timestamp:timestamp,
     version:version,
    }
    
    var signArr = [];
    _.each(params,(v,k)=>{
        signArr.push(`${k}=${v}`);
    });
    signArr.push(appSecret)
    
    var singText = signArr.join('&');
    
    sign = CryptoJS.MD5(singText).toString();
    console.log(sign)
    
    postman.setEnvironmentVariable('appid',appid);
    postman.setEnvironmentVariable('method',method);
    postman.setEnvironmentVariable('version',version);
    postman.setEnvironmentVariable('timestamp',timestamp);
    postman.setEnvironmentVariable('sign_type',sign_type);
    postman.setEnvironmentVariable('sign',sign);
    postman.setEnvironmentVariable('biz_content',JSON.stringify(biz_content));

    设置 Post 的 Body#

    method:{{method}}
    timestamp:{{timestamp}}
    sign_type:{{sign_type}}
    sign:{{sign}}
    biz_content:{{biz_content}}
    appid:{{appid}}
    version:{{version}}

    设置请求头的 Header#

    Content-Type:application/x-www-form-urlencoded
    修改于 2024-01-11 05:20:12
    下一页
    场景:自取柜第三方支付业务逻辑
    Built with