-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.py
61 lines (47 loc) · 1.53 KB
/
Solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from datetime import datetime
class Payment(object):
amount = 0
username = ""
events = []
status = 0
def __repr__(self):
return f"<{self.amount}€ Payment of {self.username}>"
class PaymentStatus:
UNDEFINED = 0
PROCESSED = 100
PAYED = 200
DECLINED = 300
class CheckoutService(object):
@staticmethod
def add_payment_to_successful_payments(payment, successful_payments=None):
if successful_payments == None:
successful_payments = []
successful_payments.append(payment)
return successful_payments
@staticmethod
def get_payment_status(status_number):
if status_number == PaymentStatus.PROCESSED:
return "Your Payment is processed."
if status_number == PaymentStatus.PAYED:
return "Your Payment is payed."
if status_number == PaymentStatus.DECLINED:
return "Sorry your Payment was declined."
return "Your Payment is unknown."
@staticmethod
def create_payment(amount: int, username: str):
payment = Payment()
payment.amount = amount
payment.username = username
payment.events = [{
'name': "payment_created",
'date': datetime.now()
}]
return payment
all_processed_payments = 0
def get_processed_payments():
global all_processed_payments
return all_processed_payments
def increase_processed_payments():
global all_processed_payments
all_processed_payments += 1
return all_processed_payments