接口说明
购买商品
接口地址
/api/buy
传入参数
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
product_id | int | true | 商品编号 |
recharge_account | string | false | 充值账号 |
quantity | int | true | 购买数量 |
notify_url | string | false | 异步通知地址 |
outer_order_id | string | false | 外部订单号,同一商家编号下不允许重复 |
safe_cost | string | false | 安全进价(见下方说明) |
client_ip | string | false | 购买的用户真实IP |
安全进价说明
为防止平台调价导致客户亏本,可以传入此参数用于对比,当平台售价高于此安全进价时,系统将不会受理此订单。该值按照进货单价计算,单位:元。
返回数据
参数名 | 类型 | 说明 |
---|---|---|
order_id | string | 订单号 |
product_price | decimal | 商品价格 |
total_price | decimal | 总支付价格 |
recharge_url | string | 卡密充值网址 |
state | int | 订单状态(100:等待发货,101:正在充值,200:交易成功,500:交易失败,501:未知状态) |
cards | json | 卡密(仅当订单成功并且商品类型为卡密时返回此数据) |
tickets | json | 卡券(仅当订单成功并且商品类型为卡券时返回此数据) |
注意:因为部分商品的库存是异步的,cards、tickets可能会存在不返回或返回值为空的情况,此时请轮询调用获取单个订单信息接口获取卡密卡券信息,或者在下单时接入订单状态异步通知
示例
{
"code": "ok",
"message": "",
"data": {
"order_id": "557305089422",
"product_price": "3.0000",
"total_price": "9.0000",
"recharge_url": "http://abc.com",
"state": 200,
"cards": [{
"card_no": "vip009",
"card_password": "DDd2kpCxZosyy7d",
"expired_at": "2022-12-31 00:00:00"
}, {
"card_no": "vip010",
"card_password": "UwQ4WnAKfi6wby6",
"expired_at": "2022-12-31 00:00:00"
}, {
"card_no": "vip011",
"card_password": "qKgITDZUuahfmiu",
"expired_at": "2022-12-31 00:00:00"
}],
"tickets":[{
"no":"",
"ticket":"https://oss.cqmeihu.com/alZpSdMXgeI7mGM3vZNLaPZ5y.png",
"expired_at": "2022-12-31 00:00:00"
}]
}
}