Skip to content

Commit

Permalink
Snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
clr-li committed Dec 30, 2023
1 parent 549d99f commit 06944cc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions routers/paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
router = APIRouter()


def generateAccessToken():
def generate_access_token():
"""
Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs.
@see https://developer.paypal.com/api/rest/authentication/
Expand All @@ -41,10 +41,10 @@ def generateAccessToken():

# Create an order to start the transaction.
# @see https://developer.paypal.com/docs/api/orders/v2/#orders_create
def createOrder(payload: dict, uid: str):
def create_order(payload: dict, uid: str):
# use the cart information passed from the front-end to calculate the purchase unit details

accessToken = generateAccessToken()
accessToken = generate_access_token()
url = str(furl(settings.PAYPAL_BASE) / "v2/checkout/orders")
payload = {
"intent": "CAPTURE",
Expand Down Expand Up @@ -78,8 +78,8 @@ def createOrder(payload: dict, uid: str):

# Capture payment for the created order to complete the transaction.
# @see https://developer.paypal.com/docs/api/orders/v2/#orders_capture
def captureOrder(orderID: str):
accessToken = generateAccessToken()
def capture_order(orderID: str):
accessToken = generate_access_token()
url = str(furl(settings.PAYPAL_BASE) / f"v2/checkout/orders/{orderID}/capture")

response = requests.post(
Expand All @@ -105,13 +105,13 @@ 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)
jsonResponse, httpStatusCode = createOrder(payload, uid)
jsonResponse, httpStatusCode = create_order(payload, uid)
return JSONResponse(jsonResponse, httpStatusCode)


@router.post("/__/paypal/orders/{orderID}/capture")
def capture(req: Request, orderID: str):
jsonResponse, httpStatusCode = captureOrder(orderID)
jsonResponse, httpStatusCode = capture_order(orderID)
return JSONResponse(jsonResponse, httpStatusCode)


Expand All @@ -124,7 +124,7 @@ def create_payment(request: Request):
@router.post("/__/paypal/webhook", status_code=200)
def create_webhook(request: Request, _payload: bytes = Depends(request_body)):
# Verify
accessToken = generateAccessToken()
accessToken = generate_access_token()
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {accessToken}",
Expand Down

0 comments on commit 06944cc

Please sign in to comment.