充值平台文档
Table of Contents

总览

前后端放在同一服务器,但是依旧是分离的。所以不用考虑跨域。

后端所有URL都是/pay/ 为前缀

获取手机信息以及商品信息

URL :

[GET] {phone}/products   [实际为pay/{phone}/products,见总览说明]

参数

phone

返回值

{
  "phone": {
    "province": "湖北",
    "isp": "联通",
    "redisKey": "联通:湖北",//也可忽略
    "defaultKey": "联通:默认", //可忽略
    "valid": true //当为false时,不存在products,一般为手机号码有误
  },
  "products": [
    {
      "id": 33,
      "isp": "联通",
      "province": "默认",
      "nt": "20",//流量大小
      "price": 3,
      "discount": 0.92,//折扣
      "finalPrice": 276 //实际价格,为分
    },
    ......
  ]
}

创建订单

URL

[POST] create

参数

code 微信的code,可复用
nt 根据之前返回的流量值
phone 手机号码

返回值

字符串,
如果为0 则证明创建订单失败
不为0,则可作为pingxxCharge使用,发起支付
正常格式如下
{
  "id": "ch_5y5C040ar1W5fvf9OSWfzHC8",
  "object": "charge",
  "created": 1461777505,
  "livemode": true,
  "paid": false,
  "refunded": false,
  "app": "app_SC48CS18ab149an9",
  "channel": "wx_pub",
  "order_no": "1461777504835993",//订单编号orderId,需保存,可复用
  "client_ip": "128.199.123.215",
  "amount": 2760,
  "amount_settle": 2705,
  "currency": "cny",
  "subject": "500M流量", //商品名称
  "body": "联通:湖北:13297077039 流量充值", //商品介绍
  "time_paid": null,
  "time_expire": 1461781104,
  "time_settle": null,
  "transaction_no": null,
  "refunds": {
    "object": "list",
    "url": "/v1/charges/ch_5y5C040ar1W5fvf9OSWfzHC8/refunds",
    "has_more": false,
    "data": []
  },
  "amount_refunded": 0,
  "failure_code": null,
  "failure_msg": null,
  "metadata": {},
  "credential": {
    "object": "credential",
    "wx_pub": {
      "appId": "wxe46d00c3907e3691",
      "timeStamp": "1461777505",
      "nonceStr": "def62d7be032ff5dec39bbaf2370bbc2",
      "package": "prepay_id=wx201604280118253d4d191eff0490005405",
      "signType": "MD5",
      "paySign": "0476C2F6F0729AB7E8D77758FD1604AE"
    }
  },
  "extra": {
    "open_id": "oaviTs4-nobh9sn_TzmZHP2taLq0"
  },
  "description": null
}

取消订单

URL

[POST] cancel

参数

code
orderId 订单id(见上)

返回值

始终返回空,
因为不取消也不要紧……

检查订单支付状态

URL

[POST] finish

参数

code
orderId

返回

{
  "paymentStatu":"1", //1为已支付,0为未支付
  "chargeStatus":"1", //1为已充值成功,0为已提交充值,-1为充值失败,-2为未知状态
  "refundStatus":""//1为已退款成功,0为已提交退款,
}
//所有的null表示还未经历此状态

检查订单充值状态

URL

[POST] check

参数

code
orderId

返回

{
  "paymentStatu":"1", //1为已支付,0为未支付
  "chargeStatus":"1", //1为已充值成功,0为已提交充值,-1为充值失败,-2为未知状态
  "refundStatus":""//1为已退款成功,0为已提交退款,
}
//所有的null表示还未经历此状态 xxxxxxxxxx -3 帐号或者订单问题-2 未知-1 失败0 正在充值1 充值成功

获取订单列表

URL

[POST] list

参数

code
phone 
两个参数二选一

返回

// null 为权限问题
//[]为无订单
[
  {
    "id": "1461776909852392",
    "openId": "oaviTs4-nobh9sn_TzmZHP2taLq0",
    "pingxxId": "ch_XrT4qP004y5KK4WzPKn5u10S",
    "phone": "13297077039", //充值手机号
    "date": 20160428, //充值日期
    "ts": 1461776910325,
    "paymentStatus": "已创建", //订单的支付状态
    "refundStatus": null, //订单的退款状态
    "chargeStatus": null, //充值状态
    "product": 20,
    "type": 1,
    "price": 276
  },
  ......
]

获取所有订单

URL

[GET] orders

参数

search 关键词 为空则为全部
sort 排序词(如IDts 
order 排序方向(ascdesc //默认为ts(时间戳)倒序
limit 单次取多少条 默认为10
offset 位移量 默认为0
//均可为空

获取剩余金额

URL

[GET] money