Implement validate product

This commit is contained in:
PCoder 2019-09-14 13:39:30 +05:30
parent 77dd6cb14e
commit a7ba9669f8
1 changed files with 9 additions and 0 deletions

View File

@ -226,6 +226,15 @@ class ProductOrder(Resource):
return {"message": "Wrong Credentials"}, 403
# Validate the given product is ok
product_id = data["product_id"]
product = client.get_prefix(
"/v1/products/{}/".format(product_id), value_in_json=True
)
if not product:
logging.debug("User chose invalid product {}".format(product))
return {"message": "Invalid product"}, 400
logging.debug("Got product {}".format(str(product)))
# Check the user has a payment source added