MoonRecharge

白月光充值系统


MoonRecharge-说明

<p>一.请求方式</p> <p>所有的接口统一使用post方式</p> <p>二.报文格式</p> <p>所有的接口请求与返回均为application/json</p> <p>三.DES加密参数 (1)所有加密都需要privateKey(代理商私钥),如果没有,请联系平台工作人员进行配置。</p> <p>(2)平台对ip进行白名单限定,下游需要提供相应ip给平台工作人员进行授权,否则将无法调用平台API</p> <p>(3)平台加密方式为DES加密: 偏移变量,固定占8位字节:12345678 密钥算法:DES 加密-工作模式-填充模式:DES/CBC/PKCS5Padding 默认编码:utf-8 使用privateKey(代理商私钥)作为加密密码,,把参数转换为json作为加密字符串 参考链接:<code>https://blog.csdn.net/Luck_ZZ/article/details/104805562</code></p> <p>拼接规则见每个api的参数描述</p> <p>java例子:</p> <pre><code class="language-java">public static void main(String[] args) { for (int i = 0; i &amp;lt; 1; i++){ Gson gson = new Gson(); String json = &amp;quot;{\n&amp;quot; + &amp;quot; \&amp;quot;serialNumber\&amp;quot;:&amp;quot;+System.currentTimeMillis()+&amp;quot;,\n&amp;quot; + &amp;quot; \&amp;quot;timestamp\&amp;quot;:&amp;quot;+ System.currentTimeMillis() + &amp;quot;,\n&amp;quot; + &amp;quot; \&amp;quot;version\&amp;quot;:\&amp;quot;1\&amp;quot;\n&amp;quot; + &amp;quot;}&amp;quot;; EncryptionRechargeDO encryptionRechargeDO = new EncryptionRechargeDO(); encryptionRechargeDO.setPrivateKey(&amp;quot;TM34ZrPp8DLn+shdXH7mBxFURhYha2eo&amp;quot;); encryptionRechargeDO.setEncryptionData(DESUtil.encrypt(&amp;quot;TM34ZrPp8DLn+shdXH7mBxFURhYha2eo&amp;quot;, json)); String responseData = null; try { responseData = HttpUtil.post(&amp;quot;http://moon.cqxinhuayun.com/recharge/api/recharge.html&amp;quot;, gson.toJson(encryptionRechargeDO), conn -&amp;gt; { conn.setRequestProperty(&amp;quot;Content-Type&amp;quot;, &amp;quot;application/json;charset=utf-8&amp;quot;); conn.setRequestProperty(&amp;quot;accept&amp;quot;, &amp;quot;application/json;charset=utf-8&amp;quot;); } ); } catch (Exception e) { e.printStackTrace(); } System.out.println(&amp;quot;回调下游接口返回结果为:&amp;quot; + responseData); System.out.println(gson.toJson(encryptionRechargeDO)); }</code></pre> <p>java加密:</p> <pre><code class="language-java"> public static String encrypt(String password, String data) { if (password== null || password.length() &amp;lt; 8) { throw new RuntimeException(&amp;quot;加密失败,key不能小于8位&amp;quot;); } if (data == null) return null; try { DESKeySpec dks = new DESKeySpec(password.getBytes(&amp;quot;utf-8&amp;quot;)); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(&amp;quot;DES&amp;quot;); SecretKey secretKey = keyFactory.generateSecret(dks); Cipher cipher = Cipher.getInstance(&amp;quot;DES/CBC/PKCS5Padding&amp;quot;); IvParameterSpec iv = new IvParameterSpec(&amp;quot;12345678&amp;quot;.getBytes(&amp;quot;utf-8&amp;quot;)); cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv); byte[] bytes = cipher.doFinal(data.getBytes(&amp;quot;utf-8&amp;quot;)); //JDK1.8及以上可直接使用Base64,JDK1.7及以下可以使用BASE64Encoder //Android平台可以使用android.util.Base64 return new String(Base64.getEncoder().encode(bytes)); } catch (Exception e) { e.printStackTrace(); return data; } }</code></pre> <p>4.接口返回规范</p> <h5>返回参数说明</h5> <table> <thead> <tr> <th>参数名</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>status</td> <td>int</td> <td>响应状态码</td> </tr> <tr> <td>msg</td> <td>string</td> <td>响应信息</td> </tr> <tr> <td>version</td> <td>int</td> <td>响应状态码</td> </tr> <tr> <td>data</td> <td>object</td> <td>响应数据</td> </tr> </tbody> </table> <p>详情见每个具体的接口</p> <h5>返回示例</h5> <pre><code> {&amp;quot;status&amp;quot;:200,&amp;quot;msg&amp;quot;:&amp;quot;操作成功&amp;quot;,&amp;quot;version&amp;quot;:1,&amp;quot;data&amp;quot;:null} </code></pre>

页面列表

ITEM_HTML