在使用/op接口之前,先阅读接口API文档,
点击查看/op的API接口文档
如下图所示:
交易纪录数据结构为:token_x op(sms) token_y opval(phone and code) extra_data ;(非转帐推荐使用assert、config、notice等指令)
一般情况下,除非是send消息,令token_x=coin_0000000000000000(即token_root)
令token_y=coin_28PU1xiGV56VssZS(我们使用上面fork接口API创建的token-id)
这里须使用pay指令,并且令opval={"order_number":"your-order-no","order_name":"充值1元钱","pay_money":1,"auto":1,"version":1,"extra_data":"云支付自动充值"}(其中order_name为充值名目,order_number为业务订单号,pay_money为充值金额(元),auto非空代表自动充值,version暂时只能为1,extra_data附加信息可填可不填)
因为在浏览器里直接使用该参数,所以我们进行urlencode转码:
转码工具
转码得到opval:%7b%22order_number%22%3a%22your-order-no%22%2c%22order_name%22%3a%22%e5%85%85%e5%80%bc1%e5%85%83%e9%92%b1%22%2c%22pay_money%22%3a1%2c%22auto%22%3a1%2c%22version%22%3a1%2c%22extra_data%22%3a%22%e4%ba%91%e6%94%af%e4%bb%98%e8%87%aa%e5%8a%a8%e5%85%85%e5%80%bc%22%7d
接口API的URL拼接如下:
https://c0.6dgs.opencom.cn/node.testphone.coin/op?appid=10001&secret_key=bfc51077860b2927be95c0807766ca56&token_x=coin_0000000000000000&token_y=coin_28PU1xiGV56VssZS&opcode=pay&opval=%7b%22order_number%22%3a%22your-order-no%22%2c%22order_name%22%3a%22%e5%85%85%e5%80%bc1%e5%85%83%e9%92%b1%22%2c%22pay_money%22%3a1%2c%22auto%22%3a1%2c%22version%22%3a1%2c%22extra_data%22%3a%22%e4%ba%91%e6%94%af%e4%bb%98%e8%87%aa%e5%8a%a8%e5%85%85%e5%80%bc%22%7d&extra_data=pay-helloworld
得到的返回结果如下:
{"ret":true,"msg":"success","txid":"txid_25ruochfeTnEz3MA","token_x":"coin_0000000000000000","token_y":"coin_28PU1xiGV56VssZS","x_state":{"token_state_p":"[]","token_state_val":"20","token_height":38,"pre_txid":"txid_21EfrwpDyD5MfHVq","public_key":"yizNoHddKNvchoikGRdrTaqeDJptUh9XvpnRiDfb85vz","token":"coin_0000000000000000"},"y_state":{"token_state_p":"[\"coin_0000000000000000\"]","token_state_val":"0","token_height":2,"public_key":"pTp6prhtAMfHKNTaeVFY5e8fGJc3K2SkSAKFx86ToHBE","token":"coin_28PU1xiGV56VssZS"},"x6dgs_cloud_func_ret":{"ret":true,"msg":"success","order_id":"order_rmb27ECgiS3TWzpe","pay_url":"https://cloud.6dgs.opencom.cn/h5.html?order_rmb27ECgiS3TWzpe"}}
ret=true代表op接口调用和写入数据成功,这里获取聚合支付链接URL成功与否是通过x6dgs_cloud_func_ret的回参数判断:
如这里所示:"x6dgs_cloud_func_ret":{"ret":true,"msg":"success","order_id":"order_rmb27ECgiS3TWzpe","pay_url":"https://cloud.6dgs.opencom.cn/h5.html?order_rmb27ECgiS3TWzpe"},其中pay_url代表提供给用户点击支付充值的链接
点击充值URL:https://cloud.6dgs.opencom.cn/h5.html?order_rmb27ECgiS3TWzpe,得到图所未:
在非微信客户端扫一扫后,完成支付,即可在6DGS云控制台-帐户管理-余额管理看到自己有了1元钱的收入,如下图所示:
通过6DGS云控制台的G节点的数据管理,可看到token_y=coin_28PU1xiGV56VssZS已经成功自动充值1元(币):
这里,txjson为:{"txid":"txid_33WCnUpp78VxfnTT","token_x":"coin_0000000000000000","token_y":"coin_28PU1xiGV56VssZS","opcode":"send","opval":"1","extra_data":"{\"order_id\":\"order_rmb27ECgiS3TWzpe\",\"order_name\":\"充值1元钱\",\"order_number\":\"your-order-no\",\"pay_money\":\"1\",\"cloud_pay_fee\":\"0.050\",\"send_status\":2,\"ret\":true,\"msg\":\"success\",\"extra_data\":\"云支付自动充值\"}","timestamp_i":"1565954919","token_state":"1","token_height":3,"pre_txid":"null"},
这里的token_state为1,且opcode=send,token_x为token_root,代表自动充值成功
通过6DGS云控制台的G节点的数据管理,还可以可看到token_y=coin_28PU1xiGV56VssZS的第二条pay指令的存储纪录(method=callback)代表回调时将结果状态写入:
这里,txjson为:{"txid":"txid_265nepS4gmJkewfK","token_x":"coin_0000000000000000","token_y":"coin_28PU1xiGV56VssZS","opcode":"pay","opval":"{\"order_id\":\"order_rmb27ECgiS3TWzpe\",\"order_name\":\"充值1元钱\",\"order_number\":\"your-order-no\",\"pay_money\":\"1\",\"cloud_pay_fee\":\"0.050\",\"send_status\":2,\"ret\":true,\"msg\":\"success\",\"extra_data\":\"云支付自动充值\",\"auto_send_cloud_rmb_ret\":{\"ret\":true,\"msg\":\"success\",\"txid\":\"txid_33WCnUpp78VxfnTT\",\"token_x\":\"coin_0000000000000000\",\"token_y\":\"coin_28PU1xiGV56VssZS\",\"x_state\":{\"token_state_p\":\"[]\",\"token_state_val\":\"19\",\"token_height\":40,\"pre_txid\":\"txid_21EfrwpDyD5MfHVq\",\"public_key\":\"yizNoHddKNvchoikGRdrTaqeDJptUh9XvpnRiDfb85vz\",\"token\":\"coin_0000000000000000\"},\"y_state\":{\"token_state_p\":\"[\\\"coin_0000000000000000\\\"]\",\"token_state_val\":\"1\",\"token_height\":3,\"public_key\":\"pTp6prhtAMfHKNTaeVFY5e8fGJc3K2SkSAKFx86ToHBE\",\"token\":\"coin_28PU1xiGV56VssZS\"}},\"method\":\"callback\"}","extra_data":"云支付自动充值","timestamp_i":"1565954919"}
opval里的值为回调的处理结果状态JSON的文本,注解如下:
- 6DGS云开发者帐户余额成功收入1元钱:"pay_money\":\"1\",\"cloud_pay_fee\":\"0.050\",\"send_status\":2,这里:cloud_pay_fee代表系统扣手续费,这里手续费率为5%,(如果send_status=2代表充值成功,但是手续费率没有扣成功,当send_status=3时,充值成功并且费率也扣取成功)
- 用户token-id:coin_28PU1xiGV56VssZS收入1:"auto_send_cloud_rmb_ret\":{\"ret\":true,\"msg\":\"success\"...\"token_state_val\":\"1\",这里ret=true代表用户token帐户充值1成功,token_state_val=1代表当前余额为:1
- "method\":\"callback,这里说明的是pay指令存储的是回调的结果,以区分由opcode=pay的云支付API发起的获取聚合支付URL的请求。
成功扣除费率的图示如下(5%的手续费在6DGS云开发者帐户自动扣除):
当然,因为是op操作(opcode=pay),也可通过/chain/opcode可以查询到op接口的每一条存储纪录点击查看/chain接口文档