Skip to content

Commit

Permalink
Payment types added
Browse files Browse the repository at this point in the history
  • Loading branch information
clr-li committed Dec 27, 2023
1 parent 4471151 commit 8cab5af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app_users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def add_balance(self, amount: int, invoice_id: str) -> "AppUserTransaction":
"""
# if an invoice entry exists
try:
if len(invoice_id) > 17:
if "-" in invoice_id and "_" not in invoice_id:
type = "Paypal"
else:
type = "Stripe"
# avoid updating twice for same invoice
return AppUserTransaction.objects.get(invoice_id=invoice_id)
# avoid updating twice for same invoice
return AppUserTransaction.objects.get(invoice_id=invoice_id)
except AppUserTransaction.DoesNotExist:
type = "SavedRun"
pass
Expand Down
10 changes: 1 addition & 9 deletions routers/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import requests
from fastapi import APIRouter, Depends
from fastapi.requests import Request
from fastapi.responses import RedirectResponse, JSONResponse, HTMLResponse
from fastapi.responses import JSONResponse
from furl import furl
from starlette.datastructures import FormData
from sentry_sdk import capture_exception
import json

Expand Down Expand Up @@ -44,10 +43,6 @@ def generateAccessToken():
# @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
def createOrder(payload: dict, uid: str):
# use the cart information passed from the front-end to calculate the purchase unit details
print(
"shopping cart information passed from the frontend createOrder() callback:",
payload,
)

accessToken = generateAccessToken()
url = f"{settings.PAYPAL_BASE}/v2/checkout/orders"
Expand Down Expand Up @@ -114,9 +109,6 @@ async def request_body(request: Request):
def orders(req: Request, uid: str, _payload: bytes = Depends(request_body)):
# use the cart information passed from the front-end to calculate the order amount detals
payload: dict = json.loads(_payload)
print(
"shopping cart information passed from the frontend orders() callback:", payload
)
jsonResponse, httpStatusCode = createOrder(payload, uid)
return JSONResponse(jsonResponse, httpStatusCode)

Expand Down

0 comments on commit 8cab5af

Please sign in to comment.