Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from . import users
from . import groups
from . import channels
from . import payments
1 change: 1 addition & 0 deletions handlers/payments/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import payme
76 changes: 76 additions & 0 deletions handlers/payments/payme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import requests
import uuid

def create_transactions():
charge_id = str(uuid.uuid4())

url = "https://checkout.paycom.uz"

# Data to be sent in the POST request
data = {
'merchant': '672b8224c628bf0c13f3c4ef',
'amount': '500000',
'account[charge_id]': charge_id
}
# Sending POST request
response = requests.post(url, data=data)
# Check the response
if response.status_code == 200:
# Extract and print the form name="redirect"
if '<form name="redirect"' in response.text:
start_index = response.text.find('<form name="redirect"')
end_index = response.text.find('>', start_index) + 1
html_content = response.text
start = html_content.find('property="og:description" content="') + len(
'property="og:description" content="')
end = html_content.find('"', start_index)
meta_description = html_content[start:end]

# Split the content to find 'Номер чека'
parts = meta_description.split(',')
check_id = parts[1].split(':')[1]
a = 'https://checkout.paycom.uz/' + response.text[start_index:end_index].split('/')[5]
return [check_id, a]

else:
print("Redirect form not found in the response.")
else:
print(f"Failed to send request. Status code: {response.status_code}")

print(create_transactions())


def check_transactions(check_id):
a = "SmchgGopUu5rAxpCsjOpr64ridAP3VrrDutv"
b = "672b8224c628bf0c13f3c4ef"
url = "https://checkout.paycom.uz/api"
headers = {
"X-auth": f"{b}:{a}",
"Content-Type": "application/json"
}
payload = {
"id": check_id, # This is a random ID for your request
"method": "receipts.check",
"params": {
"id": f"{check_id}" # Your transaction ID
}
}

try:
response = requests.post(url, json=payload, headers=headers)
response_data = response.json()

# Check if the request was successful
if 'result' in response_data:
transaction_state = response_data['result'].get('state')
# If the payment was successful
if transaction_state != 0:
return True # Payment successful
else:
return False # Payment not successful or in another state
else:
# Handle errors
error_message = response_data.get('error', {}).get('message', 'Unknown error')
print(f"Error: {error_message}")
except Exception as e:
print(f"An error occurred while checking transaction status: {e}")
26 changes: 17 additions & 9 deletions handlers/users/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def check_subscription(user_id):
return False


@dp.message_handler(commands='start')
@dp.message_handler(commands='start',state='*')
async def start_bosganda(message: types.Message, state: FSMContext):
if " " in message.text:
param = message.text.split(" ", 1)[1]
Expand All @@ -44,11 +44,10 @@ async def start_bosganda(message: types.Message, state: FSMContext):

Agar siz shaxsiy hayotingizda extiros va baxtli munosabatlarni, energiyanga boy bolishni istasangiz, sizni….. dekabr kuni Vebinarga ishtirok etishingiz uchun ishonch hosil qiling! 🔥

Sizning bonusingiz sizni bu erda kutmoqda 👇""" , reply_markup=bonus_2)
Sizning bonusingiz sizni bu erda kutmoqda 👇""", reply_markup=bonus_2)
await message.answer(f"Assalomu Aleykum {message.from_user.first_name}")
# await message.answer_video_note(video_note=open('media/start_reklama.mp4', "rb"))


is_subscribed = await check_subscription(message.from_user.id)

if not is_subscribed:
Expand Down Expand Up @@ -77,6 +76,8 @@ async def process_user_registration(message: types.Message):
await message.delete()
await message.answer("Botda foydalanish uchun ismingizni kiriting", reply_markup=ReplyKeyboardRemove())
await BotStates.name_state.set()


@dp.callback_query_handler(text="bonus_2")
async def bonus_22(call: types.CallbackQuery):
await call.message.answer_document(open('media/Intim-xavfsizlik-qoidalari.pdf', 'rb'))
Expand Down Expand Up @@ -157,7 +158,8 @@ async def reklama(message: types.Message):
from states.aloqa_states import BotStates
await BotStates.reklama_state.set()

@dp.message_handler(state=BotStates.reklama_state,content_types=types.ContentType.PHOTO)

@dp.message_handler(state=BotStates.reklama_state, content_types=types.ContentType.PHOTO)
async def handle_photo_with_caption(message: types.Message, state: FSMContext):
photo = message.photo[-1]
photo_file_id = photo.file_id
Expand All @@ -170,6 +172,7 @@ async def handle_photo_with_caption(message: types.Message, state: FSMContext):
await message.reply("Reklama Foydalanuvchiga yuborildi")
await state.finish()


@dp.message_handler(commands=["video"])
async def video_handler(message: Message):
if message.from_user.id == 433943:
Expand All @@ -180,17 +183,22 @@ async def video_handler(message: Message):
@dp.message_handler(state=BotStates.reklame_video, content_types=ContentType.VIDEO)
async def video_handler(message: Message, state: FSMContext):
video = message.video
try:
if message.caption:
caption = message.caption
except:
for i in ADMINS:
await bot.send_message(i, f"Reklama jo`natildi Caption {caption}")

file_id = video.file_id
await state.finish()
user_id = cursor.execute("SELECT tg_id FROM user_full_data").fetchall()
for i in user_id:
for user in i:
await bot.send_video(user, file_id)
await bot.send_video(user, file_id,caption=caption)
await message.answer("Videoni Foydalanuvchilarga yubordim!")




@dp.message_handler(content_types=types.ContentType.PHOTO)
async def reklama_send(message: types.Message):
users = cursor.execute("SELECT user_id FROM users_table")
Expand Down Expand Up @@ -267,8 +275,8 @@ async def admin_bilan_boglanish(message: types.Message):
kanal_btn = InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton("@nadia_admini",url="https://t.me/@nadia_admini")
InlineKeyboardButton("@nadia_admini", url="https://t.me/@nadia_admini")
]
]
)
await message.answer("Admin bilan bo'glanish",reply_markup=kanal_btn)
await message.answer("Admin bilan bo'glanish", reply_markup=kanal_btn)
Loading