diff --git a/.env b/.env index 31b5a46..7338549 100644 --- a/.env +++ b/.env @@ -45,6 +45,15 @@ MAIL_USERNAME=message@chiefsoft.com MAIL_PASSWORD=may12002! JWT_SECRET_KEY=dce6bd64f7d7101de4fed7cfc185a12851611a79bd60bbfdcc5b414b85f1fdb75e0905691c2a77ce94a7351b261fab4e183e17731ed40089f68f7290a793119f285d8ec7902d248ce15e8b1d4996ebacf5e7bcb06a38ac7ce0736f17d5c2895a499661d27095ac20aa174f9af2fba9a849dd2e6fd0aad8aa7e1ecc030c11eb8dc8dcb71d32233de3530d04f85918b9582f8b02587a7350aa34232825d4831707c7c5775026f3fdd92c5df555e6ff8b785525922709830206bbd49c371fb6e16bcab01ffccaf904108bb9789c578bce6afbb33bc77960051e680b2428d1f026473e71ef0f9997b2a6dc496e1c40509a1d289e3ff8b384c2d49e1d7719f9f4aaa1 + +#Publishable key +STRIPE_PUB_KEY="pk_test_51RqL5WLjZLojw6IZmEpwFidNZSl9lLlVUHNvuFZNEz1eTR9XXepnyyVhfvXe9cp4eMnqkDPpoe9wxLLRSV0dxRee00UfhayUOT" +#Secret key +STRIPE_PRIV_KEY="sk_test_51RqL5WLjZLojw6IZZa921BftQWmxZ4JDxrHUrFZvc5kwJhxtK3ijZguUw42c4Rl5yjmpkdYlbpslDOaMGtOSrsL100oaN72Lne" + + + + # APP_PORT=14700 # FLASK_APP=project/__init__.py # FLASK_DEBUG=1 diff --git a/.env.live b/.env.live index 338b9c6..f82a879 100644 --- a/.env.live +++ b/.env.live @@ -25,6 +25,12 @@ DATABASE_NAME=merms_panel KAFKA_BROKER = 'dev-events.simbrellang.net:9085' +#Publishable key +STRIPE_PUB_KEY="pk_test_51RqL5WLjZLojw6IZmEpwFidNZSl9lLlVUHNvuFZNEz1eTR9XXepnyyVhfvXe9cp4eMnqkDPpoe9wxLLRSV0dxRee00UfhayUOT" +#Secret key +STRIPE_PRIV_KEY="sk_test_51RqL5WLjZLojw6IZZa921BftQWmxZ4JDxrHUrFZvc5kwJhxtK3ijZguUw42c4Rl5yjmpkdYlbpslDOaMGtOSrsL100oaN72Lne" + + # DATABASE_HOST=10.20.30.60 # DATABASE_USER=firstadvance # DATABASE_PASSWORD=firstadvance diff --git a/.env.local.example b/.env.local.example index 3521430..aca0479 100644 --- a/.env.local.example +++ b/.env.local.example @@ -33,3 +33,10 @@ VALID_API_KEY=test-api-key-12345 # Event Bus Broker Configuration KAFKA_BROKER="10.0.0.246:9092" + + +#Publishable key +STRIPE_PUB_KEY="pk_test_51RqL5WLjZLojw6IZmEpwFidNZSl9lLlVUHNvuFZNEz1eTR9XXepnyyVhfvXe9cp4eMnqkDPpoe9wxLLRSV0dxRee00UfhayUOT" +#Secret key +STRIPE_PRIV_KEY="sk_test_51RqL5WLjZLojw6IZZa921BftQWmxZ4JDxrHUrFZvc5kwJhxtK3ijZguUw42c4Rl5yjmpkdYlbpslDOaMGtOSrsL100oaN72Lne" + diff --git a/.env.qa b/.env.qa index 0d7a128..dcc33e9 100644 --- a/.env.qa +++ b/.env.qa @@ -45,6 +45,12 @@ MAIL_USERNAME=message@chiefsoft.com MAIL_PASSWORD=may12002! JWT_SECRET_KEY=dce6bd64f7d7101de4fed7cfc185a12851611a79bd60bbfdcc5b414b85f1fdb75e0905691c2a77ce94a7351b261fab4e183e17731ed40089f68f7290a793119f285d8ec7902d248ce15e8b1d4996ebacf5e7bcb06a38ac7ce0736f17d5c2895a499661d27095ac20aa174f9af2fba9a849dd2e6fd0aad8aa7e1ecc030c11eb8dc8dcb71d32233de3530d04f85918b9582f8b02587a7350aa34232825d4831707c7c5775026f3fdd92c5df555e6ff8b785525922709830206bbd49c371fb6e16bcab01ffccaf904108bb9789c578bce6afbb33bc77960051e680b2428d1f026473e71ef0f9997b2a6dc496e1c40509a1d289e3ff8b384c2d49e1d7719f9f4aaa1 +#Publishable key +STRIPE_PUB_KEY="pk_test_51RqL5WLjZLojw6IZmEpwFidNZSl9lLlVUHNvuFZNEz1eTR9XXepnyyVhfvXe9cp4eMnqkDPpoe9wxLLRSV0dxRee00UfhayUOT" +#Secret key +STRIPE_PRIV_KEY="sk_test_51RqL5WLjZLojw6IZZa921BftQWmxZ4JDxrHUrFZvc5kwJhxtK3ijZguUw42c4Rl5yjmpkdYlbpslDOaMGtOSrsL100oaN72Lne" + + # APP_PORT=14700 # FLASK_APP=project/__init__.py # FLASK_DEBUG=1 diff --git a/.example.env b/.example.env index 47a154c..f71cb0b 100644 --- a/.example.env +++ b/.example.env @@ -22,5 +22,10 @@ DATABASE_NAME=***** FLASK_APP=wsgi.py FLASK_ENV=development APP_PORT=4500 +#Publishable key +STRIPE_PUB_KEY="pk_test_51RqL5WLjZLojw6IZmEpwFidNZSl9lLlVUHNvuFZNEz1eTR9XXepnyyVhfvXe9cp4eMnqkDPpoe9wxLLRSV0dxRee00UfhayUOT" +#Secret key +STRIPE_PRIV_KEY="sk_test_51RqL5WLjZLojw6IZZa921BftQWmxZ4JDxrHUrFZvc5kwJhxtK3ijZguUw42c4Rl5yjmpkdYlbpslDOaMGtOSrsL100oaN72Lne" + SIMBRELLA_BASE_URL=*************** \ No newline at end of file diff --git a/app/api/integrations/merms_stripe.py b/app/api/integrations/merms_stripe.py new file mode 100644 index 0000000..578f6ae --- /dev/null +++ b/app/api/integrations/merms_stripe.py @@ -0,0 +1,38 @@ +import stripe +import json +import logging +from app.config import settings + +logger = logging.getLogger(__name__) + +stripe.api_key = settings.STRIPE_PRIV_KEY + +class StripeIntegration: + + def create_customer(self, data): + customer = stripe.Customer.create( + email="customer@example.com", + description="Customer for subscription", + payment_method="pm_card_visa", # Replace with a valid payment method ID or attach one later + invoice_settings={"default_payment_method": "pm_card_visa"}, + ) + + def create_product(self, data): + # Example of creating a Product and Price + product = stripe.Product.create(name="Premium Plan") + price = stripe.Price.create( + unit_amount=1000, # Amount in cents (e.g., $10.00) + currency="usd", + recurring={"interval": "month"}, + product=product.id, + ) + + def create_subscription(self, data): + subscription = stripe.Subscription.create( + customer='customer.id', + items=[ + {"price": 'price.id'}, + ], + payment_behavior="default_incomplete", # Recommended for handling initial payment + expand=["latest_invoice.payment_intent"], # To get details for payment confirmation + ) \ No newline at end of file diff --git a/app/config.py b/app/config.py index d7209cf..c40e2fa 100644 --- a/app/config.py +++ b/app/config.py @@ -85,6 +85,9 @@ class Config: ] + STRIPE_PRIV_KEY = os.getenv("STRIPE_PRIV_KEY", "WRONG_KEY_SUPPLIED") + + settings = Config() diff --git a/requirements.txt b/requirements.txt index fdcfee1..5f666a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -42,3 +42,5 @@ python-dateutil Flask-Mail pycountry + +stripe