支付流程 - jues-zz/ddexpert_server GitHub Wiki

支付流程 :首先用户请求后台生成订单(initOrder)然后会得到返回数据,如果是支付宝或者微信支付,则跳到第三方平台处理,如果是选择钱包支付,则需请求后台payByWallet方法。支付完成后默认会开启24小时自动转到对方可提现金额,如果买家需要手动确认订单,则需请求后台confirmOrder方法.

错误码对应: 0:"未知错误", 2:"参数错误", 4:"支付密码错误", 6:"找不到此订单", 7:"此人不存在", 8:"缺少收款人或用户余额不足", 10:"用户余额不足", 12:"参数类型错误"

1. post /api/v1/initOrder 新建订单

接收 post 参数

subject 商品名称 如:购买...服务
amount 金钱数额  以分为单位
userId  买家Id 
receiverId 卖家Id
chatId  聊天Id
skillId 技能Id

返回值示例

{"success": true, "order":order,"charge":charge}

说明:若渠道为钱包,则不返回charge这个字段
order字段:

{ __v: 0,
 type: 'deal',
 status: '未支付',
 receiverId: '55370ecc30b55c7805829b34',
 userId: '55370ecc30b55c7805829b33',
 amount: 100,
 orderNo: '83aac82bbbfc084a',
 channel: '',
 subject: '购买xx服务',
 _id: '5552c15fa145bd880311a245',
 create_at: '2015-05-13T03:13:35.129Z' },

2. post /api/v1/payByWallet 钱包支付

接收 post 参数

payPass 用户支付密码
userId 用户id
oid "订单id";

返回值示例

{"success": true,}

or { code: 4, msg: '支付密码错误' }

3. post /api/v1/payByPing 第三方支付

接收 post 参数

oid "订单id";
channel 交易渠道 :alipay  wx  (选两个参数其中之一,分别对应支付宝 微信 )

返回值示例

{"success": true,charge:charge};

or { code: 4, msg: '支付密码错误' }

4. post /api/v1/withdrawCash 充值

接收 post 参数

payPass     用户支付密码
userId      用户id
alipayNo    提现时填的支付宝账号
alipayName  提现时填的支付宝用户名

返回值示例

{"success": true,}

or { code: 4, msg: '支付密码错误' }

5. post /api/v1/confirmOrder 手动确认订单

接收 post 参数

id 订单id 

返回值示例

{"success": true,}

6. post /api/v1/setPayPass 设置支付密码

接收 post 参数

uid 用户id
newPass 新密码
oldPass  旧密码  如果是第一次设置则不填
accessToken 用户密令

返回值示例

{"success": true,}

or {"success":false , msg: "the old pass is wrong"}

7. post /api/v1/getOrderDetail 获取订单详情

接收 post 参数

accesstoken 用户密令
oid 订单id

返回值示例

{
success: true,
order: {
    _id: '557f8c7f22ff73f70fbe1716',
    skillId: '5555c4a1390c9ed166fc7f15',
    chatId: 'room_77340061',
    alipayName: '',
    alipayNo: '',
    type: 'deal',
    status: '未支付',
    receiverId: '55516ed14522f7917465e4da',
    userId: '55506c67f73577b459968be1',
    amount: 1,
    orderNoHash: '$2a$10$hHobH5YK1PqMwJqoXK2w5.glPUknVPAdjHskavI5fXG95Wb9BsDUO',
    orderNo: 'c5a625721b790437',
    channel: '',
    pingChargeId: '',
    subject: '个人魅力提升',
    __v: 0,
    create_at: '2015-06-16T02: 39: 59.282Z',
    user: 'Michael',
    userOJ: {
        _id: '55516ed14522f7917465e4da',
        avatar: 'http: //192.168.1.9: 3000/public/upload/05bf686c17b14f2248fb3aac3b6e6391.jpg',
        name: '郭利军',
        skills: [
            Object
        ],
        careers: [
            Object
        ]
    }
}receiver: {
    _id: '55516ed14522f7917465e4da',
    avatar: 'http: //192.168.1.9: 3000/public/upload/05bf686c17b14f2248fb3aac3b6e6391.jpg',
    name: '郭利军',
    skills: [
        Object
    ],
    careers: [
        Object
    ]
}
}
}

or
{ code: 4, msg: '' }

8. post /api/v1/getOrder 获取订单列表

接收 post 参数 以下参数均为选填

accesstoken 用户密令
type 订单类型 'deal', 'recharge','withdrawals' 三选一 分别对应交易,充值 提现
status 订单状态 '未支付', '已付款','已完成', '退款申请中', '退款成功', '提现申请中', '提现成功' 选一
uid 订单付款人id 
receiverId 订单收款人id 
pageNo  页码
pageSize 每页大小

返回值示例

{
success: true,
orders: [
    {
        _id: '5552c3b95bab4495037e007c',
        type: 'deal',
        status: '退款成功',
        receiverId: '5551cc99cdaf45a115049bcf',
        userId: '55370ecc30b55c7805829b33',
        amount: 100,
        orderNo: '2356a902f3be2d02',
        channel: 'wallet',
        pingChargeId: '',
        subject: '购买xx服务',
        __v: 0,
        refundReason: 'tobad!!!',
        create_at: '2015-05-13T03: 23: 37.684Z',
        user: 'xx',
        receiver: {
            _id: '55516ed14522f7917465e4da',
            avatar_url: 'http: //192.168.1.9: 3000/public/upload/05bf686c17b14f2248fb3aac3b6e6391.jpg',
            name: '郭利军',
            skills: [
                Object
            ],
            careers: [
                Object
            ]
        }
    }
]
}

or
{"success":false , msg: ""}

9. post /api/v1/applyRefund 申请退款

接收 post 参数

reason 退款理由
accesstoken
oid 订单id 可从上一个方法返回的order字段获取

返回值示例

{"success": true,}  

or
{"error":'the pwd is wrong'}

10. post /api/v1/getCash 获取用户钱包信息

接收 post 参数

uid 用户id
accessToken 用户密令

返回值示例

{ success: true,

info: { _id: '55370ecc30b55c7805829b44', withdrawCash: 503, cash: 600 } }

//withdrawCash 可提现现金 cash 现金 or

{ code: 4, msg: '' }

11. post /api/v1/confirmPass 验证登录密码

接收 post 参数

uid 用户id
pass 密码

返回值示例

{"success": true}

or { code: 4, msg: '' }

12. post /api/v1/shouldCreateNewTalk 是否创建新对话

接收 post 参数

userId 买家id
receiverId 卖家id
skillId 技能id

返回值示例

{"success":true,chatId:0,oid:33}  chatId 为0即表示未找到对话 否则为已付款但不足24小时或未手动关闭的对话id
如果chatId不为0 即订单id也会返回

or
{ code: 4, msg: '' }

13. post /api/v1/shouldContinueTalk 是否可以继续聊天

接收 post 参数

chatId  聊天id

返回值示例

{"success":true,should:true, payTime:2015-05-13T03:23:37.684Z} should字段即代表可以或否,payTime为支付时间                 加24小时即为到期时间

or { code: 4, msg: '' }

14. post /api/v1/comment 评价订单

接收 post 参数

accesstoken 
oid 订单id
score 分数
comment 评价内容

返回值示例

{"success":true}

or { code: 4, msg: '' }