Bird
0
0
LLDsystem_design~10 mins

Payment handling in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the main class for payment processing.

LLD
class [1]:
    def __init__(self):
        self.transactions = []
Drag options to blanks, or click blank then click option'
ATransactionManager
BPaymentProcessor
COrderHandler
DUserAccount
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated class names like OrderHandler or UserAccount.
2fill in blank
medium

Complete the code to add a method that initiates a payment.

LLD
def [1](self, amount, method):
    # code to start payment
    pass
Drag options to blanks, or click blank then click option'
Ainitiate_payment
Bprocess_order
Ccancel_payment
Drefund_payment
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names like cancel_payment or refund_payment which do not start payments.
3fill in blank
hard

Fix the error in the method that validates payment status.

LLD
def validate_status(self, status):
    if status == [1]:
        return True
    return False
Drag options to blanks, or click blank then click option'
A"completed"
Bcompleted
CTrue
D"pending"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around string literals.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps transaction IDs to amounts for successful payments.

LLD
successful_payments = {txn['id']: txn[1] for txn in transactions if txn['status'] [2] 'success'}
Drag options to blanks, or click blank then click option'
A['amount']
B==
C!=
D['status']
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong dictionary keys or incorrect comparison operators.
5fill in blank
hard

Fill all three blanks to create a method that refunds payments over a certain amount and updates their status.

LLD
def refund_large_payments(self, threshold):
    for txn in self.transactions:
        if txn['amount'] [1] threshold:
            self.process_refund(txn[2])
            txn['status'] = [3]
Drag options to blanks, or click blank then click option'
A>
B['id']
C'refunded'
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or wrong keys for refund.