Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add purchase request logging API #210

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions iap/api/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from googleapiclient.errors import HttpError
from sqlalchemy import select
from sqlalchemy.orm import joinedload
from starlette.responses import JSONResponse

from common.enums import ReceiptStatus, Store, GooglePurchaseState
from common.models.product import Product
Expand Down Expand Up @@ -95,6 +96,21 @@ def raise_error(sess, receipt: Receipt, e: Exception):
raise e


@router.get("/log")
def log_request_product(planet_id: str, agent_address: str, avatar_address: str, product_id: str,
order_id: Optional[str] = "", data: Optional[str] = ""):
"""
# Purchase log
---

Logs purchase request data
"""
logger.info(f"[PURCHASE_LOG] {planet_id} :: {agent_address} :: {avatar_address} :: {product_id} :: {order_id}")
if data:
logger.info(data)
return JSONResponse(status_code=200, content=f"Order {order_id} for product {product_id} logged.")


@router.post("/request", response_model=ReceiptDetailSchema)
def request_product(receipt_data: ReceiptSchema, sess=Depends(session)):
"""
Expand Down