def foxyfeed(request): if request.POST and 'FoxyData' in request.POST: try: # IMPORTANT: unquote_plus is necessary for the non-ASCII binary that # FoxyCart sends. data = FoxyData.from_crypted_str(urllib.unquote_plus(request.POST['FoxyData']), settings.FOXYCART_DATAFEED_KEY) for transaction in data.transactions: # Your code goes here # Make sure we don't have a duplicate transaction id # Verify the pricing of the products # Add the order to the database pass return HttpResponse('foxy') except Exception, e: # Something went wrong, handle the error... raise
def foxyfeed(request): """ This is what will get hit whenever someone creates an account, foxycart is hitting this from a webhook, we need to create a new user in our system. We look at customer id, email, hash, and verify correct product was bought. """ if request.POST and "FoxyData" in request.POST: try: # IMPORTANT: unquote_plus is necessary for the non-ASCII binary that # FoxyCart sends. data = FoxyData.from_crypted_str( urllib.unquote_plus(request.POST["FoxyData"]), settings.FOXYCART_DATAFEED_KEY ) for transaction in data.transactions: new_user = User.objects.create_user(transaction.customer_email, transaction.customer_email) new_user.password = "******".format( algorithm="sha1", salt=transaction.customer_password_salt, password_hash=transaction.customer_password, ) new_user.save() logger = logging.getLogger("foxycart") logger.error(transaction.customer_password_salt) logger.error(transaction.customer_password) new_review_user = review_app.models.ReviewUser() new_review_user.user = new_user new_review_user.customer_id = transaction.customer_id new_review_user.save() # Your code goes here # Make sure we don't have a duplicate transaction id # Verify the pricing of the products # Add the order to the database pass return HttpResponse("foxy") except Exception, e: # Something went wrong, handle the error... raise