def open_pay(id): if 'plan' not in request.args: abort(400, {'message': PLAN_INVALID_OR_NOT_PROVIDED }) lead = _get_lead(int(id)) plan = Plan.find_by_slug(request.args['plan']) payment = Payment.find_last(lead.key, plan.key) if payment is not None: return jsonify(data=payment.to_json()), 200 else: abort(404, {'message': 'Payment not found'})