(20241218) Getting full individual payment records is now possible.

This commit is contained in:
2024-12-18 09:59:14 +05:30
parent bfe7b1a78b
commit 85cc330711
7 changed files with 360 additions and 60 deletions
+1 -39
View File
@@ -228,45 +228,12 @@ class CorePaymentController(BaseModel):
async def get_payment(
self,
mongo_conn: AsyncMongo,
token_id: ObjectId | str,
payment_id: ObjectId | str,
) -> CorePaymentModel | None:
"""
Gets one payment detail if you know its payment id.
:param mongo_conn: The instance of the database connector to use for the operation.
:param token_id: The id of the auth-token associated with the payment. Needed for security.
:param payment_id: The id of the payment detail that needs to be read.
:return: The contents of that one payment detail in a structured format.
"""
# We fetch the whole payload of that one message:
record = await mongo_conn.find_one(
collection = self.PAYMENTS_COLLECTION,
filter = {
"_id": ObjectId(payment_id),
"tokenId": ObjectId(token_id)
},
raise_exception = True
)
# If no such message was found:
if record is None: return None
# If a record was found,
# we return it as our data model:
return CorePaymentModel(**record)
async def get_payment_internal(
self,
mongo_conn: AsyncMongo,
payment_id: ObjectId | str,
) -> CorePaymentModel | None:
"""
NOTE: DO NOT USE THIS IN USER-FACING APIS. USE THIS INTERNALLY TO FETCH RECORDS.
Gets one payment detail if you know its payment id.
:param mongo_conn: The instance of the database connector to use for the operation.
:param payment_id: The id of the payment detail that needs to be read.
:return: The contents of that one payment detail in a structured format.
"""
@@ -374,7 +341,6 @@ class CorePaymentController(BaseModel):
async def update_tags(
self,
mongo_conn: AsyncMongo,
token_id: ObjectId | str,
payment_id: ObjectId | str,
unset_tags: List[str] = None,
set_tags: List[str] = None
@@ -383,7 +349,6 @@ class CorePaymentController(BaseModel):
"""
Updates the tags on one payment. The tags to remove are processed first, the ones to add are processed later.
:param mongo_conn: The instance of the database connector to use for the operation.
:param token_id: The id of the auth-token associated with the payment. Needed for security.
:param payment_id: The id of the payment detail that needs to be read.
:param unset_tags: The tags to remove from the payment record.
:param set_tags: The tags to add to the payment record.
@@ -393,10 +358,7 @@ class CorePaymentController(BaseModel):
# Update the tags:
return await mongo_conn.update_one(
collection = self.PAYMENTS_COLLECTION,
filter = {
"_id": ObjectId(payment_id),
"tokenId": ObjectId(token_id)
},
filter = {"_id": ObjectId(payment_id)},
update = [{
"$set": {
"tags": {