Getting database error while using django-paypal
Im using Mongodb (djongo engine) for the database for my django project, I can't work out I always get this error when paypal posts to my website:
[13/Dec/2021 15:59:44] "POST /paypal/ HTTP/1.1" 500 28196
Internal Server Error: /paypal/
Traceback (most recent call last):
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 857, in parse
return handler(self, statement)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 933, in _select
return SelectQuery(self.db, self.connection_properties, sm, self._params)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 116, in __init__
super().__init__(*args)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 62, in __init__
self.parse()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 152, in parse
self.where = WhereConverter(self, statement)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\converters.py", line 27, in __init__
self.parse()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\converters.py", line 119, in parse
self.op = WhereOp(
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 475, in __init__
self._statement2ops()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 428, in _statement2ops
op = self._token2op(tok, statement)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 405, in _token2op
op = ParenthesisOp(SQLStatement(tok), self.query)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 493, in __init__
self._statement2ops()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 428, in _statement2ops
op = self._token2op(tok, statement)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 405, in _token2op
op = ParenthesisOp(SQLStatement(tok), self.query)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 493, in __init__
self._statement2ops()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\operators.py", line 438, in _statement2ops
if prev_op.lhs is None:
AttributeError: 'NoneType' object has no attribute 'lhs'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 784, in __init__
self._query = self.parse()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 885, in parse
raise exe from e
djongo.exceptions.SQLDecodeError:
Keyword: None
Sub SQL: None
FAILED SQL: SELECT "paypal_ipn"."id", "paypal_ipn"."business", "paypal_ipn"."charset", "paypal_ipn"."custom", "paypal_ipn"."notify_version", "paypal_ipn"."parent_txn_id", "paypal_ipn"."receiver_email", "paypal_ipn"."receiver_id", "paypal_ipn"."residence_country", "paypal_ipn"."test_ipn", "paypal_ipn"."txn_id", "paypal_ipn"."txn_type", "paypal_ipn"."verify_sign", "paypal_ipn"."address_country", "paypal_ipn"."address_city", "paypal_ipn"."address_country_code", "paypal_ipn"."address_name", "paypal_ipn"."address_state", "paypal_ipn"."address_status", "paypal_ipn"."address_street", "paypal_ipn"."address_zip", "paypal_ipn"."contact_phone", "paypal_ipn"."first_name", "paypal_ipn"."last_name", "paypal_ipn"."payer_business_name", "paypal_ipn"."payer_email", "paypal_ipn"."payer_id", "paypal_ipn"."auth_amount", "paypal_ipn"."auth_exp", "paypal_ipn"."auth_id", "paypal_ipn"."auth_status", "paypal_ipn"."exchange_rate", "paypal_ipn"."invoice", "paypal_ipn"."item_name", "paypal_ipn"."item_number", "paypal_ipn"."mc_currency", "paypal_ipn"."mc_fee", "paypal_ipn"."mc_gross", "paypal_ipn"."mc_handling", "paypal_ipn"."mc_shipping", "paypal_ipn"."memo", "paypal_ipn"."num_cart_items", "paypal_ipn"."option_name1", "paypal_ipn"."option_name2", "paypal_ipn"."option_selection1", "paypal_ipn"."option_selection2", "paypal_ipn"."payer_status", "paypal_ipn"."payment_date", "paypal_ipn"."payment_gross", "paypal_ipn"."payment_status", "paypal_ipn"."payment_type", "paypal_ipn"."pending_reason", "paypal_ipn"."protection_eligibility", "paypal_ipn"."quantity", "paypal_ipn"."reason_code", "paypal_ipn"."remaining_settle", "paypal_ipn"."settle_amount", "paypal_ipn"."settle_currency", "paypal_ipn"."shipping", "paypal_ipn"."shipping_method", "paypal_ipn"."tax", "paypal_ipn"."transaction_entity", "paypal_ipn"."auction_buyer_id", "paypal_ipn"."auction_closing_date", "paypal_ipn"."auction_multi_item", "paypal_ipn"."for_auction", "paypal_ipn"."amount", "paypal_ipn"."amount_per_cycle", "paypal_ipn"."initial_payment_amount", "paypal_ipn"."next_payment_date", "paypal_ipn"."outstanding_balance", "paypal_ipn"."payment_cycle", "paypal_ipn"."period_type", "paypal_ipn"."product_name", "paypal_ipn"."product_type", "paypal_ipn"."profile_status", "paypal_ipn"."recurring_payment_id", "paypal_ipn"."rp_invoice_id", "paypal_ipn"."time_created", "paypal_ipn"."amount1", "paypal_ipn"."amount2", "paypal_ipn"."amount3", "paypal_ipn"."mc_amount1", "paypal_ipn"."mc_amount2", "paypal_ipn"."mc_amount3", "paypal_ipn"."password", "paypal_ipn"."period1", "paypal_ipn"."period2", "paypal_ipn"."period3", "paypal_ipn"."reattempt", "paypal_ipn"."recur_times", "paypal_ipn"."recurring", "paypal_ipn"."retry_at", "paypal_ipn"."subscr_date", "paypal_ipn"."subscr_effective", "paypal_ipn"."subscr_id", "paypal_ipn"."username", "paypal_ipn"."mp_id", "paypal_ipn"."case_creation_date", "paypal_ipn"."case_id", "paypal_ipn"."case_type", "paypal_ipn"."receipt_id", "paypal_ipn"."currency_code", "paypal_ipn"."handling_amount", "paypal_ipn"."transaction_subject", "paypal_ipn"."ipaddress", "paypal_ipn"."flag", "paypal_ipn"."flag_code", "paypal_ipn"."flag_info", "paypal_ipn"."query", "paypal_ipn"."response", "paypal_ipn"."created_at", "paypal_ipn"."updated_at", "paypal_ipn"."from_view" FROM "paypal_ipn" WHERE ("paypal_ipn"."txn_id" = %(0)s AND NOT ("paypal_ipn"."id" IS NULL) AND NOT ("paypal_ipn"."flag")) ORDER BY "paypal_ipn"."created_at" DESC LIMIT 1
Params: ('5JV347551H953243B',)
Version: 1.3.6
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\views\decorators\http.py", line 40, in inner
return func(request, *args, **kwargs)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\paypal\standard\ipn\views.py", line 101, in ipn
ipn_obj.verify()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\paypal\standard\models.py", line 362, in verify
if duplicate_txn_id(self):
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\paypal\standard\helpers.py", line 34, in duplicate_txn_id
if len(similars) > 0:
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\models\query.py", line 262, in __len__
self._fetch_all()
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\models\query.py", line 1324, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\models\query.py", line 51, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\models\sql\compiler.py", line 1175, in execute_sql
cursor.execute(sql, params)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\backends\utils.py", line 98, in execute
return super().execute(sql, params)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\backends\utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\backends\utils.py", line 79, in _execute
with self.db.wrap_database_errors:
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\utils.py",
line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\user\Documents\Building systems\VintageWebsite\.venv\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
django.db.utils.DatabaseError
Any ideas how I can fix this, it happens when I try to migrate as well a note my ipn signals are also not firing but paypal can succesfully redirect to my payment failed or payment successful pages