Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,15 @@
|
|
| 1 |
# app.py
|
| 2 |
|
| 3 |
-
# Import necessary libraries
|
| 4 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import requests
|
| 6 |
import base64
|
| 7 |
import uuid
|
|
@@ -27,23 +35,21 @@ from oauthlib.oauth1 import Client # For MasterCard OAuth1
|
|
| 27 |
import json
|
| 28 |
|
| 29 |
# Optional imports for barcode scanning
|
|
|
|
| 30 |
try:
|
| 31 |
import cv2
|
| 32 |
from pyzbar import pyzbar
|
| 33 |
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
|
| 34 |
except ImportError:
|
| 35 |
-
st.warning("OpenCV and pyzbar are not available. Barcode scanning will be disabled.")
|
| 36 |
cv2 = None
|
| 37 |
pyzbar = None
|
| 38 |
webrtc_streamer = None
|
| 39 |
VideoTransformerBase = object
|
|
|
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
page_icon="💳",
|
| 45 |
-
layout="wide",
|
| 46 |
-
)
|
| 47 |
|
| 48 |
# Load environment variables securely
|
| 49 |
def load_env_vars():
|
|
@@ -100,7 +106,7 @@ else:
|
|
| 100 |
huggingface_token = HfFolder.get_token()
|
| 101 |
|
| 102 |
# Initialize Plaid client if credentials are provided
|
| 103 |
-
if
|
| 104 |
from plaid.api import plaid_api
|
| 105 |
from plaid.model import *
|
| 106 |
from plaid.api_client import ApiClient
|
|
@@ -173,7 +179,7 @@ else:
|
|
| 173 |
if service_choice == "In-Store Scanner & Payment":
|
| 174 |
st.header("In-Store Item Scanner and Payment")
|
| 175 |
|
| 176 |
-
if
|
| 177 |
# Mock database of items
|
| 178 |
ITEM_DATABASE = {
|
| 179 |
"123456789012": {"name": "Product A", "price": 9.99},
|
|
@@ -399,8 +405,8 @@ else:
|
|
| 399 |
# Plaid Services
|
| 400 |
elif service_choice == "Plaid Services":
|
| 401 |
st.header("Plaid Services")
|
| 402 |
-
if not
|
| 403 |
-
st.error("Plaid API credentials
|
| 404 |
else:
|
| 405 |
plaid_action = st.selectbox("Choose an Action", [
|
| 406 |
"Link Account",
|
|
@@ -784,6 +790,7 @@ else:
|
|
| 784 |
st.error(f"Error: {response.text}")
|
| 785 |
elif visa_action == "Initiate Payment":
|
| 786 |
st.subheader("Initiate a Payment")
|
|
|
|
| 787 |
st.info("Payment initiation with Visa API is not implemented in this example.")
|
| 788 |
|
| 789 |
# MasterCard Services
|
|
@@ -824,6 +831,7 @@ else:
|
|
| 824 |
st.error(f"Error: {response.text}")
|
| 825 |
elif mastercard_action == "Process Payment":
|
| 826 |
st.subheader("Process a Payment")
|
|
|
|
| 827 |
st.info("Payment processing with MasterCard API is not implemented in this example.")
|
| 828 |
|
| 829 |
# Pipedream Integration
|
|
@@ -939,4 +947,4 @@ else:
|
|
| 939 |
|
| 940 |
# Display footer
|
| 941 |
st.sidebar.markdown("Powered by Streamlit")
|
| 942 |
-
st.sidebar.markdown("Made by Citibank Demo Business Inc.")
|
|
|
|
| 1 |
# app.py
|
| 2 |
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
+
|
| 5 |
+
# Set page config
|
| 6 |
+
st.set_page_config(
|
| 7 |
+
page_title="TransactPro: The Ultimate Financial Platform",
|
| 8 |
+
page_icon="💳",
|
| 9 |
+
layout="wide",
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
# Import necessary libraries
|
| 13 |
import requests
|
| 14 |
import base64
|
| 15 |
import uuid
|
|
|
|
| 35 |
import json
|
| 36 |
|
| 37 |
# Optional imports for barcode scanning
|
| 38 |
+
barcode_scanning_available = True
|
| 39 |
try:
|
| 40 |
import cv2
|
| 41 |
from pyzbar import pyzbar
|
| 42 |
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
|
| 43 |
except ImportError:
|
|
|
|
| 44 |
cv2 = None
|
| 45 |
pyzbar = None
|
| 46 |
webrtc_streamer = None
|
| 47 |
VideoTransformerBase = object
|
| 48 |
+
barcode_scanning_available = False
|
| 49 |
|
| 50 |
+
# Now, after st.set_page_config(), you can use Streamlit commands
|
| 51 |
+
if not barcode_scanning_available:
|
| 52 |
+
st.warning("OpenCV and pyzbar are not available. Barcode scanning will be disabled.")
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# Load environment variables securely
|
| 55 |
def load_env_vars():
|
|
|
|
| 106 |
huggingface_token = HfFolder.get_token()
|
| 107 |
|
| 108 |
# Initialize Plaid client if credentials are provided
|
| 109 |
+
if get_env_var('PLAID_CLIENT_ID') and get_env_var('PLAID_SECRET'):
|
| 110 |
from plaid.api import plaid_api
|
| 111 |
from plaid.model import *
|
| 112 |
from plaid.api_client import ApiClient
|
|
|
|
| 179 |
if service_choice == "In-Store Scanner & Payment":
|
| 180 |
st.header("In-Store Item Scanner and Payment")
|
| 181 |
|
| 182 |
+
if barcode_scanning_available:
|
| 183 |
# Mock database of items
|
| 184 |
ITEM_DATABASE = {
|
| 185 |
"123456789012": {"name": "Product A", "price": 9.99},
|
|
|
|
| 405 |
# Plaid Services
|
| 406 |
elif service_choice == "Plaid Services":
|
| 407 |
st.header("Plaid Services")
|
| 408 |
+
if not plaid_client_id or not plaid_secret:
|
| 409 |
+
st.error("Please provide Plaid API credentials.")
|
| 410 |
else:
|
| 411 |
plaid_action = st.selectbox("Choose an Action", [
|
| 412 |
"Link Account",
|
|
|
|
| 790 |
st.error(f"Error: {response.text}")
|
| 791 |
elif visa_action == "Initiate Payment":
|
| 792 |
st.subheader("Initiate a Payment")
|
| 793 |
+
# Implement payment initiation with Visa API
|
| 794 |
st.info("Payment initiation with Visa API is not implemented in this example.")
|
| 795 |
|
| 796 |
# MasterCard Services
|
|
|
|
| 831 |
st.error(f"Error: {response.text}")
|
| 832 |
elif mastercard_action == "Process Payment":
|
| 833 |
st.subheader("Process a Payment")
|
| 834 |
+
# Implement payment processing with MasterCard API
|
| 835 |
st.info("Payment processing with MasterCard API is not implemented in this example.")
|
| 836 |
|
| 837 |
# Pipedream Integration
|
|
|
|
| 947 |
|
| 948 |
# Display footer
|
| 949 |
st.sidebar.markdown("Powered by Streamlit")
|
| 950 |
+
st.sidebar.markdown("Made by Citibank Demo Business Inc.")
|