Skip to content

Commit

Permalink
debug payment
Browse files Browse the repository at this point in the history
  • Loading branch information
ebosh-alt committed Feb 21, 2023
1 parent 7048942 commit a3cdd85
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
1 change: 1 addition & 0 deletions Openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class OpenAi:
def __init__(self, openai_api_key):
self.openai = openai
self.openai.log = "info"
self.openai.api_key = openai_api_key

async def question(self, text: str) -> str:
Expand Down
20 changes: 9 additions & 11 deletions Reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import datetime
from multiprocessing import Process

import schedule

import functions
import texts
from Enum_classes import Reminder
Expand Down Expand Up @@ -36,7 +34,7 @@ async def work():
time_transition_payment = datetime.datetime.utcfromtimestamp(user.time_transition_payment)
if (now_time - time_transition_payment) > time_reminder_1 and user.count_reminder == 0:
data = functions.create_pay(user_id=str(user_id),
price="2990.00")
price=2990)
key = data[1]
link = data[0]
user.key_payment = key
Expand All @@ -57,7 +55,7 @@ async def work():
and time_reminder.tm_min == now_time_tuple.tm_min:
if user.reminder == Reminder.first_reminder:
data = functions.create_pay(user_id=str(user_id),
price="2990.00")
price=2990)
key = data[1]
link = data[0]
user.key_payment = key
Expand All @@ -76,17 +74,17 @@ async def work():

elif user.reminder == Reminder.second_reminder:
data = functions.create_pay(user_id=str(user_id),
price="9990.00")
price=9990)
key = data[1]
link = data[0]
user.key_payment = key
await bot.send_message(chat_id=user_id,
text=texts.text_for_reminder_4.format(username=user.username),
reply_markup=functions.inl_create_keyboard(buttons=
[["Написать нам",
link_to_bot],
["Оплатить 9990 руб.",
link]]))
[["Написать нам",link_to_bot],
["Оплатить 9990 руб.", link]]
)
)
time_rem = datetime.datetime(year=now_time_tuple.tm_year, month=now_time_tuple.tm_mon,
day=now_time_tuple.tm_mday, hour=15, minute=15, second=0)
time_rem += datetime.timedelta(days=2)
Expand All @@ -96,7 +94,7 @@ async def work():

elif user.reminder == Reminder.third_reminder:
data = functions.create_pay(user_id=str(user_id),
price="990.00")
price=990)
key = data[1]
link = data[0]
user.key_payment = key
Expand All @@ -114,7 +112,7 @@ async def work():

elif user.reminder == Reminder.fourth_reminder:
data = functions.create_pay(user_id=str(user_id),
price="990.00")
price=990)
key = data[1]
link = data[0]
user.key_payment = key
Expand Down
Binary file modified db.db
Binary file not shown.
Binary file removed db.db-shm
Binary file not shown.
Binary file removed db.db-wal
Binary file not shown.
14 changes: 9 additions & 5 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Configuration.secret_key = 'live_JB-sjh_-FPp_2Rl5QeX5Rlm6lwqarahXnk4YAbZCOnQ'


def create_pay(user_id: str, price: str) -> tuple:
def create_pay(user_id: str, price: int) -> tuple:
payment = Payment.create({
"amount": {
"value": price,
Expand All @@ -17,9 +17,13 @@ def create_pay(user_id: str, price: str) -> tuple:

},
"capture": True,
"description": user_id
"description": user_id,
"receipt": {"customer": {"email": "evsevm@gmail.com"}}
})

# print(payment.amount.__dict__)
# print(payment.recipient.__dict__)
# print(payment.confirmation.__dict__)
# print(payment.confirmation.confirmation_url, payment.id)
return payment.confirmation.confirmation_url, payment.id


Expand All @@ -34,7 +38,7 @@ def create_keyboard(name_buttons: list, ) -> types.ReplyKeyboardMarkup:
return keyboard


def inl_create_keyboard(buttons: list[list], ):
def inl_create_keyboard(buttons: list, ):
keyboard = types.InlineKeyboardMarkup(row_width=len(buttons), resize_keyboard=True)
array = []
for button in buttons:
Expand All @@ -55,4 +59,4 @@ def inl_create_keyboard(buttons: list[list], ):


if __name__ == "__main__":
create_pay("55", "29990.00")
print(create_pay("55", 2))
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,32 @@ async def main_hand(message: types.Message):

elif text == "Хочу начать":
data = functions.create_pay(user_id=str(user_id),
price="2990.00")
price=2990)
key = data[1]
link = data[0]
user.key_payment = key
await bot.send_message(chat_id=user_id,
text=texts.text_for_payment,
reply_markup=functions.inl_create_keyboard(
buttons=[["Оплатить 2990 руб.", link
buttons=[["Оплатить 2990 руб.", f"{link}"
]]
),
parse_mode="Markdown",
disable_web_page_preview=True,
)
now_time = message.date
now_time = message.date.utcnow()
now_time_tuple = now_time.timetuple()
user.flag = Flags.Payment
user.time_transition_payment = time.mktime(now_time_tuple)
user.reminder = Reminder.first_reminder
if now_time_tuple.tm_hour >= 20 and now_time_tuple.tm_min >= 15:
if now_time_tuple.tm_hour >= 16 and now_time_tuple.tm_min >= 15:
time_rem = datetime.datetime(year=now_time_tuple.tm_year, month=now_time_tuple.tm_mon,
day=now_time_tuple.tm_mday, hour=19, minute=48, second=0)
day=now_time_tuple.tm_mday, hour=16, minute=15, second=0)
time_rem += datetime.timedelta(days=1)
user.time_reminder = time.mktime(time_rem.timetuple())
else:
time_rem = datetime.datetime(year=now_time_tuple.tm_year, month=now_time_tuple.tm_mon,
day=now_time_tuple.tm_mday, hour=19, minute=54, second=0)
day=now_time_tuple.tm_mday, hour=16, minute=15, second=0)

user.time_reminder = time.mktime(time_rem.timetuple())

Expand Down
2 changes: 1 addition & 1 deletion texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

text_after_pay = "Спасибо за оплату! \n\nНу что, начнем?"

text_for_reminder = "Вы можете подробнее прочитать про наш курс на нашем сайте. Если у вас останутся вопросы, " \
text_for_reminder = "Вы можете подробнее прочитать про наш курс на [нашем сайте](https://www.skillbots.ru/design?utm_source=error_code_tg&utm_medium=tgbot). Если у вас останутся вопросы, " \
"то напишите на [@skillbots_support]" \
"(https://t.me/skillbots_support)\n\nТакже напоминаю, " \
"что сегодня у вас есть возможность получить курс всего за 2990 руб."
Expand Down

0 comments on commit a3cdd85

Please sign in to comment.