(20250811) - Added RazorPay Integration class with auth api and requires validations and many more.

This commit is contained in:
yatmesh
2025-08-11 14:19:24 +05:30
parent 1732e12adf
commit ddc29a7fe1
9 changed files with 723 additions and 7 deletions
@@ -162,6 +162,7 @@ async def authorize_payment_gateway(
# Start by assuming failure:
success = False
message = ""
# ┏┓ ┏ • ┳┳┓ ┏┓ ┏┓
# ┗┓┏┓╋┏┓┏┓┓┏┏┓┏┳┓ ┃┃┃━━┃┃┏┓┏┏┓ ┣ ┓┏┏┓┏┓┏┓┏┏
@@ -191,6 +192,31 @@ async def authorize_payment_gateway(
session_token = inbound_headers["X-Session-Token"]
)
if inbound_data.client == "razorpay":
# Make the client controller test and save the auth:
response = await current_app.razorPay_controller.save_auth(
sql_conn=current_app.sql_writer,
mongo_data_conn=current_app.data_mongo,
auth=inbound_data.auth,
user=kwargs.get("session_info"),
session_token=inbound_headers.get("X-Session-Token")
)
# Note down the results:
success = response.success
message = response.message
token_id = response.token_id
auth_url_success = ""
auth_url_failed = ""
if token_id is not None:
auth_url_success = f"https://api.thecaoffice.com/shopify/razorpay/auth/template?status=1&token={token_id}&razorPayKeyId={inbound_data.auth.razorPayKeyId}&razorPayKeyId={inbound_data.auth.razorPayKeySecret}"
# auth_url_success = f"http://192.168.2.99:5220/shopify/razorpay/auth/template?status=1&token={token_id}&razorPayKeyId={inbound_data.auth.razorPayKeyId}&razorPayKeyId={inbound_data.auth.razorPayKeySecret}"
else:
auth_url_failed = f"https://api.thecaoffice.com/shopify/razorpay/auth/template?status=0&razorPayKeyId={inbound_data.auth.razorPayKeyId}&razorPayKeyId={inbound_data.auth.razorPayKeySecret}"
# auth_url_failed = f"http://192.168.2.99:5220/shopify/razorpay/auth/template?status=0&razorPayKeyId={inbound_data.auth.razorPayKeyId}&razorPayKeyId={inbound_data.auth.razorPayKeySecret}"
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
# ┛┗┗ ┛┣┛┗┛┛┗┛┗
@@ -198,11 +224,13 @@ async def authorize_payment_gateway(
# Done here:
return ResponseModel(
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
data = {
status_code=StatusCodes.OK if success else StatusCodes.FAILED,
http_code=HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
message=message,
data={
"client": inbound_data.client,
"authorized": success
"authorized": success,
"authorizationUrl": auth_url_success if success else auth_url_failed
}
)