Add basic flow for ProductOrder

This commit is contained in:
PCoder 2019-09-14 13:33:23 +05:30
parent c83c7720b3
commit fefc1947e2

View file

@ -215,9 +215,36 @@ class UserRegisterPayment(Resource):
return {"message": "Missing or wrong parameters"}, 400
class ProductOrder(Resource):
@staticmethod
def post():
data = request.json
try:
otp_response = check_otp(data["name"], data["realm"],
data["token"])
if otp_response != 200:
return {"message": "Wrong Credentials"}, 403
# Validate the given product is ok
# Check the user has a payment source added
# Initiate a one-time/subscription based on product type
# If charge successful, create an order object
# Else handle unsuccessful cases with grace
except KeyError as key_error:
logging.error("Key error occurred")
logging.error(str(key_error))
return {"message": "Missing or wrong parameters"}, 400
api.add_resource(ListProducts, "/product/list")
api.add_resource(AddProduct, "/product/add")
api.add_resource(ProductOrder, "/product/order")
api.add_resource(UserRegisterPayment, "/user/register_payment")
if __name__ == '__main__':
app.run(host="::", port=APP_PORT, debug=True)