payment_data

This commit is contained in:
CHIEFSOFT\ameye
2025-08-30 05:33:14 -04:00
parent a2c84b7b5c
commit 6c9f7666e0
+13 -14
View File
@@ -12,7 +12,6 @@ from app.api.integrations import StripeIntegration
import json import json
class SubscriptionsService(BaseService): class SubscriptionsService(BaseService):
# def get_all_subscriptions(cls, product_id=None, member_id=None, page=1, limit=20): # def get_all_subscriptions(cls, product_id=None, member_id=None, page=1, limit=20):
@staticmethod @staticmethod
@@ -100,8 +99,8 @@ class SubscriptionsService(BaseService):
price_create_result = StripeIntegration.create_product(t.display_name, t.monthly) price_create_result = StripeIntegration.create_product(t.display_name, t.monthly)
logger.info(f"Inside Stripe_Product ===== : {price_create_result}") logger.info(f"Inside Stripe_Product ===== : {price_create_result}")
if price_create_result: if price_create_result:
SubscriptionOptions.set_stripe_product_id(t.uid,price_create_result['product_id']) SubscriptionOptions.set_stripe_product_id(t.uid, price_create_result['product_id'])
SubscriptionOptions.set_stripe_price_id(t.uid,price_create_result['price_id']) SubscriptionOptions.set_stripe_price_id(t.uid, price_create_result['price_id'])
res_options.append({ res_options.append({
'option_id': t.id, 'option_id': t.id,
@@ -164,7 +163,7 @@ class SubscriptionsService(BaseService):
member_data = Members.get_member_by_uid(uid) member_data = Members.get_member_by_uid(uid)
member_id = member_data.id member_id = member_data.id
option_name = validated_data.get('option_name') option_name = validated_data.get('option_name')
sub_option = SubscriptionOptions.get_subscription_options_by_option_name(option_name) sub_option = SubscriptionOptions.get_subscription_options_by_option_name(option_name)
if sub_option is None: if sub_option is None:
logger.error(f"Invalid Option Name") logger.error(f"Invalid Option Name")
@@ -191,7 +190,6 @@ class SubscriptionsService(BaseService):
# product_subscription_external_url = memberSubscription.external_url # product_subscription_external_url = memberSubscription.external_url
# product_subscription_internal_url = memberSubscription.internal_url # product_subscription_internal_url = memberSubscription.internal_url
# "banner": "banner.jpg", # "banner": "banner.jpg",
# myproduct_data = { # myproduct_data = {
# "myproudct": { # "myproudct": {
@@ -215,7 +213,7 @@ class SubscriptionsService(BaseService):
# Simulate processing # Simulate processing
response_data = { response_data = {
"stripe_session":stripe_session.url, "stripe_session": stripe_session.url,
"member_id": member_id, "member_id": member_id,
"uid": uid, "uid": uid,
} }
@@ -238,8 +236,6 @@ class SubscriptionsService(BaseService):
db.session.rollback() db.session.rollback()
return ResponseHelper.internal_server_error() return ResponseHelper.internal_server_error()
@staticmethod @staticmethod
def subscription_webhook_start(data): def subscription_webhook_start(data):
try: try:
@@ -252,14 +248,19 @@ class SubscriptionsService(BaseService):
logger.info(f"**************** Key: {key}, *********** Value: {value}") logger.info(f"**************** Key: {key}, *********** Value: {value}")
data_id = hook_data["id"] data_id = hook_data["id"]
amount_subtotal =hook_data["amount_subtotal"] amount_subtotal = hook_data["amount_subtotal"]
logger.info(f"HOOK Result DATA ==>>>> {data_id} {amount_subtotal}") logger.info(f"HOOK Result DATA ==>>>> {data_id} {amount_subtotal}")
currentPaymentsession = PaymentsSession.get_payment_session_with_session_id(data_id) currentPaymentsession = PaymentsSession.get_payment_session_with_session_id(data_id)
logger.info(f"HOOK currentPaymentsession ==>>>> {currentPaymentsession}") logger.info(f"HOOK currentPaymentsession ==>>>> {currentPaymentsession}")
if currentPaymentsession:
payment_data = {
"payment_uid": currentPaymentsession.uid,
"member_id": currentPaymentsession.member_id,
"option_name": currentPaymentsession.option_name,
}
logger.info(f"HOOK payment_data ==>>>> {payment_data}")
# Simulate processing # Simulate processing
response_data = { response_data = {
@@ -285,5 +286,3 @@ class SubscriptionsService(BaseService):
logger.error(f"An error occurred: {str(e)}", exc_info=True) logger.error(f"An error occurred: {str(e)}", exc_info=True)
db.session.rollback() db.session.rollback()
return ResponseHelper.internal_server_error() return ResponseHelper.internal_server_error()