     }
     
     return (orderList, count)
+}
+/// 支付信息JSON解析器
+let parseChargeToken: JSONDictionary -> JSONDictionary? = { chargeInfo in
+    
+    // 支付信息获取失败（课程被占用）
+    if let
+        result = chargeInfo["ok"] as? Bool,
+        errorCode = chargeInfo["code"] as? Int
+       where
+        !result {
+        return nil
+    }
+    
+    // 支付信息获取成功
+    return chargeInfo
 }
///  - parameter orderID:        订单id
///  - parameter failureHandler: 失败处理闭包
///  - parameter completion:     成功处理闭包
func getChargeTokenWithChannel(channel: MalaPaymentChannel, orderID: Int, failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) {
    let requestParameters = [
        "action": PaymentMethod.Pay.rawValue,
        "channel": channel.rawValue
    ]
    
    let parse: JSONDictionary -> JSONDictionary = { data in
        return data
    }
    
    let resource = authJsonResource(path: "/orders/\(orderID)", method: .PATCH, requestParameters: requestParameters, parse: parse)

    
    // 订单创建成功
    if let
        id          = orderInfo["id"] as? Int,
        teacher     = orderInfo["teacher"] as? Int,
        teacherName = orderInfo["teacher_name"] as? String,
        avatar      = orderInfo["teacher_avatar"] as? String,
        school      = orderInfo["school"] as? String,
        grade       = orderInfo["grade"] as? String,
        subject     = orderInfo["subject"] as? String,
        hours       = orderInfo["hours"] as? Int,
        status      = orderInfo["status"] as? String,
        orderId     = orderInfo["order_id"] as? String,
        amount      = orderInfo["to_pay"] as? Int,
        evaluated   = orderInfo["evaluated"] as? Bool {
        return OrderForm(id: id, orderId: orderId, teacherId: teacher, teacherName: teacherName, avatarURL: avatar, schoolName: school, gradeName: grade, subjectName: subject, orderStatus: status, amount: amount, evaluated: evaluated)
    }
    return nil
}
